Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix and test module federation with ESM
- Loading branch information
Showing
7 changed files
with
198 additions
and
112 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,5 @@ | ||
module.exports = { | ||
findBundle: function (i, options) { | ||
return i === 0 ? "./main.js" : "./module/main.mjs"; | ||
} | ||
}; |
80 changes: 55 additions & 25 deletions
80
test/configCases/container/0-container-full/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 |
---|---|---|
@@ -1,28 +1,58 @@ | ||
const { ModuleFederationPlugin } = require("../../../../").container; | ||
|
||
/** @type {import("../../../../").Configuration} */ | ||
module.exports = { | ||
plugins: [ | ||
new ModuleFederationPlugin({ | ||
name: "container", | ||
library: { type: "commonjs-module" }, | ||
filename: "container.js", | ||
exposes: { | ||
"./ComponentA": { | ||
import: "./ComponentA" | ||
} | ||
}, | ||
remotes: { | ||
containerA: { | ||
external: "./container.js" | ||
} | ||
}, | ||
shared: { | ||
react: { | ||
version: false, | ||
requiredVersion: false | ||
} | ||
} | ||
}) | ||
] | ||
const common = { | ||
name: "container", | ||
exposes: { | ||
"./ComponentA": { | ||
import: "./ComponentA" | ||
} | ||
}, | ||
shared: { | ||
react: { | ||
version: false, | ||
requiredVersion: false | ||
} | ||
} | ||
}; | ||
|
||
/** @type {import("../../../../").Configuration[]} */ | ||
module.exports = [ | ||
{ | ||
output: { | ||
filename: "[name].js" | ||
}, | ||
plugins: [ | ||
new ModuleFederationPlugin({ | ||
library: { type: "commonjs-module" }, | ||
filename: "container.js", | ||
remotes: { | ||
containerA: { | ||
external: "./container.js" | ||
} | ||
}, | ||
...common | ||
}) | ||
] | ||
}, | ||
{ | ||
experiments: { | ||
outputModule: true | ||
}, | ||
output: { | ||
filename: "module/[name].mjs" | ||
}, | ||
plugins: [ | ||
new ModuleFederationPlugin({ | ||
library: { type: "module" }, | ||
filename: "module/container.mjs", | ||
remotes: { | ||
containerA: { | ||
external: "./container.mjs" | ||
} | ||
}, | ||
...common | ||
}) | ||
], | ||
target: "node14" | ||
} | ||
]; |
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
{ | ||
"private": true, | ||
"engines": { | ||
"node": ">=10.13.0" | ||
}, | ||
"dependencies": { | ||
"react": "*" | ||
} | ||
|
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 @@ | ||
module.exports = { | ||
findBundle: function (i, options) { | ||
return i === 0 ? "./main.js" : "./module/main.mjs"; | ||
} | ||
}; |
Oops, something went wrong.