@module-federation/node 0.0.1 → 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.
Files changed (32) hide show
  1. package/README.md +43 -6
  2. package/package.json +16 -6
  3. package/src/index.d.ts +3 -0
  4. package/src/index.js +13 -0
  5. package/src/index.js.map +1 -0
  6. package/src/plugins/CommonJsChunkLoadingPlugin.d.ts +16 -0
  7. package/src/plugins/CommonJsChunkLoadingPlugin.js +83 -0
  8. package/src/plugins/CommonJsChunkLoadingPlugin.js.map +1 -0
  9. package/src/plugins/LoadFileChunkLoadingRuntimeModule.d.ts +29 -0
  10. package/src/plugins/LoadFileChunkLoadingRuntimeModule.js +333 -0
  11. package/src/plugins/LoadFileChunkLoadingRuntimeModule.js.map +1 -0
  12. package/src/plugins/NodeFederationPlugin.d.ts +16 -0
  13. package/src/plugins/NodeFederationPlugin.js +225 -0
  14. package/src/plugins/NodeFederationPlugin.js.map +1 -0
  15. package/src/plugins/StreamingTargetPlugin.d.ts +11 -0
  16. package/src/plugins/StreamingTargetPlugin.js +41 -0
  17. package/src/plugins/StreamingTargetPlugin.js.map +1 -0
  18. package/src/plugins/UniversalFederationPlugin.d.ts +16 -0
  19. package/src/plugins/UniversalFederationPlugin.js +26 -0
  20. package/src/plugins/UniversalFederationPlugin.js.map +1 -0
  21. package/src/plugins/loadScript.d.ts +6 -0
  22. package/src/{loadScript.js → plugins/loadScript.js} +4 -2
  23. package/src/plugins/loadScript.js.map +1 -0
  24. package/src/types/index.d.ts +3 -0
  25. package/src/types/index.js +3 -0
  26. package/src/types/index.js.map +1 -0
  27. package/LICENSE +0 -21
  28. package/index.js +0 -5
  29. package/src/CommonJsChunkLoadingPlugin.js +0 -89
  30. package/src/LoadFileChunkLoadingRuntimeModule.js +0 -410
  31. package/src/NodeFederationPlugin.js +0 -245
  32. package/src/StreamingTargetPlugin.js +0 -42
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Module Federation Support for Node Environments
2
2
 
3
- This package exposes two Webpack Plugins to bring the concept and power of Module Federation to NodeJS. This will allow your server to fetch chunks across the network allowing for distributed deployments of federated applications.
3
+ This package exposes three Webpack Plugins to bring the concept and power of Module Federation to NodeJS. This will allow your server to fetch chunks across the network allowing for distributed deployments of federated applications.
4
4
 
5
5
  ## Installation
6
6
 
@@ -16,22 +16,59 @@ yarn add @module-federation/node
16
16
 
17
17
  ## Usage
18
18
 
19
- To then use the plugin, modify your `webpack.config.js` to include and use the two plugins.
19
+ There are two approaches to using the plugins exported from this package, dependent on your use case.
20
+
21
+ ### UniversalFederationPlugin
22
+
23
+ This plugin is an abstraction over both `StreamingTargetPlugin` and `ModuleFederationPlugin`. It will alternate between which it uses based on where the build is intended to be used.
24
+
25
+ If the build is intended to be used on the `browser`, it will use the standard `ModuleFederationPlugin` and bundle your code accordingly, however, if it is intended for `server` usage, it will use `StreamingTargetPlugin` to create the bundle.
26
+
27
+ This simplifies the code required in your `webpack.config.js` to enable SSR Module Federation. It determines which platform it needs to build for based on two things:
28
+
29
+ 1. If the options passed to the plugin has specified `isServer: true`
30
+ 2. If the name assigned to the config being used is `server`
31
+
32
+ It accepts the other standard options from `ModuleFederationPlugin` as well. You can see an example usage below:
33
+
34
+ ```js
35
+ const {UniversalFederationPlugin} = require("@module-federation/node");
36
+
37
+ const config = {
38
+ target: isServer ? false : "web",
39
+ plugins: [
40
+ new UniversalFederationPlugin({
41
+ name: 'website2',
42
+ library: {type: 'commonjs-module'},
43
+ isServer: true, // or false
44
+ remotes: {},
45
+ filename: 'remoteEntry.js',
46
+ exposes: {
47
+ './SharedComponent': './remoteServer/SharedComponent',
48
+ },
49
+ }),
50
+ ]
51
+ }
52
+ ```
53
+
54
+ ### StreamingTargetPlugin and NodeFederationPlugin
55
+
56
+ You can also use each of the underlying plugins individually if you need more control over when they are used.
20
57
 
21
58
  At build time, you need to be aware if you're building for the `server` or for the `browser`.
22
59
  If it's building for server, we need to set `target: false` to allow the plugins to function correctly.
23
60
 
