@module-federation/enhanced 0.1.5 → 0.1.7
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/dist/package.json +67 -0
- package/dist/src/declarations/plugins/container/AsyncDependenciesBlock.d.ts +57 -0
- package/dist/src/declarations/plugins/container/Dependency.d.ts +285 -0
- package/dist/src/declarations/plugins/container/Module.d.ts +138 -0
- package/dist/src/declarations/plugins/container/ModuleFactory.d.ts +33 -0
- package/dist/src/declarations/plugins/container/ObjectDeserializerContext.d.ts +4 -0
- package/dist/src/declarations/plugins/container/StaticExportsDependency.d.ts +28 -0
- package/dist/src/declarations/plugins/container/Template.d.ts +198 -0
- package/dist/src/declarations/plugins/container/WebpackError.d.ts +32 -0
- package/dist/src/declarations/plugins/container/WebpackOptions.d.ts +140 -0
- package/dist/src/declarations/plugins/sharing/ConsumeSharedPlugin.d.ts +74 -0
- package/dist/src/declarations/plugins/sharing/ProvideSharedPlugin.d.ts +67 -0
- package/dist/src/declarations/plugins/sharing/SharePlugin.d.ts +78 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +37 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib/Constants.d.ts +117 -0
- package/dist/src/lib/Constants.js +125 -0
- package/dist/src/lib/Constants.js.map +1 -0
- package/dist/src/lib/RuntimeGlobals.d.ts +0 -0
- package/dist/src/lib/RuntimeGlobals.js +316 -0
- package/dist/src/lib/RuntimeGlobals.js.map +1 -0
- package/dist/src/lib/container/AsyncBoundaryPlugin.d.ts +20 -0
- package/dist/src/lib/container/AsyncBoundaryPlugin.js +183 -0
- package/dist/src/lib/container/AsyncBoundaryPlugin.js.map +1 -0
- package/dist/src/lib/container/ContainerEntryDependency.d.ts +24 -0
- package/dist/src/lib/container/ContainerEntryDependency.js +39 -0
- package/dist/src/lib/container/ContainerEntryDependency.js.map +1 -0
- package/dist/src/lib/container/ContainerEntryModule.d.ts +75 -0
- package/dist/src/lib/container/ContainerEntryModule.js +250 -0
- package/dist/src/lib/container/ContainerEntryModule.js.map +1 -0
- package/dist/src/lib/container/ContainerEntryModuleFactory.d.ts +15 -0
- package/dist/src/lib/container/ContainerEntryModuleFactory.js +30 -0
- package/dist/src/lib/container/ContainerEntryModuleFactory.js.map +1 -0
- package/dist/src/lib/container/ContainerExposedDependency.d.ts +19 -0
- package/dist/src/lib/container/ContainerExposedDependency.js +49 -0
- package/dist/src/lib/container/ContainerExposedDependency.js.map +1 -0
- package/dist/src/lib/container/ContainerPlugin.d.ts +13 -0
- package/dist/src/lib/container/ContainerPlugin.js +185 -0
- package/dist/src/lib/container/ContainerPlugin.js.map +1 -0
- package/dist/src/lib/container/ContainerReferencePlugin.d.ts +14 -0
- package/dist/src/lib/container/ContainerReferencePlugin.js +102 -0
- package/dist/src/lib/container/ContainerReferencePlugin.js.map +1 -0
- package/dist/src/lib/container/FallbackDependency.d.ts +15 -0
- package/dist/src/lib/container/FallbackDependency.js +47 -0
- package/dist/src/lib/container/FallbackDependency.js.map +1 -0
- package/dist/src/lib/container/FallbackItemDependency.d.ts +3 -0
- package/dist/src/lib/container/FallbackItemDependency.js +26 -0
- package/dist/src/lib/container/FallbackItemDependency.js.map +1 -0
- package/dist/src/lib/container/FallbackModule.d.ts +54 -0
- package/dist/src/lib/container/FallbackModule.js +152 -0
- package/dist/src/lib/container/FallbackModule.js.map +1 -0
- package/dist/src/lib/container/FallbackModuleFactory.d.ts +11 -0
- package/dist/src/lib/container/FallbackModuleFactory.js +28 -0
- package/dist/src/lib/container/FallbackModuleFactory.js.map +1 -0
- package/dist/src/lib/container/HoistContainerReferencesPlugin.d.ts +14 -0
- package/dist/src/lib/container/HoistContainerReferencesPlugin.js +61 -0
- package/dist/src/lib/container/HoistContainerReferencesPlugin.js.map +1 -0
- package/dist/src/lib/container/ModuleFederationPlugin.d.ts +16 -0
- package/dist/src/lib/container/ModuleFederationPlugin.js +122 -0
- package/dist/src/lib/container/ModuleFederationPlugin.js.map +1 -0
- package/dist/src/lib/container/RemoteModule.d.ts +90 -0
- package/dist/src/lib/container/RemoteModule.js +148 -0
- package/dist/src/lib/container/RemoteModule.js.map +1 -0
- package/dist/src/lib/container/RemoteRuntimeModule.d.ts +12 -0
- package/dist/src/lib/container/RemoteRuntimeModule.js +101 -0
- package/dist/src/lib/container/RemoteRuntimeModule.js.map +1 -0
- package/dist/src/lib/container/RemoteToExternalDependency.d.ts +4 -0
- package/dist/src/lib/container/RemoteToExternalDependency.js +26 -0
- package/dist/src/lib/container/RemoteToExternalDependency.js.map +1 -0
- package/dist/src/lib/container/constant.d.ts +3 -0
- package/dist/src/lib/container/constant.js +12 -0
- package/dist/src/lib/container/constant.js.map +1 -0
- package/dist/src/lib/container/options.d.ts +26 -0
- package/dist/src/lib/container/options.js +81 -0
- package/dist/src/lib/container/options.js.map +1 -0
- package/dist/src/lib/container/runtime/FederationRuntimeModule.d.ts +13 -0
- package/dist/src/lib/container/runtime/FederationRuntimeModule.js +27 -0
- package/dist/src/lib/container/runtime/FederationRuntimeModule.js.map +1 -0
- package/dist/src/lib/container/runtime/FederationRuntimePlugin.d.ts +17 -0
- package/dist/src/lib/container/runtime/FederationRuntimePlugin.js +209 -0
- package/dist/src/lib/container/runtime/FederationRuntimePlugin.js.map +1 -0
- package/dist/src/lib/container/runtime/getFederationGlobal.d.ts +5 -0
- package/dist/src/lib/container/runtime/getFederationGlobal.js +24 -0
- package/dist/src/lib/container/runtime/getFederationGlobal.js.map +1 -0
- package/dist/src/lib/container/runtime/utils.d.ts +16 -0
- package/dist/src/lib/container/runtime/utils.js +83 -0
- package/dist/src/lib/container/runtime/utils.js.map +1 -0
- package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.d.ts +3 -0
- package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.js +26 -0
- package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.js.map +1 -0
- package/dist/src/lib/sharing/ConsumeSharedModule.d.ts +99 -0
- package/dist/src/lib/sharing/ConsumeSharedModule.js +206 -0
- package/dist/src/lib/sharing/ConsumeSharedModule.js.map +1 -0
- package/dist/src/lib/sharing/ConsumeSharedPlugin.d.ts +30 -0
- package/dist/src/lib/sharing/ConsumeSharedPlugin.js +245 -0
- package/dist/src/lib/sharing/ConsumeSharedPlugin.js.map +1 -0
- package/dist/src/lib/sharing/ConsumeSharedRuntimeModule.d.ts +31 -0
- package/dist/src/lib/sharing/ConsumeSharedRuntimeModule.js +124 -0
- package/dist/src/lib/sharing/ConsumeSharedRuntimeModule.js.map +1 -0
- package/dist/src/lib/sharing/ProvideForSharedDependency.d.ts +3 -0
- package/dist/src/lib/sharing/ProvideForSharedDependency.js +27 -0
- package/dist/src/lib/sharing/ProvideForSharedDependency.js.map +1 -0
- package/dist/src/lib/sharing/ProvideSharedDependency.d.ts +36 -0
- package/dist/src/lib/sharing/ProvideSharedDependency.js +70 -0
- package/dist/src/lib/sharing/ProvideSharedDependency.js.map +1 -0
- package/dist/src/lib/sharing/ProvideSharedModule.d.ts +67 -0
- package/dist/src/lib/sharing/ProvideSharedModule.js +186 -0
- package/dist/src/lib/sharing/ProvideSharedModule.js.map +1 -0
- package/dist/src/lib/sharing/ProvideSharedModuleFactory.d.ts +18 -0
- package/dist/src/lib/sharing/ProvideSharedModuleFactory.js +30 -0
- package/dist/src/lib/sharing/ProvideSharedModuleFactory.js.map +1 -0
- package/dist/src/lib/sharing/ProvideSharedPlugin.d.ts +47 -0
- package/dist/src/lib/sharing/ProvideSharedPlugin.js +195 -0
- package/dist/src/lib/sharing/ProvideSharedPlugin.js.map +1 -0
- package/dist/src/lib/sharing/SharePlugin.d.ts +41 -0
- package/dist/src/lib/sharing/SharePlugin.js +79 -0
- package/dist/src/lib/sharing/SharePlugin.js.map +1 -0
- package/dist/src/lib/sharing/ShareRuntimeModule.d.ts +14 -0
- package/dist/src/lib/sharing/ShareRuntimeModule.js +102 -0
- package/dist/src/lib/sharing/ShareRuntimeModule.js.map +1 -0
- package/dist/src/lib/sharing/resolveMatchedConfigs.d.ts +12 -0
- package/dist/src/lib/sharing/resolveMatchedConfigs.js +66 -0
- package/dist/src/lib/sharing/resolveMatchedConfigs.js.map +1 -0
- package/dist/src/lib/sharing/utils.d.ts +37 -0
- package/dist/src/lib/sharing/utils.js +359 -0
- package/dist/src/lib/sharing/utils.js.map +1 -0
- package/dist/src/rspack.d.ts +1 -0
- package/dist/src/rspack.js +6 -0
- package/dist/src/rspack.js.map +1 -0
- package/dist/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +5 -0
- package/dist/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.js +19 -0
- package/dist/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.js.map +1 -0
- package/dist/src/runtime.d.ts +1 -0
- package/dist/src/runtime.js +18 -0
- package/dist/src/runtime.js.map +1 -0
- package/dist/src/schemas/container/ContainerPlugin.check.d.ts +7 -0
- package/dist/src/schemas/container/ContainerPlugin.check.js +2318 -0
- package/dist/src/schemas/container/ContainerPlugin.check.js.map +1 -0
- package/dist/src/schemas/container/ContainerPlugin.d.ts +289 -0
- package/dist/src/schemas/container/ContainerPlugin.js +326 -0
- package/dist/src/schemas/container/ContainerPlugin.js.map +1 -0
- package/dist/src/schemas/container/ContainerReferencePlugin.check.d.ts +7 -0
- package/dist/src/schemas/container/ContainerReferencePlugin.check.js +939 -0
- package/dist/src/schemas/container/ContainerReferencePlugin.check.js.map +1 -0
- package/dist/src/schemas/container/ContainerReferencePlugin.d.ts +87 -0
- package/dist/src/schemas/container/ContainerReferencePlugin.js +132 -0
- package/dist/src/schemas/container/ContainerReferencePlugin.js.map +1 -0
- package/dist/src/schemas/container/ModuleFederationPlugin.check.d.ts +9 -0
- package/dist/src/schemas/container/ModuleFederationPlugin.check.js +4001 -0
- package/dist/src/schemas/container/ModuleFederationPlugin.check.js.map +1 -0
- package/dist/src/schemas/container/ModuleFederationPlugin.d.ts +626 -0
- package/dist/src/schemas/container/ModuleFederationPlugin.js +720 -0
- package/dist/src/schemas/container/ModuleFederationPlugin.js.map +1 -0
- package/dist/src/schemas/sharing/ProviderSharedPlugin.check.d.ts +7 -0
- package/dist/src/schemas/sharing/ProviderSharedPlugin.check.js +434 -0
- package/dist/src/schemas/sharing/ProviderSharedPlugin.check.js.map +1 -0
- package/dist/src/schemas/sharing/ProviderSharedPlugin.d.ts +104 -0
- package/dist/src/schemas/sharing/ProviderSharedPlugin.js +119 -0
- package/dist/src/schemas/sharing/ProviderSharedPlugin.js.map +1 -0
- package/dist/src/types/runtime.d.ts +7 -0
- package/dist/src/types/runtime.js +3 -0
- package/dist/src/types/runtime.js.map +1 -0
- package/dist/src/webpack.d.ts +1 -0
- package/dist/src/webpack.js +9 -0
- package/dist/src/webpack.js.map +1 -0
- package/dist/src/wrapper/AsyncBoundaryPlugin.d.ts +8 -0
- package/dist/src/wrapper/AsyncBoundaryPlugin.js +19 -0
- package/dist/src/wrapper/AsyncBoundaryPlugin.js.map +1 -0
- package/dist/src/wrapper/ConsumeSharedPlugin.d.ts +8 -0
- package/dist/src/wrapper/ConsumeSharedPlugin.js +19 -0
- package/dist/src/wrapper/ConsumeSharedPlugin.js.map +1 -0
- package/dist/src/wrapper/ContainerPlugin.d.ts +8 -0
- package/dist/src/wrapper/ContainerPlugin.js +19 -0
- package/dist/src/wrapper/ContainerPlugin.js.map +1 -0
- package/dist/src/wrapper/ContainerReferencePlugin.d.ts +8 -0
- package/dist/src/wrapper/ContainerReferencePlugin.js +19 -0
- package/dist/src/wrapper/ContainerReferencePlugin.js.map +1 -0
- package/dist/src/wrapper/FederationRuntimePlugin.d.ts +9 -0
- package/dist/src/wrapper/FederationRuntimePlugin.js +22 -0
- package/dist/src/wrapper/FederationRuntimePlugin.js.map +1 -0
- package/dist/src/wrapper/HoistContainerReferencesPlugin.d.ts +6 -0
- package/dist/src/wrapper/HoistContainerReferencesPlugin.js +18 -0
- package/dist/src/wrapper/HoistContainerReferencesPlugin.js.map +1 -0
- package/dist/src/wrapper/ModuleFederationPlugin.d.ts +8 -0
- package/dist/src/wrapper/ModuleFederationPlugin.js +24 -0
- package/dist/src/wrapper/ModuleFederationPlugin.js.map +1 -0
- package/dist/src/wrapper/ProvideSharedPlugin.d.ts +8 -0
- package/dist/src/wrapper/ProvideSharedPlugin.js +19 -0
- package/dist/src/wrapper/ProvideSharedPlugin.js.map +1 -0
- package/dist/src/wrapper/SharePlugin.d.ts +8 -0
- package/dist/src/wrapper/SharePlugin.js +19 -0
- package/dist/src/wrapper/SharePlugin.js.map +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy
|
|
4
|
+
*/
|
|
5
|
+
'use strict';
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const normalize_webpack_path_1 = require("@module-federation/sdk/normalize-webpack-path");
|
|
11
|
+
const FallbackItemDependency_1 = __importDefault(require("./FallbackItemDependency"));
|
|
12
|
+
const Constants_1 = require("../Constants");
|
|
13
|
+
const { sources: webpackSources } = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack'));
|
|
14
|
+
const { Template, Module, RuntimeGlobals } = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack'));
|
|
15
|
+
const makeSerializable = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/util/makeSerializable'));
|
|
16
|
+
const TYPES = new Set(['javascript']);
|
|
17
|
+
const RUNTIME_REQUIREMENTS = new Set([RuntimeGlobals.module]);
|
|
18
|
+
class FallbackModule extends Module {
|
|
19
|
+
/**
|
|
20
|
+
* @param {string[]} requests list of requests to choose one
|
|
21
|
+
*/
|
|
22
|
+
constructor(requests) {
|
|
23
|
+
super(Constants_1.WEBPACK_MODULE_TYPE_FALLBACK);
|
|
24
|
+
this.requests = requests;
|
|
25
|
+
this._identifier = `fallback ${this.requests.join(' ')}`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @returns {string} a unique identifier of the module
|
|
29
|
+
*/
|
|
30
|
+
identifier() {
|
|
31
|
+
return this._identifier;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @param {RequestShortener} requestShortener the request shortener
|
|
35
|
+
* @returns {string} a user readable identifier of the module
|
|
36
|
+
*/
|
|
37
|
+
readableIdentifier(requestShortener) {
|
|
38
|
+
return this._identifier;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @param {LibIdentOptions} options options
|
|
42
|
+
* @returns {string | null} an identifier for library inclusion
|
|
43
|
+
*/
|
|
44
|
+
libIdent(options) {
|
|
45
|
+
return `${this.layer ? `(${this.layer})/` : ''}webpack/container/fallback/${this.requests[0]}/and ${this.requests.length - 1} more`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @param {Chunk} chunk the chunk which condition should be checked
|
|
49
|
+
* @param {Compilation} compilation the compilation
|
|
50
|
+
* @returns {boolean} true, if the chunk is ok for the module
|
|
51
|
+
*/
|
|
52
|
+
chunkCondition(chunk, { chunkGraph }) {
|
|
53
|
+
return chunkGraph.getNumberOfEntryModules(chunk) > 0;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @param {NeedBuildContext} context context info
|
|
57
|
+
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
|
58
|
+
* @returns {void}
|
|
59
|
+
*/
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
needBuild(context, callback) {
|
|
62
|
+
callback(null, !this.buildInfo);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @param {WebpackOptions} options webpack options
|
|
66
|
+
* @param {Compilation} compilation the compilation
|
|
67
|
+
* @param {ResolverWithOptions} resolver the resolver
|
|
68
|
+
* @param {InputFileSystem} fs the file system
|
|
69
|
+
* @param {function(WebpackError=): void} callback callback function
|
|
70
|
+
* @returns {void}
|
|
71
|
+
*/
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
build(options, compilation, resolver, fs, callback) {
|
|
74
|
+
this.buildMeta = {};
|
|
75
|
+
this.buildInfo = {
|
|
76
|
+
strict: true,
|
|
77
|
+
};
|
|
78
|
+
this.clearDependenciesAndBlocks();
|
|
79
|
+
for (const request of this.requests)
|
|
80
|
+
this.addDependency(new FallbackItemDependency_1.default(request));
|
|
81
|
+
callback();
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* @param {string=} type the source type for which the size should be estimated
|
|
85
|
+
* @returns {number} the estimated size of the module (must be non-zero)
|
|
86
|
+
*/
|
|
87
|
+
size(type) {
|
|
88
|
+
return this.requests.length * 5 + 42;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @returns {Set<string>} types available (do not mutate)
|
|
92
|
+
*/
|
|
93
|
+
getSourceTypes() {
|
|
94
|
+
return TYPES;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* @param {CodeGenerationContext} context context for code generation
|
|
98
|
+
* @returns {CodeGenerationResult} result
|
|
99
|
+
*/
|
|
100
|
+
// @ts-ignore
|
|
101
|
+
codeGeneration({ runtimeTemplate, moduleGraph, chunkGraph, }) {
|
|
102
|
+
const ids = this.dependencies.map((dep) =>
|
|
103
|
+
//@ts-ignore
|
|
104
|
+
chunkGraph.getModuleId(moduleGraph.getModule(dep)));
|
|
105
|
+
const code = Template.asString([
|
|
106
|
+
`var ids = ${JSON.stringify(ids)};`,
|
|
107
|
+
'var error, result, i = 0;',
|
|
108
|
+
`var loop = ${runtimeTemplate.basicFunction('next', [
|
|
109
|
+
'while(i < ids.length) {',
|
|
110
|
+
Template.indent([
|
|
111
|
+
`try { next = ${RuntimeGlobals.require}(ids[i++]); } catch(e) { return handleError(e); }`,
|
|
112
|
+
'if(next) return next.then ? next.then(handleResult, handleError) : handleResult(next);',
|
|
113
|
+
]),
|
|
114
|
+
'}',
|
|
115
|
+
'if(error) throw error;',
|
|
116
|
+
])}`,
|
|
117
|
+
`var handleResult = ${runtimeTemplate.basicFunction('result', [
|
|
118
|
+
'if(result) return result;',
|
|
119
|
+
'return loop();',
|
|
120
|
+
])};`,
|
|
121
|
+
`var handleError = ${runtimeTemplate.basicFunction('e', [
|
|
122
|
+
'error = e;',
|
|
123
|
+
'return loop();',
|
|
124
|
+
])};`,
|
|
125
|
+
'module.exports = loop();',
|
|
126
|
+
]);
|
|
127
|
+
const sources = new Map();
|
|
128
|
+
sources.set('javascript', new webpackSources.RawSource(code));
|
|
129
|
+
return { sources, runtimeRequirements: RUNTIME_REQUIREMENTS };
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* @param {ObjectSerializerContext} context context
|
|
133
|
+
*/
|
|
134
|
+
serialize(context) {
|
|
135
|
+
const { write } = context;
|
|
136
|
+
write(this.requests);
|
|
137
|
+
super.serialize(context);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @param {ObjectDeserializerContext} context context
|
|
141
|
+
* @returns {FallbackModule} deserialized fallback module
|
|
142
|
+
*/
|
|
143
|
+
static deserialize(context) {
|
|
144
|
+
const { read } = context;
|
|
145
|
+
const obj = new FallbackModule(read());
|
|
146
|
+
obj.deserialize(context);
|
|
147
|
+
return obj;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
makeSerializable(FallbackModule, 'enhanced/lib/container/FallbackModule');
|
|
151
|
+
exports.default = FallbackModule;
|
|
152
|
+
//# sourceMappingURL=FallbackModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FallbackModule.js","sourceRoot":"","sources":["../../../../src/lib/container/FallbackModule.ts"],"names":[],"mappings":"AAAA;;;EAGE;AAEF,YAAY,CAAC;;;;;AAEb,0FAAqF;AAgBrF,sFAA8D;AAC9D,4CAA4D;AAE5D,MAAM,E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Factory {}
|
|
3
|
+
declare namespace FallbackModuleFactory {
|
|
4
|
+
export { ModuleFactoryCreateData, ModuleFactoryResult, FallbackDependency };
|
|
5
|
+
}
|
|
6
|
+
import ModuleFactory = require('webpack/lib/ModuleFactory');
|
|
7
|
+
type ModuleFactoryCreateData =
|
|
8
|
+
import('webpack/lib/ModuleFactory').ModuleFactoryCreateData;
|
|
9
|
+
type ModuleFactoryResult =
|
|
10
|
+
import('webpack/lib/ModuleFactory').ModuleFactoryResult;
|
|
11
|
+
type FallbackDependency = import('./FallbackDependency');
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr
|
|
4
|
+
*/
|
|
5
|
+
'use strict';
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const normalize_webpack_path_1 = require("@module-federation/sdk/normalize-webpack-path");
|
|
11
|
+
const FallbackModule_1 = __importDefault(require("./FallbackModule"));
|
|
12
|
+
const ModuleFactory = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/ModuleFactory'));
|
|
13
|
+
class FallbackModuleFactory extends ModuleFactory {
|
|
14
|
+
/**
|
|
15
|
+
* @param {ModuleFactoryCreateData} data data object
|
|
16
|
+
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
|
|
17
|
+
* @returns {void}
|
|
18
|
+
*/
|
|
19
|
+
create(data, callback) {
|
|
20
|
+
const dependency = data.dependencies[0];
|
|
21
|
+
callback(null, {
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
module: new FallbackModule_1.default(dependency.requests),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.default = FallbackModuleFactory;
|
|
28
|
+
//# sourceMappingURL=FallbackModuleFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FallbackModuleFactory.js","sourceRoot":"","sources":["../../../../src/lib/container/FallbackModuleFactory.ts"],"names":[],"mappings":"AAAA;;;EAGE;AAEF,YAAY,CAAC;;;;;AAKb,0FAAqF;AACrF,sEAA8C;AAE9C,MAAM,aAAa,GAAG,OAAO,CAC3B,IAAA,6CAAoB,EAAC,2BAA2B,CAAC,CACJ,CAAC;AAEhD,MAAqB,qBAAsB,SAAQ,aAAa;IAC9D;;;;OAIG;IACM,MAAM,CACb,IAA6B,EAC7B,QAAqE;QAErE,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACxC,QAAQ,CAAC,IAAI,EAAE;YACb,aAAa;YACb,MAAM,EAAE,IAAI,wBAAc,CAAC,UAAU,CAAC,QAAQ,CAAC;SAChD,CAAC,CAAC;IACL,CAAC;CACF;AAhBD,wCAgBC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Compiler, WebpackPluginInstance } from 'webpack';
|
|
2
|
+
/**
|
|
3
|
+
* This class is used to hoist container references in the code.
|
|
4
|
+
* @constructor
|
|
5
|
+
*/
|
|
6
|
+
export declare class HoistContainerReferences implements WebpackPluginInstance {
|
|
7
|
+
private containerName?;
|
|
8
|
+
constructor(name?: string | undefined);
|
|
9
|
+
apply(compiler: Compiler): void;
|
|
10
|
+
private chunkContainsContainerEntryModule;
|
|
11
|
+
private hoistModulesInChunk;
|
|
12
|
+
private getRuntimeChunks;
|
|
13
|
+
}
|
|
14
|
+
export default HoistContainerReferences;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HoistContainerReferences = void 0;
|
|
7
|
+
const ContainerEntryModule_1 = __importDefault(require("./ContainerEntryModule"));
|
|
8
|
+
/**
|
|
9
|
+
* This class is used to hoist container references in the code.
|
|
10
|
+
* @constructor
|
|
11
|
+
*/
|
|
12
|
+
class HoistContainerReferences {
|
|
13
|
+
constructor(name) {
|
|
14
|
+
this.containerName = name;
|
|
15
|
+
}
|
|
16
|
+
apply(compiler) {
|
|
17
|
+
compiler.hooks.thisCompilation.tap('HoistContainerReferences', (compilation) => {
|
|
18
|
+
compilation.hooks.afterOptimizeChunks.tap('HoistContainerReferences', (chunks) => {
|
|
19
|
+
for (const chunk of chunks) {
|
|
20
|
+
if (this.chunkContainsContainerEntryModule(chunk, compilation)) {
|
|
21
|
+
this.hoistModulesInChunk(chunk, compilation);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
chunkContainsContainerEntryModule(chunk, compilation) {
|
|
28
|
+
for (const module of compilation.chunkGraph.getChunkModulesIterable(chunk)) {
|
|
29
|
+
if (module instanceof ContainerEntryModule_1.default) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
hoistModulesInChunk(chunk, compilation) {
|
|
36
|
+
const chunkGraph = compilation.chunkGraph;
|
|
37
|
+
const runtimeChunks = this.getRuntimeChunks(chunk, compilation);
|
|
38
|
+
for (const module of chunkGraph.getChunkModulesIterable(chunk)) {
|
|
39
|
+
if (!chunk.hasRuntime()) {
|
|
40
|
+
chunkGraph.disconnectChunkAndModule(chunk, module);
|
|
41
|
+
}
|
|
42
|
+
for (const runtimeChunk of runtimeChunks) {
|
|
43
|
+
if (runtimeChunk.containsModule(module))
|
|
44
|
+
continue;
|
|
45
|
+
chunkGraph.connectChunkAndModule(runtimeChunk, module);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
getRuntimeChunks(chunk, compilation) {
|
|
50
|
+
const runtimeChunks = [];
|
|
51
|
+
for (const c of compilation.chunks) {
|
|
52
|
+
if (c.hasRuntime() && c !== chunk) {
|
|
53
|
+
runtimeChunks.push(c);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return runtimeChunks;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.HoistContainerReferences = HoistContainerReferences;
|
|
60
|
+
exports.default = HoistContainerReferences;
|
|
61
|
+
//# sourceMappingURL=HoistContainerReferencesPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HoistContainerReferencesPlugin.js","sourceRoot":"","sources":["../../../../src/lib/container/HoistContainerReferencesPlugin.ts"],"names":[],"mappings":";;;;;;AAMA,kFAA0D;AAE1D;;;GAGG;AACH,MAAa,wBAAwB;IAGnC,YAAY,IAAyB;QACnC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,QAAkB;QACtB,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAChC,0BAA0B,EAC1B,CAAC,WAAwB,EAAE,EAAE;YAC3B,WAAW,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,CACvC,0BAA0B,EAC1B,CAAC,MAAuB,EAAE,EAAE;gBAC1B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;oBAC3B,IAAI,IAAI,CAAC,iCAAiC,CAAC,KAAK,EAAE,WAAW,CAAC,EAAE,CAAC;wBAC/D,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;oBAC/C,CAAC;gBACH,CAAC;YACH,CAAC,CACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;IAEO,iCAAiC,CACvC,KAAY,EACZ,WAAwB;QAExB,KAAK,MAAM,MAAM,IAAI,WAAW,CAAC,UAAU,CAAC,uBAAuB,CACjE,KAAK,CACN,EAAE,CAAC;YACF,IAAI,MAAM,YAAY,8BAAoB,EAAE,CAAC;gBAC3C,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,mBAAmB,CAAC,KAAY,EAAE,WAAwB;QAChE,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC;QAC1C,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QAEhE,KAAK,MAAM,MAAM,IAAI,UAAU,CAAC,uBAAuB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/D,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC;gBACxB,UAAU,CAAC,wBAAwB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YACrD,CAAC;YACD,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;gBACzC,IAAI,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC;oBAAE,SAAS;gBAClD,UAAU,CAAC,qBAAqB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;IACH,CAAC;IAEO,gBAAgB,CAAC,KAAY,EAAE,WAAwB;QAC7D,MAAM,aAAa,GAAG,EAAE,CAAC;QACzB,KAAK,MAAM,CAAC,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;YACnC,IAAI,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC;gBAClC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;CACF;AA/DD,4DA+DC;AAED,kBAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Compiler, WebpackPluginInstance } from 'webpack';
|
|
2
|
+
import { type moduleFederationPlugin } from '@module-federation/sdk';
|
|
3
|
+
declare class ModuleFederationPlugin implements WebpackPluginInstance {
|
|
4
|
+
private _options;
|
|
5
|
+
/**
|
|
6
|
+
* @param {moduleFederationPlugin.ModuleFederationPluginOptions} options options
|
|
7
|
+
*/
|
|
8
|
+
constructor(options: moduleFederationPlugin.ModuleFederationPluginOptions);
|
|
9
|
+
/**
|
|
10
|
+
* Apply the plugin
|
|
11
|
+
* @param {Compiler} compiler the compiler instance
|
|
12
|
+
* @returns {void}
|
|
13
|
+
*/
|
|
14
|
+
apply(compiler: Compiler): void;
|
|
15
|
+
}
|
|
16
|
+
export default ModuleFederationPlugin;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy
|
|
4
|
+
*/
|
|
5
|
+
'use strict';
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const normalize_webpack_path_1 = require("@module-federation/sdk/normalize-webpack-path");
|
|
11
|
+
const manifest_1 = require("@module-federation/manifest");
|
|
12
|
+
const managers_1 = require("@module-federation/managers");
|
|
13
|
+
const dts_plugin_1 = require("@module-federation/dts-plugin");
|
|
14
|
+
const SharePlugin_1 = __importDefault(require("../sharing/SharePlugin"));
|
|
15
|
+
const ContainerPlugin_1 = __importDefault(require("./ContainerPlugin"));
|
|
16
|
+
const ContainerReferencePlugin_1 = __importDefault(require("./ContainerReferencePlugin"));
|
|
17
|
+
const ModuleFederationPlugin_1 = __importDefault(require("../../schemas/container/ModuleFederationPlugin"));
|
|
18
|
+
const FederationRuntimePlugin_1 = __importDefault(require("./runtime/FederationRuntimePlugin"));
|
|
19
|
+
const isValidExternalsType = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/schemas/plugins/container/ExternalsType.check.js'));
|
|
20
|
+
const createSchemaValidation = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/util/create-schema-validation'));
|
|
21
|
+
const validate = createSchemaValidation(
|
|
22
|
+
// just use schema to validate
|
|
23
|
+
() => false, () => ModuleFederationPlugin_1.default, {
|
|
24
|
+
name: 'Module Federation Plugin',
|
|
25
|
+
baseDataPath: 'options',
|
|
26
|
+
});
|
|
27
|
+
class ModuleFederationPlugin {
|
|
28
|
+
/**
|
|
29
|
+
* @param {moduleFederationPlugin.ModuleFederationPluginOptions} options options
|
|
30
|
+
*/
|
|
31
|
+
constructor(options) {
|
|
32
|
+
validate(options);
|
|
33
|
+
this._options = options;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Apply the plugin
|
|
37
|
+
* @param {Compiler} compiler the compiler instance
|
|
38
|
+
* @returns {void}
|
|
39
|
+
*/
|
|
40
|
+
apply(compiler) {
|
|
41
|
+
const { _options: options } = this;
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
new FederationRuntimePlugin_1.default(options).apply(compiler);
|
|
44
|
+
const library = options.library || { type: 'var', name: options.name };
|
|
45
|
+
const remoteType = options.remoteType ||
|
|
46
|
+
(options.library && isValidExternalsType(options.library.type)
|
|
47
|
+
? options.library.type
|
|
48
|
+
: 'script');
|
|
49
|
+
const useContainerPlugin = options.exposes &&
|
|
50
|
+
(Array.isArray(options.exposes)
|
|
51
|
+
? options.exposes.length > 0
|
|
52
|
+
: Object.keys(options.exposes).length > 0);
|
|
53
|
+
let disableManifest = options.manifest === false;
|
|
54
|
+
if (useContainerPlugin) {
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
ContainerPlugin_1.default.patchChunkSplit(compiler, this._options.name);
|
|
57
|
+
}
|
|
58
|
+
if (!disableManifest && useContainerPlugin) {
|
|
59
|
+
try {
|
|
60
|
+
const containerManager = new managers_1.ContainerManager();
|
|
61
|
+
containerManager.init(options);
|
|
62
|
+
options.exposes = containerManager.containerPluginExposesOptions;
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
if (err instanceof Error) {
|
|
66
|
+
err.message = `[ ModuleFederationPlugin ]: Manifest will not generate, because: ${err.message}`;
|
|
67
|
+
}
|
|
68
|
+
console.warn(err);
|
|
69
|
+
disableManifest = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (options.dts !== false) {
|
|
73
|
+
new dts_plugin_1.DtsPlugin(options).apply(compiler);
|
|
74
|
+
}
|
|
75
|
+
if (library &&
|
|
76
|
+
!compiler.options.output.enabledLibraryTypes?.includes(library.type)) {
|
|
77
|
+
compiler.options.output.enabledLibraryTypes?.push(library.type);
|
|
78
|
+
}
|
|
79
|
+
compiler.hooks.afterPlugins.tap('ModuleFederationPlugin', () => {
|
|
80
|
+
if (useContainerPlugin) {
|
|
81
|
+
new ContainerPlugin_1.default({
|
|
82
|
+
//@ts-ignore
|
|
83
|
+
name: options.name,
|
|
84
|
+
library,
|
|
85
|
+
filename: options.filename,
|
|
86
|
+
runtime: options.runtime,
|
|
87
|
+
shareScope: options.shareScope,
|
|
88
|
+
//@ts-ignore
|
|
89
|
+
exposes: options.exposes,
|
|
90
|
+
runtimePlugins: options.runtimePlugins,
|
|
91
|
+
//@ts-ignore
|
|
92
|
+
}).apply(compiler);
|
|
93
|
+
}
|
|
94
|
+
if (options.remotes &&
|
|
95
|
+
(Array.isArray(options.remotes)
|
|
96
|
+
? options.remotes.length > 0
|
|
97
|
+
: Object.keys(options.remotes).length > 0)) {
|
|
98
|
+
new ContainerReferencePlugin_1.default({
|
|
99
|
+
//@ts-ignore
|
|
100
|
+
remoteType,
|
|
101
|
+
shareScope: options.shareScope,
|
|
102
|
+
remotes: options.remotes,
|
|
103
|
+
}).apply(compiler);
|
|
104
|
+
}
|
|
105
|
+
if (options.shared) {
|
|
106
|
+
new SharePlugin_1.default({
|
|
107
|
+
shared: options.shared,
|
|
108
|
+
shareScope: options.shareScope,
|
|
109
|
+
}).apply(compiler);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
if (!disableManifest) {
|
|
113
|
+
const pkg = require('../../../../package.json');
|
|
114
|
+
new manifest_1.StatsPlugin(options, {
|
|
115
|
+
pluginVersion: pkg.version,
|
|
116
|
+
bundler: 'webpack',
|
|
117
|
+
}).apply(compiler);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.default = ModuleFederationPlugin;
|
|
122
|
+
//# sourceMappingURL=ModuleFederationPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModuleFederationPlugin.js","sourceRoot":"","sources":["../../../../src/lib/container/ModuleFederationPlugin.ts"],"names":[],"mappings":"AAAA;;;EAGE;AAEF,YAAY,CAAC;;;;;AAEb,0FAAqF;AAErF,0DAA0D;AAC1D,0DAA+D;AAC/D,8DAA0D;AAC1D,yEAAiD;AACjD,wEAAgD;AAChD,0FAAkE;AAClE,4GAAoE;AACpE,gGAAwE;AAGxE,MAAM,oBAAoB,GAAG,OAAO,CAClC,IAAA,6CAAoB,EAClB,0DAA0D,CAC3D,CAC2E,CAAC;AAE/E,MAAM,sBAAsB,GAAG,OAAO,CACpC,IAAA,6CAAoB,EAAC,2CAA2C,CAAC,CACJ,CAAC;AAChE,MAAM,QAAQ,GAAG,sBAAsB;AACrC,8BAA8B;AAC9B,GAAG,EAAE,CAAC,KAAK,EACX,GAAG,EAAE,CAAC,gCAAM,EACZ;IACE,IAAI,EAAE,0BAA0B;IAChC,YAAY,EAAE,SAAS;CACxB,CACF,CAAC;AAEF,MAAM,sBAAsB;IAE1B;;OAEG;IACH,YAAY,OAA6D;QACvE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAkB;QACtB,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QACnC,aAAa;QACb,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AAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAC5C,CAAC;gBACD,IAAI,kCAAwB,CAAC;oBAC3B,YAAY;oBACZ,UAAU;oBACV,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,OAAO,EAAE,OAAO,CAAC,OAAO;iBACzB,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACrB,CAAC;YACD,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;gBACnB,IAAI,qBAAW,CAAC;oBACd,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,UAAU,EAAE,OAAO,CAAC,UAAU;iBAC/B,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACrB,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,MAAM,GAAG,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;YAChD,IAAI,sBAAW,CAAC,OAAO,EAAE;gBACvB,aAAa,EAAE,GAAG,CAAC,OAAO;gBAC1B,OAAO,EAAE,SAAS;aACnB,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAED,kBAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export default RemoteModule;
|
|
2
|
+
declare class RemoteModule extends Module {
|
|
3
|
+
/**
|
|
4
|
+
* @param {ObjectDeserializerContext} context context
|
|
5
|
+
* @returns {RemoteModule} deserialized module
|
|
6
|
+
*/
|
|
7
|
+
static deserialize(context: ObjectDeserializerContext): RemoteModule;
|
|
8
|
+
/**
|
|
9
|
+
* @param {string} request request string
|
|
10
|
+
* @param {string[]} externalRequests list of external requests to containers
|
|
11
|
+
* @param {string} internalRequest name of exposed module in container
|
|
12
|
+
* @param {string} shareScope the used share scope name
|
|
13
|
+
*/
|
|
14
|
+
constructor(
|
|
15
|
+
request: string,
|
|
16
|
+
externalRequests: string[],
|
|
17
|
+
internalRequest: string,
|
|
18
|
+
shareScope: string,
|
|
19
|
+
);
|
|
20
|
+
request: string;
|
|
21
|
+
externalRequests: string[];
|
|
22
|
+
internalRequest: string;
|
|
23
|
+
shareScope: string;
|
|
24
|
+
_identifier: string;
|
|
25
|
+
/**
|
|
26
|
+
* @param {NeedBuildContext} context context info
|
|
27
|
+
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
|
28
|
+
* @returns {void}
|
|
29
|
+
*/
|
|
30
|
+
needBuild(
|
|
31
|
+
context: NeedBuildContext,
|
|
32
|
+
callback: (
|
|
33
|
+
arg0: (WebpackError | null) | undefined,
|
|
34
|
+
arg1: boolean | undefined,
|
|
35
|
+
) => void,
|
|
36
|
+
): void;
|
|
37
|
+
/**
|
|
38
|
+
* @param {WebpackOptions} options webpack options
|
|
39
|
+
* @param {Compilation} compilation the compilation
|
|
40
|
+
* @param {ResolverWithOptions} resolver the resolver
|
|
41
|
+
* @param {InputFileSystem} fs the file system
|
|
42
|
+
* @param {function(WebpackError=): void} callback callback function
|
|
43
|
+
* @returns {void}webpack
|
|
44
|
+
*/
|
|
45
|
+
build(
|
|
46
|
+
options: WebpackOptions,
|
|
47
|
+
compilation: Compilation,
|
|
48
|
+
resolver: ResolverWithOptions,
|
|
49
|
+
fs: InputFileSystem,
|
|
50
|
+
callback: (arg0: WebpackError | undefined) => void,
|
|
51
|
+
): void;
|
|
52
|
+
}
|
|
53
|
+
declare namespace RemoteModule {
|
|
54
|
+
export {
|
|
55
|
+
WebpackOptionsohunkGraph,
|
|
56
|
+
ChunkGroup,
|
|
57
|
+
Compilation,
|
|
58
|
+
CodeGenerationContext,
|
|
59
|
+
CodeGenerationResult,
|
|
60
|
+
LibIdentOptions,
|
|
61
|
+
NeedBuildContext,
|
|
62
|
+
RequestShortener,
|
|
63
|
+
ResolverWithOptions,
|
|
64
|
+
WebpackError,
|
|
65
|
+
ObjectDeserializerContext,
|
|
66
|
+
ObjectSerializerContext,
|
|
67
|
+
Hash,
|
|
68
|
+
InputFileSystem,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
import Module = require('webpack/lib/Module');
|
|
72
|
+
type NeedBuildContext = import('webpack/lib/Module').NeedBuildContext;
|
|
73
|
+
type WebpackError = import('webpack/lib/WebpackError');
|
|
74
|
+
type WebpackOptions =
|
|
75
|
+
import('webpack/declarations/WebpackOptions').WebpackOptionsNormalized;
|
|
76
|
+
type Compilation = import('webpack/lib/Compilation');
|
|
77
|
+
type ResolverWithOptions =
|
|
78
|
+
import('webpack/lib/ResolverFactory').ResolverWithOptions;
|
|
79
|
+
type InputFileSystem = import('webpack/lib/util/fs').InputFileSystem;
|
|
80
|
+
type ObjectDeserializerContext =
|
|
81
|
+
import('webpack/lib/serialization/ObjectMiddleware').ObjectDeserializerContext;
|
|
82
|
+
type ChunkGraph = import('webpack/lib/ChunkGraph');
|
|
83
|
+
type ChunkGroup = import('webpack/lib/ChunkGroup');
|
|
84
|
+
type CodeGenerationContext = import('webpack/lib/Module').CodeGenerationContext;
|
|
85
|
+
type CodeGenerationResult = import('webpack/lib/Module').CodeGenerationResult;
|
|
86
|
+
type LibIdentOptions = import('webpack/lib/Module').LibIdentOptions;
|
|
87
|
+
type RequestShortener = import('webpack/lib/RequestShortener');
|
|
88
|
+
type ObjectSerializerContext =
|
|
89
|
+
import('webpack/lib/serialization/ObjectMiddleware').ObjectSerializerContext;
|
|
90
|
+
type Hash = import('webpack/lib/util/Hash');
|