mirror of https://github.com/webpack/webpack.git
fix: do not duplicate modules with import attributes and reexport (#19290)
This commit is contained in:
parent
98221f239b
commit
59ede3c64a
|
@ -149,6 +149,7 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
||||||
parser.state.harmonyNamedExports || new Set());
|
parser.state.harmonyNamedExports || new Set());
|
||||||
harmonyNamedExports.add(name);
|
harmonyNamedExports.add(name);
|
||||||
InnerGraph.addVariableUsage(parser, id, name);
|
InnerGraph.addVariableUsage(parser, id, name);
|
||||||
|
console.log(settings);
|
||||||
const dep = settings
|
const dep = settings
|
||||||
? new HarmonyExportImportedSpecifierDependency(
|
? new HarmonyExportImportedSpecifierDependency(
|
||||||
settings.source,
|
settings.source,
|
||||||
|
@ -189,6 +190,7 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
||||||
harmonyStarExports = parser.state.harmonyStarExports =
|
harmonyStarExports = parser.state.harmonyStarExports =
|
||||||
parser.state.harmonyStarExports || new HarmonyStarExportsList();
|
parser.state.harmonyStarExports || new HarmonyStarExportsList();
|
||||||
}
|
}
|
||||||
|
const attributes = getImportAttributes(statement);
|
||||||
const dep = new HarmonyExportImportedSpecifierDependency(
|
const dep = new HarmonyExportImportedSpecifierDependency(
|
||||||
/** @type {string} */ (source),
|
/** @type {string} */ (source),
|
||||||
parser.state.lastHarmonyImportOrder,
|
parser.state.lastHarmonyImportOrder,
|
||||||
|
@ -197,7 +199,8 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
||||||
harmonyNamedExports,
|
harmonyNamedExports,
|
||||||
harmonyStarExports && harmonyStarExports.slice(),
|
harmonyStarExports && harmonyStarExports.slice(),
|
||||||
exportPresenceMode,
|
exportPresenceMode,
|
||||||
harmonyStarExports
|
harmonyStarExports,
|
||||||
|
attributes
|
||||||
);
|
);
|
||||||
if (harmonyStarExports) {
|
if (harmonyStarExports) {
|
||||||
harmonyStarExports.push(dep);
|
harmonyStarExports.push(dep);
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
export {b} from "./b" with {type: "RANDOM"}
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { c } from "./c.js";
|
||||||
|
|
||||||
|
export function b() {
|
||||||
|
return "b" + c();
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
export function c() {
|
||||||
|
return "c";
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { b } from "./a.js";
|
||||||
|
|
||||||
|
function foo() {
|
||||||
|
return "a" + b();
|
||||||
|
}
|
||||||
|
|
||||||
|
it("should not duplicate modules", function() {
|
||||||
|
expect(foo()).toEqual("ab");
|
||||||
|
});
|
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = function loader() {
|
||||||
|
return "export function b() { return 'b'; }";
|
||||||
|
};
|
|
@ -0,0 +1,11 @@
|
||||||
|
/** @type {import("../../../../").Configuration} */
|
||||||
|
module.exports = {
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
with: { type: "RANDOM" },
|
||||||
|
use: require.resolve("./test-loader")
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue