@module-federation/node 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -6
- package/package.json +16 -6
- package/src/index.d.ts +3 -0
- package/src/index.js +13 -0
- package/src/index.js.map +1 -0
- package/src/plugins/CommonJsChunkLoadingPlugin.d.ts +16 -0
- package/src/plugins/CommonJsChunkLoadingPlugin.js +83 -0
- package/src/plugins/CommonJsChunkLoadingPlugin.js.map +1 -0
- package/src/plugins/LoadFileChunkLoadingRuntimeModule.d.ts +29 -0
- package/src/plugins/LoadFileChunkLoadingRuntimeModule.js +333 -0
- package/src/plugins/LoadFileChunkLoadingRuntimeModule.js.map +1 -0
- package/src/plugins/NodeFederationPlugin.d.ts +16 -0
- package/src/plugins/NodeFederationPlugin.js +225 -0
- package/src/plugins/NodeFederationPlugin.js.map +1 -0
- package/src/plugins/StreamingTargetPlugin.d.ts +11 -0
- package/src/plugins/StreamingTargetPlugin.js +41 -0
- package/src/plugins/StreamingTargetPlugin.js.map +1 -0
- package/src/plugins/UniversalFederationPlugin.d.ts +16 -0
- package/src/plugins/UniversalFederationPlugin.js +26 -0
- package/src/plugins/UniversalFederationPlugin.js.map +1 -0
- package/src/plugins/loadScript.d.ts +6 -0
- package/src/{loadScript.js → plugins/loadScript.js} +4 -2
- package/src/plugins/loadScript.js.map +1 -0
- package/src/types/index.d.ts +3 -0
- package/src/types/index.js +3 -0
- package/src/types/index.js.map +1 -0
- package/LICENSE +0 -21
- package/index.js +0 -7
- package/src/CommonJsChunkLoadingPlugin.js +0 -89
- package/src/LoadFileChunkLoadingRuntimeModule.js +0 -410
- package/src/NodeFederationPlugin.js +0 -244
- package/src/StreamingTargetPlugin.js +0 -42
- package/src/UniversalFederationPlugin.js +0 -28
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const CommonJsChunkLoadingPlugin = require('./CommonJsChunkLoadingPlugin');
|
|
2
|
-
|
|
3
|
-
class StreamingTargetPlugin {
|
|
4
|
-
constructor(options, context) {
|
|
5
|
-
this.options = options || {};
|
|
6
|
-
this.context = context || {};
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
apply(compiler) {
|
|
10
|
-
if (compiler.options.target) {
|
|
11
|
-
console.warn(
|
|
12
|
-
`target should be set to false while using NodeSoftwareStreamRuntime plugin, actual target: ${compiler.options.target}`
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// When used with Next.js, context is needed to use Next.js webpack
|
|
17
|
-
const { webpack } = compiler;
|
|
18
|
-
|
|
19
|
-
// This will enable CommonJsChunkFormatPlugin
|
|
20
|
-
compiler.options.output.chunkFormat = 'commonjs';
|
|
21
|
-
// This will force async chunk loading
|
|
22
|
-
compiler.options.output.chunkLoading = 'async-node';
|
|
23
|
-
// Disable default config
|
|
24
|
-
compiler.options.output.enabledChunkLoadingTypes = false;
|
|
25
|
-
|
|
26
|
-
new ((webpack && webpack.node && webpack.node.NodeEnvironmentPlugin) ||
|
|
27
|
-
require('webpack/lib/node/NodeEnvironmentPlugin'))({
|
|
28
|
-
infrastructureLogging: compiler.options.infrastructureLogging,
|
|
29
|
-
}).apply(compiler);
|
|
30
|
-
new ((webpack && webpack.node && webpack.node.NodeTargetPlugin) ||
|
|
31
|
-
require('webpack/lib/node/NodeTargetPlugin'))().apply(compiler);
|
|
32
|
-
new CommonJsChunkLoadingPlugin({
|
|
33
|
-
asyncChunkLoading: true,
|
|
34
|
-
name: this.options.name,
|
|
35
|
-
remotes: this.options.remotes,
|
|
36
|
-
baseURI: compiler.options.output.publicPath, //TODO: should remove?
|
|
37
|
-
promiseBaseURI: this.options.promiseBaseURI, //TODO: should remove?
|
|
38
|
-
}).apply(compiler);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
module.exports = StreamingTargetPlugin;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const NodeFederationPlugin = require("./NodeFederationPlugin");
|
|
2
|
-
const StreamingTargetPlugin = require("./StreamingTargetPlugin");
|
|
3
|
-
|
|
4
|
-
class UniversalFederationPlugin {
|
|
5
|
-
|
|
6
|
-
constructor({experiments, ...options}, context) {
|
|
7
|
-
this.options = options || {};
|
|
8
|
-
this.context = context || {};
|
|
9
|
-
this.experiments = experiments || {};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
apply(compiler) {
|
|
13
|
-
const isServer = this.options.isServer || compiler.options.name === 'server';
|
|
14
|
-
const {webpack} = compiler;
|
|
15
|
-
|
|
16
|
-
if(isServer) {
|
|
17
|
-
new NodeFederationPlugin({experiments: this.experiments, ...this.options}).apply(compiler);
|
|
18
|
-
new StreamingTargetPlugin(this.options).apply(compiler);
|
|
19
|
-
} else {
|
|
20
|
-
new (this.context.ModuleFederationPlugin || (webpack && webpack.container.ModuleFederationPlugin) ||
|
|
21
|
-
require('webpack/lib/container/ModuleFederationPlugin'))(
|
|
22
|
-
this.options
|
|
23
|
-
).apply(compiler);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = UniversalFederationPlugin;
|