@module-federation/node 2.0.1 → 2.0.2-beta.2
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/CHANGELOG.md +43 -0
- package/README.md +27 -0
- package/jest.config.d.ts +11 -0
- package/jest.config.js +19 -0
- package/jest.config.js.map +1 -0
- package/package.json +3 -2
- package/src/filesystem/DynamicFilesystemRuntimeModule.d.ts +6 -0
- package/src/filesystem/DynamicFilesystemRuntimeModule.js +30 -0
- package/src/filesystem/DynamicFilesystemRuntimeModule.js.map +1 -0
- package/src/filesystem/stratagies.d.ts +11 -0
- package/src/filesystem/stratagies.js +105 -0
- package/src/filesystem/stratagies.js.map +1 -0
- package/src/plugins/CommonJsChunkLoadingPlugin.js +29 -2
- package/src/plugins/CommonJsChunkLoadingPlugin.js.map +1 -1
- package/src/plugins/{LoadFileChunkLoadingRuntimeModule.d.ts → DynamicFilesystemChunkLoadingRuntimeModule.d.ts} +8 -4
- package/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js +145 -0
- package/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js.map +1 -0
- package/src/plugins/FederationModuleInfoRuntimeModule.d.ts +9 -0
- package/src/plugins/FederationModuleInfoRuntimeModule.js +55 -0
- package/src/plugins/FederationModuleInfoRuntimeModule.js.map +1 -0
- package/src/plugins/NodeFederationPlugin.d.ts +18 -25
- package/src/plugins/NodeFederationPlugin.js +41 -102
- package/src/plugins/NodeFederationPlugin.js.map +1 -1
- package/src/plugins/RemotePublicPathRuntimeModule.d.ts +10 -0
- package/src/plugins/RemotePublicPathRuntimeModule.js +86 -0
- package/src/plugins/RemotePublicPathRuntimeModule.js.map +1 -0
- package/src/plugins/StreamingTargetPlugin.js +6 -7
- package/src/plugins/StreamingTargetPlugin.js.map +1 -1
- package/src/plugins/UniversalFederationPlugin.js +2 -1
- package/src/plugins/UniversalFederationPlugin.js.map +1 -1
- package/src/plugins/parts.d.ts +50 -0
- package/src/plugins/parts.js +316 -0
- package/src/plugins/parts.js.map +1 -0
- package/src/plugins/LoadFileChunkLoadingRuntimeModule.js +0 -434
- package/src/plugins/LoadFileChunkLoadingRuntimeModule.js.map +0 -1
- package/src/plugins/loadScript.d.ts +0 -7
- package/src/plugins/loadScript.js +0 -116
- package/src/plugins/loadScript.js.map +0 -1
|
@@ -1,434 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const webpack_1 = require("webpack");
|
|
30
|
-
const identifier_1 = require("webpack/lib/util/identifier");
|
|
31
|
-
const compileBooleanMatcher_1 = __importDefault(require("webpack/lib/util/compileBooleanMatcher"));
|
|
32
|
-
const loadScript_1 = __importStar(require("./loadScript"));
|
|
33
|
-
class ReadFileChunkLoadingRuntimeModule extends webpack_1.RuntimeModule {
|
|
34
|
-
constructor(runtimeRequirements, options, chunkLoadingContext) {
|
|
35
|
-
super('readFile chunk loading', webpack_1.RuntimeModule.STAGE_ATTACH);
|
|
36
|
-
this.runtimeRequirements = runtimeRequirements;
|
|
37
|
-
this.options = options;
|
|
38
|
-
this.chunkLoadingContext = chunkLoadingContext;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* @private
|
|
42
|
-
* @param {Chunk} chunk chunk
|
|
43
|
-
* @param {string} rootOutputDir root output directory
|
|
44
|
-
* @returns {string} generated code
|
|
45
|
-
*/
|
|
46
|
-
_generateBaseUri(chunk, rootOutputDir) {
|
|
47
|
-
const options = chunk.getEntryOptions();
|
|
48
|
-
if (options && options.baseUri) {
|
|
49
|
-
return `${webpack_1.RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;
|
|
50
|
-
}
|
|
51
|
-
return `${webpack_1.RuntimeGlobals.baseURI} = require("url").pathToFileURL(${rootOutputDir
|
|
52
|
-
? `__dirname + ${JSON.stringify('/' + rootOutputDir)}`
|
|
53
|
-
: '__filename'});`;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* @private
|
|
57
|
-
* @param {unknown[]} items item to log
|
|
58
|
-
*/
|
|
59
|
-
_getLogger(...items) {
|
|
60
|
-
if (!this.options.debug) {
|
|
61
|
-
return '';
|
|
62
|
-
}
|
|
63
|
-
return `console.log(${items.join(',')});`;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* @returns {string} runtime code
|
|
67
|
-
*/
|
|
68
|
-
generate() {
|
|
69
|
-
// name in this context is always the current remote itself.
|
|
70
|
-
// this code below is in each webpack runtime, host and remotes
|
|
71
|
-
// remote entries handle their own loading of chunks, so i have fractal self awareness
|
|
72
|
-
// hosts will likely never run the http chunk loading runtime, they use fs.readFile
|
|
73
|
-
// remotes only use fs.readFile if we were to cache the chunks on disk after fetching - otherwise its always using http
|
|
74
|
-
// so for example, if im in hostA and require(remoteb/module) --> console.log of name in runtime code will return remoteb
|
|
75
|
-
const { remotes = {}, name } = this.options;
|
|
76
|
-
// for delegate modules, we need to avoid serializing internal modules, only register primitive configs in the runtime
|
|
77
|
-
// delegates have their own registration code, so we dont need to handle them here.
|
|
78
|
-
const remotesByType = Object.values(remotes).reduce((acc, remote) => {
|
|
79
|
-
if (remote.startsWith('promise ') ||
|
|
80
|
-
remote.startsWith('internal ') ||
|
|
81
|
-
remote.startsWith('external ')) {
|
|
82
|
-
acc.functional.push(remote);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
acc.normal.push(remote);
|
|
86
|
-
}
|
|
87
|
-
return acc;
|
|
88
|
-
}, { functional: [], normal: [] });
|
|
89
|
-
const { webpack } = this.chunkLoadingContext;
|
|
90
|
-
const { chunkGraph, chunk, compilation } = this;
|
|
91
|
-
if (!chunkGraph || !chunk || !compilation) {
|
|
92
|
-
return '';
|
|
93
|
-
}
|
|
94
|
-
const { runtimeTemplate } = compilation;
|
|
95
|
-
const jsModulePlugin = webpack?.javascript.JavascriptModulesPlugin ||
|
|
96
|
-
require('webpack/lib/javascript/JavascriptModulesPlugin');
|
|
97
|
-
const { chunkHasJs } = jsModulePlugin;
|
|
98
|
-
// workaround for next.js
|
|
99
|
-
const getInitialChunkIds = (chunk, chunkGraph) => {
|
|
100
|
-
const initialChunkIds = new Set(chunk.ids);
|
|
101
|
-
for (const c of chunk.getAllInitialChunks()) {
|
|
102
|
-
if (c === chunk || chunkHasJs(c, chunkGraph)) {
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
if (c.ids) {
|
|
106
|
-
for (const id of c.ids)
|
|
107
|
-
initialChunkIds.add(id);
|
|
108
|
-
}
|
|
109
|
-
for (const c of chunk.getAllAsyncChunks()) {
|
|
110
|
-
if (c === chunk || chunkHasJs(c, chunkGraph)) {
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
if (c.ids) {
|
|
114
|
-
for (const id of c.ids)
|
|
115
|
-
initialChunkIds.add(id);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return initialChunkIds;
|
|
120
|
-
};
|
|
121
|
-
const fn = webpack_1.RuntimeGlobals.ensureChunkHandlers;
|
|
122
|
-
const withBaseURI = this.runtimeRequirements.has(webpack_1.RuntimeGlobals.baseURI);
|
|
123
|
-
const withExternalInstallChunk = this.runtimeRequirements.has(webpack_1.RuntimeGlobals.externalInstallChunk);
|
|
124
|
-
const withOnChunkLoad = this.runtimeRequirements.has(webpack_1.RuntimeGlobals.onChunksLoaded);
|
|
125
|
-
const withLoading = this.runtimeRequirements.has(webpack_1.RuntimeGlobals.ensureChunkHandlers);
|
|
126
|
-
const withHmr = this.runtimeRequirements.has(webpack_1.RuntimeGlobals.hmrDownloadUpdateHandlers);
|
|
127
|
-
const withHmrManifest = this.runtimeRequirements.has(webpack_1.RuntimeGlobals.hmrDownloadManifest);
|
|
128
|
-
const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);
|
|
129
|
-
const hasJsMatcher = (0, compileBooleanMatcher_1.default)(conditionMap);
|
|
130
|
-
const initialChunkIds = getInitialChunkIds(chunk, chunkGraph); // , chunkHasJs);
|
|
131
|
-
const outputName = compilation.getPath(jsModulePlugin.getChunkFilenameTemplate(chunk, compilation.outputOptions), {
|
|
132
|
-
chunk,
|
|
133
|
-
contentHashType: 'javascript',
|
|
134
|
-
});
|
|
135
|
-
const rootOutputDir = (0, identifier_1.getUndoPath)(outputName, compilation.outputOptions.path, false);
|
|
136
|
-
const stateExpression = withHmr
|
|
137
|
-
? `${webpack_1.RuntimeGlobals.hmrRuntimeStatePrefix}_readFileVm`
|
|
138
|
-
: undefined;
|
|
139
|
-
return webpack_1.Template.asString([
|
|
140
|
-
withBaseURI
|
|
141
|
-
? this._generateBaseUri(chunk, rootOutputDir)
|
|
142
|
-
: '// no baseURI',
|
|
143
|
-
'',
|
|
144
|
-
'// object to store loaded chunks',
|
|
145
|
-
'// "0" means "already loaded", Promise means loading',
|
|
146
|
-
`var installedChunks = ${stateExpression ? `${stateExpression} = ${stateExpression} || ` : ''}{`,
|
|
147
|
-
webpack_1.Template.indent(Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(',\n')),
|
|
148
|
-
'};',
|
|
149
|
-
'',
|
|
150
|
-
withOnChunkLoad
|
|
151
|
-
? `${webpack_1.RuntimeGlobals.onChunksLoaded}.readFileVm = ${runtimeTemplate.returningFunction('installedChunks[chunkId] === 0', 'chunkId')};`
|
|
152
|
-
: '// no on chunks loaded',
|
|
153
|
-
'',
|
|
154
|
-
withLoading || withExternalInstallChunk
|
|
155
|
-
? `var installChunk = ${runtimeTemplate.basicFunction('chunk', [
|
|
156
|
-
'var moreModules = chunk.modules, chunkIds = chunk.ids, runtime = chunk.runtime;',
|
|
157
|
-
'for(var moduleId in moreModules) {',
|
|
158
|
-
webpack_1.Template.indent([
|
|
159
|
-
`if(${webpack_1.RuntimeGlobals.hasOwnProperty}(moreModules, moduleId)) {`,
|
|
160
|
-
webpack_1.Template.indent([
|
|
161
|
-
`${webpack_1.RuntimeGlobals.moduleFactories}[moduleId] = moreModules[moduleId];`,
|
|
162
|
-
]),
|
|
163
|
-
'}',
|
|
164
|
-
]),
|
|
165
|
-
'}',
|
|
166
|
-
`if(runtime) runtime(__webpack_require__);`,
|
|
167
|
-
'for(var i = 0; i < chunkIds.length; i++) {',
|
|
168
|
-
webpack_1.Template.indent([
|
|
169
|
-
'if(installedChunks[chunkIds[i]]) {',
|
|
170
|
-
webpack_1.Template.indent(['installedChunks[chunkIds[i]][0]();']),
|
|
171
|
-
'}',
|
|
172
|
-
'installedChunks[chunkIds[i]] = 0;',
|
|
173
|
-
]),
|
|
174
|
-
'}',
|
|
175
|
-
withOnChunkLoad ? `${webpack_1.RuntimeGlobals.onChunksLoaded}();` : '',
|
|
176
|
-
])};`
|
|
177
|
-
: '// no chunk install function needed',
|
|
178
|
-
'',
|
|
179
|
-
withLoading
|
|
180
|
-
? webpack_1.Template.asString([
|
|
181
|
-
'// load script equivalent for server side',
|
|
182
|
-
`${webpack_1.RuntimeGlobals.loadScript} = ${runtimeTemplate.basicFunction('url,callback,chunkId', [
|
|
183
|
-
webpack_1.Template.indent([
|
|
184
|
-
'if(!globalThis.__remote_scope__) {',
|
|
185
|
-
webpack_1.Template.indent([
|
|
186
|
-
'// create a global scope for container, similar to how remotes are set on window in the browser',
|
|
187
|
-
'globalThis.__remote_scope__ = {',
|
|
188
|
-
'_config: {},',
|
|
189
|
-
'}',
|
|
190
|
-
]),
|
|
191
|
-
'}',
|
|
192
|
-
]),
|
|
193
|
-
webpack_1.Template.indent([
|
|
194
|
-
loadScript_1.executeLoadTemplate,
|
|
195
|
-
`executeLoad(url,callback,chunkId)`,
|
|
196
|
-
]),
|
|
197
|
-
])}`,
|
|
198
|
-
])
|
|
199
|
-
: '// no remote script loader needed',
|
|
200
|
-
withLoading
|
|
201
|
-
? webpack_1.Template.asString([
|
|
202
|
-
'// ReadFile + VM.run chunk loading for javascript',
|
|
203
|
-
`${fn}.readFileVm = function(chunkId, promises) {`,
|
|
204
|
-
hasJsMatcher !== false
|
|
205
|
-
? webpack_1.Template.indent([
|
|
206
|
-
'',
|
|
207
|
-
'var installedChunkData = installedChunks[chunkId];',
|
|
208
|
-
'if(installedChunkData !== 0) { // 0 means "already installed".',
|
|
209
|
-
webpack_1.Template.indent([
|
|
210
|
-
'// array of [resolve, reject, promise] means "currently loading"',
|
|
211
|
-
'if(installedChunkData) {',
|
|
212
|
-
webpack_1.Template.indent(['promises.push(installedChunkData[2]);']),
|
|
213
|
-
'} else {',
|
|
214
|
-
webpack_1.Template.indent([
|
|
215
|
-
hasJsMatcher === true
|
|
216
|
-
? 'if(true) { // all chunks have JS'
|
|
217
|
-
: `if(${hasJsMatcher('chunkId')}) {`,
|
|
218
|
-
webpack_1.Template.indent([
|
|
219
|
-
'// load the chunk and return promise to it',
|
|
220
|
-
'var promise = new Promise(async function(resolve, reject) {',
|
|
221
|
-
webpack_1.Template.indent([
|
|
222
|
-
'installedChunkData = installedChunks[chunkId] = [resolve, reject];',
|
|
223
|
-
`var filename = typeof process !== "undefined" ? require('path').join(__dirname, ${JSON.stringify(rootOutputDir)} + ${webpack_1.RuntimeGlobals.getChunkScriptFilename}(chunkId)) : false;`,
|
|
224
|
-
'var fs = typeof process !== "undefined" ? require(\'fs\') : false;',
|
|
225
|
-
'if(fs && fs.existsSync(filename)) {',
|
|
226
|
-
this._getLogger(`'chunk filename local load', chunkId`),
|
|
227
|
-
webpack_1.Template.indent([
|
|
228
|
-
"fs.readFile(filename, 'utf-8', function(err, content) {",
|
|
229
|
-
webpack_1.Template.indent([
|
|
230
|
-
'if(err) return reject(err);',
|
|
231
|
-
'var chunk = {};',
|
|
232
|
-
"require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" +
|
|
233
|
-
"(chunk, require, require('path').dirname(filename), filename);",
|
|
234
|
-
'installChunk(chunk);',
|
|
235
|
-
]),
|
|
236
|
-
'});',
|
|
237
|
-
]),
|
|
238
|
-
'} else {',
|
|
239
|
-
webpack_1.Template.indent([
|
|
240
|
-
loadScript_1.default,
|
|
241
|
-
this._getLogger(`'needs to load remote module from ${JSON.stringify(name)}'`),
|
|
242
|
-
this._getLogger(`'remotes known to'`, JSON.stringify(name), JSON.stringify(remotes)),
|
|
243
|
-
// keys are mostly useless here, we want to find remote by its global (unique name)
|
|
244
|
-
`var remotes = ${JSON.stringify(Object.values(remotes).reduce((acc, remote) => {
|
|
245
|
-
//TODO: need to handle all other cases like when remote is not a @ syntax string
|
|
246
|
-
const [global, url] = remote.split('@');
|
|
247
|
-
acc[global] = url;
|
|
248
|
-
return acc;
|
|
249
|
-
}, {}))};`,
|
|
250
|
-
webpack_1.Template.indent([
|
|
251
|
-
'if(!globalThis.__remote_scope__) {',
|
|
252
|
-
webpack_1.Template.indent([
|
|
253
|
-
'// create a global scope for container, similar to how remotes are set on window in the browser',
|
|
254
|
-
'globalThis.__remote_scope__ = {',
|
|
255
|
-
'_config: {},',
|
|
256
|
-
'}',
|
|
257
|
-
]),
|
|
258
|
-
'}',
|
|
259
|
-
]),
|
|
260
|
-
//TODO: double check this file and see if we can remove assigning to global scope (its a older hack)
|
|
261
|
-
// 'Object.assign(globalThis.__remote_scope__._config, remotes)',
|
|
262
|
-
'const remoteRegistry = globalThis.__remote_scope__._config',
|
|
263
|
-
/*
|
|
264
|
-
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
|
|
265
|
-
*/
|
|
266
|
-
this._getLogger(`'remotes keyed by global name'`, JSON.stringify(remotes)),
|
|
267
|
-
this._getLogger(`'remote scope configs'`, 'globalThis.__remote_scope__._config'),
|
|
268
|
-
this._getLogger(`'before remote scope'`),
|
|
269
|
-
this._getLogger(`'globalThis.__remote_scope__'`, `globalThis.__remote_scope__`),
|
|
270
|
-
this._getLogger(`'globalThis.__remote_scope__[${JSON.stringify(name)}]'`, `globalThis.__remote_scope__[${JSON.stringify(name)}]`),
|
|
271
|
-
/* TODO: this global.REMOTE_CONFIG doesnt work in this v5 core, not sure if i need to keep it or not
|
|
272
|
-
not deleting it yet since i might need this for tracking all the remote entries across systems
|
|
273
|
-
for now, im going to use locally known remote scope from remoteEntry config
|
|
274
|
-
update: We will most likely need this, since remote would not have its own config
|
|
275
|
-
id need to access the host system and find the known url
|
|
276
|
-
basically this is how i create publicPath: auto on servers.
|
|
277
|
-
`var requestedRemote = global.REMOTE_CONFIG[${JSON.stringify(
|
|
278
|
-
name
|
|
279
|
-
)}]`,
|
|
280
|
-
*/
|
|
281
|
-
`var requestedRemote = remoteRegistry[${JSON.stringify(name)}]`,
|
|
282
|
-
this._getLogger(`'requested remote'`, `requestedRemote`),
|
|
283
|
-
/*TODO: we need to support when user implements own promise new promise function
|
|
284
|
-
for example i have my own promise remotes, not global@remotename
|
|
285
|
-
so there could be cases where remote may be function still - not sure */
|
|
286
|
-
/*TODO: need to handle if chunk fetch fails/crashes - ensure server still can keep loading
|
|
287
|
-
right now if you throw an error in here, server will stall forever */
|
|
288
|
-
`if(typeof requestedRemote === 'function'){
|
|
289
|
-
requestedRemote = await requestedRemote()
|
|
290
|
-
}`,
|
|
291
|
-
this._getLogger(`'var requestedRemote'`, `requestedRemote`),
|
|
292
|
-
// example: uncomment this and server will never reply
|
|
293
|
-
// `var scriptUrl = new URL(requestedRemote.split("@")[1]);`,
|
|
294
|
-
// since im looping over remote and creating global at build time, i dont need to split string at runtime
|
|
295
|
-
// there may still be a use case for that with promise new promise, depending on how we design it.
|
|
296
|
-
this._getLogger('"requestedRemote"', 'requestedRemote', 'current name', JSON.stringify(name)),
|
|
297
|
-
`var scriptUrl = new URL(requestedRemote);`,
|
|
298
|
-
this._getLogger(`'globalThis.__remote_scope__'`, `globalThis.__remote_scope__`),
|
|
299
|
-
`var chunkName = ${webpack_1.RuntimeGlobals.getChunkScriptFilename}(chunkId);`,
|
|
300
|
-
this._getLogger(`'chunkname to request'`, `chunkName`),
|
|
301
|
-
`
|
|
302
|
-
var getBasenameFromUrl = (url) => {
|
|
303
|
-
const urlParts = url.split('/');
|
|
304
|
-
return urlParts[urlParts.length - 1];
|
|
305
|
-
};
|
|
306
|
-
var fileToReplace = typeof process !== "undefined" ? require('path').basename(scriptUrl.pathname) : getBasenameFromUrl(scriptUrl.pathname);`,
|
|
307
|
-
`scriptUrl.pathname = scriptUrl.pathname.replace(fileToReplace, chunkName);`,
|
|
308
|
-
this._getLogger(`'will load remote chunk'`, `scriptUrl.toString()`),
|
|
309
|
-
`loadScript(scriptUrl.toString(), function(err, content) {`,
|
|
310
|
-
webpack_1.Template.indent([
|
|
311
|
-
this._getLogger(`'load script callback fired'`),
|
|
312
|
-
"if(err) {console.error('error loading remote chunk', scriptUrl.toString(),'got',content); return reject(err);}",
|
|
313
|
-
'var chunk = {};',
|
|
314
|
-
"if(typeof process !== 'undefined') {",
|
|
315
|
-
'try {',
|
|
316
|
-
"require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" +
|
|
317
|
-
"(chunk, require, require('path').dirname(filename), filename);",
|
|
318
|
-
'} catch (e) {',
|
|
319
|
-
"console.error('runInThisContext threw', e)",
|
|
320
|
-
'}',
|
|
321
|
-
'} else {',
|
|
322
|
-
"eval('(function(exports, require, __dirname, __filename) {' + content + '\\n})')(chunk, __webpack_require__, '.', chunkName);",
|
|
323
|
-
'}',
|
|
324
|
-
'installChunk(chunk);',
|
|
325
|
-
]),
|
|
326
|
-
'});',
|
|
327
|
-
]),
|
|
328
|
-
'}',
|
|
329
|
-
]),
|
|
330
|
-
'});',
|
|
331
|
-
'promises.push(installedChunkData[2] = promise);',
|
|
332
|
-
]),
|
|
333
|
-
'} else installedChunks[chunkId] = 0;',
|
|
334
|
-
]),
|
|
335
|
-
'}',
|
|
336
|
-
]),
|
|
337
|
-
'}',
|
|
338
|
-
])
|
|
339
|
-
: webpack_1.Template.indent(['installedChunks[chunkId] = 0;']),
|
|
340
|
-
'};',
|
|
341
|
-
])
|
|
342
|
-
: '// no chunk loading',
|
|
343
|
-
'',
|
|
344
|
-
withExternalInstallChunk
|
|
345
|
-
? webpack_1.Template.asString([
|
|
346
|
-
'module.exports = __webpack_require__;',
|
|
347
|
-
`${webpack_1.RuntimeGlobals.externalInstallChunk} = function(){`,
|
|
348
|
-
this.options.debug
|
|
349
|
-
? `console.debug('node: webpack installing to install chunk id:', arguments['0'].id);`
|
|
350
|
-
: '',
|
|
351
|
-
`return installChunk.apply(this, arguments)};`,
|
|
352
|
-
])
|
|
353
|
-
: '// no external install chunk',
|
|
354
|
-
'',
|
|
355
|
-
withHmr
|
|
356
|
-
? webpack_1.Template.asString([
|
|
357
|
-
'function loadUpdateChunk(chunkId, updatedModulesList) {',
|
|
358
|
-
webpack_1.Template.indent([
|
|
359
|
-
'return new Promise(function(resolve, reject) {',
|
|
360
|
-
webpack_1.Template.indent([
|
|
361
|
-
`var filename = require('path').join(__dirname, ${JSON.stringify(rootOutputDir)} + ${webpack_1.RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId));`,
|
|
362
|
-
"require('fs').readFile(filename, 'utf-8', function(err, content) {",
|
|
363
|
-
webpack_1.Template.indent([
|
|
364
|
-
'if(err) return reject(err);',
|
|
365
|
-
'var update = {};',
|
|
366
|
-
"require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" +
|
|
367
|
-
"(update, require, require('path').dirname(filename), filename);",
|
|
368
|
-
'var updatedModules = update.modules;',
|
|
369
|
-
'var runtime = update.runtime;',
|
|
370
|
-
'for(var moduleId in updatedModules) {',
|
|
371
|
-
webpack_1.Template.indent([
|
|
372
|
-
`if(${webpack_1.RuntimeGlobals.hasOwnProperty}(updatedModules, moduleId)) {`,
|
|
373
|
-
webpack_1.Template.indent([
|
|
374
|
-
`currentUpdate[moduleId] = updatedModules[moduleId];`,
|
|
375
|
-
'if(updatedModulesList) updatedModulesList.push(moduleId);',
|
|
376
|
-
]),
|
|
377
|
-
'}',
|
|
378
|
-
]),
|
|
379
|
-
'}',
|
|
380
|
-
'if(runtime) currentUpdateRuntime.push(runtime);',
|
|
381
|
-
'resolve();',
|
|
382
|
-
]),
|
|
383
|
-
'});',
|
|
384
|
-
]),
|
|
385
|
-
'});',
|
|
386
|
-
]),
|
|
387
|
-
'}',
|
|
388
|
-
'',
|
|
389
|
-
webpack_1.Template.getFunctionContent(
|
|
390
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
391
|
-
require('webpack/lib/hmr/JavascriptHotModuleReplacement.runtime.js'))
|
|
392
|
-
.replace(/\$key\$/g, 'readFileVm')
|
|
393
|
-
.replace(/\$installedChunks\$/g, 'installedChunks')
|
|
394
|
-
.replace(/\$loadUpdateChunk\$/g, 'loadUpdateChunk')
|
|
395
|
-
.replace(/\$moduleCache\$/g, webpack_1.RuntimeGlobals.moduleCache)
|
|
396
|
-
.replace(/\$moduleFactories\$/g, webpack_1.RuntimeGlobals.moduleFactories)
|
|
397
|
-
.replace(/\$ensureChunkHandlers\$/g, webpack_1.RuntimeGlobals.ensureChunkHandlers)
|
|
398
|
-
.replace(/\$hasOwnProperty\$/g, webpack_1.RuntimeGlobals.hasOwnProperty)
|
|
399
|
-
.replace(/\$hmrModuleData\$/g, webpack_1.RuntimeGlobals.hmrModuleData)
|
|
400
|
-
.replace(/\$hmrDownloadUpdateHandlers\$/g, webpack_1.RuntimeGlobals.hmrDownloadUpdateHandlers)
|
|
401
|
-
.replace(/\$hmrInvalidateModuleHandlers\$/g, webpack_1.RuntimeGlobals.hmrInvalidateModuleHandlers),
|
|
402
|
-
])
|
|
403
|
-
: '// no HMR',
|
|
404
|
-
'',
|
|
405
|
-
withHmrManifest
|
|
406
|
-
? webpack_1.Template.asString([
|
|
407
|
-
`${webpack_1.RuntimeGlobals.hmrDownloadManifest} = function() {`,
|
|
408
|
-
webpack_1.Template.indent([
|
|
409
|
-
'return new Promise(function(resolve, reject) {',
|
|
410
|
-
webpack_1.Template.indent([
|
|
411
|
-
`var filename = require('path').join(__dirname, ${JSON.stringify(rootOutputDir)} + ${webpack_1.RuntimeGlobals.getUpdateManifestFilename}());`,
|
|
412
|
-
"require('fs').readFile(filename, 'utf-8', function(err, content) {",
|
|
413
|
-
webpack_1.Template.indent([
|
|
414
|
-
'if(err) {',
|
|
415
|
-
webpack_1.Template.indent([
|
|
416
|
-
'if(err.code === "ENOENT") return resolve();',
|
|
417
|
-
'return reject(err);',
|
|
418
|
-
]),
|
|
419
|
-
'}',
|
|
420
|
-
'try { resolve(JSON.parse(content)); }',
|
|
421
|
-
'catch(e) { reject(e); }',
|
|
422
|
-
]),
|
|
423
|
-
'});',
|
|
424
|
-
]),
|
|
425
|
-
'});',
|
|
426
|
-
]),
|
|
427
|
-
'}',
|
|
428
|
-
])
|
|
429
|
-
: '// no HMR manifest',
|
|
430
|
-
]);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
exports.default = ReadFileChunkLoadingRuntimeModule;
|
|
434
|
-
//# sourceMappingURL=LoadFileChunkLoadingRuntimeModule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LoadFileChunkLoadingRuntimeModule.js","sourceRoot":"","sources":["../../../../../packages/node/src/plugins/LoadFileChunkLoadingRuntimeModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,qCAAkE;AAClE,4DAA0D;AAC1D,mGAA2E;AAE3E,2DAAuE;AAmBvE,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;QAE/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;;;OA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Script(scriptUrl, cb)
|
|
4
|
-
*/
|
|
5
|
-
declare const _default: "\n function loadScript(url, cb, chunkID) {\n var url;\n var cb = arguments[arguments.length - 1];\n if (typeof cb !== \"function\") {\n throw new Error(\"last argument should be a function\");\n }\n if (arguments.length === 2) {\n url = arguments[0];\n } else if (arguments.length === 3) {\n url = new URL(arguments[1], arguments[0]).toString();\n } else {\n throw new Error(\"invalid number of arguments\");\n }\n if (globalThis.webpackChunkLoad) {\n globalThis.webpackChunkLoad(url).then(function (resp) {\n return resp.text();\n }).then(function (rawData) {\n cb(null, rawData);\n }).catch(function (err) {\n console.error('Federated Chunk load failed', err);\n return cb(err)\n });\n } else if (typeof process !== 'undefined') {\n //TODO https support\n let request = (url.startsWith('https') ? require('https') : require('http')).get(url, function (resp) {\n if (resp.statusCode === 200) {\n let rawData = '';\n resp.setEncoding('utf8');\n resp.on('data', chunk => {\n rawData += chunk;\n });\n resp.on('end', () => {\n cb(null, rawData);\n });\n } else {\n cb(resp);\n }\n });\n request.on('error', error => {\n console.error('Federated Chunk load failed', error);\n return cb(error)\n });\n } else {\n fetch(url).then(function (resp) {\n return resp.text();\n }).then(function (rawData) {\n cb(null, rawData);\n }).catch(function (err) {\n console.error('Federated Chunk load failed', err);\n return cb(err)\n })\n }\n }\n";
|
|
6
|
-
export default _default;
|
|
7
|
-
export declare const executeLoadTemplate = "\n function executeLoad(url, callback, name) {\n if (!name) {\n throw new Error('__webpack_require__.l name is required for ' + url);\n }\n if (typeof globalThis.__remote_scope__[name] !== 'undefined') return callback(globalThis.__remote_scope__[name]);\n // if its a worker or node\n if (typeof process !== 'undefined') {\n const vm = require('vm');\n (globalThis.webpackChunkLoad || globalThis.fetch || require(\"node-fetch\"))(url).then(function (res) {\n return res.text();\n }).then(function (scriptContent) {\n try {\n const m = require('module');\n\n const remoteCapsule = vm.runInThisContext(m.wrap(scriptContent), 'node-federation-loader-' + name + '.vm')\n const exp = {};\n let remote = {exports:{}};\n remoteCapsule(exp,require,remote,'node-federation-loader-' + name + '.vm',__dirname);\n remote = remote.exports || remote;\n globalThis.__remote_scope__[name] = remote[name] || remote;\n globalThis.__remote_scope__._config[name] = url;\n callback(globalThis.__remote_scope__[name])\n } catch (e) {\n console.error('executeLoad hit catch block', e);\n e.target = {src: url};\n callback(e);\n }\n }).catch((e) => {\n e.target = {src: url};\n callback(e);\n });\n } else {\n fetch(url).then(function (res) {\n return res.text();\n }).then(function (scriptContent) {\n try {\n const remote = eval('let module = {};' + scriptContent + '\\nmodule.exports')\n globalThis.__remote_scope__[name] = remote[name] || remote;\n globalThis.__remote_scope__._config[name] = url;\n callback(globalThis.__remote_scope__[name])\n } catch (e) {\n console.error('executeLoad hit catch block',e);\n e.target = {src: url};\n callback(e);\n }\n });\n }\n }\n";
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* loadScript(baseURI, fileName, cb)
|
|
4
|
-
* loadScript(scriptUrl, cb)
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.executeLoadTemplate = void 0;
|
|
8
|
-
//language=JS
|
|
9
|
-
exports.default = `
|
|
10
|
-
function loadScript(url, cb, chunkID) {
|
|
11
|
-
var url;
|
|
12
|
-
var cb = arguments[arguments.length - 1];
|
|
13
|
-
if (typeof cb !== "function") {
|
|
14
|
-
throw new Error("last argument should be a function");
|
|
15
|
-
}
|
|
16
|
-
if (arguments.length === 2) {
|
|
17
|
-
url = arguments[0];
|
|
18
|
-
} else if (arguments.length === 3) {
|
|
19
|
-
url = new URL(arguments[1], arguments[0]).toString();
|
|
20
|
-
} else {
|
|
21
|
-
throw new Error("invalid number of arguments");
|
|
22
|
-
}
|
|
23
|
-
if (globalThis.webpackChunkLoad) {
|
|
24
|
-
globalThis.webpackChunkLoad(url).then(function (resp) {
|
|
25
|
-
return resp.text();
|
|
26
|
-
}).then(function (rawData) {
|
|
27
|
-
cb(null, rawData);
|
|
28
|
-
}).catch(function (err) {
|
|
29
|
-
console.error('Federated Chunk load failed', err);
|
|
30
|
-
return cb(err)
|
|
31
|
-
});
|
|
32
|
-
} else if (typeof process !== 'undefined') {
|
|
33
|
-
//TODO https support
|
|
34
|
-
let request = (url.startsWith('https') ? require('https') : require('http')).get(url, function (resp) {
|
|
35
|
-
if (resp.statusCode === 200) {
|
|
36
|
-
let rawData = '';
|
|
37
|
-
resp.setEncoding('utf8');
|
|
38
|
-
resp.on('data', chunk => {
|
|
39
|
-
rawData += chunk;
|
|
40
|
-
});
|
|
41
|
-
resp.on('end', () => {
|
|
42
|
-
cb(null, rawData);
|
|
43
|
-
});
|
|
44
|
-
} else {
|
|
45
|
-
cb(resp);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
request.on('error', error => {
|
|
49
|
-
console.error('Federated Chunk load failed', error);
|
|
50
|
-
return cb(error)
|
|
51
|
-
});
|
|
52
|
-
} else {
|
|
53
|
-
fetch(url).then(function (resp) {
|
|
54
|
-
return resp.text();
|
|
55
|
-
}).then(function (rawData) {
|
|
56
|
-
cb(null, rawData);
|
|
57
|
-
}).catch(function (err) {
|
|
58
|
-
console.error('Federated Chunk load failed', err);
|
|
59
|
-
return cb(err)
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
`;
|
|
64
|
-
// Shim to recreate browser version of webpack_require.loadChunk, same api
|
|
65
|
-
//language=JS
|
|
66
|
-
exports.executeLoadTemplate = `
|
|
67
|
-
function executeLoad(url, callback, name) {
|
|
68
|
-
if (!name) {
|
|
69
|
-
throw new Error('__webpack_require__.l name is required for ' + url);
|
|
70
|
-
}
|
|
71
|
-
if (typeof globalThis.__remote_scope__[name] !== 'undefined') return callback(globalThis.__remote_scope__[name]);
|
|
72
|
-
// if its a worker or node
|
|
73
|
-
if (typeof process !== 'undefined') {
|
|
74
|
-
const vm = require('vm');
|
|
75
|
-
(globalThis.webpackChunkLoad || globalThis.fetch || require("node-fetch"))(url).then(function (res) {
|
|
76
|
-
return res.text();
|
|
77
|
-
}).then(function (scriptContent) {
|
|
78
|
-
try {
|
|
79
|
-
const m = require('module');
|
|
80
|
-
|
|
81
|
-
const remoteCapsule = vm.runInThisContext(m.wrap(scriptContent), 'node-federation-loader-' + name + '.vm')
|
|
82
|
-
const exp = {};
|
|
83
|
-
let remote = {exports:{}};
|
|
84
|
-
remoteCapsule(exp,require,remote,'node-federation-loader-' + name + '.vm',__dirname);
|
|
85
|
-
remote = remote.exports || remote;
|
|
86
|
-
globalThis.__remote_scope__[name] = remote[name] || remote;
|
|
87
|
-
globalThis.__remote_scope__._config[name] = url;
|
|
88
|
-
callback(globalThis.__remote_scope__[name])
|
|
89
|
-
} catch (e) {
|
|
90
|
-
console.error('executeLoad hit catch block', e);
|
|
91
|
-
e.target = {src: url};
|
|
92
|
-
callback(e);
|
|
93
|
-
}
|
|
94
|
-
}).catch((e) => {
|
|
95
|
-
e.target = {src: url};
|
|
96
|
-
callback(e);
|
|
97
|
-
});
|
|
98
|
-
} else {
|
|
99
|
-
fetch(url).then(function (res) {
|
|
100
|
-
return res.text();
|
|
101
|
-
}).then(function (scriptContent) {
|
|
102
|
-
try {
|
|
103
|
-
const remote = eval('let module = {};' + scriptContent + '\\nmodule.exports')
|
|
104
|
-
globalThis.__remote_scope__[name] = remote[name] || remote;
|
|
105
|
-
globalThis.__remote_scope__._config[name] = url;
|
|
106
|
-
callback(globalThis.__remote_scope__[name])
|
|
107
|
-
} catch (e) {
|
|
108
|
-
console.error('executeLoad hit catch block',e);
|
|
109
|
-
e.target = {src: url};
|
|
110
|
-
callback(e);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
`;
|
|
116
|
-
//# sourceMappingURL=loadScript.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loadScript.js","sourceRoot":"","sources":["../../../../../packages/node/src/plugins/loadScript.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,aAAa;AACb,kBAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsDd,CAAC;AAEF,0EAA0E;AAC1E,aAAa;AACA,QAAA,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDlC,CAAC"}
|