Skip to content

Commit 2bbd356

Browse files
authored
Merge pull request #2698 from modernweb-dev/fix/storybook-builder-clean-up-prebundled-modules
fix(storybook-builder): clean up .prebundled_modules before creating new bundles
2 parents e766137 + a506c35 commit 2bbd356

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.changeset/tricky-schools-unite.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@web/storybook-builder': patch
3+
---
4+
5+
clean up `.prebundled_modules` before creating new bundles

packages/storybook-builder/src/rollup-plugin-prebundle-modules.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { stringifyProcessEnvs } from '@storybook/core-common';
22
import { build } from 'esbuild';
3+
import { remove } from 'fs-extra';
34
import { join } from 'path';
45
import type { Plugin } from 'rollup';
56
import { esbuildPluginCommonjsNamedExports } from './esbuild-plugin-commonjs-named-exports.js';
@@ -16,10 +17,12 @@ export function rollupPluginPrebundleModules(env: Record<string, string>): Plugi
1617
async buildStart() {
1718
const modules = CANDIDATES.filter(moduleExists);
1819

20+
const modulesDir = join(process.cwd(), PREBUNDLED_MODULES_DIR);
21+
await remove(modulesDir);
22+
1923
for (const module of modules) {
2024
modulePaths[module] = join(
21-
process.cwd(),
22-
PREBUNDLED_MODULES_DIR,
25+
modulesDir,
2326
module.endsWith('.js') ? module.replace(/\.js$/, '.mjs') : `${module}.mjs`,
2427
);
2528
}

0 commit comments

Comments
 (0)