-
-
Notifications
You must be signed in to change notification settings - Fork 616
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: "module-import" simply falls back to "module" when bails
- Loading branch information
Showing
8 changed files
with
105 additions
and
13 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
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,6 @@ | ||
import external0 from "external0"; // module | ||
const external1 = require("external1"); // module | ||
const external2 = require("external2"); // node-commonjs | ||
const external3 = import("external3"); // import | ||
|
||
console.log(external0, external1, external2, external3); |
10 changes: 10 additions & 0 deletions
10
tests/webpack-test/configCases/externals/module-import/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,10 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
it("module-import should correctly get fallback type", function() { | ||
const content = fs.readFileSync(path.resolve(__dirname, "a.js"), "utf-8"); | ||
expect(content).toContain(`import * as __WEBPACK_EXTERNAL_MODULE_external0__ from "external0";`); // module | ||
expect(content).toContain(`import * as __WEBPACK_EXTERNAL_MODULE_external1__ from "external1";`); // module | ||
expect(content).toContain(`module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("external2");`); // node-commonjs | ||
expect(content).toContain(`module.exports = import("external3");`); // import | ||
}); |
3 changes: 3 additions & 0 deletions
3
tests/webpack-test/configCases/externals/module-import/test.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,3 @@ | ||
module.exports = { | ||
findBundle: (i, options) => ["main.js"] | ||
}; |
41 changes: 41 additions & 0 deletions
41
tests/webpack-test/configCases/externals/module-import/webpack.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,41 @@ | ||
/** @type {import("../../../../types").Configuration} */ | ||
module.exports = { | ||
target: ["web", "es2020"], | ||
node: { | ||
__dirname: false, | ||
__filename: false | ||
}, | ||
output: { | ||
module: true, | ||
filename: "[name].js" | ||
}, | ||
entry: { | ||
a: "./a", | ||
main: "./index" | ||
}, | ||
optimization: { | ||
concatenateModules: true | ||
}, | ||
experiments: { | ||
outputModule: true | ||
}, | ||
externalsType: "module-import", | ||
externals: [ | ||
function ( | ||
{ context, request, contextInfo, getResolve, dependencyType }, | ||
callback | ||
) { | ||
if (request === "external2") { | ||
return callback(null, "node-commonjs external2"); | ||
} | ||
callback(); | ||
}, | ||
{ | ||
external0: "external0", | ||
external1: "external1", | ||
external3: "external3", | ||
fs: "commonjs fs", | ||
path: "commonjs path" | ||
} | ||
] | ||
}; |
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