Skip to content

Commit

Permalink
Merge pull request #28507 from storybookjs/norbert/apply-fixes-on-inc…
Browse files Browse the repository at this point in the history
…orrect-types-due-to-cpc

CPC: Fix type generation
(cherry picked from commit a937895)
  • Loading branch information
ndelangen authored and storybook-bot committed Jul 10, 2024
1 parent ffe743f commit 64fc031
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
15 changes: 14 additions & 1 deletion scripts/prepare/addon-bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { exec } from '../utils/exec';

import { globalPackages as globalPreviewPackages } from '../../code/core/src/preview/globals/globals';
import { globalPackages as globalManagerPackages } from '../../code/core/src/manager/globals/globals';
import { glob } from 'glob';

/* TYPES */

Expand Down Expand Up @@ -62,8 +63,9 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => {

const tasks: Promise<any>[] = [];

const outDir = join(process.cwd(), 'dist');
const commonOptions: Options = {
outDir: join(process.cwd(), 'dist'),
outDir,
silent: true,
treeshake: true,
shims: false,
Expand Down Expand Up @@ -190,6 +192,17 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => {

await Promise.all(tasks);

const dtsFiles = await glob(outDir + '/**/*.d.ts');
await Promise.all(
dtsFiles.map(async (file) => {
const content = await fs.readFile(file, 'utf-8');
await fs.writeFile(
file,
content.replace(/from \'core\/dist\/(.*)\'/g, `from 'storybook/internal/$1'`)
);
})
);

if (post) {
await exec(`bun ${post}`, { cwd }, { debug: true });
}
Expand Down
12 changes: 12 additions & 0 deletions scripts/prepare/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import aliasPlugin from 'esbuild-plugin-alias';
import { dedent } from 'ts-dedent';
import slash from 'slash';
import { exec } from '../utils/exec';
import { glob } from 'glob';

/* TYPES */

Expand Down Expand Up @@ -147,6 +148,17 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => {

await Promise.all(tasks);

const dtsFiles = await glob(outDir + '/**/*.d.ts');
await Promise.all(
dtsFiles.map(async (file) => {
const content = await fs.readFile(file, 'utf-8');
await fs.writeFile(
file,
content.replace(/from \'core\/dist\/(.*)\'/g, `from 'storybook/internal/$1'`)
);
})
);

if (post) {
await exec(`bun ${post}`, { cwd }, { debug: true });
}
Expand Down

0 comments on commit 64fc031

Please sign in to comment.