Skip to content

Commit

Permalink
fix: external node builtin
Browse files Browse the repository at this point in the history
  • Loading branch information
HomyeeKing committed Jan 6, 2025
1 parent 613d44a commit 4fc1d06
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/ice/src/service/serverCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import type { PreBundleDepsMetaData } from './preBundleDeps.js';
import preBundleDeps from './preBundleDeps.js';
import { WebpackServerCompiler } from './webpackServerCompiler/compiler.js';
import VirualAssetPlugin from './webpackServerCompiler/virtualAssetPlugin.js';
import { externalNodeBuiltin } from './webpackServerCompiler/externalNodeBuiltin.js';

const logger = createLogger('server-compiler');

Expand Down Expand Up @@ -268,6 +269,7 @@ export function createServerCompiler(options: Options) {
...buildOptions,
externals,
plugins: [
externalNodeBuiltin.webpack(),
compilationInfo && new VirualAssetPlugin({ compilationInfo, rootDir }),
...transformWebpackPlugins,
].filter(Boolean),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { createUnplugin } from 'unplugin';
import { isNodeBuiltin } from 'mlly';

export const unpluginFactory = (options) => [
{
name: 'external-node-builtin',
resolveId(id) {
if (isNodeBuiltin(id)) {
return { id, external: true };
}
return null;
},
},
];

export const externalNodeBuiltin = /* #__PURE__ */ createUnplugin(unpluginFactory);

0 comments on commit 4fc1d06

Please sign in to comment.