Skip to content

Commit

Permalink
fix(webpack): avoid duplicate import core package (#3871)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Oct 31, 2024
1 parent 062817f commit d594eb0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
1 change: 1 addition & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"!{projectRoot}/**/*.{md,mdx}",
"{projectRoot}/tsconfig.json",
"{projectRoot}/package.json",
"{projectRoot}/rslib.config.*",
"{projectRoot}/modern.config.*",
"{projectRoot}/scripts/**/*"
],
Expand Down
37 changes: 27 additions & 10 deletions packages/compat/webpack/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
import path from 'node:path';
import { pureEsmPackage } from '@rsbuild/config/rslib.config.ts';
import {
cjsConfig,
dualPackage,
esmConfig,
} from '@rsbuild/config/rslib.config.ts';
import { defineConfig } from '@rslib/core';

export default defineConfig({
...pureEsmPackage,
output: {
...pureEsmPackage.output,
copy: [
{
from: path.resolve(__dirname, 'src/index.cjs'),
...dualPackage,
lib: [
esmConfig,
{
...cjsConfig,
output: {
target: 'node',
// TODO https://github.com/web-infra-dev/rslib/issues/287
externals: {
webpack: 'import webpack',
'copy-webpack-plugin': 'import copy-webpack-plugin',
'mini-css-extract-plugin': 'import mini-css-extract-plugin',
'tsconfig-paths-webpack-plugin':
'import tsconfig-paths-webpack-plugin',
},
},
],
},
footer: {
// TODO https://github.com/web-infra-dev/rslib/issues/351
js: `// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = { webpackProvider: exports.webpackProvider });`,
},
},
],
});
5 changes: 0 additions & 5 deletions scripts/config/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,3 @@ export const dualPackage = defineConfig({
},
},
});

export const pureEsmPackage = defineConfig({
...dualPackage,
lib: [esmConfig],
});

1 comment on commit d594eb0

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ❌ failure
plugins ✅ success
rspress ✅ success
rslib ✅ success
examples ✅ success

Please sign in to comment.