-
-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(modern-module): export syntax detect more invalid chars
- Loading branch information
Showing
4 changed files
with
49 additions
and
1 deletion.
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
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/configCases/library/modern-module-export-char/foo.cjs
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 @@ | ||
module.exports = 'foo' |
5 changes: 5 additions & 0 deletions
5
packages/rspack-test-tools/tests/configCases/library/modern-module-export-char/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,5 @@ | ||
import defaultImport from 'external-module' | ||
import { namedImport } from 'external-module' | ||
import cjsInterop from './foo.cjs' | ||
|
||
export { defaultImport, namedImport, cjsInterop } |
39 changes: 39 additions & 0 deletions
39
...es/rspack-test-tools/tests/configCases/library/modern-module-export-char/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,39 @@ | ||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
entry: { | ||
"index": "./index.js", | ||
}, | ||
output: { | ||
filename: `[name].js`, | ||
module: true, | ||
libraryTarget: "modern-module", | ||
iife: false, | ||
chunkFormat: "module", | ||
}, | ||
externalsType: 'module-import', | ||
experiments: { | ||
outputModule: true | ||
}, | ||
externals: "external-module", | ||
optimization: { | ||
concatenateModules: true, | ||
minimize: false | ||
}, | ||
plugins: [ | ||
function () { | ||
/** | ||
* @param {import("@rspack/core").Compilation} compilation compilation | ||
* @returns {void} | ||
*/ | ||
const handler = compilation => { | ||
compilation.hooks.afterProcessAssets.tap("testcase", assets => { | ||
const bundle = Object.values(assets)[0]._value | ||
expect(bundle).toContain(`var __webpack_exports__cjsInterop = (foo_default()); | ||
var __webpack_exports__defaultImport = external_external_module_namespaceObject["default"]; | ||
var __webpack_exports__namedImport = external_external_module_namespaceObject.namedImport;`) | ||
}); | ||
}; | ||
this.hooks.compilation.tap("testcase", handler); | ||
} | ||
] | ||
}; |