@module-federation/enhanced 0.1.0 → 0.2.0-canary.1
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/package.json +2 -4
- package/src/lib/container/AsyncBoundaryPlugin.d.ts +11 -43
- package/src/lib/container/AsyncBoundaryPlugin.js +76 -93
- package/src/lib/container/AsyncBoundaryPlugin.js.map +1 -1
- package/src/lib/container/ContainerEntryModule.js +3 -1
- package/src/lib/container/ContainerEntryModule.js.map +1 -1
- package/src/lib/container/ContainerEntryModuleFactory.js +2 -1
- package/src/lib/container/ContainerEntryModuleFactory.js.map +1 -1
- package/src/lib/container/ContainerReferencePlugin.js +3 -1
- package/src/lib/container/ContainerReferencePlugin.js.map +1 -1
- package/src/lib/container/FallbackModuleFactory.js +2 -1
- package/src/lib/container/FallbackModuleFactory.js.map +1 -1
- package/src/lib/container/ModuleFederationPlugin.js +1 -1
- package/src/lib/container/ModuleFederationPlugin.js.map +1 -1
- package/src/lib/sharing/ConsumeSharedModule.js +3 -1
- package/src/lib/sharing/ConsumeSharedModule.js.map +1 -1
- package/src/lib/sharing/ConsumeSharedPlugin.js +3 -1
- package/src/lib/sharing/ConsumeSharedPlugin.js.map +1 -1
- package/src/lib/sharing/ConsumeSharedRuntimeModule.js +3 -1
- package/src/lib/sharing/ConsumeSharedRuntimeModule.js.map +1 -1
- package/src/lib/sharing/ProvideSharedModule.js +3 -1
- package/src/lib/sharing/ProvideSharedModule.js.map +1 -1
- package/src/lib/sharing/ShareRuntimeModule.js +3 -1
- package/src/lib/sharing/ShareRuntimeModule.js.map +1 -1
- package/src/schemas/container/ModuleFederationPlugin.check.d.ts +10 -0
- package/CHANGELOG.md +0 -134
- package/README.md +0 -11
package/package.json
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
-
"public": true,
|
|
3
2
|
"name": "@module-federation/enhanced",
|
|
4
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-canary.1",
|
|
5
4
|
"type": "commonjs",
|
|
6
5
|
"main": "./src/index.js",
|
|
7
6
|
"types": "src/index.d.ts",
|
|
8
7
|
"publishConfig": {
|
|
9
|
-
"
|
|
8
|
+
"access": "public"
|
|
10
9
|
},
|
|
11
10
|
"peerDependencies": {
|
|
12
11
|
"webpack": "^5.0.0"
|
|
13
12
|
},
|
|
14
13
|
"dependencies": {
|
|
15
|
-
"tapable": "2.2.1",
|
|
16
14
|
"webpack-sources": "3.2.3"
|
|
17
15
|
}
|
|
18
16
|
}
|
|
@@ -1,45 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* Define hooks
|
|
12
|
-
* @property {SyncBailHook} checkInvalidContext - A hook that checks if the render context is invalid.
|
|
13
|
-
*/
|
|
14
|
-
hooks: {
|
|
15
|
-
checkInvalidContext: SyncBailHook<[Module, Compilation], boolean, import("tapable").UnsetAdditionalOptions>;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Apply the plugin to the Webpack compiler instance.
|
|
19
|
-
* @param {Compiler} compiler - Webpack compiler instance.
|
|
20
|
-
*/
|
|
1
|
+
import Compiler from 'webpack/lib/Compiler';
|
|
2
|
+
import Chunk from 'webpack/lib/Chunk';
|
|
3
|
+
import Module from 'webpack/lib/Module';
|
|
4
|
+
interface Options {
|
|
5
|
+
eager?: RegExp | ((module: Module) => boolean);
|
|
6
|
+
excludeChunk?: (chunk: Chunk) => boolean;
|
|
7
|
+
}
|
|
8
|
+
declare class AsyncEntryStartupPlugin {
|
|
9
|
+
private _options;
|
|
10
|
+
constructor(options?: Options);
|
|
21
11
|
apply(compiler: Compiler): void;
|
|
22
|
-
/**
|
|
23
|
-
* Render the startup logic for the plugin.
|
|
24
|
-
* @param {Source} source - The source code.
|
|
25
|
-
* @param {RenderContext} renderContext - The render context.
|
|
26
|
-
* @param {any} startupRenderContext - The startup render context.
|
|
27
|
-
* @param {Compilation} compilation - The Webpack compilation instance.
|
|
28
|
-
* @returns {string} - The modified source code.
|
|
29
|
-
*/
|
|
30
|
-
private renderStartupLogic;
|
|
31
|
-
/**
|
|
32
|
-
* Replace the webpack exec string.
|
|
33
|
-
* @param {string} webpack_exec - The webpack exec string.
|
|
34
|
-
* @returns {string} - The replaced webpack exec string.
|
|
35
|
-
*/
|
|
36
|
-
private replaceWebpackExec;
|
|
37
|
-
/**
|
|
38
|
-
* Get the IDs of the dependent chunks.
|
|
39
|
-
* @param {any} startupRenderContext - The startup render context.
|
|
40
|
-
* @param {any} chunkGraph - The chunk graph.
|
|
41
|
-
* @returns {Set} - The set of dependent chunk IDs.
|
|
42
|
-
*/
|
|
43
|
-
private getDependentChunkIds;
|
|
44
12
|
}
|
|
45
|
-
export default
|
|
13
|
+
export default AsyncEntryStartupPlugin;
|
|
@@ -8,103 +8,86 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return _default;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Render the startup logic for the plugin.
|
|
32
|
-
* @param {Source} source - The source code.
|
|
33
|
-
* @param {RenderContext} renderContext - The render context.
|
|
34
|
-
* @param {any} startupRenderContext - The startup render context.
|
|
35
|
-
* @param {Compilation} compilation - The Webpack compilation instance.
|
|
36
|
-
* @returns {string} - The modified source code.
|
|
37
|
-
*/ renderStartupLogic(source, renderContext, startupRenderContext, compilation) {
|
|
38
|
-
var _this_hooks_checkInvalidContext_call;
|
|
39
|
-
const isInvalidContext = (_this_hooks_checkInvalidContext_call = this.hooks.checkInvalidContext.call(renderContext, compilation)) != null ? _this_hooks_checkInvalidContext_call : false;
|
|
40
|
-
if (isInvalidContext) return source.source().toString();
|
|
41
|
-
const { chunkGraph } = compilation;
|
|
42
|
-
const replaceSource = source.source().toString();
|
|
43
|
-
const replaceSourceLines = replaceSource.split('\n');
|
|
44
|
-
const webpack_exec_index = replaceSourceLines.findIndex((line)=>line.includes('webpack_exec'));
|
|
45
|
-
const webpack_exec = replaceSourceLines[webpack_exec_index];
|
|
46
|
-
const webpack_exports = replaceSourceLines.slice(webpack_exec_index + 1);
|
|
47
|
-
const dependentChunkIds = this.getDependentChunkIds(startupRenderContext, chunkGraph);
|
|
48
|
-
return _webpack.Template.asString([
|
|
49
|
-
this.replaceWebpackExec(webpack_exec),
|
|
50
|
-
`globalThis.ongoingRemotes = globalThis.ongoingRemotes || [];`,
|
|
51
|
-
`var __webpack_exec__ = async function() {`,
|
|
52
|
-
_webpack.Template.indent([
|
|
53
|
-
`var chunkIds = ${JSON.stringify(Array.from(dependentChunkIds))};`,
|
|
54
|
-
`if (${_webpack.RuntimeGlobals.ensureChunkHandlers}.consumes) {`,
|
|
55
|
-
` chunkIds.forEach(function(id) { ${_webpack.RuntimeGlobals.ensureChunkHandlers}.consumes(id, globalThis.ongoingRemotes); });`,
|
|
56
|
-
` await Promise.all(globalThis.ongoingRemotes);`,
|
|
57
|
-
`}`,
|
|
58
|
-
`if (${_webpack.RuntimeGlobals.ensureChunkHandlers}.remotes) {`,
|
|
59
|
-
` chunkIds.forEach(function(id) { ${_webpack.RuntimeGlobals.ensureChunkHandlers}.remotes(id, globalThis.ongoingRemotes); });`,
|
|
60
|
-
` await Promise.all(globalThis.ongoingRemotes);`,
|
|
61
|
-
`}`,
|
|
62
|
-
`return __original_webpack_exec__.apply(this, arguments);`
|
|
63
|
-
]),
|
|
64
|
-
`};`,
|
|
65
|
-
...webpack_exports
|
|
66
|
-
]);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Replace the webpack exec string.
|
|
70
|
-
* @param {string} webpack_exec - The webpack exec string.
|
|
71
|
-
* @returns {string} - The replaced webpack exec string.
|
|
72
|
-
*/ replaceWebpackExec(webpack_exec) {
|
|
73
|
-
return webpack_exec.replace('__webpack_exec__', '__original_webpack_exec__');
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Get the IDs of the dependent chunks.
|
|
77
|
-
* @param {any} startupRenderContext - The startup render context.
|
|
78
|
-
* @param {any} chunkGraph - The chunk graph.
|
|
79
|
-
* @returns {Set} - The set of dependent chunk IDs.
|
|
80
|
-
*/ getDependentChunkIds(startupRenderContext, chunkGraph) {
|
|
81
|
-
const entries = Array.from(chunkGraph.getChunkEntryModulesWithChunkGroupIterable(startupRenderContext.chunk));
|
|
82
|
-
const chunkIds = new Set();
|
|
83
|
-
for (const [module, entrypoint] of entries){
|
|
84
|
-
if (entrypoint) {
|
|
85
|
-
const runtimeChunk = entrypoint.getRuntimeChunk();
|
|
86
|
-
if (runtimeChunk) {
|
|
87
|
-
const chunks = (0, _ChunkHelpers.getAllChunks)(entrypoint, runtimeChunk);
|
|
88
|
-
for (const c of chunks){
|
|
89
|
-
chunkIds.add(c.id);
|
|
11
|
+
const _RuntimeGlobals = /*#__PURE__*/ _interop_require_default(require("webpack/lib/RuntimeGlobals"));
|
|
12
|
+
const _Template = /*#__PURE__*/ _interop_require_default(require("webpack/lib/Template"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
// Class to handle asynchronous entry startup
|
|
19
|
+
let AsyncEntryStartupPlugin = class AsyncEntryStartupPlugin {
|
|
20
|
+
apply(compiler) {
|
|
21
|
+
const chunkRuntimes = new Map();
|
|
22
|
+
compiler.hooks.thisCompilation.tap('AsyncEntryStartupPlugin', (compilation)=>{
|
|
23
|
+
compiler.webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(compilation).renderStartup.tap('AsyncEntryStartupPlugin', (source, renderContext, upperContext)=>{
|
|
24
|
+
var _compiler_options_optimization, _compiler_options;
|
|
25
|
+
// Check if single runtime chunk is enabled
|
|
26
|
+
if (compiler == null ? void 0 : (_compiler_options = compiler.options) == null ? void 0 : (_compiler_options_optimization = _compiler_options.optimization) == null ? void 0 : _compiler_options_optimization.runtimeChunk) {
|
|
27
|
+
if (upperContext == null ? void 0 : upperContext.chunk.hasRuntime()) {
|
|
28
|
+
chunkRuntimes.set(upperContext.chunk.id, upperContext.chunk);
|
|
29
|
+
return source;
|
|
90
30
|
}
|
|
91
31
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
32
|
+
// Check if excludeChunk is provided, use it to decide further processing
|
|
33
|
+
if (this._options.excludeChunk && this._options.excludeChunk(upperContext.chunk)) {
|
|
34
|
+
return source;
|
|
35
|
+
}
|
|
36
|
+
const runtime = chunkRuntimes.get(upperContext.chunk.runtime);
|
|
37
|
+
// Get the runtime requirements of the chunk
|
|
38
|
+
const requirements = compilation.chunkGraph.getTreeRuntimeRequirements(runtime || upperContext.chunk);
|
|
39
|
+
let remotes = '';
|
|
40
|
+
let shared = '';
|
|
41
|
+
const hasRemoteModules = compilation.chunkGraph.getChunkModulesIterableBySourceType(upperContext.chunk, 'remote');
|
|
42
|
+
// Check if the chunk has remote get scope
|
|
43
|
+
if (requirements.has(_RuntimeGlobals.default.currentRemoteGetScope) || hasRemoteModules || requirements.has('__webpack_require__.vmok')) {
|
|
44
|
+
remotes = `if(__webpack_require__.f && __webpack_require__.f.remotes) __webpack_require__.f.remotes(${JSON.stringify(upperContext.chunk.id)}, promiseTrack);`;
|
|
45
|
+
}
|
|
46
|
+
// Check if the chunk has share scope map or initialize sharing
|
|
47
|
+
if (requirements.has(_RuntimeGlobals.default.shareScopeMap) || requirements.has(_RuntimeGlobals.default.initializeSharing)) {
|
|
48
|
+
shared = `if(__webpack_require__.f && __webpack_require__.f.consumes) __webpack_require__.f.consumes(${JSON.stringify(upperContext.chunk.id)}, promiseTrack);`;
|
|
49
|
+
}
|
|
50
|
+
// If no remotes or shared, return the source
|
|
51
|
+
if (!remotes && !shared) {
|
|
52
|
+
return source;
|
|
53
|
+
}
|
|
54
|
+
// Get the entry modules of the chunk
|
|
55
|
+
const entryModules = compilation.chunkGraph.getChunkEntryModulesIterable(upperContext.chunk);
|
|
56
|
+
const initialEntryModules = [];
|
|
57
|
+
// Iterate over the entry modules
|
|
58
|
+
for (const entryModule of entryModules){
|
|
59
|
+
if (entryModule.id) {
|
|
60
|
+
let shouldInclude = false;
|
|
61
|
+
// Check if eager is a function and call it
|
|
62
|
+
if (typeof this._options.eager === 'function') {
|
|
63
|
+
shouldInclude = this._options.eager(entryModule);
|
|
64
|
+
} else if (this._options.eager && this._options.eager.test(entryModule.identifier())) {
|
|
65
|
+
// Check if eager is a RegExp and test it
|
|
66
|
+
shouldInclude = true;
|
|
67
|
+
}
|
|
68
|
+
// If shouldInclude is true, push the module to initialEntryModules
|
|
69
|
+
if (shouldInclude) {
|
|
70
|
+
initialEntryModules.push(`__webpack_require__(${JSON.stringify(entryModule.id)});`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return _Template.default.asString([
|
|
75
|
+
'var promiseTrack = [];',
|
|
76
|
+
_Template.default.asString(initialEntryModules),
|
|
77
|
+
shared,
|
|
78
|
+
remotes,
|
|
79
|
+
'var __webpack_exports__ = Promise.all(promiseTrack).then(function() {',
|
|
80
|
+
_Template.default.indent(source.source()),
|
|
81
|
+
_Template.default.indent('return __webpack_exports__'),
|
|
82
|
+
'});'
|
|
83
|
+
]);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
95
86
|
}
|
|
96
|
-
constructor(){
|
|
97
|
-
|
|
98
|
-
* Define hooks
|
|
99
|
-
* @property {SyncBailHook} checkInvalidContext - A hook that checks if the render context is invalid.
|
|
100
|
-
*/ this.hooks = {
|
|
101
|
-
checkInvalidContext: new _tapable.SyncBailHook([
|
|
102
|
-
'renderContext',
|
|
103
|
-
'compilation'
|
|
104
|
-
])
|
|
105
|
-
};
|
|
87
|
+
constructor(options){
|
|
88
|
+
this._options = options || {};
|
|
106
89
|
}
|
|
107
90
|
};
|
|
108
|
-
const _default =
|
|
91
|
+
const _default = AsyncEntryStartupPlugin;
|
|
109
92
|
|
|
110
93
|
//# sourceMappingURL=AsyncBoundaryPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/AsyncBoundaryPlugin.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/AsyncBoundaryPlugin.ts"],"sourcesContent":["import Compiler from 'webpack/lib/Compiler';\nimport Compilation from 'webpack/lib/Compilation';\nimport Chunk from 'webpack/lib/Chunk';\nimport RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport Template from 'webpack/lib/Template';\nimport Module from 'webpack/lib/Module';\n\ninterface Options {\n eager?: RegExp | ((module: Module) => boolean);\n excludeChunk?: (chunk: Chunk) => boolean;\n}\n\n// Class to handle asynchronous entry startup\nclass AsyncEntryStartupPlugin {\n private _options: Options;\n\n constructor(options?: Options) {\n this._options = options || {};\n }\n\n apply(compiler: Compiler): void {\n const chunkRuntimes = new Map();\n compiler.hooks.thisCompilation.tap(\n 'AsyncEntryStartupPlugin',\n (compilation: Compilation) => {\n compiler.webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(\n compilation,\n ).renderStartup.tap(\n 'AsyncEntryStartupPlugin',\n (\n source: any,\n renderContext: Module,\n upperContext: { chunk: Chunk },\n ) => {\n // Check if single runtime chunk is enabled\n if (compiler?.options?.optimization?.runtimeChunk) {\n if (upperContext?.chunk.hasRuntime()) {\n chunkRuntimes.set(upperContext.chunk.id, upperContext.chunk);\n return source;\n }\n }\n\n // Check if excludeChunk is provided, use it to decide further processing\n if (\n this._options.excludeChunk &&\n this._options.excludeChunk(upperContext.chunk)\n ) {\n return source;\n }\n\n const runtime = chunkRuntimes.get(upperContext.chunk.runtime);\n\n // Get the runtime requirements of the chunk\n const requirements =\n compilation.chunkGraph.getTreeRuntimeRequirements(\n runtime || upperContext.chunk,\n );\n\n let remotes = '';\n let shared = '';\n const hasRemoteModules =\n compilation.chunkGraph.getChunkModulesIterableBySourceType(\n upperContext.chunk,\n 'remote',\n );\n\n // Check if the chunk has remote get scope\n if (\n requirements.has(RuntimeGlobals.currentRemoteGetScope) ||\n hasRemoteModules ||\n requirements.has('__webpack_require__.vmok')\n ) {\n remotes = `if(__webpack_require__.f && __webpack_require__.f.remotes) __webpack_require__.f.remotes(${JSON.stringify(\n upperContext.chunk.id,\n )}, promiseTrack);`;\n }\n\n // Check if the chunk has share scope map or initialize sharing\n if (\n requirements.has(RuntimeGlobals.shareScopeMap) ||\n requirements.has(RuntimeGlobals.initializeSharing)\n ) {\n shared = `if(__webpack_require__.f && __webpack_require__.f.consumes) __webpack_require__.f.consumes(${JSON.stringify(\n upperContext.chunk.id,\n )}, promiseTrack);`;\n }\n\n // If no remotes or shared, return the source\n if (!remotes && !shared) {\n return source;\n }\n\n // Get the entry modules of the chunk\n const entryModules =\n compilation.chunkGraph.getChunkEntryModulesIterable(\n upperContext.chunk,\n );\n\n const initialEntryModules = [];\n\n // Iterate over the entry modules\n for (const entryModule of entryModules) {\n if (entryModule.id) {\n let shouldInclude = false;\n\n // Check if eager is a function and call it\n if (typeof this._options.eager === 'function') {\n shouldInclude = this._options.eager(entryModule);\n } else if (\n this._options.eager &&\n this._options.eager.test(entryModule.identifier())\n ) {\n // Check if eager is a RegExp and test it\n shouldInclude = true;\n }\n\n // If shouldInclude is true, push the module to initialEntryModules\n if (shouldInclude) {\n initialEntryModules.push(\n `__webpack_require__(${JSON.stringify(entryModule.id)});`,\n );\n }\n }\n }\n\n return Template.asString([\n 'var promiseTrack = [];',\n Template.asString(initialEntryModules),\n shared,\n remotes,\n 'var __webpack_exports__ = Promise.all(promiseTrack).then(function() {',\n Template.indent(source.source()),\n Template.indent('return __webpack_exports__'),\n '});',\n ]);\n },\n );\n },\n );\n }\n}\n\nexport default AsyncEntryStartupPlugin;\n"],"names":["AsyncEntryStartupPlugin","apply","compiler","chunkRuntimes","Map","hooks","thisCompilation","tap","compilation","webpack","javascript","JavascriptModulesPlugin","getCompilationHooks","renderStartup","source","renderContext","upperContext","options","optimization","runtimeChunk","chunk","hasRuntime","set","id","_options","excludeChunk","runtime","get","requirements","chunkGraph","getTreeRuntimeRequirements","remotes","shared","hasRemoteModules","getChunkModulesIterableBySourceType","has","RuntimeGlobals","currentRemoteGetScope","JSON","stringify","shareScopeMap","initializeSharing","entryModules","getChunkEntryModulesIterable","initialEntryModules","entryModule","shouldInclude","eager","test","identifier","push","Template","asString","indent","constructor"],"mappings":";;;;+BA8IA;;;eAAA;;;uEA3I2B;iEACN;;;;;;AAQrB,6CAA6C;AAC7C,IAAA,AAAMA,0BAAN,MAAMA;IAOJC,MAAMC,QAAkB,EAAQ;QAC9B,MAAMC,gBAAgB,IAAIC;QAC1BF,SAASG,KAAK,CAACC,eAAe,CAACC,GAAG,CAChC,2BACA,CAACC;YACCN,SAASO,OAAO,CAACC,UAAU,CAACC,uBAAuB,CAACC,mBAAmB,CACrEJ,aACAK,aAAa,CAACN,GAAG,CACjB,2BACA,CACEO,QACAC,eACAC;oBAGId,gCAAAA;gBADJ,2CAA2C;gBAC3C,IAAIA,6BAAAA,oBAAAA,SAAUe,OAAO,sBAAjBf,iCAAAA,kBAAmBgB,YAAY,qBAA/BhB,+BAAiCiB,YAAY,EAAE;oBACjD,IAAIH,gCAAAA,aAAcI,KAAK,CAACC,UAAU,IAAI;wBACpClB,cAAcmB,GAAG,CAACN,aAAaI,KAAK,CAACG,EAAE,EAAEP,aAAaI,KAAK;wBAC3D,OAAON;oBACT;gBACF;gBAEA,yEAAyE;gBACzE,IACE,IAAI,CAACU,QAAQ,CAACC,YAAY,IAC1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,IAAI,CAACtB,QAAQ,CAACuB,KAAK,CAACF;wBACtC,OAAO,IACL,IAAI,CAACrB,QAAQ,CAACuB,KAAK,IACnB,IAAI,CAACvB,QAAQ,CAACuB,KAAK,CAACC,IAAI,CAACH,YAAYI,UAAU,KAC/C;4BACA,yCAAyC;4BACzCH,gBAAgB;wBAClB;wBAEA,mEAAmE;wBACnE,IAAIA,eAAe;4BACjBF,oBAAoBM,IAAI,CACtB,CAAC,oBAAoB,EAAEZ,KAAKC,SAAS,CAACM,YAAYtB,EAAE,EAAE,EAAE,CAAC;wBAE7D;oBACF;gBACF;gBAEA,OAAO4B,iBAAQ,CAACC,QAAQ,CAAC;oBACvB;oBACAD,iBAAQ,CAACC,QAAQ,CAACR;oBAClBZ;oBACAD;oBACA;oBACAoB,iBAAQ,CAACE,MAAM,CAACvC,OAAOA,MAAM;oBAC7BqC,iBAAQ,CAACE,MAAM,CAAC;oBAChB;iBACD;YACH;QAEJ;IAEJ;IA3HAC,YAAYrC,OAAiB,CAAE;QAC7B,IAAI,CAACO,QAAQ,GAAGP,WAAW,CAAC;IAC9B;AA0HF;MAEA,WAAejB"}
|
|
@@ -46,7 +46,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
46
46
|
if (cache && cache.has(obj)) {
|
|
47
47
|
return cache.get(obj);
|
|
48
48
|
}
|
|
49
|
-
var newObj = {
|
|
49
|
+
var newObj = {
|
|
50
|
+
__proto__: null
|
|
51
|
+
};
|
|
50
52
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
51
53
|
for(var key in obj){
|
|
52
54
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/ContainerEntryModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr\n*/\n\n'use strict';\nimport AsyncDependenciesBlock from 'webpack/lib/AsyncDependenciesBlock';\nimport Dependency from 'webpack/lib/Dependency';\nimport Template from 'webpack/lib/Template';\nimport Module from 'webpack/lib/Module';\nimport * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport { OriginalSource, RawSource } from 'webpack-sources';\nimport { JAVASCRIPT_MODULE_TYPE_DYNAMIC } from 'webpack/lib/ModuleTypeConstants';\nimport ContainerExposedDependency from './ContainerExposedDependency';\nimport StaticExportsDependency from 'webpack/lib/dependencies/StaticExportsDependency';\nimport type Compilation from 'webpack/lib/Compilation';\nimport type {\n LibIdentOptions,\n NeedBuildContext,\n RequestShortener,\n ObjectDeserializerContext,\n ObjectSerializerContext,\n WebpackOptions,\n InputFileSystem,\n ResolverWithOptions,\n} from 'webpack/lib/Module';\nimport type WebpackError from 'webpack/lib/WebpackError';\nimport makeSerializable from 'webpack/lib/util/makeSerializable';\n\nconst SOURCE_TYPES = new Set(['javascript']);\n\nexport type ExposeOptions = {\n /**\n * requests to exposed modules (last one is exported)\n */\n import: string[];\n /**\n * custom chunk name for the exposed module\n */\n name: string;\n};\n\nclass ContainerEntryModule extends Module {\n private _name: string;\n private _exposes: [string, ExposeOptions][];\n private _shareScope: string;\n /**\n * @param {string} name container entry name\n * @param {[string, ExposeOptions][]} exposes list of exposed modules\n * @param {string} shareScope name of the share scope\n */\n constructor(\n name: string,\n exposes: [string, ExposeOptions][],\n shareScope: string,\n ) {\n super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);\n this._name = name;\n this._exposes = exposes;\n this._shareScope = shareScope;\n }\n /**\n * @param {ObjectDeserializerContext} context context\n * @returns {ContainerEntryModule} deserialized container entry module\n */\n static deserialize(context: ObjectDeserializerContext): ContainerEntryModule {\n const { read } = context;\n const obj = new ContainerEntryModule(read(), read(), read());\n //@ts-ignore\n obj.deserialize(context);\n return obj;\n }\n\n /**\n * @returns {Set<string>} types available (do not mutate)\n */\n override getSourceTypes(): Set<string> {\n return SOURCE_TYPES;\n }\n /**\n * @returns {string} a unique identifier of the module\n */\n override identifier(): string {\n return `container entry (${this._shareScope}) ${JSON.stringify(\n this._exposes,\n )}`;\n }\n /**\n * @param {RequestShortener} requestShortener the request shortener\n * @returns {string} a user readable identifier of the module\n */\n override readableIdentifier(requestShortener: RequestShortener): string {\n return 'container entry';\n }\n /**\n * @param {LibIdentOptions} options options\n * @returns {string | null} an identifier for library inclusion\n */\n override libIdent(options: LibIdentOptions): string | null {\n return `${this.layer ? `(${this.layer})/` : ''}webpack/container/entry/${\n this._name\n }`;\n }\n /**\n * @param {NeedBuildContext} context context info\n * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild\n * @returns {void}\n */\n override needBuild(\n context: NeedBuildContext,\n callback: (\n arg0: (WebpackError | null) | undefined,\n arg1: boolean | undefined,\n ) => void,\n ): void {\n const baseContext = context as NeedBuildContext;\n callback(null, !this.buildMeta);\n }\n /**\n * @param {WebpackOptions} options webpack options\n * @param {Compilation} compilation the compilation\n * @param {ResolverWithOptions} resolver the resolver\n * @param {InputFileSystem} fs the file system\n * @param {function(WebpackError): void} callback callback function\n * @returns {void}\n */\n override build(\n options: WebpackOptions,\n compilation: Compilation,\n resolver: ResolverWithOptions,\n fs: InputFileSystem,\n callback: (err?: WebpackError) => void,\n ): void {\n this.buildMeta = {};\n this.buildInfo = {\n strict: true,\n topLevelDeclarations: new Set(['moduleMap', 'get', 'init']),\n };\n this.buildMeta.exportsType = 'namespace';\n //@ts-ignore\n this.clearDependenciesAndBlocks();\n\n for (const [name, options] of this._exposes) {\n const block = new AsyncDependenciesBlock(\n {\n name: options.name,\n },\n { name },\n options.import[options.import.length - 1],\n );\n let idx = 0;\n for (const request of options.import) {\n const dep = new ContainerExposedDependency(name, request);\n dep.loc = {\n name,\n index: idx++,\n };\n //@ts-ignore\n block.addDependency(dep);\n }\n //@ts-ignore\n this.addBlock(block);\n }\n //@ts-ignore\n this.addDependency(\n //@ts-ignore\n new StaticExportsDependency(\n ['get', 'init'],\n false,\n ) as unknown as Dependency,\n );\n\n callback();\n }\n\n /**\n * @param {CodeGenerationContext} context context for code generation\n * @returns {CodeGenerationResult} result\n */\n //@ts-ignore\n override codeGeneration({ moduleGraph, chunkGraph, runtimeTemplate }) {\n const sources = new Map();\n const runtimeRequirements = new Set([\n RuntimeGlobals.definePropertyGetters,\n RuntimeGlobals.hasOwnProperty,\n RuntimeGlobals.exports,\n ]);\n const getters = [];\n //@ts-ignore\n for (const block of this.blocks) {\n const { dependencies } = block;\n\n const modules = dependencies.map((dependency: Dependency) => {\n const dep = dependency as unknown as ContainerExposedDependency;\n return {\n name: dep.exposedName,\n module: moduleGraph.getModule(dep),\n request: dep.userRequest,\n };\n });\n\n let str;\n //@ts-ignore\n if (modules.some((m) => !m.module)) {\n str = runtimeTemplate.throwMissingModuleErrorBlock({\n //@ts-ignore\n request: modules.map((m) => m.request).join(', '),\n });\n } else {\n str = `return ${runtimeTemplate.blockPromise({\n block,\n message: '',\n chunkGraph,\n runtimeRequirements,\n })}.then(${runtimeTemplate.returningFunction(\n runtimeTemplate.returningFunction(\n `(${modules\n //@ts-ignore\n .map(({ module, request }) =>\n runtimeTemplate.moduleRaw({\n module,\n chunkGraph,\n request,\n weak: false,\n runtimeRequirements,\n }),\n )\n .join(', ')})`,\n ),\n )});`;\n }\n\n getters.push(\n `${JSON.stringify(modules[0].name)}: ${runtimeTemplate.basicFunction(\n '',\n str,\n )}`,\n );\n }\n\n const source = Template.asString([\n `var moduleMap = {`,\n Template.indent(getters.join(',\\n')),\n '};',\n `var get = ${runtimeTemplate.basicFunction('module, getScope', [\n `${RuntimeGlobals.currentRemoteGetScope} = getScope;`,\n // reusing the getScope variable to avoid creating a new var (and module is also used later)\n 'getScope = (',\n Template.indent([\n `${RuntimeGlobals.hasOwnProperty}(moduleMap, module)`,\n Template.indent([\n '? moduleMap[module]()',\n `: Promise.resolve().then(${runtimeTemplate.basicFunction(\n '',\n \"throw new Error('Module \\\"' + module + '\\\" does not exist in container.');\",\n )})`,\n ]),\n ]),\n ');',\n `${RuntimeGlobals.currentRemoteGetScope} = undefined;`,\n 'return getScope;',\n ])};`,\n `var init = ${runtimeTemplate.basicFunction('shareScope, initScope', [\n `if (!${RuntimeGlobals.shareScopeMap}) return;`,\n `var name = ${JSON.stringify(this._shareScope)}`,\n `var oldScope = ${RuntimeGlobals.shareScopeMap}[name];`,\n `if(oldScope && oldScope !== shareScope) throw new Error(\"Container initialization failed as it has already been initialized with a different share scope\");`,\n `${RuntimeGlobals.shareScopeMap}[name] = shareScope;`,\n `return ${RuntimeGlobals.initializeSharing}(name, initScope);`,\n ])};`,\n '',\n '// This exports getters to disallow modifications',\n `${RuntimeGlobals.definePropertyGetters}(exports, {`,\n Template.indent([\n `get: ${runtimeTemplate.returningFunction('get')},`,\n `init: ${runtimeTemplate.returningFunction('init')}`,\n ]),\n '});',\n ]);\n\n sources.set(\n 'javascript',\n this.useSourceMap || this.useSimpleSourceMap\n ? new OriginalSource(source, 'webpack/container-entry')\n : new RawSource(source),\n );\n\n return {\n sources,\n runtimeRequirements,\n };\n }\n\n /**\n * @param {string=} type the source type for which the size should be estimated\n * @returns {number} the estimated size of the module (must be non-zero)\n */\n override size(type?: string): number {\n return 42;\n }\n /**\n * @param {ObjectSerializerContext} context context\n */\n //@ts-ignore\n override serialize(context: ObjectSerializerContext): void {\n const { write } = context;\n write(this._name);\n write(this._exposes);\n write(this._shareScope);\n //@ts-ignore\n super.serialize(context);\n }\n}\n//@ts-ignore\nmakeSerializable(\n ContainerEntryModule,\n 'enhanced/lib/container/ContainerEntryModule',\n);\n\nexport default ContainerEntryModule;\n"],"names":["SOURCE_TYPES","Set","ContainerEntryModule","Module","deserialize","context","read","obj","getSourceTypes","identifier","_shareScope","JSON","stringify","_exposes","readableIdentifier","requestShortener","libIdent","options","layer","_name","needBuild","callback","baseContext","buildMeta","build","compilation","resolver","fs","buildInfo","strict","topLevelDeclarations","exportsType","clearDependenciesAndBlocks","name","block","AsyncDependenciesBlock","import","length","idx","request","dep","ContainerExposedDependency","loc","index","addDependency","addBlock","StaticExportsDependency","codeGeneration","moduleGraph","chunkGraph","runtimeTemplate","sources","Map","runtimeRequirements","RuntimeGlobals","definePropertyGetters","hasOwnProperty","exports","getters","blocks","dependencies","modules","map","dependency","exposedName","module","getModule","userRequest","str","some","m","throwMissingModuleErrorBlock","join","blockPromise","message","returningFunction","moduleRaw","weak","push","basicFunction","source","Template","asString","indent","currentRemoteGetScope","shareScopeMap","initializeSharing","set","useSourceMap","useSimpleSourceMap","OriginalSource","RawSource","size","type","serialize","write","constructor","exposes","shareScope","JAVASCRIPT_MODULE_TYPE_DYNAMIC","makeSerializable"],"mappings":"AAAA;;;AAGA,GAEA;;;;+BA0TA;;;eAAA;;;+EAzTmC;iEAEd;+DACF;wEACa;gCACU;qCACK;mFACR;gFACH;yEAaP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7B,MAAMA,eAAe,IAAIC,IAAI;IAAC;CAAa;AAa3C,IAAA,AAAMC,uBAAN,MAAMA,6BAA6BC,eAAM;IAmBvC;;;GAGC,GACD,OAAOC,YAAYC,OAAkC,EAAwB;QAC3E,MAAM,EAAEC,IAAI,EAAE,GAAGD;QACjB,MAAME,MAAM,IAAIL,qBAAqBI,QAAQA,QAAQA;QACrD,YAAY;QACZC,IAAIH,WAAW,CAACC;QAChB,OAAOE;IACT;IAEA;;GAEC,GACD,AAASC,iBAA8B;QACrC,OAAOR;IACT;IACA;;GAEC,GACD,AAASS,aAAqB;QAC5B,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAACC,WAAW,CAAC,EAAE,EAAEC,KAAKC,SAAS,CAC5D,IAAI,CAACC,QAAQ,EACb,CAAC;IACL;IACA;;;GAGC,GACD,AAASC,mBAAmBC,gBAAkC,EAAU;QACtE,OAAO;IACT;IACA;;;GAGC,GACD,AAASC,SAASC,OAAwB,EAAiB;QACzD,O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AC;YACpD0B,iBAAQ,CAACE,MAAM,CAAC;gBACd,CAAC,KAAK,EAAEjC,gBAAgByB,iBAAiB,CAAC,OAAO,CAAC,CAAC;gBACnD,CAAC,MAAM,EAAEzB,gBAAgByB,iBAAiB,CAAC,QAAQ,CAAC;aACrD;YACD;SACD;QAEDxB,QAAQoC,GAAG,CACT,cACA,IAAI,CAACC,YAAY,IAAI,IAAI,CAACC,kBAAkB,GACxC,IAAIC,8BAAc,CAACV,QAAQ,6BAC3B,IAAIW,yBAAS,CAACX;QAGpB,OAAO;YACL7B;YACAE;QACF;IACF;IAEA;;;GAGC,GACD,AAASuC,KAAKC,IAAa,EAAU;QACnC,OAAO;IACT;IACA;;GAEC,GACD,YAAY;IACHC,UAAUzF,OAAgC,EAAQ;QACzD,MAAM,EAAE0F,KAAK,EAAE,GAAG1F;QAClB0F,MAAM,IAAI,CAAC5E,KAAK;QAChB4E,MAAM,IAAI,CAAClF,QAAQ;QACnBkF,MAAM,IAAI,CAACrF,WAAW;QACtB,YAAY;QACZ,KAAK,CAACoF,UAAUzF;IAClB;IAzQA;;;;GAIC,GACD2F,YACE/D,IAAY,EACZgE,OAAkC,EAClCC,UAAkB,CAClB;QACA,KAAK,CAACC,mDAA8B,EAAE;QACtC,IAAI,CAAChF,KAAK,GAAGc;QACb,IAAI,CAACpB,QAAQ,GAAGoF;QAChB,IAAI,CAACvF,WAAW,GAAGwF;IACrB;AA4PF;AACA,YAAY;AACZE,IAAAA,yBAAgB,EACdlG,sBACA;MAGF,WAAeA"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/ContainerEntryModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr\n*/\n\n'use strict';\nimport AsyncDependenciesBlock from 'webpack/lib/AsyncDependenciesBlock';\nimport Dependency from 'webpack/lib/Dependency';\nimport Template from 'webpack/lib/Template';\nimport Module from 'webpack/lib/Module';\nimport * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport { OriginalSource, RawSource } from 'webpack-sources';\nimport { JAVASCRIPT_MODULE_TYPE_DYNAMIC } from 'webpack/lib/ModuleTypeConstants';\nimport ContainerExposedDependency from './ContainerExposedDependency';\nimport StaticExportsDependency from 'webpack/lib/dependencies/StaticExportsDependency';\nimport type Compilation from 'webpack/lib/Compilation';\nimport type {\n LibIdentOptions,\n NeedBuildContext,\n RequestShortener,\n ObjectDeserializerContext,\n ObjectSerializerContext,\n WebpackOptions,\n InputFileSystem,\n ResolverWithOptions,\n} from 'webpack/lib/Module';\nimport type WebpackError from 'webpack/lib/WebpackError';\nimport makeSerializable from 'webpack/lib/util/makeSerializable';\n\nconst SOURCE_TYPES = new Set(['javascript']);\n\nexport type ExposeOptions = {\n /**\n * requests to exposed modules (last one is exported)\n */\n import: string[];\n /**\n * custom chunk name for the exposed module\n */\n name: string;\n};\n\nclass ContainerEntryModule extends Module {\n private _name: string;\n private _exposes: [string, ExposeOptions][];\n private _shareScope: string;\n /**\n * @param {string} name container entry name\n * @param {[string, ExposeOptions][]} exposes list of exposed modules\n * @param {string} shareScope name of the share scope\n */\n constructor(\n name: string,\n exposes: [string, ExposeOptions][],\n shareScope: string,\n ) {\n super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);\n this._name = name;\n this._exposes = exposes;\n this._shareScope = shareScope;\n }\n /**\n * @param {ObjectDeserializerContext} context context\n * @returns {ContainerEntryModule} deserialized container entry module\n */\n static deserialize(context: ObjectDeserializerContext): ContainerEntryModule {\n const { read } = context;\n const obj = new ContainerEntryModule(read(), read(), read());\n //@ts-ignore\n obj.deserialize(context);\n return obj;\n }\n\n /**\n * @returns {Set<string>} types available (do not mutate)\n */\n override getSourceTypes(): Set<string> {\n return SOURCE_TYPES;\n }\n /**\n * @returns {string} a unique identifier of the module\n */\n override identifier(): string {\n return `container entry (${this._shareScope}) ${JSON.stringify(\n this._exposes,\n )}`;\n }\n /**\n * @param {RequestShortener} requestShortener the request shortener\n * @returns {string} a user readable identifier of the module\n */\n override readableIdentifier(requestShortener: RequestShortener): string {\n return 'container entry';\n }\n /**\n * @param {LibIdentOptions} options options\n * @returns {string | null} an identifier for library inclusion\n */\n override libIdent(options: LibIdentOptions): string | null {\n return `${this.layer ? `(${this.layer})/` : ''}webpack/container/entry/${\n this._name\n }`;\n }\n /**\n * @param {NeedBuildContext} context context info\n * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild\n * @returns {void}\n */\n override needBuild(\n context: NeedBuildContext,\n callback: (\n arg0: (WebpackError | null) | undefined,\n arg1: boolean | undefined,\n ) => void,\n ): void {\n const baseContext = context as NeedBuildContext;\n callback(null, !this.buildMeta);\n }\n /**\n * @param {WebpackOptions} options webpack options\n * @param {Compilation} compilation the compilation\n * @param {ResolverWithOptions} resolver the resolver\n * @param {InputFileSystem} fs the file system\n * @param {function(WebpackError): void} callback callback function\n * @returns {void}\n */\n override build(\n options: WebpackOptions,\n compilation: Compilation,\n resolver: ResolverWithOptions,\n fs: InputFileSystem,\n callback: (err?: WebpackError) => void,\n ): void {\n this.buildMeta = {};\n this.buildInfo = {\n strict: true,\n topLevelDeclarations: new Set(['moduleMap', 'get', 'init']),\n };\n this.buildMeta.exportsType = 'namespace';\n //@ts-ignore\n this.clearDependenciesAndBlocks();\n\n for (const [name, options] of this._exposes) {\n const block = new AsyncDependenciesBlock(\n {\n name: options.name,\n },\n { name },\n options.import[options.import.length - 1],\n );\n let idx = 0;\n for (const request of options.import) {\n const dep = new ContainerExposedDependency(name, request);\n dep.loc = {\n name,\n index: idx++,\n };\n //@ts-ignore\n block.addDependency(dep);\n }\n //@ts-ignore\n this.addBlock(block);\n }\n //@ts-ignore\n this.addDependency(\n //@ts-ignore\n new StaticExportsDependency(\n ['get', 'init'],\n false,\n ) as unknown as Dependency,\n );\n\n callback();\n }\n\n /**\n * @param {CodeGenerationContext} context context for code generation\n * @returns {CodeGenerationResult} result\n */\n //@ts-ignore\n override codeGeneration({ moduleGraph, chunkGraph, runtimeTemplate }) {\n const sources = new Map();\n const runtimeRequirements = new Set([\n RuntimeGlobals.definePropertyGetters,\n RuntimeGlobals.hasOwnProperty,\n RuntimeGlobals.exports,\n ]);\n const getters = [];\n //@ts-ignore\n for (const block of this.blocks) {\n const { dependencies } = block;\n\n const modules = dependencies.map((dependency: Dependency) => {\n const dep = dependency as unknown as ContainerExposedDependency;\n return {\n name: dep.exposedName,\n module: moduleGraph.getModule(dep),\n request: dep.userRequest,\n };\n });\n\n let str;\n //@ts-ignore\n if (modules.some((m) => !m.module)) {\n str = runtimeTemplate.throwMissingModuleErrorBlock({\n //@ts-ignore\n request: modules.map((m) => m.request).join(', '),\n });\n } else {\n str = `return ${runtimeTemplate.blockPromise({\n block,\n message: '',\n chunkGraph,\n runtimeRequirements,\n })}.then(${runtimeTemplate.returningFunction(\n runtimeTemplate.returningFunction(\n `(${modules\n //@ts-ignore\n .map(({ module, request }) =>\n runtimeTemplate.moduleRaw({\n module,\n chunkGraph,\n request,\n weak: false,\n runtimeRequirements,\n }),\n )\n .join(', ')})`,\n ),\n )});`;\n }\n\n getters.push(\n `${JSON.stringify(modules[0].name)}: ${runtimeTemplate.basicFunction(\n '',\n str,\n )}`,\n );\n }\n\n const source = Template.asString([\n `var moduleMap = {`,\n Template.indent(getters.join(',\\n')),\n '};',\n `var get = ${runtimeTemplate.basicFunction('module, getScope', [\n `${RuntimeGlobals.currentRemoteGetScope} = getScope;`,\n // reusing the getScope variable to avoid creating a new var (and module is also used later)\n 'getScope = (',\n Template.indent([\n `${RuntimeGlobals.hasOwnProperty}(moduleMap, module)`,\n Template.indent([\n '? moduleMap[module]()',\n `: Promise.resolve().then(${runtimeTemplate.basicFunction(\n '',\n \"throw new Error('Module \\\"' + module + '\\\" does not exist in container.');\",\n )})`,\n ]),\n ]),\n ');',\n `${RuntimeGlobals.currentRemoteGetScope} = undefined;`,\n 'return getScope;',\n ])};`,\n `var init = ${runtimeTemplate.basicFunction('shareScope, initScope', [\n `if (!${RuntimeGlobals.shareScopeMap}) return;`,\n `var name = ${JSON.stringify(this._shareScope)}`,\n `var oldScope = ${RuntimeGlobals.shareScopeMap}[name];`,\n `if(oldScope && oldScope !== shareScope) throw new Error(\"Container initialization failed as it has already been initialized with a different share scope\");`,\n `${RuntimeGlobals.shareScopeMap}[name] = shareScope;`,\n `return ${RuntimeGlobals.initializeSharing}(name, initScope);`,\n ])};`,\n '',\n '// This exports getters to disallow modifications',\n `${RuntimeGlobals.definePropertyGetters}(exports, {`,\n Template.indent([\n `get: ${runtimeTemplate.returningFunction('get')},`,\n `init: ${runtimeTemplate.returningFunction('init')}`,\n ]),\n '});',\n ]);\n\n sources.set(\n 'javascript',\n this.useSourceMap || this.useSimpleSourceMap\n ? new OriginalSource(source, 'webpack/container-entry')\n : new RawSource(source),\n );\n\n return {\n sources,\n runtimeRequirements,\n };\n }\n\n /**\n * @param {string=} type the source type for which the size should be estimated\n * @returns {number} the estimated size of the module (must be non-zero)\n */\n override size(type?: string): number {\n return 42;\n }\n /**\n * @param {ObjectSerializerContext} context context\n */\n //@ts-ignore\n override serialize(context: ObjectSerializerContext): void {\n const { write } = context;\n write(this._name);\n write(this._exposes);\n write(this._shareScope);\n //@ts-ignore\n super.serialize(context);\n }\n}\n//@ts-ignore\nmakeSerializable(\n ContainerEntryModule,\n 'enhanced/lib/container/ContainerEntryModule',\n);\n\nexport default ContainerEntryModule;\n"],"names":["SOURCE_TYPES","Set","ContainerEntryModule","Module","deserialize","context","read","obj","getSourceTypes","identifier","_shareScope","JSON","stringify","_exposes","readableIdentifier","requestShortener","libIdent","options","layer","_name","needBuild","callback","baseContext","buildMeta","build","compilation","resolver","fs","buildInfo","strict","topLevelDeclarations","exportsType","clearDependenciesAndBlocks","name","block","AsyncDependenciesBlock","import","length","idx","request","dep","ContainerExposedDependency","loc","index","addDependency","addBlock","StaticExportsDependency","codeGeneration","moduleGraph","chunkGraph","runtimeTemplate","sources","Map","runtimeRequirements","RuntimeGlobals","definePropertyGetters","hasOwnProperty","exports","getters","blocks","dependencies","modules","map","dependency","exposedName","module","getModule","userRequest","str","some","m","throwMissingModuleErrorBlock","join","blockPromise","message","returningFunction","moduleRaw","weak","push","basicFunction","source","Template","asString","indent","currentRemoteGetScope","shareScopeMap","initializeSharing","set","useSourceMap","useSimpleSourceMap","OriginalSource","RawSource","size","type","serialize","write","constructor","exposes","shareScope","JAVASCRIPT_MODULE_TYPE_DYNAMIC","makeSerializable"],"mappings":"AAAA;;;AAGA,GAEA;;;;+BA0TA;;;eAAA;;;+EAzTmC;iEAEd;+DACF;wEACa;gCACU;qCACK;mFACR;gFACH;yEAaP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7B,MAAMA,eAAe,IAAIC,IAAI;IAAC;CAAa;AAa3C,IAAA,AAAMC,uBAAN,MAAMA,6BAA6BC,eAAM;IAmBvC;;;GAGC,GACD,OAAOC,YAAYC,OAAkC,EAAwB;QAC3E,MAAM,EAAEC,IAAI,EAAE,GAAGD;QACjB,MAAME,MAAM,IAAIL,qBAAqBI,QAAQA,QAAQA;QACrD,YAAY;QACZC,IAAIH,WAAW,CAACC;QAChB,OAAOE;IACT;IAEA;;GAEC,GACD,AAASC,iBAA8B;QACrC,OAAOR;IACT;IACA;;GAEC,GACD,AAASS,aAAqB;QAC5B,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAACC,WAAW,CAAC,EAAE,EAAEC,KAAKC,SAAS,CAC5D,IAAI,CAACC,QAAQ,EACb,CAAC;IACL;IACA;;;GAGC,GACD,AAASC,mBAAmBC,gBAAkC,EAAU;QACtE,OAAO;IACT;IACA;;;GAGC,GACD,AAASC,SAASC,OAAwB,EAAiB;QACzD,OAAO,CAAC,EAAE,IAAI,CAACC,KAAK,GAAG,CAAC,CAAC,EAAE,IAAI,CAACA,KAAK,CAAC,EAAE,CAAC,GAAG,GAAG,wBAAwB,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AAC,MAAM,EAAEzB,gBAAgByB,iBAAiB,CAAC,QAAQ,CAAC;aACrD;YACD;SACD;QAEDxB,QAAQoC,GAAG,CACT,cACA,IAAI,CAACC,YAAY,IAAI,IAAI,CAACC,kBAAkB,GACxC,IAAIC,8BAAc,CAACV,QAAQ,6BAC3B,IAAIW,yBAAS,CAACX;QAGpB,OAAO;YACL7B;YACAE;QACF;IACF;IAEA;;;GAGC,GACD,AAASuC,KAAKC,IAAa,EAAU;QACnC,OAAO;IACT;IACA;;GAEC,GACD,YAAY;IACHC,UAAUzF,OAAgC,EAAQ;QACzD,MAAM,EAAE0F,KAAK,EAAE,GAAG1F;QAClB0F,MAAM,IAAI,CAAC5E,KAAK;QAChB4E,MAAM,IAAI,CAAClF,QAAQ;QACnBkF,MAAM,IAAI,CAACrF,WAAW;QACtB,YAAY;QACZ,KAAK,CAACoF,UAAUzF;IAClB;IAzQA;;;;GAIC,GACD2F,YACE/D,IAAY,EACZgE,OAAkC,EAClCC,UAAkB,CAClB;QACA,KAAK,CAACC,mDAA8B,EAAE;QACtC,IAAI,CAAChF,KAAK,GAAGc;QACb,IAAI,CAACpB,QAAQ,GAAGoF;QAChB,IAAI,CAACvF,WAAW,GAAGwF;IACrB;AA4PF;AACA,YAAY;AACZE,IAAAA,yBAAgB,EACdlG,sBACA;MAGF,WAAeA"}
|
|
@@ -18,7 +18,8 @@ function _interop_require_default(obj) {
|
|
|
18
18
|
default: obj
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
var ContainerEntryModuleFactory;
|
|
22
|
+
ContainerEntryModuleFactory = class ContainerEntryModuleFactory extends _ModuleFactory.default {
|
|
22
23
|
/**
|
|
23
24
|
* @param {ModuleFactoryCreateData} data data object
|
|
24
25
|
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/ContainerEntryModuleFactory.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr\n*/\n\n'use strict';\n\nimport ContainerEntryModule from './ContainerEntryModule';\nimport ContainerEntryDependency from './ContainerEntryDependency';\nimport ModuleFactory from 'webpack/lib/ModuleFactory';\nimport type {\n ModuleFactoryCreateData,\n ModuleFactoryResult,\n} from 'webpack/lib/ModuleFactory';\n\nexport default class ContainerEntryModuleFactory extends ModuleFactory {\n /**\n * @param {ModuleFactoryCreateData} data data object\n * @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback\n * @returns {void}\n */\n override create(\n data: ModuleFactoryCreateData,\n callback: (error: Error | null, result: ModuleFactoryResult) => void,\n ): void {\n const { dependencies } = data;\n const containerDependencies =\n dependencies as unknown as ContainerEntryDependency[];\n const dep = containerDependencies[0];\n\n callback(null, {\n module: new ContainerEntryModule(dep.name, dep.exposes, dep.shareScope),\n });\n }\n}\n"],"names":["ContainerEntryModuleFactory","ModuleFactory","create","data","callback","dependencies","containerDependencies","dep","module","ContainerEntryModule","name","exposes","shareScope"],"mappings":"AAAA;;;AAGA,GAEA;;;;;;;eAUqBA;;;6EARY;sEAEP;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/ContainerEntryModuleFactory.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr\n*/\n\n'use strict';\n\nimport ContainerEntryModule from './ContainerEntryModule';\nimport ContainerEntryDependency from './ContainerEntryDependency';\nimport ModuleFactory from 'webpack/lib/ModuleFactory';\nimport type {\n ModuleFactoryCreateData,\n ModuleFactoryResult,\n} from 'webpack/lib/ModuleFactory';\n\nexport default class ContainerEntryModuleFactory extends ModuleFactory {\n /**\n * @param {ModuleFactoryCreateData} data data object\n * @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback\n * @returns {void}\n */\n override create(\n data: ModuleFactoryCreateData,\n callback: (error: Error | null, result: ModuleFactoryResult) => void,\n ): void {\n const { dependencies } = data;\n const containerDependencies =\n dependencies as unknown as ContainerEntryDependency[];\n const dep = containerDependencies[0];\n\n callback(null, {\n module: new ContainerEntryModule(dep.name, dep.exposes, dep.shareScope),\n });\n }\n}\n"],"names":["ContainerEntryModuleFactory","ModuleFactory","create","data","callback","dependencies","containerDependencies","dep","module","ContainerEntryModule","name","exposes","shareScope"],"mappings":"AAAA;;;AAGA,GAEA;;;;;;;eAUqBA;;;6EARY;sEAEP;;;;;;IAMLA;AAAAA,8BAAN,MAAMA,oCAAoCC,sBAAa;IACpE;;;;GAIC,GACD,AAASC,OACPC,IAA6B,EAC7BC,QAAoE,EAC9D;QACN,MAAM,EAAEC,YAAY,EAAE,GAAGF;QACzB,MAAMG,wBACJD;QACF,MAAME,MAAMD,qBAAqB,CAAC,EAAE;QAEpCF,SAAS,MAAM;YACbI,QAAQ,IAAIC,6BAAoB,CAACF,IAAIG,IAAI,EAAEH,IAAII,OAAO,EAAEJ,IAAIK,UAAU;QACxE;IACF;AACF"}
|
|
@@ -47,7 +47,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
47
47
|
if (cache && cache.has(obj)) {
|
|
48
48
|
return cache.get(obj);
|
|
49
49
|
}
|
|
50
|
-
var newObj = {
|
|
50
|
+
var newObj = {
|
|
51
|
+
__proto__: null
|
|
52
|
+
};
|
|
51
53
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
52
54
|
for(var key in obj){
|
|
53
55
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/ContainerReferencePlugin.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy\n*/\n\nimport type Compiler from 'webpack/lib/Compiler';\nimport * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport createSchemaValidation from 'webpack/lib/util/create-schema-validation';\nimport FallbackDependency from './FallbackDependency';\nimport FallbackItemDependency from './FallbackItemDependency';\nimport FallbackModuleFactory from './FallbackModuleFactory';\nimport RemoteModule from './RemoteModule';\nimport RemoteRuntimeModule from './RemoteRuntimeModule';\nimport RemoteToExternalDependency from './RemoteToExternalDependency';\nimport { parseOptions } from './options';\nimport ExternalsPlugin from 'webpack/lib/ExternalsPlugin';\nimport type Compilation from 'webpack/lib/Compilation';\nimport type { ResolveData } from 'webpack/lib/NormalModuleFactory';\nimport NormalModuleFactory from 'webpack/lib/NormalModuleFactory';\nimport {\n ExternalsType,\n ContainerReferencePluginOptions,\n RemotesConfig,\n} from '../../declarations/plugins/container/ContainerReferencePlugin';\n\nconst validate = createSchemaValidation(\n //eslint-disable-next-line\n require('webpack/schemas/plugins/container/ContainerReferencePlugin.check.js'),\n () =>\n require('webpack/schemas/plugins/container/ContainerReferencePlugin.json'),\n {\n name: 'Container Reference Plugin',\n baseDataPath: 'options',\n },\n);\n\nconst slashCode = '/'.charCodeAt(0);\n\nclass ContainerReferencePlugin {\n private _remoteType: ExternalsType;\n private _remotes: [string, RemotesConfig][];\n\n constructor(options: ContainerReferencePluginOptions) {\n validate(options);\n\n this._remoteType = options.remoteType;\n this._remotes = parseOptions(\n options.remotes,\n (item) => ({\n external: Array.isArray(item) ? item : [item],\n shareScope: options.shareScope || 'default',\n }),\n (item) => ({\n external: Array.isArray(item.external)\n ? item.external\n : [item.external],\n shareScope: item.shareScope || options.shareScope || 'default',\n }),\n );\n }\n\n /**\n * Apply the plugin\n * @param {Compiler} compiler the compiler instance\n * @returns {void}\n */\n apply(compiler: Compiler): void {\n const { _remotes: remotes, _remoteType: remoteType } = this;\n\n /** @type {Record<string, string>} */\n const remoteExternals: Record<string, string> = {};\n\n for (const [key, config] of remotes) {\n let i = 0;\n for (const external of config.external) {\n if (typeof external === 'string' && external.startsWith('internal ')) {\n continue;\n }\n remoteExternals[\n `webpack/container/reference/${key}${i ? `/fallback-${i}` : ''}`\n ] = external;\n i++;\n }\n }\n const Externals = compiler.webpack.ExternalsPlugin || ExternalsPlugin;\n //@ts-ignore\n new Externals(remoteType, remoteExternals).apply(compiler);\n\n compiler.hooks.compilation.tap(\n 'ContainerReferencePlugin',\n (\n compilation: Compilation,\n { normalModuleFactory }: { normalModuleFactory: NormalModuleFactory },\n ) => {\n compilation.dependencyFactories.set(\n RemoteToExternalDependency,\n normalModuleFactory,\n );\n\n compilation.dependencyFactories.set(\n FallbackItemDependency,\n normalModuleFactory,\n );\n\n compilation.dependencyFactories.set(\n FallbackDependency,\n new FallbackModuleFactory(),\n );\n\n normalModuleFactory.hooks.factorize.tap(\n 'ContainerReferencePlugin',\n //@ts-ignore\n (data: ResolveData): Module => {\n if (!data.request.includes('!')) {\n for (const [key, config] of remotes) {\n if (\n data.request.startsWith(`${key}`) &&\n (data.request.length === key.length ||\n data.request.charCodeAt(key.length) === slashCode)\n ) {\n return new RemoteModule(\n data.request,\n //@ts-ignore\n config.external.map((external: any, i: any) =>\n external.startsWith('internal ')\n ? external.slice(9)\n : `webpack/container/reference/${key}${\n i ? `/fallback-${i}` : ''\n }`,\n ),\n `.${data.request.slice(key.length)}`,\n //@ts-ignore\n config.shareScope,\n );\n }\n }\n }\n },\n );\n\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.ensureChunkHandlers)\n .tap('ContainerReferencePlugin', (chunk, set) => {\n set.add(RuntimeGlobals.module);\n set.add(RuntimeGlobals.moduleFactoriesAddOnly);\n set.add(RuntimeGlobals.hasOwnProperty);\n set.add(RuntimeGlobals.initializeSharing);\n set.add(RuntimeGlobals.shareScopeMap);\n compilation.addRuntimeModule(chunk, new RemoteRuntimeModule());\n });\n },\n );\n }\n}\n\nexport default ContainerReferencePlugin;\n"],"names":["validate","createSchemaValidation","require","name","baseDataPath","slashCode","charCodeAt","ContainerReferencePlugin","apply","compiler","_remotes","remotes","_remoteType","remoteType","remoteExternals","key","config","i","external","startsWith","Externals","webpack","ExternalsPlugin","hooks","compilation","tap","normalModuleFactory","dependencyFactories","set","RemoteToExternalDependency","FallbackItemDependency","FallbackDependency","FallbackModuleFactory","factorize","data","request","includes","length","RemoteModule","map","slice","shareScope","runtimeRequirementInTree","for","RuntimeGlobals","ensureChunkHandlers","chunk","add","module","moduleFactoriesAddOnly","hasOwnProperty","initializeSharing","shareScopeMap","addRuntimeModule","RemoteRuntimeModule","constructor","options","parseOptions","item","Array","isArray"],"mappings":"AAAA;;;AAGA;;;;+BAwJA;;;eAAA;;;wEArJgC;+EACG;2EACJ;+EACI;8EACD;qEACT;4EACO;mFACO;yBACV;wEACD
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/ContainerReferencePlugin.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy\n*/\n\nimport type Compiler from 'webpack/lib/Compiler';\nimport * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport createSchemaValidation from 'webpack/lib/util/create-schema-validation';\nimport FallbackDependency from './FallbackDependency';\nimport FallbackItemDependency from './FallbackItemDependency';\nimport FallbackModuleFactory from './FallbackModuleFactory';\nimport RemoteModule from './RemoteModule';\nimport RemoteRuntimeModule from './RemoteRuntimeModule';\nimport RemoteToExternalDependency from './RemoteToExternalDependency';\nimport { parseOptions } from './options';\nimport ExternalsPlugin from 'webpack/lib/ExternalsPlugin';\nimport type Compilation from 'webpack/lib/Compilation';\nimport type { ResolveData } from 'webpack/lib/NormalModuleFactory';\nimport NormalModuleFactory from 'webpack/lib/NormalModuleFactory';\nimport {\n ExternalsType,\n ContainerReferencePluginOptions,\n RemotesConfig,\n} from '../../declarations/plugins/container/ContainerReferencePlugin';\n\nconst validate = createSchemaValidation(\n //eslint-disable-next-line\n require('webpack/schemas/plugins/container/ContainerReferencePlugin.check.js'),\n () =>\n require('webpack/schemas/plugins/container/ContainerReferencePlugin.json'),\n {\n name: 'Container Reference Plugin',\n baseDataPath: 'options',\n },\n);\n\nconst slashCode = '/'.charCodeAt(0);\n\nclass ContainerReferencePlugin {\n private _remoteType: ExternalsType;\n private _remotes: [string, RemotesConfig][];\n\n constructor(options: ContainerReferencePluginOptions) {\n validate(options);\n\n this._remoteType = options.remoteType;\n this._remotes = parseOptions(\n options.remotes,\n (item) => ({\n external: Array.isArray(item) ? item : [item],\n shareScope: options.shareScope || 'default',\n }),\n (item) => ({\n external: Array.isArray(item.external)\n ? item.external\n : [item.external],\n shareScope: item.shareScope || options.shareScope || 'default',\n }),\n );\n }\n\n /**\n * Apply the plugin\n * @param {Compiler} compiler the compiler instance\n * @returns {void}\n */\n apply(compiler: Compiler): void {\n const { _remotes: remotes, _remoteType: remoteType } = this;\n\n /** @type {Record<string, string>} */\n const remoteExternals: Record<string, string> = {};\n\n for (const [key, config] of remotes) {\n let i = 0;\n for (const external of config.external) {\n if (typeof external === 'string' && external.startsWith('internal ')) {\n continue;\n }\n remoteExternals[\n `webpack/container/reference/${key}${i ? `/fallback-${i}` : ''}`\n ] = external;\n i++;\n }\n }\n const Externals = compiler.webpack.ExternalsPlugin || ExternalsPlugin;\n //@ts-ignore\n new Externals(remoteType, remoteExternals).apply(compiler);\n\n compiler.hooks.compilation.tap(\n 'ContainerReferencePlugin',\n (\n compilation: Compilation,\n { normalModuleFactory }: { normalModuleFactory: NormalModuleFactory },\n ) => {\n compilation.dependencyFactories.set(\n RemoteToExternalDependency,\n normalModuleFactory,\n );\n\n compilation.dependencyFactories.set(\n FallbackItemDependency,\n normalModuleFactory,\n );\n\n compilation.dependencyFactories.set(\n FallbackDependency,\n new FallbackModuleFactory(),\n );\n\n normalModuleFactory.hooks.factorize.tap(\n 'ContainerReferencePlugin',\n //@ts-ignore\n (data: ResolveData): Module => {\n if (!data.request.includes('!')) {\n for (const [key, config] of remotes) {\n if (\n data.request.startsWith(`${key}`) &&\n (data.request.length === key.length ||\n data.request.charCodeAt(key.length) === slashCode)\n ) {\n return new RemoteModule(\n data.request,\n //@ts-ignore\n config.external.map((external: any, i: any) =>\n external.startsWith('internal ')\n ? external.slice(9)\n : `webpack/container/reference/${key}${\n i ? `/fallback-${i}` : ''\n }`,\n ),\n `.${data.request.slice(key.length)}`,\n //@ts-ignore\n config.shareScope,\n );\n }\n }\n }\n },\n );\n\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.ensureChunkHandlers)\n .tap('ContainerReferencePlugin', (chunk, set) => {\n set.add(RuntimeGlobals.module);\n set.add(RuntimeGlobals.moduleFactoriesAddOnly);\n set.add(RuntimeGlobals.hasOwnProperty);\n set.add(RuntimeGlobals.initializeSharing);\n set.add(RuntimeGlobals.shareScopeMap);\n compilation.addRuntimeModule(chunk, new RemoteRuntimeModule());\n });\n },\n );\n }\n}\n\nexport default ContainerReferencePlugin;\n"],"names":["validate","createSchemaValidation","require","name","baseDataPath","slashCode","charCodeAt","ContainerReferencePlugin","apply","compiler","_remotes","remotes","_remoteType","remoteType","remoteExternals","key","config","i","external","startsWith","Externals","webpack","ExternalsPlugin","hooks","compilation","tap","normalModuleFactory","dependencyFactories","set","RemoteToExternalDependency","FallbackItemDependency","FallbackDependency","FallbackModuleFactory","factorize","data","request","includes","length","RemoteModule","map","slice","shareScope","runtimeRequirementInTree","for","RuntimeGlobals","ensureChunkHandlers","chunk","add","module","moduleFactoriesAddOnly","hasOwnProperty","initializeSharing","shareScopeMap","addRuntimeModule","RemoteRuntimeModule","constructor","options","parseOptions","item","Array","isArray"],"mappings":"AAAA;;;AAGA;;;;+BAwJA;;;eAAA;;;wEArJgC;+EACG;2EACJ;+EACI;8EACD;qEACT;4EACO;mFACO;yBACV;wEACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAU5B,MAAMA,WAAWC,IAA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+C,OAAU,CAAA;gBACTxC,UAAUyC,MAAMC,OAAO,CAACF,QAAQA,OAAO;oBAACA;iBAAK;gBAC7CjB,YAAYe,QAAQf,UAAU,IAAI;YACpC,CAAA,GACA,CAACiB,OAAU,CAAA;gBACTxC,UAAUyC,MAAMC,OAAO,CAACF,KAAKxC,QAAQ,IACjCwC,KAAKxC,QAAQ,GACb;oBAACwC,KAAKxC,QAAQ;iBAAC;gBACnBuB,YAAYiB,KAAKjB,UAAU,IAAIe,QAAQf,UAAU,IAAI;YACvD,CAAA;IAEJ;AA8FF;MAEA,WAAelC"}
|
|
@@ -18,7 +18,8 @@ function _interop_require_default(obj) {
|
|
|
18
18
|
default: obj
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
var FallbackModuleFactory;
|
|
22
|
+
FallbackModuleFactory = class FallbackModuleFactory extends _ModuleFactory.default {
|
|
22
23
|
/**
|
|
23
24
|
* @param {ModuleFactoryCreateData} data data object
|
|
24
25
|
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/FallbackModuleFactory.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr\n*/\n\n'use strict';\nimport {\n ModuleFactoryCreateData,\n ModuleFactoryResult,\n} from 'webpack/lib/ModuleFactory';\nimport ModuleFactory from 'webpack/lib/ModuleFactory';\nimport FallbackModule from './FallbackModule';\nimport FallbackDependency from './FallbackDependency';\n\nexport default class FallbackModuleFactory extends ModuleFactory {\n /**\n * @param {ModuleFactoryCreateData} data data object\n * @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback\n * @returns {void}\n */\n override create(\n data: ModuleFactoryCreateData,\n callback: (error: Error | null, result?: ModuleFactoryResult) => void,\n ): void {\n const dependency = data.dependencies[0] as FallbackDependency;\n callback(null, {\n module: new FallbackModule(dependency.requests),\n });\n }\n}\n"],"names":["FallbackModuleFactory","ModuleFactory","create","data","callback","dependency","dependencies","module","FallbackModule","requests"],"mappings":"AAAA;;;AAGA,GAEA;;;;;;;eASqBA;;;sEAJK;uEACC;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/FallbackModuleFactory.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr\n*/\n\n'use strict';\nimport {\n ModuleFactoryCreateData,\n ModuleFactoryResult,\n} from 'webpack/lib/ModuleFactory';\nimport ModuleFactory from 'webpack/lib/ModuleFactory';\nimport FallbackModule from './FallbackModule';\nimport FallbackDependency from './FallbackDependency';\n\nexport default class FallbackModuleFactory extends ModuleFactory {\n /**\n * @param {ModuleFactoryCreateData} data data object\n * @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback\n * @returns {void}\n */\n override create(\n data: ModuleFactoryCreateData,\n callback: (error: Error | null, result?: ModuleFactoryResult) => void,\n ): void {\n const dependency = data.dependencies[0] as FallbackDependency;\n callback(null, {\n module: new FallbackModule(dependency.requests),\n });\n }\n}\n"],"names":["FallbackModuleFactory","ModuleFactory","create","data","callback","dependency","dependencies","module","FallbackModule","requests"],"mappings":"AAAA;;;AAGA,GAEA;;;;;;;eASqBA;;;sEAJK;uEACC;;;;;;IAGNA;AAAAA,wBAAN,MAAMA,8BAA8BC,sBAAa;IAC9D;;;;GAIC,GACD,AAASC,OACPC,IAA6B,EAC7BC,QAAqE,EAC/D;QACN,MAAMC,aAAaF,KAAKG,YAAY,CAAC,EAAE;QACvCF,SAAS,MAAM;YACbG,QAAQ,IAAIC,uBAAc,CAACH,WAAWI,QAAQ;QAChD;IACF;AACF"}
|
|
@@ -22,7 +22,7 @@ function _interop_require_default(obj) {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
const validate = (0, _createschemavalidation.default)(//eslint-disable-next-line
|
|
25
|
-
require('webpack/schemas/plugins/container/ModuleFederationPlugin.check.js'), ()=>require('
|
|
25
|
+
require('webpack/schemas/plugins/container/ModuleFederationPlugin.check.js'), ()=>require('../../schemas/container/ModuleFederationPlugin.json'), {
|
|
26
26
|
name: 'Module Federation Plugin',
|
|
27
27
|
baseDataPath: 'options'
|
|
28
28
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/ModuleFederationPlugin.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy\n*/\n\n'use strict';\n\nimport type Compiler from 'webpack/lib/Compiler';\nimport isValidExternalsType from 'webpack/schemas/plugins/container/ExternalsType.check.js';\nimport type { ModuleFederationPluginOptions } from './ModuleFederationPluginTypes';\nimport SharePlugin from '../sharing/SharePlugin';\nimport createSchemaValidation from 'webpack/lib/util/create-schema-validation';\nimport ContainerPlugin from './ContainerPlugin';\nimport ContainerReferencePlugin from './ContainerReferencePlugin';\n\nconst validate = createSchemaValidation(\n //eslint-disable-next-line\n require('webpack/schemas/plugins/container/ModuleFederationPlugin.check.js'),\n ()
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/ModuleFederationPlugin.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy\n*/\n\n'use strict';\n\nimport type Compiler from 'webpack/lib/Compiler';\nimport isValidExternalsType from 'webpack/schemas/plugins/container/ExternalsType.check.js';\nimport type { ModuleFederationPluginOptions } from './ModuleFederationPluginTypes';\nimport SharePlugin from '../sharing/SharePlugin';\nimport createSchemaValidation from 'webpack/lib/util/create-schema-validation';\nimport ContainerPlugin from './ContainerPlugin';\nimport ContainerReferencePlugin from './ContainerReferencePlugin';\n\nconst validate = createSchemaValidation(\n //eslint-disable-next-line\n require('webpack/schemas/plugins/container/ModuleFederationPlugin.check.js'),\n () => require('../../schemas/container/ModuleFederationPlugin.json'),\n {\n name: 'Module Federation Plugin',\n baseDataPath: 'options',\n },\n);\n\nclass ModuleFederationPlugin {\n private _options: ModuleFederationPluginOptions;\n /**\n * @param {ModuleFederationPluginOptions} options options\n */\n constructor(options: ModuleFederationPluginOptions) {\n validate(options);\n\n this._options = options;\n }\n\n /**\n * Apply the plugin\n * @param {Compiler} compiler the compiler instance\n * @returns {void}\n */\n apply(compiler: Compiler): void {\n const { _options: options } = this;\n const library = options.library || { type: 'var', name: options.name };\n const remoteType =\n options.remoteType ||\n (options.library && isValidExternalsType(options.library.type)\n ? options.library.type\n : 'script');\n if (\n library &&\n !compiler.options.output.enabledLibraryTypes?.includes(library.type)\n ) {\n compiler.options.output.enabledLibraryTypes?.push(library.type);\n }\n compiler.hooks.afterPlugins.tap('ModuleFederationPlugin', () => {\n if (\n options.exposes &&\n (Array.isArray(options.exposes)\n ? options.exposes.length > 0\n : Object.keys(options.exposes).length > 0)\n ) {\n new ContainerPlugin({\n //@ts-ignore\n name: options.name,\n library,\n filename: options.filename,\n runtime: options.runtime,\n shareScope: options.shareScope,\n exposes: options.exposes,\n }).apply(compiler);\n }\n if (\n options.remotes &&\n (Array.isArray(options.remotes)\n ? options.remotes.length > 0\n : Object.keys(options.remotes).length > 0)\n ) {\n new ContainerReferencePlugin({\n //@ts-ignore\n remoteType,\n shareScope: options.shareScope,\n remotes: options.remotes,\n }).apply(compiler);\n }\n if (options.shared) {\n new SharePlugin({\n shared: options.shared,\n shareScope: options.shareScope,\n }).apply(compiler);\n }\n });\n }\n}\n\nexport default ModuleFederationPlugin;\n"],"names":["validate","createSchemaValidation","require","name","baseDataPath","ModuleFederationPlugin","apply","compiler","_options","options","library","type","remoteType","isValidExternalsType","output","enabledLibraryTypes","includes","push","hooks","afterPlugins","tap","exposes","Array","isArray","length","Object","keys","ContainerPlugin","filename","runtime","shareScope","remotes","ContainerReferencePlugin","shared","SharePlugin","constructor"],"mappings":"AAAA;;;AAGA,GAEA;;;;+BA0FA;;;eAAA;;;2EAvFiC;oEAET;+EACW;wEACP;iFACS;;;;;;AAErC,MAAMA,WAAWC,IAAAA,+BAAsB,EACrC,0BAA0B;AAC1BC,QAAQ,sEACR,IAAMA,QAAQ,wDACd;IACEC,MAAM;IACNC,cAAc;AAChB;AAGF,IAAA,AAAMC,yBAAN,MAAMA;IAWJ;;;;GAIC,GACDC,MAAMC,QAAkB,EAAQ;YAU3BA;QATH,MAAM,EAAEC,UAAUC,OAAO,EAAE,GAAG,IAAI;QAClC,MAAMC,UAAUD,QAAQC,OAAO,IAAI;YAAEC,MAAM;YAAOR,MAAMM,QAAQN,IAAI;QAAC;QACrE,MAAMS,aACJH,QAAQG,UAAU,IACjBH,CAAAA,QAAQC,OAAO,IAAIG,IAAAA,2BAAoB,EAACJ,QAAQC,OAAO,CAACC,IAAI,IACzDF,QAAQC,OAAO,CAACC,IAAI,GACpB,QAAO;QACb,IACED,WACA,GAACH,+CAAAA,SAASE,OAAO,CAACK,MAAM,CAACC,mBAAmB,qBAA3CR,6CAA6CS,QAAQ,CAACN,QAAQC,IAAI,IACnE;gBACAJ;aAAAA,gDAAAA,SAASE,OAAO,CAACK,MAAM,CAACC,mBAAmB,qBAA3CR,8CAA6CU,IAAI,CAACP,QAAQC,IAAI;QAChE;QACAJ,SAASW,KAAK,CAACC,YAAY,CAACC,GAAG,CAAC,0BAA0B;YACxD,IACEX,QAAQY,OAAO,IACdC,CAAAA,MAAMC,OAAO,CAACd,QAAQY,OAAO,IAC1BZ,QAAQY,OAAO,CAACG,MAAM,GAAG,IACzBC,OAAOC,IAAI,CAACjB,QAAQY,OAAO,EAAEG,MAAM,GAAG,CAAA,GAC1C;gBACA,IAAIG,wBAAe,CAAC;oBAClB,YAAY;oBACZxB,MAAMM,QAAQN,IAAI;oBAClBO;oBACAkB,UAAUnB,QAAQmB,QAAQ;oBAC1BC,SAASpB,QAAQoB,OAAO;oBACxBC,YAAYrB,QAAQqB,UAAU;oBAC9BT,SAASZ,QAAQY,OAAO;gBAC1B,GAAGf,KAAK,CAACC;YACX;YACA,IACEE,QAAQsB,OAAO,IACdT,CAAAA,MAAMC,OAAO,CAACd,QAAQsB,OAAO,IAC1BtB,QAAQsB,OAAO,CAACP,MAAM,GAAG,IACzBC,OAAOC,IAAI,CAACjB,QAAQsB,OAAO,EAAEP,MAAM,GAAG,CAAA,GAC1C;gBACA,IAAIQ,iCAAwB,CAAC;oBAC3B,YAAY;oBACZpB;oBACAkB,YAAYrB,QAAQqB,UAAU;oBAC9BC,SAAStB,QAAQsB,OAAO;gBAC1B,GAAGzB,KAAK,CAACC;YACX;YACA,IAAIE,QAAQwB,MAAM,EAAE;gBAClB,IAAIC,oBAAW,CAAC;oBACdD,QAAQxB,QAAQwB,MAAM;oBACtBH,YAAYrB,QAAQqB,UAAU;gBAChC,GAAGxB,KAAK,CAACC;YACX;QACF;IACF;IAjEA;;GAEC,GACD4B,YAAY1B,OAAsC,CAAE;QAClDT,SAASS;QAET,IAAI,CAACD,QAAQ,GAAGC;IAClB;AA2DF;MAEA,WAAeJ"}
|
|
@@ -45,7 +45,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
45
45
|
if (cache && cache.has(obj)) {
|
|
46
46
|
return cache.get(obj);
|
|
47
47
|
}
|
|
48
|
-
var newObj = {
|
|
48
|
+
var newObj = {
|
|
49
|
+
__proto__: null
|
|
50
|
+
};
|
|
49
51
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
50
52
|
for(var key in obj){
|
|
51
53
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|