Skip to content

Commit 24efc95

Browse files
committed
fix: preserve require.resolve / dynamic require / dynamic import
1 parent e3907d4 commit 24efc95

File tree

18 files changed

+311
-184
lines changed

18 files changed

+311
-184
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,6 @@ Here are the steps to publish (we generally use CI for releases and avoid publis
138138

139139
The project is still in its early stages and under active development, so it possible dependents on Rsbuild or Rspack canary versions to test the latest features. The current versions are:
140140

141-
| Package | Link |
142-
| ------------ | --------------------------------------------------------------------------------------- |
143-
| @rspack/core | https://github.com/web-infra-dev/rspack/commit/bb0219fd3eaee45d9957b4c29a176f2ac67a84ee |
141+
| Package | Link |
142+
| ------------ | ------------------------------------------------- |
143+
| @rspack/core | https://github.com/web-infra-dev/rspack/pull/7939 |

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
},
6363
"pnpm": {
6464
"overrides": {
65-
"@rspack/core": "npm:@rspack/[email protected].6-canary-bb0219fd-20240920080859"
65+
"@rspack/core": "npm:@rspack/[email protected].9-canary-0cad17d5-20240929151646"
6666
}
6767
}
6868
}

packages/core/src/config.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,14 @@ export async function createConstantRsbuildConfig(): Promise<RsbuildConfig> {
432432
}
433433

434434
const composeFormatConfig = (format: Format): RsbuildConfig => {
435+
const jsParserOptions = {
436+
importMeta: false,
437+
requireResolve: false,
438+
requireDynamic: false,
439+
requireAsExpression: false,
440+
importDynamic: false,
441+
};
442+
435443
switch (format) {
436444
case 'esm':
437445
return {
@@ -446,13 +454,12 @@ const composeFormatConfig = (format: Format): RsbuildConfig => {
446454
},
447455
module: {
448456
parser: {
449-
javascript: {
450-
importMeta: false,
451-
},
457+
javascript: jsParserOptions,
452458
},
453459
},
454460
optimization: {
455461
concatenateModules: true,
462+
sideEffects: 'flag',
456463
},
457464
experiments: {
458465
outputModule: true,
@@ -467,9 +474,7 @@ const composeFormatConfig = (format: Format): RsbuildConfig => {
467474
rspack: {
468475
module: {
469476
parser: {
470-
javascript: {
471-
importMeta: false,
472-
},
477+
javascript: jsParserOptions,
473478
},
474479
},
475480
output: {

pnpm-lock.yaml

Lines changed: 61 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)