24
- The `NodeFederationPlugin` follows the same API as the [Module Federation Plugin](https://webpack.js.org/plugins/module-federation-plugin) and therefore should be a drop-in replacement if you already have it set up in your `webpack.config.js`.
61
+ The `StreamingTargetPlugin` follows the same API as the [Module Federation Plugin](https://webpack.js.org/plugins/module-federation-plugin) and therefore should be a drop-in replacement if you already have it set up in your `webpack.config.js`.
25
62
 
26
63
  An example configuration is presented below:
27
64
  ```js
28
65
 
29
- const {NodeFederationPlugin, StreamingTargetPlugin} = require("@module-federation/node");
66
+ const {StreamingTargetPlugin, NodeFederationPlugin} = require("@module-federation/node");
30
67
 
31
68
  const config = {
32
69
  target: isServer ? false : "web",
33
70
  plugins: [
34
- new NodeFederationPlugin({
71
+ new StreamingTargetPlugin({
35
72
  name: 'website2',
36
73
  library: {type: 'commonjs-module'},
37
74
  remotes: {},
@@ -40,7 +77,7 @@ const config = {
40
77
  './SharedComponent': './remoteServer/SharedComponent',
41
78
  },
42
79
  }),
43
- new StreamingTargetPlugin({
80
+ new NodeFederationPlugin({
44
81
  name: 'website2',
45
82
  library: {type: 'commonjs-module'},
46
83
  remotes: {},
package/package.json CHANGED
@@ -1,10 +1,20 @@
1
1
  {
2
+ "public": true,
2
3
  "name": "@module-federation/node",
3
- "version": "0.0.1",
4
- "description": "Module Federation for Node.js",
5
- "main": "index.js",
4
+ "version": "0.2.0",
5
+ "type": "commonjs",
6
+ "main": "src/index.js",
7
+ "types": "src/index.d.ts",
8
+ "description": "Module Federation helper for Node",
9
+ "repository": "https://github.com/module-federation/nextjs-mf/tree/main/packages/node",
10
+ "author": "Zack Jackson <zackary.l.jackson@gmail.com>",
11
+ "license": "MIT",
12
+ "dependencies": {
13
+ "node-fetch": "^2.6.7",
14
+ "tslib": "^2.3.0"
15
+ },
6
16
  "peerDependencies": {
7
- "webpack": "5.40.0",
8
- "node-fetch": "^3.2.10"
9
- }
17
+ "webpack": "^5.46.0"
18
+ },
19
+ "typings": "./src/index.d.ts"
10
20
  }
package/src/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { default as StreamingTargetPlugin } from './plugins/StreamingTargetPlugin';
2
+ export { default as NodeFederationPlugin } from './plugins/NodeFederationPlugin';
3
+ export { default as UniversalFederationPlugin } from './plugins/UniversalFederationPlugin';
package/src/index.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.UniversalFederationPlugin = exports.NodeFederationPlugin = exports.StreamingTargetPlugin = void 0;
7
+ var StreamingTargetPlugin_1 = require("./plugins/StreamingTargetPlugin");
8
+ Object.defineProperty(exports, "StreamingTargetPlugin", { enumerable: true, get: function () { return __importDefault(StreamingTargetPlugin_1).default; } });
9
+ var NodeFederationPlugin_1 = require("./plugins/NodeFederationPlugin");
10
+ Object.defineProperty(exports, "NodeFederationPlugin", { enumerable: true, get: function () { return __importDefault(NodeFederationPlugin_1).default; } });
11
+ var UniversalFederationPlugin_1 = require("./plugins/UniversalFederationPlugin");
12
+ Object.defineProperty(exports, "UniversalFederationPlugin", { enumerable: true, get: function () { return __importDefault(UniversalFederationPlugin_1).default; } });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/node/src/index.ts"],"names":[],"mappings":";;;;;;AAAA,yEAAmF;AAA1E,+IAAA,OAAO,OAAyB;AACzC,uEAAiF;AAAxE,6IAAA,OAAO,OAAwB;AACxC,iFAA2F;AAAlF,uJAAA,OAAO,OAA6B"}
@@ -0,0 +1,16 @@
1
+ import type { Compiler } from 'webpack';
2
+ import type { ModuleFederationPluginOptions } from '../types';
3
+ interface CommonJsChunkLoadingOptions extends ModuleFederationPluginOptions {
4
+ baseURI: Compiler['options']['output']['publicPath'];
5
+ promiseBaseURI?: string;
6
+ remotes: Record<string, string>;
7
+ name?: string;
8
+ asyncChunkLoading: boolean;
9
+ }
10
+ declare class CommonJsChunkLoadingPlugin {
11
+ private options;
12
+ private _asyncChunkLoading;
13
+ constructor(options: CommonJsChunkLoadingOptions);
14
+ apply(compiler: Compiler): void;
15
+ }
16
+ export default CommonJsChunkLoadingPlugin;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const RuntimeGlobals_1 = tslib_1.__importDefault(require("webpack/lib/RuntimeGlobals"));
5
+ const StartupChunkDependenciesPlugin_1 = tslib_1.__importDefault(require("webpack/lib/runtime/StartupChunkDependenciesPlugin"));
6
+ const LoadFileChunkLoadingRuntimeModule_1 = tslib_1.__importDefault(require("./LoadFileChunkLoadingRuntimeModule"));
7
+ class CommonJsChunkLoadingPlugin {
8
+ constructor(options) {
9
+ this.options = options || {};
10
+ this._asyncChunkLoading = this.options.asyncChunkLoading;
11
+ }
12
+ apply(compiler) {
13
+ const chunkLoadingValue = this._asyncChunkLoading
14
+ ? 'async-node'
15
+ : 'require';
16
+ new StartupChunkDependenciesPlugin_1.default({
17
+ chunkLoading: chunkLoadingValue,
18
+ asyncChunkLoading: this._asyncChunkLoading,
19
+ }).apply(compiler);
20
+ compiler.hooks.thisCompilation.tap('CommonJsChunkLoadingPlugin', (compilation) => {
21
+ // Always enabled
22
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
23
+ const isEnabledForChunk = (_) => true;
24
+ const onceForChunkSet = new WeakSet();
25
+ const handler = (chunk, set) => {
26
+ if (onceForChunkSet.has(chunk))
27
+ return;
28
+ onceForChunkSet.add(chunk);
29
+ if (!isEnabledForChunk(chunk))
30
+ return;
31
+ set.add(RuntimeGlobals_1.default.moduleFactoriesAddOnly);
32
+ set.add(RuntimeGlobals_1.default.hasOwnProperty);
33
+ compilation.addRuntimeModule(chunk, new LoadFileChunkLoadingRuntimeModule_1.default(set, this.options, {
34
+ webpack: compiler.webpack,
35
+ }));
36
+ };
37
+ compilation.hooks.runtimeRequirementInTree
38
+ .for(RuntimeGlobals_1.default.ensureChunkHandlers)
39
+ .tap('CommonJsChunkLoadingPlugin', handler);
40
+ compilation.hooks.runtimeRequirementInTree
41
+ .for(RuntimeGlobals_1.default.hmrDownloadUpdateHandlers)
42
+ .tap('CommonJsChunkLoadingPlugin', handler);
43
+ compilation.hooks.runtimeRequirementInTree
44
+ .for(RuntimeGlobals_1.default.hmrDownloadManifest)
45
+ .tap('CommonJsChunkLoadingPlugin', handler);
46
+ compilation.hooks.runtimeRequirementInTree
47
+ .for(RuntimeGlobals_1.default.baseURI)
48
+ .tap('CommonJsChunkLoadingPlugin', handler);
49
+ compilation.hooks.runtimeRequirementInTree
50
+ .for(RuntimeGlobals_1.default.externalInstallChunk)
51
+ .tap('CommonJsChunkLoadingPlugin', handler);
52
+ compilation.hooks.runtimeRequirementInTree
53
+ .for(RuntimeGlobals_1.default.onChunksLoaded)
54
+ .tap('CommonJsChunkLoadingPlugin', handler);
55
+ compilation.hooks.runtimeRequirementInTree
56
+ .for(RuntimeGlobals_1.default.ensureChunkHandlers)
57
+ .tap('CommonJsChunkLoadingPlugin', (chunk, set) => {
58
+ if (!isEnabledForChunk(chunk))
59
+ return;
60
+ set.add(RuntimeGlobals_1.default.getChunkScriptFilename);
61
+ });
62
+ compilation.hooks.runtimeRequirementInTree
63
+ .for(RuntimeGlobals_1.default.hmrDownloadUpdateHandlers)
64
+ .tap('CommonJsChunkLoadingPlugin', (chunk, set) => {
65
+ if (!isEnabledForChunk(chunk))
66
+ return;
67
+ set.add(RuntimeGlobals_1.default.getChunkUpdateScriptFilename);
68
+ set.add(RuntimeGlobals_1.default.moduleCache);
69
+ set.add(RuntimeGlobals_1.default.hmrModuleData);
70
+ set.add(RuntimeGlobals_1.default.moduleFactoriesAddOnly);
71
+ });
72
+ compilation.hooks.runtimeRequirementInTree
73
+ .for(RuntimeGlobals_1.default.hmrDownloadManifest)
74
+ .tap('CommonJsChunkLoadingPlugin', (chunk, set) => {
75
+ if (!isEnabledForChunk(chunk))
76
+ return;
77
+ set.add(RuntimeGlobals_1.default.getUpdateManifestFilename);
78
+ });
79
+ });
80
+ }
81
+ }
82
+ exports.default = CommonJsChunkLoadingPlugin;
83
+ //# sourceMappingURL=CommonJsChunkLoadingPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommonJsChunkLoadingPlugin.js","sourceRoot":"","sources":["../../../../../packages/node/src/plugins/CommonJsChunkLoadingPlugin.ts"],"names":[],"mappings":";;;AAGA,wFAAwD;AACxD,gIAAgG;AAEhG,oHAA4E;AAU5E,MAAM,0BAA0B;IAI9B,YAAY,OAAoC;QAC9C,IAAI,CAAC,OAAO,GAAG,OAAO,IAAK,EAAkC,CAAC;QAC9D,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;IAC3D,CAAC;IAED,KAAK,CAAC,QAAkB;QACtB,MAAM,iBAAiB,GAAG,IAAI,CAAC,kBAAkB;YAC/C,CAAC,CAAC,YAAY;YACd,CAAC,CAAC,SAAS,CAAC;QAEd,IAAI,wCAA8B,CAAC;YACjC,YAAY,EAAE,iBAAiB;YAC/B,iBAAiB,EAAE,IAAI,CAAC,kBAAkB;SAC3C,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEnB,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAChC,4BAA4B,EAC5B,CAAC,WAAW,EAAE,EAAE;YACd,iBAAiB;YACjB,6DAA6D;YAC7D,MAAM,iBAAiB,GAAG,CAAC,CAAQ,EAAE,EAAE,CAAC,IAAI,CAAC;YAC7C,MAAM,eAAe,GAAG,IAAI,OAAO,EAAE,CAAC;YAEtC,MAAM,OAAO,GAAG,CAAC,KAAY,EAAE,GAAgB,EAAE,EAAE;gBACjD,IAAI,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC;oBAAE,OAAO;gBAEvC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,C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FileChunkLoadingRuntimeModuleOptions {
4
+ baseURI: Compiler['options']['output']['publicPath'];
5
+ promiseBaseURI?: string;
6
+ remotes: Record<string, string>;
7
+ name?: string;
8
+ }
9
+ interface ChunkLoadingContext {
10
+ webpack: Compiler['webpack'];
11
+ }
12
+ declare class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
13
+ private runtimeRequirements;
14
+ private options;
15
+ private chunkLoadingContext;
16
+ constructor(runtimeRequirements: Set<string>, options: ReadFileChunkLoadingRuntimeModuleOptions, chunkLoadingContext: ChunkLoadingContext);
17
+ /**
18
+ * @private
19
+ * @param {Chunk} chunk chunk
20
+ * @param {string} rootOutputDir root output directory
21
+ * @returns {string} generated code
22
+ */
23
+ _generateBaseUri(chunk: Chunk, rootOutputDir: string): string;
24
+ /**
25
+ * @returns {string} runtime code
26
+ */
27
+ generate(): string;
28
+ }
29
+ export default ReadFileChunkLoadingRuntimeModule;
@@ -0,0 +1,333 @@
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ /*
3
+ MIT License http://www.opensource.org/licenses/mit-license.php
4
+ */
5
+ 'use strict';
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const tslib_1 = require("tslib");
8
+ const webpack_1 = require("webpack");
9
+ // import RuntimeGlobals from 'webpack/lib/RuntimeGlobals';
10
+ // import RuntimeModule from 'webpack/lib/RuntimeModule';
11
+ // import Template from 'webpack/lib/Template';
12
+ const compileBooleanMatcher_1 = tslib_1.__importDefault(require("webpack/lib/util/compileBooleanMatcher"));
13
+ const identifier_1 = require("webpack/lib/util/identifier");
14
+ const loadScript_1 = tslib_1.__importDefault(require("./loadScript"));
15
+ class ReadFileChunkLoadingRuntimeModule extends webpack_1.RuntimeModule {
16
+ constructor(runtimeRequirements, options, chunkLoadingContext) {
17
+ super('readFile chunk loading', webpack_1.RuntimeModule.STAGE_ATTACH);
18
+ this.runtimeRequirements = runtimeRequirements;
19
+ this.options = options;
20
+ this.chunkLoadingContext = chunkLoadingContext;
21
+ }
22
+ /**
23
+ * @private
24
+ * @param {Chunk} chunk chunk
25
+ * @param {string} rootOutputDir root output directory
26
+ * @returns {string} generated code
27
+ */
28
+ _generateBaseUri(chunk, rootOutputDir) {
29
+ const options = chunk.getEntryOptions();
30
+ if (options && options.baseUri) {
31
+ return `${webpack_1.RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;
32
+ }
33
+ return `${webpack_1.RuntimeGlobals.baseURI} = require("url").pathToFileURL(${rootOutputDir
34
+ ? `__dirname + ${JSON.stringify('/' + rootOutputDir)}`
35
+ : '__filename'});`;
36
+ }
37
+ /**
38
+ * @returns {string} runtime code
39
+ */
40
+ generate() {
41
+ // name in this context is always the current remote itself.
42
+ // this code below is in each webpack runtime, host and remotes
43
+ // remote entries handle their own loading of chunks, so i have fractal self awareness
44
+ // hosts will likely never run the http chunk loading runtime, they use fs.readFile
45
+ // remotes only use fs.readFile if we were to cache the chunks on disk after fetching - otherwise its always using http
46
+ // so for example, if im in hostA and require(remoteb/module) --> console.log of name in runtime code will return remoteb
47
+ const { remotes, name } = this.options;
48
+ const { webpack } = this.chunkLoadingContext;
49
+ const chunkHasJs = (webpack && webpack.javascript.JavascriptModulesPlugin.chunkHasJs) ||
50
+ require('webpack/lib/javascript/JavascriptModulesPlugin').chunkHasJs;
51
+ // workaround for next.js
52
+ const getInitialChunkIds = (chunk, chunkGraph) => {
53
+ const initialChunkIds = new Set(chunk.ids);
54
+ for (const c of chunk.getAllInitialChunks()) {
55
+ if (c === chunk || chunkHasJs(c, chunkGraph))
56
+ continue;
57
+ if (c.ids) {
58
+ for (const id of c.ids)
59
+ initialChunkIds.add(id);
60
+ }
61
+ }
62
+ return initialChunkIds;
63
+ };
64
+ const { chunkGraph, chunk } = this;
65
+ const { runtimeTemplate } = this.compilation;
66
+ const fn = webpack_1.RuntimeGlobals.ensureChunkHandlers;
67
+ const withBaseURI = this.runtimeRequirements.has(webpack_1.RuntimeGlobals.baseURI);
68
+ const withExternalInstallChunk = this.runtimeRequirements.has(webpack_1.RuntimeGlobals.externalInstallChunk);
69
+ const withOnChunkLoad = this.runtimeRequirements.has(webpack_1.RuntimeGlobals.onChunksLoaded);
70
+ const withLoading = this.runtimeRequirements.has(webpack_1.RuntimeGlobals.ensureChunkHandlers);
71
+ const withHmr = this.runtimeRequirements.has(webpack_1.RuntimeGlobals.hmrDownloadUpdateHandlers);
72
+ const withHmrManifest = this.runtimeRequirements.has(webpack_1.RuntimeGlobals.hmrDownloadManifest);
73
+ const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);
74
+ const hasJsMatcher = (0, compileBooleanMatcher_1.default)(conditionMap);
75
+ const initialChunkIds = getInitialChunkIds(chunk, chunkGraph); // , chunkHasJs);
76
+ const outputName = this.compilation.getPath(((webpack &&
77
+ webpack.javascript.JavascriptModulesPlugin
78
+ .getChunkFilenameTemplate) ||
79
+ require('webpack/lib/javascript/JavascriptModulesPlugin')
80
+ .getChunkFilenameTemplate)(chunk, this.compilation.outputOptions), {
81
+ chunk,
82
+ contentHashType: 'javascript',
83
+ });
84
+ const rootOutputDir = (0, identifier_1.getUndoPath)(outputName, this.compilation.outputOptions.path, false);
85
+ const stateExpression = withHmr
86
+ ? `${webpack_1.RuntimeGlobals.hmrRuntimeStatePrefix}_readFileVm`
87
+ : undefined;
88
+ return webpack_1.Template.asString([
89
+ withBaseURI
90
+ ? this._generateBaseUri(chunk, rootOutputDir)
91
+ : '// no baseURI',
92
+ '',
93
+ '// object to store loaded chunks',
94
+ '// "0" means "already loaded", Promise means loading',
95
+ `var installedChunks = ${stateExpression ? `${stateExpression} = ${stateExpression} || ` : ''}{`,
96
+ webpack_1.Template.indent(Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(',\n')),
97
+ '};',
98
+ '',
99
+ withOnChunkLoad
100
+ ? `${webpack_1.RuntimeGlobals.onChunksLoaded}.readFileVm = ${runtimeTemplate.returningFunction('installedChunks[chunkId] === 0', 'chunkId')};`
101
+ : '// no on chunks loaded',
102
+ '',
103
+ withLoading || withExternalInstallChunk
104
+ ? `var installChunk = ${runtimeTemplate.basicFunction('chunk', [
105
+ 'var moreModules = chunk.modules, chunkIds = chunk.ids, runtime = chunk.runtime;',
106
+ 'for(var moduleId in moreModules) {',
107
+ webpack_1.Template.indent([
108
+ `if(${webpack_1.RuntimeGlobals.hasOwnProperty}(moreModules, moduleId)) {`,
109
+ webpack_1.Template.indent([
110
+ `${webpack_1.RuntimeGlobals.moduleFactories}[moduleId] = moreModules[moduleId];`,
111
+ ]),
112
+ '}',
113
+ ]),
114
+ '}',
115
+ `if(runtime) runtime(__webpack_require__);`,
116
+ 'for(var i = 0; i < chunkIds.length; i++) {',
117
+ webpack_1.Template.indent([
118
+ 'if(installedChunks[chunkIds[i]]) {',
119
+ webpack_1.Template.indent(['installedChunks[chunkIds[i]][0]();']),
120
+ '}',
121
+ 'installedChunks[chunkIds[i]] = 0;',
122
+ ]),
123
+ '}',
124
+ withOnChunkLoad ? `${webpack_1.RuntimeGlobals.onChunksLoaded}();` : '',
125
+ ])};`
126
+ : '// no chunk install function needed',
127
+ '',
128
+ withLoading
129
+ ? webpack_1.Template.asString([
130
+ '// ReadFile + VM.run chunk loading for javascript',
131
+ `${fn}.readFileVm = function(chunkId, promises) {`,
132
+ hasJsMatcher !== false
133
+ ? webpack_1.Template.indent([
134
+ '',
135
+ 'var installedChunkData = installedChunks[chunkId];',
136
+ 'if(installedChunkData !== 0) { // 0 means "already installed".',
137
+ webpack_1.Template.indent([
138
+ '// array of [resolve, reject, promise] means "currently loading"',
139
+ 'if(installedChunkData) {',
140
+ webpack_1.Template.indent(['promises.push(installedChunkData[2]);']),
141
+ '} else {',
142
+ webpack_1.Template.indent([
143
+ hasJsMatcher === true
144
+ ? 'if(true) { // all chunks have JS'
145
+ : `if(${hasJsMatcher('chunkId')}) {`,
146
+ webpack_1.Template.indent([
147
+ '// load the chunk and return promise to it',
148
+ 'var promise = new Promise(async function(resolve, reject) {',
149
+ webpack_1.Template.indent([
150
+ 'installedChunkData = installedChunks[chunkId] = [resolve, reject];',
151
+ `var filename = require('path').join(__dirname, ${JSON.stringify(rootOutputDir)} + ${webpack_1.RuntimeGlobals.getChunkScriptFilename}(chunkId));`,
152
+ "var fs = require('fs');",
153
+ 'if(fs.existsSync(filename)) {',
154
+ webpack_1.Template.indent([
155
+ "fs.readFile(filename, 'utf-8', function(err, content) {",
156
+ webpack_1.Template.indent([
157
+ 'if(err) return reject(err);',
158
+ 'var chunk = {};',
159
+ "require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" +
160
+ "(chunk, require, require('path').dirname(filename), filename);",
161
+ 'installChunk(chunk);',
162
+ ]),
163
+ '});',
164
+ ]),
165
+ '} else {',
166
+ webpack_1.Template.indent([
167
+ loadScript_1.default,
168
+ `console.log('needs to load remote module from', ${JSON.stringify(name)});`,
169
+ `console.log('remotes known to', ${JSON.stringify(name)}, ${JSON.stringify(remotes)})`,
170
+ // keys are mostly useless here, we want to find remote by its global (unique name)
171
+ `var remotes = ${JSON.stringify(Object.values(remotes).reduce((acc, remote) => {
172
+ //TODO: need to handle all other cases like when remote is not a @ syntax string
173
+ const [global, url] = remote.split('@');
174
+ acc[global] = url;
175
+ return acc;
176
+ }, {}))};`,
177
+ 'Object.assign(global.__remote_scope__._config, remotes)',
178
+ 'const remoteRegistry = global.__remote_scope__._config',
179
+ /*
180
+ TODO: keying by global should be ok, but need to verify - need to deal with when user passes promise new promise() global will/should still exist - but can only be known at runtime
181
+ */
182
+ `console.log('remotes keyed by global name',remotes)`,
183
+ `console.log('remote scope configs',global.__remote_scope__._config)`,
184
+ `console.log('global.__remote_scope__',global.__remote_scope__)`,
185
+ `console.log('global.__remote_scope__[${JSON.stringify(name)}]',global.__remote_scope__[${JSON.stringify(name)}])`,
186
+ /* TODO: this global.REMOTE_CONFIG doesnt work in this v5 core, not sure if i need to keep it or not
187
+ not deleting it yet since i might need this for tracking all the remote entries across systems
188
+ for now, im going to use locally known remote scope from remoteEntry config
189
+ update: We will most likely need this, since remote would not have its own config
190
+ id need to access the host system and find the known url
191
+ basically this is how i create publicPath: auto on servers.
192
+ `var requestedRemote = global.REMOTE_CONFIG[${JSON.stringify(
193
+ name
194
+ )}]`,
195
+ */
196
+ "console.log('about to derive remote making request')",
197
+ `var requestedRemote = remoteRegistry[${JSON.stringify(name)}]`,
198
+ "console.log('requested remote', requestedRemote)",
199
+ /*TODO: we need to support when user implements own promise new promise function
200
+ for example i have my own promise remotes, not global@remotename
201
+ so there could be cases where remote may be function still - not sure */
202
+ /*TODO: need to handle if chunk fetch fails/crashes - ensure server still can keep loading
203
+ right now if you throw an error in here, server will stall forever */
204
+ `if(typeof requestedRemote === 'function'){
205
+ requestedRemote = await requestedRemote()
206
+ }`,
207
+ `console.log('var requestedRemote',requestedRemote);`,
208
+ // example: uncomment this and server will never reply
209
+ // `var scriptUrl = new URL(requestedRemote.split("@")[1]);`,
210
+ // since im looping over remote and creating global at build time, i dont need to split string at runtime
211
+ // there may still be a use case for that with promise new promise, depending on how we design it.
212
+ `var scriptUrl = new URL(requestedRemote);`,
213
+ `var chunkName = ${webpack_1.RuntimeGlobals.getChunkScriptFilename}(chunkId);`,
214
+ `console.log('chunkname to request',chunkName);`,
215
+ `var fileToReplace = require('path').basename(scriptUrl.pathname);`,
216
+ `scriptUrl.pathname = scriptUrl.pathname.replace(fileToReplace, chunkName);`,
217
+ `console.log('will load remote chunk', scriptUrl.toString());`,
218
+ `loadScript(scriptUrl.toString(), function(err, content) {`,
219
+ webpack_1.Template.indent([
220
+ "console.log('load script callback fired')",
221
+ "if(err) {console.error('error loading remote chunk', scriptUrl.toString(),'got',content); return reject(err);}",
222
+ 'var chunk = {};',
223
+ 'try {',
224
+ "require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" +
225
+ "(chunk, require, require('path').dirname(filename), filename);",
226
+ '} catch (e) {',
227
+ "console.log('runInThisContext thew', e)",
228
+ '}',
229
+ 'installChunk(chunk);',
230
+ ]),
231
+ '});',
232
+ ]),
233
+ '}',
234
+ ]),
235
+ '});',
236
+ 'promises.push(installedChunkData[2] = promise);',
237
+ ]),
238
+ '} else installedChunks[chunkId] = 0;',
239
+ ]),
240
+ '}',
241
+ ]),
242
+ '}',
243
+ ])
244
+ : webpack_1.Template.indent(['installedChunks[chunkId] = 0;']),
245
+ '};',
246
+ ])
247
+ : '// no chunk loading',
248
+ '',
249
+ withExternalInstallChunk
250
+ ? webpack_1.Template.asString([
251
+ 'module.exports = __webpack_require__;',
252
+ `${webpack_1.RuntimeGlobals.externalInstallChunk} = installChunk;`,
253
+ ])
254
+ : '// no external install chunk',
255
+ '',
256
+ withHmr
257
+ ? webpack_1.Template.asString([
258
+ 'function loadUpdateChunk(chunkId, updatedModulesList) {',
259
+ webpack_1.Template.indent([
260
+ 'return new Promise(function(resolve, reject) {',
261
+ webpack_1.Template.indent([
262
+ `var filename = require('path').join(__dirname, ${JSON.stringify(rootOutputDir)} + ${webpack_1.RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId));`,
263
+ "require('fs').readFile(filename, 'utf-8', function(err, content) {",
264
+ webpack_1.Template.indent([
265
+ 'if(err) return reject(err);',
266
+ 'var update = {};',
267
+ "require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" +
268
+ "(update, require, require('path').dirname(filename), filename);",
269
+ 'var updatedModules = update.modules;',
270
+ 'var runtime = update.runtime;',
271
+ 'for(var moduleId in updatedModules) {',
272
+ webpack_1.Template.indent([
273
+ `if(${webpack_1.RuntimeGlobals.hasOwnProperty}(updatedModules, moduleId)) {`,
274
+ webpack_1.Template.indent([
275
+ `currentUpdate[moduleId] = updatedModules[moduleId];`,
276
+ 'if(updatedModulesList) updatedModulesList.push(moduleId);',
277
+ ]),
278
+ '}',
279
+ ]),
280
+ '}',
281
+ 'if(runtime) currentUpdateRuntime.push(runtime);',
282
+ 'resolve();',
283
+ ]),
284
+ '});',
285
+ ]),
286
+ '});',
287
+ ]),
288
+ '}',
289
+ '',
290
+ webpack_1.Template.getFunctionContent(require('../hmr/JavascriptHotModuleReplacement.runtime.js'))
291
+ .replace(/\$key\$/g, 'readFileVm')
292
+ .replace(/\$installedChunks\$/g, 'installedChunks')
293
+ .replace(/\$loadUpdateChunk\$/g, 'loadUpdateChunk')
294
+ .replace(/\$moduleCache\$/g, webpack_1.RuntimeGlobals.moduleCache)
295
+ .replace(/\$moduleFactories\$/g, webpack_1.RuntimeGlobals.moduleFactories)
296
+ .replace(/\$ensureChunkHandlers\$/g, webpack_1.RuntimeGlobals.ensureChunkHandlers)
297
+ .replace(/\$hasOwnProperty\$/g, webpack_1.RuntimeGlobals.hasOwnProperty)
298
+ .replace(/\$hmrModuleData\$/g, webpack_1.RuntimeGlobals.hmrModuleData)
299
+ .replace(/\$hmrDownloadUpdateHandlers\$/g, webpack_1.RuntimeGlobals.hmrDownloadUpdateHandlers)
300
+ .replace(/\$hmrInvalidateModuleHandlers\$/g, webpack_1.RuntimeGlobals.hmrInvalidateModuleHandlers),
301
+ ])
302
+ : '// no HMR',
303
+ '',
304
+ withHmrManifest
305
+ ? webpack_1.Template.asString([
306
+ `${webpack_1.RuntimeGlobals.hmrDownloadManifest} = function() {`,
307
+ webpack_1.Template.indent([
308
+ 'return new Promise(function(resolve, reject) {',
309
+ webpack_1.Template.indent([
310
+ `var filename = require('path').join(__dirname, ${JSON.stringify(rootOutputDir)} + ${webpack_1.RuntimeGlobals.getUpdateManifestFilename}());`,
311
+ "require('fs').readFile(filename, 'utf-8', function(err, content) {",
312
+ webpack_1.Template.indent([
313
+ 'if(err) {',
314
+ webpack_1.Template.indent([
315
+ 'if(err.code === "ENOENT") return resolve();',
316
+ 'return reject(err);',
317
+ ]),
318
+ '}',
319
+ 'try { resolve(JSON.parse(content)); }',
320
+ 'catch(e) { reject(e); }',
321
+ ]),
322
+ '});',
323
+ ]),
324
+ '});',
325
+ ]),
326
+ '}',
327
+ ])
328
+ : '// no HMR manifest',
329
+ ]);
330
+ }
331
+ }
332
+ exports.default = ReadFileChunkLoadingRuntimeModule;
333
+ //# sourceMappingURL=LoadFileChunkLoadingRuntimeModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoadFileChunkLoadingRuntimeModule.js","sourceRoot":"","sources":["../../../../../packages/node/src/plugins/LoadFileChunkLoadingRuntimeModule.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD;;EAEE;AAEF,YAAY,CAAC;;;AAGb,qCAAkE;AAElE,2DAA2D;AAC3D,yDAAyD;AACzD,+CAA+C;AAC/C,2GAA2E;AAC3E,4DAA0D;AAE1D,sEAA8C;AAa9C,MAAM,iCAAkC,SAAQ,uBAAa;IAK3D,YACE,mBAAgC,EAChC,OAAiD,EACjD,mBAAwC;QAExC,KAAK,CAAC,wBAAwB,EAAE,uBAAa,CAAC,YAAY,CAAC,CAAC;QAC5D,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;QAC/C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,KAAY,EAAE,aAAqB;QAClD,MAAM,OAAO,GAAG,KAAK,CAAC,eAAe,EAAE,CAAC;QACxC,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,EAAE;YAC9B,OAAO,GAAG,wBAAc,CAAC,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;SAC1E;QAED,OAAO,GAAG,wBAAc,CAAC,OAAO,mCAC9B,aAAa;YACX,CAAC,CAAC,eAAe,IAAI,CAAC,SAAS,CAAC,GAAG,GAAG,aAAa,CAAC,EAAE;YACtD,CAAC,CAAC,YACN,IAAI,CAAC;IACP,CAAC;IAED;;OAEG;IACM,QAAQ;QACf,4DAA4D;QAC5D,+DAA+D;QAC/D,sFAAsF;QACtF,mFAAmF;QACnF,uHA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OAAO,CACN,0BAA0B,EAC1B,wBAAc,CAAC,mBAAmB,CACnC;yBACA,OAAO,CAAC,qBAAqB,EAAE,wBAAc,CAAC,cAAc,CAAC;yBAC7D,OAAO,CAAC,oBAAoB,EAAE,wBAAc,CAAC,aAAa,CAAC;yBAC3D,OAAO,CACN,gCAAgC,EAChC,wBAAc,CAAC,yBAAyB,CACzC;yBACA,OAAO,CACN,kCAAkC,EAClC,wBAAc,CAAC,2BAA2B,CAC3C;iBACJ,CAAC;gBACJ,CAAC,CAAC,WAAW;YACf,EAAE;YACF,eAAe;gBACb,CAAC,CAAC,kBAAQ,CAAC,QAAQ,CAAC;oBAChB,GAAG,wBAAc,CAAC,mBAAmB,iBAAiB;oBACtD,kBAAQ,CAAC,MAAM,CAAC;wBACd,gDAAgD;wBAChD,kBAAQ,CAAC,MAAM,CAAC;4BACd,kDAAkD,IAAI,CAAC,SAAS,CAC9D,aAAa,CACd,MAAM,wBAAc,CAAC,yBAAyB,MAAM;4BACrD,oEAAoE;4BACpE,kBAAQ,CAAC,MAAM,CAAC;gCACd,WAAW;gCACX,kBAAQ,CAAC,MAAM,CAAC;oCACd,6CAA6C;oCAC7C,qBAAqB;iCACtB,CAAC;gCACF,GAAG;gCACH,uCAAuC;gCACvC,yBAAyB;6BAC1B,CAAC;4BACF,KAAK;yBACN,CAAC;wBACF,KAAK;qBACN,CAAC;oBACF,GAAG;iBACJ,CAAC;gBACJ,CAAC,CAAC,oBAAoB;SACzB,CAAC,CAAC;IACL,CAAC;CACF;AAED,kBAAe,iCAAiC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Compiler, container } from 'webpack';
2
+ import type { ModuleFederationPluginOptions } from '../types';
3
+ interface NodeFederationOptions extends ModuleFederationPluginOptions {
4
+ experiments?: Record<string, unknown>;
5
+ }
6
+ interface Context {
7
+ ModuleFederationPlugin?: typeof container.ModuleFederationPlugin;
8
+ }
9
+ declare class NodeFederationPlugin {
10
+ private options;
11
+ private context;
12
+ private experiments;
13
+ constructor({ experiments, ...options }: NodeFederationOptions, context: Context);
14
+ apply(compiler: Compiler): void;
15
+ }
16
+ export default NodeFederationPlugin;