Skip to content

Commit 4184609

Browse files
committed
fix(esm): no need to set library type for web target
1 parent b3c0a58 commit 4184609

File tree

1 file changed

+8
-5
lines changed
  • packages/core/src/plugins

1 file changed

+8
-5
lines changed

packages/core/src/plugins/esm.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ export const pluginEsm = (): RsbuildPlugin => ({
1616
chain.optimization.runtimeChunk(true);
1717
}
1818

19+
if (target === 'node') {
20+
chain.output.library({
21+
...chain.output.get('library'),
22+
type: 'module',
23+
});
24+
}
25+
1926
if (target === 'web-worker') {
2027
throw new Error(
2128
'[rsbuild:config] `output.module` is not supported for web-worker target.',
@@ -26,11 +33,7 @@ export const pluginEsm = (): RsbuildPlugin => ({
2633
.module(true)
2734
.chunkFormat('module')
2835
.chunkLoading('import')
29-
.workerChunkLoading('import')
30-
.library({
31-
...chain.output.get('library'),
32-
type: 'module',
33-
});
36+
.workerChunkLoading('import');
3437

3538
chain.experiments({
3639
...chain.get('experiments'),

0 commit comments

Comments
 (0)