Skip to content

Commit

Permalink
chore: extract shared Rslib config (#3506)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Sep 18, 2024
1 parent b1e7646 commit 37ee425
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 29 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@changesets/cli": "^2.27.8",
"@modern-js/module-tools": "^2.60.0",
"@rsbuild/config": "workspace:*",
"@rslib/core": "0.0.6",
"@scripts/test-helper": "workspace:*",
"check-dependency-version-consistency": "^4.1.0",
"cross-env": "^7.0.3",
Expand Down
1 change: 0 additions & 1 deletion packages/create-rsbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"create-rstack": "1.0.3"
},
"devDependencies": {
"@rslib/core": "0.0.6",
"@types/node": "18.x",
"typescript": "^5.5.2"
},
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-less/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
},
"devDependencies": {
"@rsbuild/core": "workspace:*",
"@rslib/core": "0.0.6",
"@scripts/test-helper": "workspace:*",
"@types/less": "^3.0.6",
"less": "^4.2.0",
Expand Down
15 changes: 2 additions & 13 deletions packages/plugin-less/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
import { defineConfig } from '@rslib/core';
import { dualPackage } from '@rsbuild/config/rslib.config.ts';

export default defineConfig({
lib: [
{
format: 'esm',
dts: { bundle: false },
},
{ format: 'cjs' },
],
output: {
target: 'node',
},
});
export default dualPackage;
9 changes: 3 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions scripts/config/modern.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ export const define = {
RSBUILD_VERSION: require('../../packages/core/package.json').version,
};

export const commonExternals = [
'webpack',
'@rspack/core',
'@rsbuild/core',
/[\\/]compiled[\\/]/,
/node:/,
];

export const BUILD_TARGET = {
node: 'es2021',
client: 'es2017',
Expand All @@ -23,14 +31,6 @@ export const requireShim = {
var require = createRequire(import.meta['url']);\n`,
};

export const commonExternals = [
'webpack',
'@rspack/core',
'@rsbuild/core',
/[\\/]compiled[\\/]/,
/node:/,
];

export const esmBuildConfig: PartialBaseBuildConfig = {
format: 'esm',
target: BUILD_TARGET.node,
Expand Down
24 changes: 24 additions & 0 deletions scripts/config/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineConfig } from '@rslib/core';

export const commonExternals: Array<string | RegExp> = [
'webpack',
/[\\/]compiled[\\/]/,
];

export const dualPackage = defineConfig({
lib: [
{
format: 'esm',
dts: { bundle: false },
},
{ format: 'cjs' },
],
output: {
target: 'node',
},
tools: {
rspack: {
externals: commonExternals,
},
},
});

0 comments on commit 37ee425

Please sign in to comment.