Skip to content

Commit 87a07c4

Browse files
authored
Merge pull request #2696 from modernweb-dev/fix/storybook-builder-NODE_PATH
fix(storybook-builder): clean up NODE_PATH from bundled modules output
2 parents 482210f + 9118c64 commit 87a07c4

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

.changeset/fuzzy-poems-decide.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 NODE_PATH from bundled modules output

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,15 @@ export function rollupPluginPrebundleModules(env: Record<string, string>): Plugi
4242
'@storybook/react-dom-shim': getReactDomShimAlias(),
4343
}),
4444
},
45-
define: {
46-
...stringifyProcessEnvs(env),
47-
},
45+
define: (() => {
46+
const define = stringifyProcessEnvs(env);
47+
48+
// "NODE_PATH" pollutes the output, it's not used by prebundled modules and is not recommended in general
49+
// see more https://github.com/nodejs/node/issues/38128#issuecomment-814969356
50+
delete define['process.env.NODE_PATH'];
51+
52+
return define;
53+
})(),
4854
plugins: [
4955
esbuildPluginCommonjsNamedExports(
5056
modules.filter(

0 commit comments

Comments
 (0)