@rspack-canary/core 1.7.3-canary-58d41d16-20260115035302 → 1.7.3-canary-ef467b46-20260115180501
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/container/ModuleFederationManifestPlugin.d.ts +3 -10
- package/dist/container/ModuleFederationPlugin.d.ts +1 -17
- package/dist/exports.d.ts +0 -3
- package/dist/index.js +314 -688
- package/dist/moduleFederationDefaultRuntime.js +1 -1
- package/dist/sharing/ConsumeSharedPlugin.d.ts +0 -13
- package/dist/sharing/ProvideSharedPlugin.d.ts +0 -19
- package/dist/sharing/SharePlugin.d.ts +0 -36
- package/dist/sharing/utils.d.ts +0 -1
- package/hot/lazy-compilation-node.js +90 -34
- package/hot/lazy-compilation-web.js +61 -35
- package/package.json +6 -6
- package/dist/sharing/CollectSharedEntryPlugin.d.ts +0 -22
- package/dist/sharing/IndependentSharedPlugin.d.ts +0 -35
- package/dist/sharing/SharedContainerPlugin.d.ts +0 -23
- package/dist/sharing/SharedUsedExportsOptimizerPlugin.d.ts +0 -14
- package/dist/sharing/TreeShakingSharedPlugin.d.ts +0 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
var __module_federation_bundler_runtime__,__module_federation_runtime_plugins__,__module_federation_remote_infos__,__module_federation_container_name__,__module_federation_share_strategy__
|
|
1
|
+
var __module_federation_bundler_runtime__,__module_federation_runtime_plugins__,__module_federation_remote_infos__,__module_federation_container_name__,__module_federation_share_strategy__;module.exports=function(){if((__webpack_require__.initializeSharingData||__webpack_require__.initializeExposesData)&&__webpack_require__.federation){var _ref,_ref1,_ref2,_ref3,_ref4;var __webpack_require___remotesLoadingData,__webpack_require___remotesLoadingData1,__webpack_require___initializeSharingData,__webpack_require___consumesLoadingData,__webpack_require___consumesLoadingData1,__webpack_require___initializeExposesData,__webpack_require___consumesLoadingData2;const override=(obj,key,value)=>{if(!obj)return;if(obj[key])obj[key]=value};const merge=(obj,key,fn)=>{const value=fn();if(Array.isArray(value)){var _obj,_key,_;(_=(_obj=obj)[_key=key])!==null&&_!==void 0?_:_obj[_key]=[];obj[key].push(...value)}else if(typeof value==="object"&&value!==null){var _obj1,_key1,_1;(_1=(_obj1=obj)[_key1=key])!==null&&_1!==void 0?_1:_obj1[_key1]={};Object.assign(obj[key],value)}};const early=(obj,key,initial)=>{var _obj,_key,_;(_=(_obj=obj)[_key=key])!==null&&_!==void 0?_:_obj[_key]=initial()};const remotesLoadingChunkMapping=(_ref=(__webpack_require___remotesLoadingData=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData===void 0?void 0:__webpack_require___remotesLoadingData.chunkMapping)!==null&&_ref!==void 0?_ref:{};const remotesLoadingModuleIdToRemoteDataMapping=(_ref1=(__webpack_require___remotesLoadingData1=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData1===void 0?void 0:__webpack_require___remotesLoadingData1.moduleIdToRemoteDataMapping)!==null&&_ref1!==void 0?_ref1:{};const initializeSharingScopeToInitDataMapping=(_ref2=(__webpack_require___initializeSharingData=__webpack_require__.initializeSharingData)===null||__webpack_require___initializeSharingData===void 0?void 0:__webpack_require___initializeSharingData.scopeToSharingDataMapping)!==null&&_ref2!==void 0?_ref2:{};const consumesLoadingChunkMapping=(_ref3=(__webpack_require___consumesLoadingData=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData===void 0?void 0:__webpack_require___consumesLoadingData.chunkMapping)!==null&&_ref3!==void 0?_ref3:{};const consumesLoadingModuleToConsumeDataMapping=(_ref4=(__webpack_require___consumesLoadingData1=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData1===void 0?void 0:__webpack_require___consumesLoadingData1.moduleIdToConsumeDataMapping)!==null&&_ref4!==void 0?_ref4:{};const consumesLoadinginstalledModules={};const initializeSharingInitPromises=[];const initializeSharingInitTokens={};const containerShareScope=(__webpack_require___initializeExposesData=__webpack_require__.initializeExposesData)===null||__webpack_require___initializeExposesData===void 0?void 0:__webpack_require___initializeExposesData.shareScope;for(const key in __module_federation_bundler_runtime__){__webpack_require__.federation[key]=__module_federation_bundler_runtime__[key]}early(__webpack_require__.federation,"consumesLoadingModuleToHandlerMapping",()=>{const consumesLoadingModuleToHandlerMapping={};for(let[moduleId,data]of Object.entries(consumesLoadingModuleToConsumeDataMapping)){consumesLoadingModuleToHandlerMapping[moduleId]={getter:data.fallback,shareInfo:{shareConfig:{fixedDependencies:false,requiredVersion:data.requiredVersion,strictVersion:data.strictVersion,singleton:data.singleton,eager:data.eager},scope:[data.shareScope]},shareKey:data.shareKey}}return consumesLoadingModuleToHandlerMapping});early(__webpack_require__.federation,"initOptions",()=>({}));early(__webpack_require__.federation.initOptions,"name",()=>__module_federation_container_name__);early(__webpack_require__.federation.initOptions,"shareStrategy",()=>__module_federation_share_strategy__);early(__webpack_require__.federation.initOptions,"shared",()=>{const shared={};for(let[scope,stages]of Object.entries(initializeSharingScopeToInitDataMapping)){for(let stage of stages){if(typeof stage==="object"&&stage!==null){const{name,version,factory,eager,singleton,requiredVersion,strictVersion}=stage;const shareConfig={};const isValidValue=function(val){return typeof val!=="undefined"};if(isValidValue(singleton)){shareConfig.singleton=singleton}if(isValidValue(requiredVersion)){shareConfig.requiredVersion=requiredVersion}if(isValidValue(eager)){shareConfig.eager=eager}if(isValidValue(strictVersion)){shareConfig.strictVersion=strictVersion}const options={version,scope:[scope],shareConfig,get:factory};if(shared[name]){shared[name].push(options)}else{shared[name]=[options]}}}}return shared});merge(__webpack_require__.federation.initOptions,"remotes",()=>Object.values(__module_federation_remote_infos__).flat().filter(remote=>remote.externalType==="script"));merge(__webpack_require__.federation.initOptions,"plugins",()=>__module_federation_runtime_plugins__);early(__webpack_require__.federation,"bundlerRuntimeOptions",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions,"remotes",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"chunkMapping",()=>remotesLoadingChunkMapping);early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"remoteInfos",()=>__module_federation_remote_infos__);early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToExternalAndNameMapping",()=>{const remotesLoadingIdToExternalAndNameMappingMapping={};for(let[moduleId,data]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){remotesLoadingIdToExternalAndNameMappingMapping[moduleId]=[data.shareScope,data.name,data.externalModuleId,data.remoteName]}return remotesLoadingIdToExternalAndNameMappingMapping});early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"webpackRequire",()=>__webpack_require__);merge(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToRemoteMap",()=>{const idToRemoteMap={};for(let[id,remoteData]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){const info=__module_federation_remote_infos__[remoteData.remoteName];if(info)idToRemoteMap[id]=info}return idToRemoteMap});override(__webpack_require__,"S",__webpack_require__.federation.bundlerRuntime.S);if(__webpack_require__.federation.attachShareScopeMap){__webpack_require__.federation.attachShareScopeMap(__webpack_require__)}override(__webpack_require__.f,"remotes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.remotes({chunkId,promises,chunkMapping:remotesLoadingChunkMapping,idToExternalAndNameMapping:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToExternalAndNameMapping,idToRemoteMap:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToRemoteMap,webpackRequire:__webpack_require__}));override(__webpack_require__.f,"consumes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.consumes({chunkId,promises,chunkMapping:consumesLoadingChunkMapping,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping,installedModules:consumesLoadinginstalledModules,webpackRequire:__webpack_require__}));override(__webpack_require__,"I",(name,initScope)=>__webpack_require__.federation.bundlerRuntime.I({shareScopeName:name,initScope,initPromises:initializeSharingInitPromises,initTokens:initializeSharingInitTokens,webpackRequire:__webpack_require__}));override(__webpack_require__,"initContainer",(shareScope,initScope,remoteEntryInitOptions)=>__webpack_require__.federation.bundlerRuntime.initContainerEntry({shareScope,initScope,remoteEntryInitOptions,shareScopeKey:containerShareScope,webpackRequire:__webpack_require__}));override(__webpack_require__,"getContainer",(module1,getScope)=>{var moduleMap=__webpack_require__.initializeExposesData.moduleMap;__webpack_require__.R=getScope;getScope=Object.prototype.hasOwnProperty.call(moduleMap,module1)?moduleMap[module1]():Promise.resolve().then(()=>{throw new Error('Module "'+module1+'" does not exist in container.')});__webpack_require__.R=undefined;return getScope});__webpack_require__.federation.instance=__webpack_require__.federation.runtime.init(__webpack_require__.federation.initOptions);if((__webpack_require___consumesLoadingData2=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData2===void 0?void 0:__webpack_require___consumesLoadingData2.initialConsumes){__webpack_require__.federation.bundlerRuntime.installInitialConsumes({webpackRequire:__webpack_require__,installedModules:consumesLoadinginstalledModules,initialConsumes:__webpack_require__.consumesLoadingData.initialConsumes,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping})}}};
|
|
@@ -20,19 +20,7 @@ export type ConsumesConfig = {
|
|
|
20
20
|
shareScope?: string;
|
|
21
21
|
singleton?: boolean;
|
|
22
22
|
strictVersion?: boolean;
|
|
23
|
-
treeShakingMode?: 'server-calc' | 'runtime-infer';
|
|
24
23
|
};
|
|
25
|
-
export declare function normalizeConsumeShareOptions(consumes: Consumes, shareScope?: string): [string, {
|
|
26
|
-
import: string | undefined;
|
|
27
|
-
shareScope: string;
|
|
28
|
-
shareKey: string;
|
|
29
|
-
requiredVersion: string | false | undefined;
|
|
30
|
-
strictVersion: boolean;
|
|
31
|
-
packageName: string | undefined;
|
|
32
|
-
singleton: boolean;
|
|
33
|
-
eager: boolean;
|
|
34
|
-
treeShakingMode: "server-calc" | "runtime-infer" | undefined;
|
|
35
|
-
}][];
|
|
36
24
|
export declare class ConsumeSharedPlugin extends RspackBuiltinPlugin {
|
|
37
25
|
name: BuiltinPluginName;
|
|
38
26
|
_options: {
|
|
@@ -45,7 +33,6 @@ export declare class ConsumeSharedPlugin extends RspackBuiltinPlugin {
|
|
|
45
33
|
packageName: string | undefined;
|
|
46
34
|
singleton: boolean;
|
|
47
35
|
eager: boolean;
|
|
48
|
-
treeShakingMode: "server-calc" | "runtime-infer" | undefined;
|
|
49
36
|
}][];
|
|
50
37
|
enhanced: boolean;
|
|
51
38
|
};
|
|
@@ -23,26 +23,7 @@ type ProvidesEnhancedExtraConfig = {
|
|
|
23
23
|
singleton?: boolean;
|
|
24
24
|
strictVersion?: boolean;
|
|
25
25
|
requiredVersion?: false | string;
|
|
26
|
-
/**
|
|
27
|
-
* Tree shaking strategy for the shared module.
|
|
28
|
-
*/
|
|
29
|
-
treeShakingMode?: 'server-calc' | 'runtime-infer';
|
|
30
26
|
};
|
|
31
|
-
export declare function normalizeProvideShareOptions<Enhanced extends boolean = false>(options: Provides<Enhanced>, shareScope?: string, enhanced?: boolean): [string, {
|
|
32
|
-
shareKey: string;
|
|
33
|
-
version: string | false | undefined;
|
|
34
|
-
shareScope: string;
|
|
35
|
-
eager: boolean;
|
|
36
|
-
} | {
|
|
37
|
-
singleton: boolean | undefined;
|
|
38
|
-
requiredVersion: string | false | undefined;
|
|
39
|
-
strictVersion: boolean | undefined;
|
|
40
|
-
treeShakingMode: "server-calc" | "runtime-infer" | undefined;
|
|
41
|
-
shareKey: string;
|
|
42
|
-
version: string | false | undefined;
|
|
43
|
-
shareScope: string;
|
|
44
|
-
eager: boolean;
|
|
45
|
-
}][];
|
|
46
27
|
export declare class ProvideSharedPlugin<Enhanced extends boolean = false> extends RspackBuiltinPlugin {
|
|
47
28
|
name: BuiltinPluginName;
|
|
48
29
|
_provides: [string, Omit<RawProvideOptions, 'key'>][];
|
|
@@ -9,11 +9,6 @@ export type SharedItem = string;
|
|
|
9
9
|
export type SharedObject = {
|
|
10
10
|
[k: string]: SharedConfig | SharedItem;
|
|
11
11
|
};
|
|
12
|
-
export type TreeShakingConfig = {
|
|
13
|
-
usedExports?: string[];
|
|
14
|
-
mode?: 'server-calc' | 'runtime-infer';
|
|
15
|
-
filename?: string;
|
|
16
|
-
};
|
|
17
12
|
export type SharedConfig = {
|
|
18
13
|
eager?: boolean;
|
|
19
14
|
import?: false | SharedItem;
|
|
@@ -24,35 +19,7 @@ export type SharedConfig = {
|
|
|
24
19
|
singleton?: boolean;
|
|
25
20
|
strictVersion?: boolean;
|
|
26
21
|
version?: false | string;
|
|
27
|
-
treeShaking?: TreeShakingConfig;
|
|
28
22
|
};
|
|
29
|
-
export type NormalizedSharedOptions = [string, SharedConfig][];
|
|
30
|
-
export declare function normalizeSharedOptions(shared: Shared): NormalizedSharedOptions;
|
|
31
|
-
export declare function createProvideShareOptions(normalizedSharedOptions: NormalizedSharedOptions): {
|
|
32
|
-
[x: string]: {
|
|
33
|
-
shareKey: string;
|
|
34
|
-
shareScope: string | undefined;
|
|
35
|
-
version: string | false | undefined;
|
|
36
|
-
eager: boolean | undefined;
|
|
37
|
-
singleton: boolean | undefined;
|
|
38
|
-
requiredVersion: string | false | undefined;
|
|
39
|
-
strictVersion: boolean | undefined;
|
|
40
|
-
treeShakingMode: "server-calc" | "runtime-infer" | undefined;
|
|
41
|
-
};
|
|
42
|
-
}[];
|
|
43
|
-
export declare function createConsumeShareOptions(normalizedSharedOptions: NormalizedSharedOptions): {
|
|
44
|
-
[x: string]: {
|
|
45
|
-
import: string | false | undefined;
|
|
46
|
-
shareKey: string;
|
|
47
|
-
shareScope: string | undefined;
|
|
48
|
-
requiredVersion: string | false | undefined;
|
|
49
|
-
strictVersion: boolean | undefined;
|
|
50
|
-
singleton: boolean | undefined;
|
|
51
|
-
packageName: string | undefined;
|
|
52
|
-
eager: boolean | undefined;
|
|
53
|
-
treeShakingMode: "server-calc" | "runtime-infer" | undefined;
|
|
54
|
-
};
|
|
55
|
-
}[];
|
|
56
23
|
export declare class SharePlugin {
|
|
57
24
|
_shareScope: string | undefined;
|
|
58
25
|
_consumes: {
|
|
@@ -65,7 +32,6 @@ export declare class SharePlugin {
|
|
|
65
32
|
singleton: boolean | undefined;
|
|
66
33
|
packageName: string | undefined;
|
|
67
34
|
eager: boolean | undefined;
|
|
68
|
-
treeShakingMode: "server-calc" | "runtime-infer" | undefined;
|
|
69
35
|
};
|
|
70
36
|
}[];
|
|
71
37
|
_provides: {
|
|
@@ -77,11 +43,9 @@ export declare class SharePlugin {
|
|
|
77
43
|
singleton: boolean | undefined;
|
|
78
44
|
requiredVersion: string | false | undefined;
|
|
79
45
|
strictVersion: boolean | undefined;
|
|
80
|
-
treeShakingMode: "server-calc" | "runtime-infer" | undefined;
|
|
81
46
|
};
|
|
82
47
|
}[];
|
|
83
48
|
_enhanced: boolean;
|
|
84
|
-
_sharedOptions: NormalizedSharedOptions;
|
|
85
49
|
constructor(options: SharePluginOptions);
|
|
86
50
|
apply(compiler: Compiler): void;
|
|
87
51
|
}
|
package/dist/sharing/utils.d.ts
CHANGED
|
@@ -1,4 +1,79 @@
|
|
|
1
1
|
var urlBase = decodeURIComponent(__resourceQuery.slice(1));
|
|
2
|
+
var compiling = new Set();
|
|
3
|
+
var errorHandlers = new Set();
|
|
4
|
+
|
|
5
|
+
/** @type {import("http").ClientRequest | undefined} */
|
|
6
|
+
var pendingRequest;
|
|
7
|
+
/** @type {boolean} */
|
|
8
|
+
var hasPendingUpdate = false;
|
|
9
|
+
|
|
10
|
+
function sendRequest() {
|
|
11
|
+
if (compiling.size === 0) {
|
|
12
|
+
hasPendingUpdate = false;
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
var modules = Array.from(compiling);
|
|
17
|
+
var data = modules.join('\n');
|
|
18
|
+
|
|
19
|
+
var httpModule = urlBase.startsWith('https')
|
|
20
|
+
? require('https')
|
|
21
|
+
: require('http');
|
|
22
|
+
|
|
23
|
+
var request = httpModule.request(
|
|
24
|
+
urlBase,
|
|
25
|
+
{
|
|
26
|
+
method: 'POST',
|
|
27
|
+
agent: false,
|
|
28
|
+
headers: {
|
|
29
|
+
'Content-Type': 'text/plain',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
function (res) {
|
|
33
|
+
pendingRequest = undefined;
|
|
34
|
+
if (res.statusCode < 200 || res.statusCode >= 300) {
|
|
35
|
+
var error = new Error(
|
|
36
|
+
'Problem communicating active modules to the server: HTTP ' +
|
|
37
|
+
res.statusCode,
|
|
38
|
+
);
|
|
39
|
+
errorHandlers.forEach(function (onError) {
|
|
40
|
+
onError(error);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
// Consume response data to free up memory
|
|
44
|
+
res.resume();
|
|
45
|
+
if (hasPendingUpdate) {
|
|
46
|
+
hasPendingUpdate = false;
|
|
47
|
+
sendRequest();
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
pendingRequest = request;
|
|
53
|
+
|
|
54
|
+
request.on('error', function (err) {
|
|
55
|
+
pendingRequest = undefined;
|
|
56
|
+
var error = new Error(
|
|
57
|
+
'Problem communicating active modules to the server: ' + err.message,
|
|
58
|
+
);
|
|
59
|
+
errorHandlers.forEach(function (onError) {
|
|
60
|
+
onError(error);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
request.write(data);
|
|
65
|
+
request.end();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function sendActiveRequest() {
|
|
69
|
+
hasPendingUpdate = true;
|
|
70
|
+
|
|
71
|
+
// If no request is pending, start one
|
|
72
|
+
if (!pendingRequest) {
|
|
73
|
+
hasPendingUpdate = false;
|
|
74
|
+
sendRequest();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
2
77
|
|
|
3
78
|
/**
|
|
4
79
|
* @param {{ data: string, onError: (err: Error) => void, active: boolean, module: module }} options options
|
|
@@ -9,42 +84,23 @@ exports.activate = function (options) {
|
|
|
9
84
|
var onError = options.onError;
|
|
10
85
|
var active = options.active;
|
|
11
86
|
var module = options.module;
|
|
12
|
-
/** @type {import("http").IncomingMessage} */
|
|
13
|
-
var response;
|
|
14
|
-
var request = (
|
|
15
|
-
urlBase.startsWith('https') ? require('https') : require('http')
|
|
16
|
-
).request(
|
|
17
|
-
urlBase + encodeURIComponent(data),
|
|
18
|
-
{
|
|
19
|
-
agent: false,
|
|
20
|
-
headers: { accept: 'text/event-stream' },
|
|
21
|
-
},
|
|
22
|
-
function (res) {
|
|
23
|
-
response = res;
|
|
24
|
-
response.on('error', errorHandler);
|
|
25
|
-
if (!active && !module.hot) {
|
|
26
|
-
console.log(
|
|
27
|
-
'Hot Module Replacement is not enabled. Waiting for process restart...',
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
);
|
|
32
87
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
'Problem communicating active modules to the server' +
|
|
39
|
-
(err.message ? ': ' + err.message : '') +
|
|
40
|
-
'\nRequest: ' +
|
|
41
|
-
urlBase +
|
|
42
|
-
data;
|
|
43
|
-
onError(err);
|
|
88
|
+
errorHandlers.add(onError);
|
|
89
|
+
|
|
90
|
+
if (!compiling.has(data)) {
|
|
91
|
+
compiling.add(data);
|
|
92
|
+
sendActiveRequest();
|
|
44
93
|
}
|
|
45
|
-
|
|
46
|
-
|
|
94
|
+
|
|
95
|
+
if (!active && !module.hot) {
|
|
96
|
+
console.log(
|
|
97
|
+
'Hot Module Replacement is not enabled. Waiting for process restart...',
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
47
101
|
return function () {
|
|
48
|
-
|
|
102
|
+
errorHandlers.delete(onError);
|
|
103
|
+
compiling.delete(data);
|
|
104
|
+
sendActiveRequest();
|
|
49
105
|
};
|
|
50
106
|
};
|
|
@@ -1,47 +1,73 @@
|
|
|
1
|
-
if (typeof
|
|
1
|
+
if (typeof XMLHttpRequest === 'undefined') {
|
|
2
2
|
throw new Error(
|
|
3
|
-
"Environment doesn't support lazy compilation (requires
|
|
3
|
+
"Environment doesn't support lazy compilation (requires XMLHttpRequest)",
|
|
4
4
|
);
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
var urlBase = decodeURIComponent(__resourceQuery.slice(1));
|
|
8
|
-
/** @type {EventSource | undefined} */
|
|
9
|
-
var activeEventSource;
|
|
10
8
|
var compiling = new Set();
|
|
11
9
|
var errorHandlers = new Set();
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @this {EventSource}
|
|
24
|
-
* @param {Event & { message?: string, filename?: string, lineno?: number, colno?: number, error?: Error }} event event
|
|
25
|
-
*/
|
|
26
|
-
activeEventSource.onerror = function (event) {
|
|
27
|
-
errorHandlers.forEach(function (onError) {
|
|
28
|
-
onError(
|
|
29
|
-
new Error(
|
|
30
|
-
'Problem communicating active modules to the server' +
|
|
31
|
-
(event.message ? `: ${event.message} ` : '') +
|
|
32
|
-
(event.filename ? `: ${event.filename} ` : '') +
|
|
33
|
-
(event.lineno ? `: ${event.lineno} ` : '') +
|
|
34
|
-
(event.colno ? `: ${event.colno} ` : '') +
|
|
35
|
-
(event.error ? `: ${event.error}` : ''),
|
|
36
|
-
),
|
|
37
|
-
);
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
} else {
|
|
41
|
-
activeEventSource = undefined;
|
|
11
|
+
/** @type {XMLHttpRequest | undefined} */
|
|
12
|
+
var pendingXhr;
|
|
13
|
+
/** @type {boolean} */
|
|
14
|
+
var hasPendingUpdate = false;
|
|
15
|
+
|
|
16
|
+
var sendRequest = function sendRequest() {
|
|
17
|
+
if (compiling.size === 0) {
|
|
18
|
+
hasPendingUpdate = false;
|
|
19
|
+
return;
|
|
42
20
|
}
|
|
21
|
+
|
|
22
|
+
var modules = Array.from(compiling);
|
|
23
|
+
var data = modules.join('\n');
|
|
24
|
+
|
|
25
|
+
var xhr = new XMLHttpRequest();
|
|
26
|
+
pendingXhr = xhr;
|
|
27
|
+
xhr.open('POST', urlBase, true);
|
|
28
|
+
// text/plain Content-Type is simple request header
|
|
29
|
+
xhr.setRequestHeader('Content-Type', 'text/plain');
|
|
30
|
+
|
|
31
|
+
xhr.onreadystatechange = function () {
|
|
32
|
+
if (xhr.readyState === 4) {
|
|
33
|
+
pendingXhr = undefined;
|
|
34
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
35
|
+
var error = new Error(
|
|
36
|
+
'Problem communicating active modules to the server: HTTP ' +
|
|
37
|
+
xhr.status,
|
|
38
|
+
);
|
|
39
|
+
errorHandlers.forEach(function (onError) {
|
|
40
|
+
onError(error);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (hasPendingUpdate) {
|
|
44
|
+
hasPendingUpdate = false;
|
|
45
|
+
sendRequest();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
xhr.onerror = function () {
|
|
51
|
+
pendingXhr = undefined;
|
|
52
|
+
var error = new Error('Problem communicating active modules to the server');
|
|
53
|
+
errorHandlers.forEach(function (onError) {
|
|
54
|
+
onError(error);
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
xhr.send(data);
|
|
43
59
|
};
|
|
44
60
|
|
|
61
|
+
function sendActiveRequest() {
|
|
62
|
+
hasPendingUpdate = true;
|
|
63
|
+
|
|
64
|
+
// If no request is pending, start one
|
|
65
|
+
if (!pendingXhr) {
|
|
66
|
+
hasPendingUpdate = false;
|
|
67
|
+
sendRequest();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
45
71
|
/**
|
|
46
72
|
* @param {{ data: string, onError: (err: Error) => void, active: boolean, module: module }} options options
|
|
47
73
|
* @returns {() => void} function to destroy response
|
|
@@ -55,7 +81,7 @@ exports.activate = function (options) {
|
|
|
55
81
|
|
|
56
82
|
if (!compiling.has(data)) {
|
|
57
83
|
compiling.add(data);
|
|
58
|
-
|
|
84
|
+
sendActiveRequest();
|
|
59
85
|
}
|
|
60
86
|
|
|
61
87
|
if (!active && !module.hot) {
|
|
@@ -67,6 +93,6 @@ exports.activate = function (options) {
|
|
|
67
93
|
return function () {
|
|
68
94
|
errorHandlers.delete(onError);
|
|
69
95
|
compiling.delete(data);
|
|
70
|
-
|
|
96
|
+
sendActiveRequest();
|
|
71
97
|
};
|
|
72
98
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack-canary/core",
|
|
3
|
-
"version": "1.7.3-canary-
|
|
3
|
+
"version": "1.7.3-canary-ef467b46-20260115180501",
|
|
4
4
|
"webpackVersion": "5.75.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "The fast Rust-based web bundler with webpack-compatible API",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"directory": "packages/rspack"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@ast-grep/napi": "^0.40.
|
|
40
|
+
"@ast-grep/napi": "^0.40.5",
|
|
41
41
|
"@napi-rs/wasm-runtime": "1.0.7",
|
|
42
42
|
"@rsbuild/plugin-node-polyfill": "^1.4.2",
|
|
43
|
-
"@rslib/core": "0.19.
|
|
43
|
+
"@rslib/core": "0.19.2",
|
|
44
44
|
"@swc/types": "0.1.25",
|
|
45
|
-
"@types/node": "^20.19.
|
|
45
|
+
"@types/node": "^20.19.29",
|
|
46
46
|
"@types/watchpack": "^2.4.5",
|
|
47
47
|
"browserslist-load-config": "^1.0.1",
|
|
48
48
|
"enhanced-resolve": "5.18.4",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"webpack-sources": "3.3.3"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@module-federation/runtime-tools": "0.
|
|
59
|
+
"@module-federation/runtime-tools": "0.22.0",
|
|
60
60
|
"@rspack/lite-tapable": "1.1.0",
|
|
61
|
-
"@rspack/binding": "npm:@rspack-canary/binding@1.7.3-canary-
|
|
61
|
+
"@rspack/binding": "npm:@rspack-canary/binding@1.7.3-canary-ef467b46-20260115180501"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@swc/helpers": ">=0.5.1"
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { type BuiltinPlugin, BuiltinPluginName } from '@rspack/binding';
|
|
2
|
-
import { RspackBuiltinPlugin } from '../builtin-plugin/base';
|
|
3
|
-
import type { Compiler } from '../Compiler';
|
|
4
|
-
import { type NormalizedSharedOptions } from './SharePlugin';
|
|
5
|
-
export type CollectSharedEntryPluginOptions = {
|
|
6
|
-
sharedOptions: NormalizedSharedOptions;
|
|
7
|
-
shareScope?: string;
|
|
8
|
-
};
|
|
9
|
-
export type ShareRequestsMap = Record<string, {
|
|
10
|
-
shareScope: string;
|
|
11
|
-
requests: [string, string][];
|
|
12
|
-
}>;
|
|
13
|
-
export declare class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
|
|
14
|
-
name: BuiltinPluginName;
|
|
15
|
-
sharedOptions: NormalizedSharedOptions;
|
|
16
|
-
private _collectedEntries;
|
|
17
|
-
constructor(options: CollectSharedEntryPluginOptions);
|
|
18
|
-
getData(): ShareRequestsMap;
|
|
19
|
-
getFilename(): string;
|
|
20
|
-
apply(compiler: Compiler): void;
|
|
21
|
-
raw(): BuiltinPlugin;
|
|
22
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { Compiler } from '../Compiler';
|
|
2
|
-
import type { LibraryOptions, Plugins } from '../config';
|
|
3
|
-
import { type ModuleFederationManifestPluginOptions } from '../container/ModuleFederationManifestPlugin';
|
|
4
|
-
import type { Shared, SharedConfig } from './SharePlugin';
|
|
5
|
-
export type MakeRequired<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
|
|
6
|
-
export interface IndependentSharePluginOptions {
|
|
7
|
-
name: string;
|
|
8
|
-
shared: Shared;
|
|
9
|
-
library?: LibraryOptions;
|
|
10
|
-
outputDir?: string;
|
|
11
|
-
plugins?: Plugins;
|
|
12
|
-
treeShaking?: boolean;
|
|
13
|
-
manifest?: ModuleFederationManifestPluginOptions;
|
|
14
|
-
injectTreeShakingUsedExports?: boolean;
|
|
15
|
-
treeShakingSharedExcludePlugins?: string[];
|
|
16
|
-
}
|
|
17
|
-
export type ShareFallback = Record<string, [string, string, string][]>;
|
|
18
|
-
export declare class IndependentSharedPlugin {
|
|
19
|
-
mfName: string;
|
|
20
|
-
shared: Shared;
|
|
21
|
-
library?: LibraryOptions;
|
|
22
|
-
sharedOptions: [string, SharedConfig][];
|
|
23
|
-
outputDir: string;
|
|
24
|
-
plugins: Plugins;
|
|
25
|
-
treeShaking?: boolean;
|
|
26
|
-
manifest?: ModuleFederationManifestPluginOptions;
|
|
27
|
-
buildAssets: ShareFallback;
|
|
28
|
-
injectTreeShakingUsedExports?: boolean;
|
|
29
|
-
treeShakingSharedExcludePlugins?: string[];
|
|
30
|
-
name: string;
|
|
31
|
-
constructor(options: IndependentSharePluginOptions);
|
|
32
|
-
apply(compiler: Compiler): void;
|
|
33
|
-
private createIndependentCompilers;
|
|
34
|
-
private createIndependentCompiler;
|
|
35
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type BuiltinPlugin, BuiltinPluginName, type RawSharedContainerPluginOptions } from '@rspack/binding';
|
|
2
|
-
import { RspackBuiltinPlugin } from '../builtin-plugin/base';
|
|
3
|
-
import type { Compiler } from '../Compiler';
|
|
4
|
-
import type { LibraryOptions } from '../config';
|
|
5
|
-
export type SharedContainerPluginOptions = {
|
|
6
|
-
mfName: string;
|
|
7
|
-
shareName: string;
|
|
8
|
-
version: string;
|
|
9
|
-
request: string;
|
|
10
|
-
library?: LibraryOptions;
|
|
11
|
-
independentShareFileName?: string;
|
|
12
|
-
};
|
|
13
|
-
export declare class SharedContainerPlugin extends RspackBuiltinPlugin {
|
|
14
|
-
name: BuiltinPluginName;
|
|
15
|
-
filename: string;
|
|
16
|
-
_options: RawSharedContainerPluginOptions;
|
|
17
|
-
_shareName: string;
|
|
18
|
-
_globalName: string;
|
|
19
|
-
constructor(options: SharedContainerPluginOptions);
|
|
20
|
-
getData(): (string | undefined)[];
|
|
21
|
-
raw(compiler: Compiler): BuiltinPlugin;
|
|
22
|
-
apply(compiler: Compiler): void;
|
|
23
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { BuiltinPlugin } from '@rspack/binding';
|
|
2
|
-
import { BuiltinPluginName } from '@rspack/binding';
|
|
3
|
-
import { RspackBuiltinPlugin } from '../builtin-plugin/base';
|
|
4
|
-
import { type ModuleFederationManifestPluginOptions } from '../container/ModuleFederationManifestPlugin';
|
|
5
|
-
import type { NormalizedSharedOptions } from './SharePlugin';
|
|
6
|
-
export declare class SharedUsedExportsOptimizerPlugin extends RspackBuiltinPlugin {
|
|
7
|
-
name: BuiltinPluginName;
|
|
8
|
-
private sharedOptions;
|
|
9
|
-
private injectTreeShakingUsedExports;
|
|
10
|
-
private manifestOptions;
|
|
11
|
-
constructor(sharedOptions: NormalizedSharedOptions, injectTreeShakingUsedExports?: boolean, manifestOptions?: ModuleFederationManifestPluginOptions);
|
|
12
|
-
private buildOptions;
|
|
13
|
-
raw(): BuiltinPlugin | undefined;
|
|
14
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Compiler } from '../Compiler';
|
|
2
|
-
import type { ModuleFederationPluginOptions } from '../container/ModuleFederationPlugin';
|
|
3
|
-
export interface TreeshakingSharedPluginOptions {
|
|
4
|
-
mfConfig: ModuleFederationPluginOptions;
|
|
5
|
-
secondary?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare class TreeShakingSharedPlugin {
|
|
8
|
-
mfConfig: ModuleFederationPluginOptions;
|
|
9
|
-
outputDir: string;
|
|
10
|
-
secondary?: boolean;
|
|
11
|
-
private _independentSharePlugin?;
|
|
12
|
-
name: string;
|
|
13
|
-
constructor(options: TreeshakingSharedPluginOptions);
|
|
14
|
-
apply(compiler: Compiler): void;
|
|
15
|
-
get buildAssets(): import("./IndependentSharedPlugin").ShareFallback;
|
|
16
|
-
}
|