Skip to content

fix: preserve require.resolve / dynamic require / dynamic import #249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,6 @@ Here are the steps to publish (we generally use CI for releases and avoid publis

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:

| Package | Link |
| ------------ | --------------------------------------------------------------------------------------- |
| @rspack/core | https://github.com/web-infra-dev/rspack/commit/bb0219fd3eaee45d9957b4c29a176f2ac67a84ee |
| Package | Link |
| ------------ | ------------------------------------------------- |
| @rspack/core | https://github.com/web-infra-dev/rspack/pull/7939 |
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
"pnpm": {
"overrides": {
"@rspack/core": "npm:@rspack/[email protected].6-canary-bb0219fd-20240920080859"
"@rspack/core": "npm:@rspack/[email protected].9-canary-0cad17d5-20240929151646"
}
}
}
17 changes: 11 additions & 6 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,14 @@ export async function createConstantRsbuildConfig(): Promise<RsbuildConfig> {
}

const composeFormatConfig = (format: Format): RsbuildConfig => {
const jsParserOptions = {
importMeta: false,
requireResolve: false,
requireDynamic: false,
requireAsExpression: false,
importDynamic: false,
};

switch (format) {
case 'esm':
return {
Expand All @@ -446,13 +454,12 @@ const composeFormatConfig = (format: Format): RsbuildConfig => {
},
module: {
parser: {
javascript: {
importMeta: false,
},
javascript: jsParserOptions,
},
},
optimization: {
concatenateModules: true,
sideEffects: 'flag',
},
experiments: {
outputModule: true,
Expand All @@ -467,9 +474,7 @@ const composeFormatConfig = (format: Format): RsbuildConfig => {
rspack: {
module: {
parser: {
javascript: {
importMeta: false,
},
javascript: jsParserOptions,
},
},
output: {
Expand Down
9 changes: 9 additions & 0 deletions packages/core/tests/__snapshots__/config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,17 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config 1
"module": {
"parser": {
"javascript": {
"importDynamic": false,
"importMeta": false,
"requireAsExpression": false,
"requireDynamic": false,
"requireResolve": false,
},
},
},
"optimization": {
"concatenateModules": true,
"sideEffects": "flag",
},
"output": {
"chunkFormat": "module",
Expand Down Expand Up @@ -252,7 +257,11 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config 1
"module": {
"parser": {
"javascript": {
"importDynamic": false,
"importMeta": false,
"requireAsExpression": false,
"requireDynamic": false,
"requireResolve": false,
},
},
},
Expand Down
118 changes: 63 additions & 55 deletions pnpm-lock.yaml

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

Loading
Loading