Skip to content

Commit 9ad7563

Browse files
committed
style: included Node.js modules in external as fallback
1 parent f5fa5c6 commit 9ad7563

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

packages/core/src/bundler.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,16 @@ export async function bundleFile(
114114
// them external prevents esbuild from following their import chains and
115115
// failing on packages like @babel/preset-typescript that aren't installed
116116
// in every user project.
117-
external: ['@babel/core', 'esbuild', 'react-refresh', 'react-refresh/babel'],
117+
// Node.js built-ins (path, fs, module) are also listed here as a defensive
118+
// fallback: older adapter builds without the "browser" export condition may
119+
// contain top-level imports of these modules. Externalising them prevents a
120+
// hard build failure — esbuild's tree-shaker eliminates the dead code paths
121+
// (e.g. createFastRefreshPlugin) so they never appear in the browser output.
122+
external: [
123+
'@babel/core', 'esbuild', 'react-refresh', 'react-refresh/babel',
124+
'node:path', 'path', 'node:fs', 'node:fs/promises', 'fs', 'fs/promises',
125+
'node:module', 'module', 'node:url', 'url',
126+
],
118127
plugins: [...extraPlugins, getPostCSSPlugin(root)],
119128
loader: {
120129
'.ts': 'ts',

0 commit comments

Comments
 (0)