-
-
Notifications
You must be signed in to change notification settings - Fork 595
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: importModule should receive error correctly (#8827)
- Loading branch information
Showing
9 changed files
with
142 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,4 +51,4 @@ | |
"@rspack/binding-linux-x64-gnu": "workspace:*", | ||
"@rspack/binding-win32-x64-msvc": "workspace:*" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...spack-test-tools/tests/configCases/loader-import-module/execute-failed/import-loader-2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports.pitch = function () { | ||
const callback = this.async(); | ||
this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!./index.js`, {}, err=> { | ||
expect(err.message).toBe('Error: execute failed') | ||
callback(null, `export default "${err}"`); | ||
}) | ||
} |
10 changes: 10 additions & 0 deletions
10
.../rspack-test-tools/tests/configCases/loader-import-module/execute-failed/import-loader.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports.pitch = function () { | ||
const callback = this.async(); | ||
this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!./index.js`, {}).then((_exports) => { | ||
throw new Error("This should not be executed"); | ||
}).catch((err) => { | ||
expect(err.message).toBe('Error: execute failed') | ||
// expect(err).toBe('execute failed') | ||
callback(null, `export default "${err}"`); | ||
}) | ||
} |
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/configCases/loader-import-module/execute-failed/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
throw new Error('execute failed') |
12 changes: 12 additions & 0 deletions
12
.../rspack-test-tools/tests/configCases/loader-import-module/execute-failed/rspack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
entry: "./index.js", | ||
module: { | ||
rules: [ | ||
{ | ||
test: /index\.js/, | ||
use: ['./import-loader.js', './import-loader-2.js'], | ||
}, | ||
] | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters