@module-federation/enhanced 0.0.4-0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/index.js +12 -12
- package/src/index.js.map +1 -1
- package/src/lib/Constants.js +33 -33
- package/src/lib/Constants.js.map +1 -1
- package/src/lib/container/AsyncBoundaryPlugin.js +12 -5
- package/src/lib/container/AsyncBoundaryPlugin.js.map +1 -1
- package/src/lib/sharing/utils.js +6 -6
- package/src/lib/sharing/utils.js.map +1 -1
- package/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +5 -0
- package/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.js +34 -0
- package/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.js.map +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [0.1.0](https://github.com/module-federation/nextjs-mf/compare/enhanced-0.0.4-0...enhanced-0.1.0) (2023-10-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* ensure chunk handler exists before calling it ([98ba838](https://github.com/module-federation/nextjs-mf/commit/98ba838f979bbef11f5d678c3bf27a4de534cf9d))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* AddRuntimeRequirementToPromiseExternal ([9bc5a20](https://github.com/module-federation/nextjs-mf/commit/9bc5a20b54228de7d1f2554eee10360a34e8d8a1))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
5
19
|
## [0.0.4-0](https://github.com/module-federation/nextjs-mf/compare/enhanced-0.0.3...enhanced-0.0.4-0) (2023-10-03)
|
|
6
20
|
|
|
7
21
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -9,26 +9,26 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
|
|
13
|
-
return
|
|
12
|
+
AsyncBoundaryPlugin: function() {
|
|
13
|
+
return _AsyncBoundaryPlugin.default;
|
|
14
14
|
},
|
|
15
|
-
|
|
16
|
-
return
|
|
15
|
+
ContainerEntryModule: function() {
|
|
16
|
+
return _ContainerEntryModule.default;
|
|
17
17
|
},
|
|
18
|
-
|
|
19
|
-
return
|
|
18
|
+
ContainerPlugin: function() {
|
|
19
|
+
return _ContainerPlugin.default;
|
|
20
20
|
},
|
|
21
21
|
ContainerReferencePlugin: function() {
|
|
22
22
|
return _ContainerReferencePlugin.default;
|
|
23
23
|
},
|
|
24
|
-
|
|
25
|
-
return
|
|
24
|
+
ModuleFederationPlugin: function() {
|
|
25
|
+
return _ModuleFederationPlugin.default;
|
|
26
26
|
},
|
|
27
|
-
|
|
28
|
-
return
|
|
27
|
+
ModuleInfoRuntimeModule: function() {
|
|
28
|
+
return _ModuleInfoRuntimeModule.ModuleInfoRuntimeModule;
|
|
29
29
|
},
|
|
30
|
-
|
|
31
|
-
return
|
|
30
|
+
ModuleInfoRuntimePlugin: function() {
|
|
31
|
+
return _ModuleInfoRuntimePlugin.ModuleInfoRuntimePlugin;
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
const _ModuleInfoRuntimeModule = require("./runtime/ModuleInfoRuntimeModule");
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../packages/enhanced/src/index.ts"],"sourcesContent":["export { ModuleInfoRuntimeModule } from './runtime/ModuleInfoRuntimeModule';\nexport { ModuleInfoRuntimePlugin } from './runtime/ModuleInfoRuntimePlugin';\nexport { default as ModuleFederationPlugin } from './lib/container/ModuleFederationPlugin';\nexport { default as ContainerReferencePlugin } from './lib/container/ContainerReferencePlugin';\nexport { default as ContainerPlugin } from './lib/container/ContainerPlugin';\nexport { default as ContainerEntryModule } from './lib/container/ContainerEntryModule';\nexport { default as AsyncBoundaryPlugin } from './lib/container/AsyncBoundaryPlugin';\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../../packages/enhanced/src/index.ts"],"sourcesContent":["export { ModuleInfoRuntimeModule } from './runtime/ModuleInfoRuntimeModule';\nexport { ModuleInfoRuntimePlugin } from './runtime/ModuleInfoRuntimePlugin';\nexport { default as ModuleFederationPlugin } from './lib/container/ModuleFederationPlugin';\nexport { default as ContainerReferencePlugin } from './lib/container/ContainerReferencePlugin';\nexport { default as ContainerPlugin } from './lib/container/ContainerPlugin';\nexport { default as ContainerEntryModule } from './lib/container/ContainerEntryModule';\nexport { default as AsyncBoundaryPlugin } from './lib/container/AsyncBoundaryPlugin';\n"],"names":["AsyncBoundaryPlugin","ContainerEntryModule","ContainerPlugin","ContainerReferencePlugin","ModuleFederationPlugin","ModuleInfoRuntimeModule","ModuleInfoRuntimePlugin"],"mappings":";;;;;;;;;;;IAMoBA,mBAAmB;eAAnBA,4BAAmB;;IADnBC,oBAAoB;eAApBA,6BAAoB;;IADpBC,eAAe;eAAfA,wBAAe;;IADfC,wBAAwB;eAAxBA,iCAAwB;;IADxBC,sBAAsB;eAAtBA,+BAAsB;;IAFjCC,uBAAuB;eAAvBA,gDAAuB;;IACvBC,uBAAuB;eAAvBA,gDAAuB;;;yCADQ;yCACA;+EACU;iFACE;wEACT;6EACK;4EACD"}
|
package/src/lib/Constants.js
CHANGED
|
@@ -14,68 +14,68 @@ function _export(target, all) {
|
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
_export(exports, {
|
|
17
|
-
|
|
18
|
-
return
|
|
19
|
-
},
|
|
20
|
-
JAVASCRIPT_MODULE_TYPE_DYNAMIC: function() {
|
|
21
|
-
return JAVASCRIPT_MODULE_TYPE_DYNAMIC;
|
|
17
|
+
ASSET_MODULE_TYPE: function() {
|
|
18
|
+
return ASSET_MODULE_TYPE;
|
|
22
19
|
},
|
|
23
|
-
|
|
24
|
-
return
|
|
20
|
+
ASSET_MODULE_TYPE_INLINE: function() {
|
|
21
|
+
return ASSET_MODULE_TYPE_INLINE;
|
|
25
22
|
},
|
|
26
|
-
|
|
27
|
-
return
|
|
23
|
+
ASSET_MODULE_TYPE_RAW_DATA_URL: function() {
|
|
24
|
+
return ASSET_MODULE_TYPE_RAW_DATA_URL;
|
|
28
25
|
},
|
|
29
|
-
|
|
30
|
-
return
|
|
26
|
+
ASSET_MODULE_TYPE_RESOURCE: function() {
|
|
27
|
+
return ASSET_MODULE_TYPE_RESOURCE;
|
|
31
28
|
},
|
|
32
|
-
|
|
33
|
-
return
|
|
29
|
+
ASSET_MODULE_TYPE_SOURCE: function() {
|
|
30
|
+
return ASSET_MODULE_TYPE_SOURCE;
|
|
34
31
|
},
|
|
35
32
|
CSS_MODULE_TYPE: function() {
|
|
36
33
|
return CSS_MODULE_TYPE;
|
|
37
34
|
},
|
|
35
|
+
CSS_MODULE_TYPE_AUTO: function() {
|
|
36
|
+
return CSS_MODULE_TYPE_AUTO;
|
|
37
|
+
},
|
|
38
38
|
CSS_MODULE_TYPE_GLOBAL: function() {
|
|
39
39
|
return CSS_MODULE_TYPE_GLOBAL;
|
|
40
40
|
},
|
|
41
41
|
CSS_MODULE_TYPE_MODULE: function() {
|
|
42
42
|
return CSS_MODULE_TYPE_MODULE;
|
|
43
43
|
},
|
|
44
|
-
|
|
45
|
-
return
|
|
44
|
+
JAVASCRIPT_MODULE_TYPE_AUTO: function() {
|
|
45
|
+
return JAVASCRIPT_MODULE_TYPE_AUTO;
|
|
46
46
|
},
|
|
47
|
-
|
|
48
|
-
return
|
|
47
|
+
JAVASCRIPT_MODULE_TYPE_DYNAMIC: function() {
|
|
48
|
+
return JAVASCRIPT_MODULE_TYPE_DYNAMIC;
|
|
49
49
|
},
|
|
50
|
-
|
|
51
|
-
return
|
|
50
|
+
JAVASCRIPT_MODULE_TYPE_ESM: function() {
|
|
51
|
+
return JAVASCRIPT_MODULE_TYPE_ESM;
|
|
52
52
|
},
|
|
53
|
-
|
|
54
|
-
return
|
|
53
|
+
JSON_MODULE_TYPE: function() {
|
|
54
|
+
return JSON_MODULE_TYPE;
|
|
55
55
|
},
|
|
56
|
-
|
|
57
|
-
return
|
|
56
|
+
WEBASSEMBLY_MODULE_TYPE_ASYNC: function() {
|
|
57
|
+
return WEBASSEMBLY_MODULE_TYPE_ASYNC;
|
|
58
58
|
},
|
|
59
|
-
|
|
60
|
-
return
|
|
59
|
+
WEBASSEMBLY_MODULE_TYPE_SYNC: function() {
|
|
60
|
+
return WEBASSEMBLY_MODULE_TYPE_SYNC;
|
|
61
61
|
},
|
|
62
|
-
|
|
63
|
-
return
|
|
62
|
+
WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE: function() {
|
|
63
|
+
return WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE;
|
|
64
64
|
},
|
|
65
65
|
WEBPACK_MODULE_TYPE_FALLBACK: function() {
|
|
66
66
|
return WEBPACK_MODULE_TYPE_FALLBACK;
|
|
67
67
|
},
|
|
68
|
-
|
|
69
|
-
return
|
|
68
|
+
WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY: function() {
|
|
69
|
+
return WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY;
|
|
70
70
|
},
|
|
71
71
|
WEBPACK_MODULE_TYPE_PROVIDE: function() {
|
|
72
72
|
return WEBPACK_MODULE_TYPE_PROVIDE;
|
|
73
73
|
},
|
|
74
|
-
|
|
75
|
-
return
|
|
74
|
+
WEBPACK_MODULE_TYPE_REMOTE: function() {
|
|
75
|
+
return WEBPACK_MODULE_TYPE_REMOTE;
|
|
76
76
|
},
|
|
77
|
-
|
|
78
|
-
return
|
|
77
|
+
WEBPACK_MODULE_TYPE_RUNTIME: function() {
|
|
78
|
+
return WEBPACK_MODULE_TYPE_RUNTIME;
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
const JAVASCRIPT_MODULE_TYPE_AUTO = 'javascript/auto';
|
package/src/lib/Constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/enhanced/src/lib/Constants.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Sean Larkin @TheLarkInn\n*/\n\n/**\n * @type {Readonly<\"javascript/auto\">}\n */\nexport const JAVASCRIPT_MODULE_TYPE_AUTO: Readonly<'javascript/auto'> =\n 'javascript/auto';\n\n/**\n * @type {Readonly<\"javascript/dynamic\">}\n */\nexport const JAVASCRIPT_MODULE_TYPE_DYNAMIC: Readonly<'javascript/dynamic'> =\n 'javascript/dynamic';\n\n/**\n * @type {Readonly<\"javascript/esm\">}\n * This is the module type used for _strict_ ES Module syntax. This means that all legacy formats\n * that webpack supports (CommonJS, AMD, SystemJS) are not supported.\n */\nexport const JAVASCRIPT_MODULE_TYPE_ESM: Readonly<'javascript/esm'> =\n 'javascript/esm';\n\n/**\n * @type {Readonly<\"json\">}\n * This is the module type used for JSON files. JSON files are always parsed as ES Module.\n */\nexport const JSON_MODULE_TYPE: Readonly<'json'> = 'json';\n\n/**\n * @type {Readonly<\"webassembly/async\">}\n * This is the module type used for WebAssembly modules. In webpack 5 they are always treated as async modules.\n *\n */\nexport const WEBASSEMBLY_MODULE_TYPE_ASYNC: Readonly<'webassembly/async'> =\n 'webassembly/async';\n\n/**\n * @type {Readonly<\"webassembly/sync\">}\n * This is the module type used for WebAssembly modules. In webpack 4 they are always treated as sync modules.\n * There is a legacy option to support this usage in webpack 5 and up.\n */\nexport const WEBASSEMBLY_MODULE_TYPE_SYNC: Readonly<'webassembly/sync'> =\n 'webassembly/sync';\n\n/**\n * @type {Readonly<\"css\">}\n * This is the module type used for CSS files.\n */\nexport const CSS_MODULE_TYPE: Readonly<'css'> = 'css';\n\n/**\n * @type {Readonly<\"css/global\">}\n * This is the module type used for CSS modules files where you need to use `:local` in selector list to hash classes.\n */\nexport const CSS_MODULE_TYPE_GLOBAL: Readonly<'css/global'> = 'css/global';\n\n/**\n * @type {Readonly<\"css/module\">}\n * This is the module type used for CSS modules files, by default all classes are hashed.\n */\nexport const CSS_MODULE_TYPE_MODULE: Readonly<'css/module'> = 'css/module';\n\n/**\n * @type {Readonly<\"css/auto\">}\n * This is the module type used for CSS files, the module will be parsed as CSS modules if it's filename contains `.module.` or `.modules.`.\n */\nexport const CSS_MODULE_TYPE_AUTO: Readonly<'css/auto'> = 'css/auto';\n\n/**\n * @type {Readonly<\"asset\">}\n * This is the module type used for automatically choosing between `asset/inline`, `asset/resource` based on asset size limit (8096).\n */\nexport const ASSET_MODULE_TYPE: Readonly<'asset'> = 'asset';\n\n/**\n * @type {Readonly<\"asset/inline\">}\n * This is the module type used for assets that are inlined as a data URI. This is the equivalent of `url-loader`.\n */\nexport const ASSET_MODULE_TYPE_INLINE: Readonly<'asset/inline'> =\n 'asset/inline';\n\n/**\n * @type {Readonly<\"asset/resource\">}\n * This is the module type used for assets that are copied to the output directory. This is the equivalent of `file-loader`.\n */\nexport const ASSET_MODULE_TYPE_RESOURCE: Readonly<'asset/resource'> =\n 'asset/resource';\n\n/**\n * @type {Readonly<\"asset/source\">}\n * This is the module type used for assets that are imported as source code. This is the equivalent of `raw-loader`.\n */\nexport const ASSET_MODULE_TYPE_SOURCE: Readonly<'asset/source'> =\n 'asset/source';\n\n/**\n * @type {Readonly<\"asset/raw-data-url\">}\n * TODO: Document what this asset type is for. See css-loader tests for its usage.\n */\nexport const ASSET_MODULE_TYPE_RAW_DATA_URL: Readonly<'asset/raw-data-url'> =\n 'asset/raw-data-url';\n\n/**\n * @type {Readonly<\"runtime\">}\n * This is the module type used for the webpack runtime abstractions.\n */\nexport const WEBPACK_MODULE_TYPE_RUNTIME: Readonly<'runtime'> = 'runtime';\n\n/**\n * @type {Readonly<\"fallback-module\">}\n * This is the module type used for the ModuleFederation feature's FallbackModule class.\n * TODO: Document this better.\n */\nexport const WEBPACK_MODULE_TYPE_FALLBACK: Readonly<'fallback-module'> =\n 'fallback-module';\n\n/**\n * @type {Readonly<\"remote-module\">}\n * This is the module type used for the ModuleFederation feature's RemoteModule class.\n * TODO: Document this better.\n */\nexport const WEBPACK_MODULE_TYPE_REMOTE: Readonly<'remote-module'> =\n 'remote-module';\n\n/**\n * @type {Readonly<\"provide-module\">}\n * This is the module type used for the ModuleFederation feature's ProvideModule class.\n * TODO: Document this better.\n */\nexport const WEBPACK_MODULE_TYPE_PROVIDE: Readonly<'provide-module'> =\n 'provide-module';\n\n/**\n * @type {Readonly<\"consume-shared-module\">}\n * This is the module type used for the ModuleFederation feature's ConsumeSharedModule class.\n */\nexport const WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE: Readonly<'consume-shared-module'> =\n 'consume-shared-module';\n\n/**\n * @type {Readonly<\"lazy-compilation-proxy\">}\n * Module type used for `experiments.lazyCompilation` feature. See `LazyCompilationPlugin` for more information.\n */\nexport const WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY: Readonly<'lazy-compilation-proxy'> =\n 'lazy-compilation-proxy';\n\n/** @typedef {\"javascript/auto\" | \"javascript/dynamic\" | \"javascript/esm\"} JavaScriptModuleTypes */\n/** @typedef {\"json\"} JSONModuleType */\n/** @typedef {\"webassembly/async\" | \"webassembly/sync\"} WebAssemblyModuleTypes */\n/** @typedef {\"css\" | \"css/global\" | \"css/module\"} CSSModuleTypes */\n/** @typedef {\"asset\" | \"asset/inline\" | \"asset/resource\" | \"asset/source\" | \"asset/raw-data-url\"} AssetModuleTypes */\n/** @typedef {\"runtime\" | \"fallback-module\" | \"remote-module\" | \"provide-module\" | \"consume-shared-module\" | \"lazy-compilation-proxy\"} WebpackModuleTypes */\n/** @typedef {string} UnknownModuleTypes */\n/** @typedef {JavaScriptModuleTypes | JSONModuleType | WebAssemblyModuleTypes | CSSModuleTypes | AssetModuleTypes | WebpackModuleTypes | UnknownModuleTypes} ModuleTypes */\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/enhanced/src/lib/Constants.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Sean Larkin @TheLarkInn\n*/\n\n/**\n * @type {Readonly<\"javascript/auto\">}\n */\nexport const JAVASCRIPT_MODULE_TYPE_AUTO: Readonly<'javascript/auto'> =\n 'javascript/auto';\n\n/**\n * @type {Readonly<\"javascript/dynamic\">}\n */\nexport const JAVASCRIPT_MODULE_TYPE_DYNAMIC: Readonly<'javascript/dynamic'> =\n 'javascript/dynamic';\n\n/**\n * @type {Readonly<\"javascript/esm\">}\n * This is the module type used for _strict_ ES Module syntax. This means that all legacy formats\n * that webpack supports (CommonJS, AMD, SystemJS) are not supported.\n */\nexport const JAVASCRIPT_MODULE_TYPE_ESM: Readonly<'javascript/esm'> =\n 'javascript/esm';\n\n/**\n * @type {Readonly<\"json\">}\n * This is the module type used for JSON files. JSON files are always parsed as ES Module.\n */\nexport const JSON_MODULE_TYPE: Readonly<'json'> = 'json';\n\n/**\n * @type {Readonly<\"webassembly/async\">}\n * This is the module type used for WebAssembly modules. In webpack 5 they are always treated as async modules.\n *\n */\nexport const WEBASSEMBLY_MODULE_TYPE_ASYNC: Readonly<'webassembly/async'> =\n 'webassembly/async';\n\n/**\n * @type {Readonly<\"webassembly/sync\">}\n * This is the module type used for WebAssembly modules. In webpack 4 they are always treated as sync modules.\n * There is a legacy option to support this usage in webpack 5 and up.\n */\nexport const WEBASSEMBLY_MODULE_TYPE_SYNC: Readonly<'webassembly/sync'> =\n 'webassembly/sync';\n\n/**\n * @type {Readonly<\"css\">}\n * This is the module type used for CSS files.\n */\nexport const CSS_MODULE_TYPE: Readonly<'css'> = 'css';\n\n/**\n * @type {Readonly<\"css/global\">}\n * This is the module type used for CSS modules files where you need to use `:local` in selector list to hash classes.\n */\nexport const CSS_MODULE_TYPE_GLOBAL: Readonly<'css/global'> = 'css/global';\n\n/**\n * @type {Readonly<\"css/module\">}\n * This is the module type used for CSS modules files, by default all classes are hashed.\n */\nexport const CSS_MODULE_TYPE_MODULE: Readonly<'css/module'> = 'css/module';\n\n/**\n * @type {Readonly<\"css/auto\">}\n * This is the module type used for CSS files, the module will be parsed as CSS modules if it's filename contains `.module.` or `.modules.`.\n */\nexport const CSS_MODULE_TYPE_AUTO: Readonly<'css/auto'> = 'css/auto';\n\n/**\n * @type {Readonly<\"asset\">}\n * This is the module type used for automatically choosing between `asset/inline`, `asset/resource` based on asset size limit (8096).\n */\nexport const ASSET_MODULE_TYPE: Readonly<'asset'> = 'asset';\n\n/**\n * @type {Readonly<\"asset/inline\">}\n * This is the module type used for assets that are inlined as a data URI. This is the equivalent of `url-loader`.\n */\nexport const ASSET_MODULE_TYPE_INLINE: Readonly<'asset/inline'> =\n 'asset/inline';\n\n/**\n * @type {Readonly<\"asset/resource\">}\n * This is the module type used for assets that are copied to the output directory. This is the equivalent of `file-loader`.\n */\nexport const ASSET_MODULE_TYPE_RESOURCE: Readonly<'asset/resource'> =\n 'asset/resource';\n\n/**\n * @type {Readonly<\"asset/source\">}\n * This is the module type used for assets that are imported as source code. This is the equivalent of `raw-loader`.\n */\nexport const ASSET_MODULE_TYPE_SOURCE: Readonly<'asset/source'> =\n 'asset/source';\n\n/**\n * @type {Readonly<\"asset/raw-data-url\">}\n * TODO: Document what this asset type is for. See css-loader tests for its usage.\n */\nexport const ASSET_MODULE_TYPE_RAW_DATA_URL: Readonly<'asset/raw-data-url'> =\n 'asset/raw-data-url';\n\n/**\n * @type {Readonly<\"runtime\">}\n * This is the module type used for the webpack runtime abstractions.\n */\nexport const WEBPACK_MODULE_TYPE_RUNTIME: Readonly<'runtime'> = 'runtime';\n\n/**\n * @type {Readonly<\"fallback-module\">}\n * This is the module type used for the ModuleFederation feature's FallbackModule class.\n * TODO: Document this better.\n */\nexport const WEBPACK_MODULE_TYPE_FALLBACK: Readonly<'fallback-module'> =\n 'fallback-module';\n\n/**\n * @type {Readonly<\"remote-module\">}\n * This is the module type used for the ModuleFederation feature's RemoteModule class.\n * TODO: Document this better.\n */\nexport const WEBPACK_MODULE_TYPE_REMOTE: Readonly<'remote-module'> =\n 'remote-module';\n\n/**\n * @type {Readonly<\"provide-module\">}\n * This is the module type used for the ModuleFederation feature's ProvideModule class.\n * TODO: Document this better.\n */\nexport const WEBPACK_MODULE_TYPE_PROVIDE: Readonly<'provide-module'> =\n 'provide-module';\n\n/**\n * @type {Readonly<\"consume-shared-module\">}\n * This is the module type used for the ModuleFederation feature's ConsumeSharedModule class.\n */\nexport const WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE: Readonly<'consume-shared-module'> =\n 'consume-shared-module';\n\n/**\n * @type {Readonly<\"lazy-compilation-proxy\">}\n * Module type used for `experiments.lazyCompilation` feature. See `LazyCompilationPlugin` for more information.\n */\nexport const WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY: Readonly<'lazy-compilation-proxy'> =\n 'lazy-compilation-proxy';\n\n/** @typedef {\"javascript/auto\" | \"javascript/dynamic\" | \"javascript/esm\"} JavaScriptModuleTypes */\n/** @typedef {\"json\"} JSONModuleType */\n/** @typedef {\"webassembly/async\" | \"webassembly/sync\"} WebAssemblyModuleTypes */\n/** @typedef {\"css\" | \"css/global\" | \"css/module\"} CSSModuleTypes */\n/** @typedef {\"asset\" | \"asset/inline\" | \"asset/resource\" | \"asset/source\" | \"asset/raw-data-url\"} AssetModuleTypes */\n/** @typedef {\"runtime\" | \"fallback-module\" | \"remote-module\" | \"provide-module\" | \"consume-shared-module\" | \"lazy-compilation-proxy\"} WebpackModuleTypes */\n/** @typedef {string} UnknownModuleTypes */\n/** @typedef {JavaScriptModuleTypes | JSONModuleType | WebAssemblyModuleTypes | CSSModuleTypes | AssetModuleTypes | WebpackModuleTypes | UnknownModuleTypes} ModuleTypes */\n"],"names":["ASSET_MODULE_TYPE","ASSET_MODULE_TYPE_INLINE","ASSET_MODULE_TYPE_RAW_DATA_URL","ASSET_MODULE_TYPE_RESOURCE","ASSET_MODULE_TYPE_SOURCE","CSS_MODULE_TYPE","CSS_MODULE_TYPE_AUTO","CSS_MODULE_TYPE_GLOBAL","CSS_MODULE_TYPE_MODULE","JAVASCRIPT_MODULE_TYPE_AUTO","JAVASCRIPT_MODULE_TYPE_DYNAMIC","JAVASCRIPT_MODULE_TYPE_ESM","JSON_MODULE_TYPE","WEBASSEMBLY_MODULE_TYPE_ASYNC","WEBASSEMBLY_MODULE_TYPE_SYNC","WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE","WEBPACK_MODULE_TYPE_FALLBACK","WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY","WEBPACK_MODULE_TYPE_PROVIDE","WEBPACK_MODULE_TYPE_REMOTE","WEBPACK_MODULE_TYPE_RUNTIME"],"mappings":"AAAA;;;AAGA,GAEA;;CAEC;;;;;;;;;;;IAoEYA,iBAAiB;eAAjBA;;IAMAC,wBAAwB;eAAxBA;;IAqBAC,8BAA8B;eAA9BA;;IAdAC,0BAA0B;eAA1BA;;IAOAC,wBAAwB;eAAxBA;;IA5CAC,eAAe;eAAfA;;IAkBAC,oBAAoB;eAApBA;;IAZAC,sBAAsB;eAAtBA;;IAMAC,sBAAsB;eAAtBA;;IAvDAC,2BAA2B;eAA3BA;;IAMAC,8BAA8B;eAA9BA;;IAQAC,0BAA0B;eAA1BA;;IAOAC,gBAAgB;eAAhBA;;IAOAC,6BAA6B;eAA7BA;;IAQAC,4BAA4B;eAA5BA;;IA+FAC,yCAAyC;eAAzCA;;IAvBAC,4BAA4B;eAA5BA;;IA8BAC,0CAA0C;eAA1CA;;IAdAC,2BAA2B;eAA3BA;;IARAC,0BAA0B;eAA1BA;;IAfAC,2BAA2B;eAA3BA;;;AArGN,MAAMX,8BACX;AAKK,MAAMC,iCACX;AAOK,MAAMC,6BACX;AAMK,MAAMC,mBAAqC;AAO3C,MAAMC,gCACX;AAOK,MAAMC,+BACX;AAMK,MAAMT,kBAAmC;AAMzC,MAAME,yBAAiD;AAMvD,MAAMC,yBAAiD;AAMvD,MAAMF,uBAA6C;AAMnD,MAAMN,oBAAuC;AAM7C,MAAMC,2BACX;AAMK,MAAME,6BACX;AAMK,MAAMC,2BACX;AAMK,MAAMF,iCACX;AAMK,MAAMkB,8BAAmD;AAOzD,MAAMJ,+BACX;AAOK,MAAMG,6BACX;AAOK,MAAMD,8BACX;AAMK,MAAMH,4CACX;AAMK,MAAME,6CACX,0BAEF,iGAAiG,IACjG,qCAAqC,IACrC,+EAA+E,IAC/E,kEAAkE,IAClE,oHAAoH,IACpH,0JAA0J,IAC1J,yCAAyC,IACzC,yKAAyK"}
|
|
@@ -40,7 +40,10 @@ const _tapable = require("tapable");
|
|
|
40
40
|
if (isInvalidContext) return source.source().toString();
|
|
41
41
|
const { chunkGraph } = compilation;
|
|
42
42
|
const replaceSource = source.source().toString();
|
|
43
|
-
const
|
|
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);
|
|
44
47
|
const dependentChunkIds = this.getDependentChunkIds(startupRenderContext, chunkGraph);
|
|
45
48
|
return _webpack.Template.asString([
|
|
46
49
|
this.replaceWebpackExec(webpack_exec),
|
|
@@ -48,10 +51,14 @@ const _tapable = require("tapable");
|
|
|
48
51
|
`var __webpack_exec__ = async function() {`,
|
|
49
52
|
_webpack.Template.indent([
|
|
50
53
|
`var chunkIds = ${JSON.stringify(Array.from(dependentChunkIds))};`,
|
|
51
|
-
`
|
|
52
|
-
`
|
|
53
|
-
`
|
|
54
|
-
`
|
|
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
|
+
`}`,
|
|
55
62
|
`return __original_webpack_exec__.apply(this, arguments);`
|
|
56
63
|
]),
|
|
57
64
|
`};`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/AsyncBoundaryPlugin.ts"],"sourcesContent":["import { Template, RuntimeGlobals } from 'webpack';\nimport { Source } from 'webpack-sources';\nimport type Compilation from 'webpack/lib/Compilation';\nimport type Compiler from 'webpack/lib/Compiler';\nimport type Module from 'webpack/lib/Module';\nimport type Chunk from 'webpack/lib/Chunk';\nimport { getAllChunks } from 'webpack/lib/javascript/ChunkHelpers';\nimport { ChunkGraph } from 'webpack/lib/ChunkGroup';\nimport { StartupRenderContext } from 'webpack/lib/javascript/JavascriptModulesPlugin';\nimport { RenderContext } from 'webpack/lib/javascript/JavascriptModulesPlugin';\nimport { SyncBailHook } from 'tapable';\n/**\n * AsyncBoundaryPlugin is a Webpack plugin that handles asynchronous boundaries in a federated module.\n * @class\n */\nclass AsyncBoundaryPlugin {\n /**\n * Define hooks\n * @property {SyncBailHook} checkInvalidContext - A hook that checks if the render context is invalid.\n */\n public hooks = {\n checkInvalidContext: new SyncBailHook<[Module, Compilation], boolean>([\n 'renderContext',\n 'compilation',\n ]),\n };\n\n /**\n * Apply the plugin to the Webpack compiler instance.\n * @param {Compiler} compiler - Webpack compiler instance.\n */\n public apply(compiler: Compiler): void {\n const { javascript } = compiler.webpack;\n compiler.hooks.thisCompilation.tap(\n 'AsyncBoundaryPlugin',\n (compilation: Compilation) => {\n const hooks =\n javascript.JavascriptModulesPlugin.getCompilationHooks(compilation);\n hooks.renderStartup.tap(\n 'AsyncBoundaryPlugin',\n (\n source: Source,\n renderContext: Module,\n startupRenderContext: StartupRenderContext,\n ) => {\n return this.renderStartupLogic(\n source,\n renderContext,\n startupRenderContext,\n compilation,\n );\n },\n );\n },\n );\n }\n\n /**\n * Render the startup logic for the plugin.\n * @param {Source} source - The source code.\n * @param {RenderContext} renderContext - The render context.\n * @param {any} startupRenderContext - The startup render context.\n * @param {Compilation} compilation - The Webpack compilation instance.\n * @returns {string} - The modified source code.\n */\n private renderStartupLogic(\n source: Source,\n renderContext: Module,\n startupRenderContext: StartupRenderContext,\n compilation: Compilation,\n ): string {\n const isInvalidContext =\n this.hooks.checkInvalidContext.call(renderContext, compilation) ?? false;\n if (isInvalidContext) return source.source().toString();\n\n const { chunkGraph } = compilation;\n const replaceSource = source.source().toString();\n const
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/enhanced/src/lib/container/AsyncBoundaryPlugin.ts"],"sourcesContent":["import { Template, RuntimeGlobals } from 'webpack';\nimport { Source } from 'webpack-sources';\nimport type Compilation from 'webpack/lib/Compilation';\nimport type Compiler from 'webpack/lib/Compiler';\nimport type Module from 'webpack/lib/Module';\nimport type Chunk from 'webpack/lib/Chunk';\nimport { getAllChunks } from 'webpack/lib/javascript/ChunkHelpers';\nimport { ChunkGraph } from 'webpack/lib/ChunkGroup';\nimport { StartupRenderContext } from 'webpack/lib/javascript/JavascriptModulesPlugin';\nimport { RenderContext } from 'webpack/lib/javascript/JavascriptModulesPlugin';\nimport { SyncBailHook } from 'tapable';\n/**\n * AsyncBoundaryPlugin is a Webpack plugin that handles asynchronous boundaries in a federated module.\n * @class\n */\nclass AsyncBoundaryPlugin {\n /**\n * Define hooks\n * @property {SyncBailHook} checkInvalidContext - A hook that checks if the render context is invalid.\n */\n public hooks = {\n checkInvalidContext: new SyncBailHook<[Module, Compilation], boolean>([\n 'renderContext',\n 'compilation',\n ]),\n };\n\n /**\n * Apply the plugin to the Webpack compiler instance.\n * @param {Compiler} compiler - Webpack compiler instance.\n */\n public apply(compiler: Compiler): void {\n const { javascript } = compiler.webpack;\n compiler.hooks.thisCompilation.tap(\n 'AsyncBoundaryPlugin',\n (compilation: Compilation) => {\n const hooks =\n javascript.JavascriptModulesPlugin.getCompilationHooks(compilation);\n \n hooks.renderStartup.tap(\n 'AsyncBoundaryPlugin',\n (\n source: Source,\n renderContext: Module,\n startupRenderContext: StartupRenderContext,\n ) => {\n return this.renderStartupLogic(\n source,\n renderContext,\n startupRenderContext,\n compilation,\n );\n },\n );\n },\n );\n }\n\n /**\n * Render the startup logic for the plugin.\n * @param {Source} source - The source code.\n * @param {RenderContext} renderContext - The render context.\n * @param {any} startupRenderContext - The startup render context.\n * @param {Compilation} compilation - The Webpack compilation instance.\n * @returns {string} - The modified source code.\n */\n private renderStartupLogic(\n source: Source,\n renderContext: Module,\n startupRenderContext: StartupRenderContext,\n compilation: Compilation,\n ): string {\n const isInvalidContext =\n this.hooks.checkInvalidContext.call(renderContext, compilation) ?? false;\n if (isInvalidContext) return source.source().toString();\n\n const { chunkGraph } = compilation;\n const replaceSource = source.source().toString();\n const replaceSourceLines = replaceSource.split('\\n');\n const webpack_exec_index = replaceSourceLines.findIndex(line => line.includes('webpack_exec'));\n const webpack_exec = replaceSourceLines[webpack_exec_index];\n const webpack_exports = replaceSourceLines.slice(webpack_exec_index + 1);\n const dependentChunkIds = this.getDependentChunkIds(\n startupRenderContext,\n chunkGraph,\n );\n\n return Template.asString([\n this.replaceWebpackExec(webpack_exec),\n `globalThis.ongoingRemotes = globalThis.ongoingRemotes || [];`,\n `var __webpack_exec__ = async function() {`,\n Template.indent([\n `var chunkIds = ${JSON.stringify(Array.from(dependentChunkIds))};`,\n `if (${RuntimeGlobals.ensureChunkHandlers}.consumes) {`,\n ` chunkIds.forEach(function(id) { ${RuntimeGlobals.ensureChunkHandlers}.consumes(id, globalThis.ongoingRemotes); });`,\n ` await Promise.all(globalThis.ongoingRemotes);`,\n `}`,\n `if (${RuntimeGlobals.ensureChunkHandlers}.remotes) {`,\n ` chunkIds.forEach(function(id) { ${RuntimeGlobals.ensureChunkHandlers}.remotes(id, globalThis.ongoingRemotes); });`,\n ` await Promise.all(globalThis.ongoingRemotes);`,\n `}`,\n `return __original_webpack_exec__.apply(this, arguments);`,\n ]),\n `};`,\n ...webpack_exports,\n ]);\n }\n\n /**\n * Replace the webpack exec string.\n * @param {string} webpack_exec - The webpack exec string.\n * @returns {string} - The replaced webpack exec string.\n */\n private replaceWebpackExec(webpack_exec: string): string {\n return webpack_exec.replace(\n '__webpack_exec__',\n '__original_webpack_exec__',\n );\n }\n\n /**\n * Get the IDs of the dependent chunks.\n * @param {any} startupRenderContext - The startup render context.\n * @param {any} chunkGraph - The chunk graph.\n * @returns {Set} - The set of dependent chunk IDs.\n */\n private getDependentChunkIds(\n startupRenderContext: RenderContext,\n chunkGraph: ChunkGraph,\n ): Set<string | number | null> {\n const entries = Array.from(\n chunkGraph.getChunkEntryModulesWithChunkGroupIterable(\n startupRenderContext.chunk,\n ),\n );\n const chunkIds = new Set<string | number | null>();\n for (const [module, entrypoint] of entries) {\n if (entrypoint) {\n const runtimeChunk = entrypoint.getRuntimeChunk();\n if (runtimeChunk) {\n const chunks = getAllChunks(entrypoint, runtimeChunk);\n for (const c of chunks) {\n chunkIds.add(c.id);\n }\n }\n }\n }\n return chunkIds;\n }\n}\n\nexport default AsyncBoundaryPlugin;\n"],"names":["AsyncBoundaryPlugin","apply","compiler","javascript","webpack","hooks","thisCompilation","tap","compilation","JavascriptModulesPlugin","getCompilationHooks","renderStartup","source","renderContext","startupRenderContext","renderStartupLogic","isInvalidContext","checkInvalidContext","call","toString","chunkGraph","replaceSource","replaceSourceLines","split","webpack_exec_index","findIndex","line","includes","webpack_exec","webpack_exports","slice","dependentChunkIds","getDependentChunkIds","Template","asString","replaceWebpackExec","indent","JSON","stringify","Array","from","RuntimeGlobals","ensureChunkHandlers","replace","entries","getChunkEntryModulesWithChunkGroupIterable","chunk","chunkIds","Set","module","entrypoint","runtimeChun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BAAY,CAAiC;gBACpE;gBACA;aACD;QACH;;AA4HF;MAEA,WAAe1D"}
|
package/src/lib/sharing/utils.js
CHANGED
|
@@ -12,17 +12,17 @@ function _export(target, all) {
|
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
_export(exports, {
|
|
15
|
-
isRequiredVersion: function() {
|
|
16
|
-
return isRequiredVersion;
|
|
17
|
-
},
|
|
18
|
-
normalizeVersion: function() {
|
|
19
|
-
return normalizeVersion;
|
|
20
|
-
},
|
|
21
15
|
getDescriptionFile: function() {
|
|
22
16
|
return getDescriptionFile;
|
|
23
17
|
},
|
|
24
18
|
getRequiredVersionFromDescriptionFile: function() {
|
|
25
19
|
return getRequiredVersionFromDescriptionFile;
|
|
20
|
+
},
|
|
21
|
+
isRequiredVersion: function() {
|
|
22
|
+
return isRequiredVersion;
|
|
23
|
+
},
|
|
24
|
+
normalizeVersion: function() {
|
|
25
|
+
return normalizeVersion;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
const _fs = require("webpack/lib/util/fs");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/enhanced/src/lib/sharing/utils.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra\n*/\n\nimport { join, dirname, readJson, InputFileSystem } from 'webpack/lib/util/fs';\n\n// Extreme shorthand only for github. eg: foo/bar\nconst RE_URL_GITHUB_EXTREME_SHORT: RegExp =\n /^[^/@:.\\s][^/@:\\s]*\\/[^@:\\s]*[^/@:\\s]#\\S+/;\n\n// Short url with specific protocol. eg: github:foo/bar\nconst RE_GIT_URL_SHORT: RegExp =\n /^(github|gitlab|bitbucket|gist):\\/?[^/.]+\\/?/i;\n\n// Currently supported protocols\nconst RE_PROTOCOL: RegExp =\n /^((git\\+)?(ssh|https?|file)|git|github|gitlab|bitbucket|gist):$/i;\n\n// Has custom protocol\nconst RE_CUSTOM_PROTOCOL: RegExp = /^((git\\+)?(ssh|https?|file)|git):\\/\\//i;\n\n// Valid hash format for npm / yarn ...\nconst RE_URL_HASH_VERSION: RegExp = /#(?:semver:)?(.+)/;\n\n// Simple hostname validate\nconst RE_HOSTNAME: RegExp = /^(?:[^/.]+(\\.[^/]+)+|localhost)$/;\n\n// For hostname with colon. eg: ssh://user@github.com:foo/bar\nconst RE_HOSTNAME_WITH_COLON: RegExp =\n /([^/@#:.]+(?:\\.[^/@#:.]+)+|localhost):([^#/0-9]+)/;\n\n// Reg for url without protocol\nconst RE_NO_PROTOCOL: RegExp = /^([^/@#:.]+(?:\\.[^/@#:.]+)+)/;\n\n// RegExp for version string\nconst VERSION_PATTERN_REGEXP: RegExp = /^([\\d^=v<>~]|[*xX]$)/;\n\n// Specific protocol for short url without normal hostname\nconst PROTOCOLS_FOR_SHORT: string[] = [\n 'github:',\n 'gitlab:',\n 'bitbucket:',\n 'gist:',\n 'file:',\n];\n\n// Default protocol for git url\nconst DEF_GIT_PROTOCOL: string = 'git+ssh://';\n\n// thanks to https://github.com/npm/hosted-git-info/blob/latest/git-host-info.js\nconst extractCommithashByDomain: {\n [key: string]: (pathname: string, hash: string) => string | undefined;\n} = {\n /**\n * @param {string} pathname pathname\n * @param {string} hash hash\n * @returns {string | undefined} hash\n */\n 'github.com': (pathname: string, hash: string) => {\n const [, user, project, type, commithash] = pathname.split('/', 5);\n if (type && type !== 'tree') {\n return;\n }\n\n let commithashResult = commithash;\n if (!type) {\n commithashResult = hash;\n } else {\n commithashResult = '#' + commithash;\n }\n\n let projectResult = project;\n if (project && project.endsWith('.git')) {\n projectResult = project.slice(0, -4);\n }\n\n if (!user || !projectResult) {\n return;\n }\n\n return commithashResult;\n },\n /**\n * @param {string} pathname pathname\n * @param {string} hash hash\n * @returns {string | undefined} hash\n */\n 'gitlab.com': (pathname: string, hash: string) => {\n const path = pathname.slice(1);\n if (path.includes('/-/') || path.includes('/archive.tar.gz')) {\n return;\n }\n\n const segments = path.split('/');\n let project = segments.pop();\n if (project && project.endsWith('.git')) {\n project = project.slice(0, -4);\n }\n\n const user = segments.join('/');\n if (!user || !project) {\n return;\n }\n\n return hash;\n },\n /**\n * @param {string} pathname pathname\n * @param {string} hash hash\n * @returns {string | undefined} hash\n */\n 'bitbucket.org': (pathname: string, hash: string) => {\n const [, user, project, aux] = pathname.split('/', 4);\n if (['get'].includes(aux)) {\n return;\n }\n\n let projectResult = project;\n if (project && project.endsWith('.git')) {\n projectResult = project.slice(0, -4);\n }\n\n if (!user || !projectResult) {\n return;\n }\n\n return hash;\n },\n /**\n * @param {string} pathname pathname\n * @param {string} hash hash\n * @returns {string | undefined} hash\n */\n 'gist.github.com': (pathname: string, hash: string) => {\n const [, user, project, aux] = pathname.split('/', 4);\n if (aux === 'raw') {\n return;\n }\n\n let projectResult = project;\n if (!projectResult) {\n if (!user) {\n return;\n }\n\n projectResult = user;\n }\n\n if (projectResult.endsWith('.git')) {\n projectResult = projectResult.slice(0, -4);\n }\n\n return hash;\n },\n};\n\n/**\n * extract commit hash from parsed url\n *\n * @inner\n * @param {URL} urlParsed parsed url\n * @returns {string} commithash\n */\nfunction getCommithash(urlParsed: URL): string {\n const { hostname, pathname, hash } = urlParsed;\n const hostnameResult = hostname.replace(/^www\\./, '');\n\n let hashResult = hash;\n try {\n hashResult = decodeURIComponent(hash);\n // eslint-disable-next-line no-empty\n } catch (e) {}\n\n if (\n /** @type {keyof extractCommithashByDomain} */ extractCommithashByDomain[\n hostnameResult\n ]\n ) {\n return (\n extractCommithashByDomain\n /** @type {keyof extractCommithashByDomain} */ [hostnameResult](\n pathname,\n hashResult,\n ) || ''\n );\n }\n\n return hashResult;\n}\n\n/**\n * make url right for URL parse\n *\n * @inner\n * @param {string} gitUrl git url\n * @returns {string} fixed url\n */\nfunction correctUrl(gitUrl: string): string {\n // like:\n // proto://hostname.com:user/repo -> proto://hostname.com/user/repo\n return gitUrl.replace(RE_HOSTNAME_WITH_COLON, '$1/$2');\n}\n\n/**\n * make url protocol right for URL parse\n *\n * @inner\n * @param {string} gitUrl git url\n * @returns {string} fixed url\n */\nfunction correctProtocol(gitUrl: string): string {\n // eg: github:foo/bar#v1.0. Should not add double slash, in case of error parsed `pathname`\n if (RE_GIT_URL_SHORT.test(gitUrl)) {\n return gitUrl;\n }\n\n // eg: user@github.com:foo/bar\n if (!RE_CUSTOM_PROTOCOL.test(gitUrl)) {\n return `${DEF_GIT_PROTOCOL}${gitUrl}`;\n }\n\n return gitUrl;\n}\n\n/**\n * extract git dep version from hash\n *\n * @inner\n * @param {string} hash hash\n * @returns {string} git dep version\n */\nfunction getVersionFromHash(hash: string): string {\n const matched = hash.match(RE_URL_HASH_VERSION);\n\n return (matched && matched[1]) || '';\n}\n\n/**\n * if string can be decoded\n *\n * @inner\n * @param {string} str str to be checked\n * @returns {boolean} if can be decoded\n */\nfunction canBeDecoded(str: string): boolean {\n try {\n decodeURIComponent(str);\n } catch (e) {\n return false;\n }\n\n return true;\n}\n\n/**\n * get right dep version from git url\n *\n * @inner\n * @param {string} gitUrl git url\n * @returns {string} dep version\n */\nfunction getGitUrlVersion(gitUrl: string): string {\n const oriGitUrl = gitUrl;\n // github extreme shorthand\n if (RE_URL_GITHUB_EXTREME_SHORT.test(gitUrl)) {\n gitUrl = 'github:' + gitUrl;\n } else {\n gitUrl = correctProtocol(gitUrl);\n }\n\n gitUrl = correctUrl(gitUrl);\n\n let parsed;\n try {\n parsed = new URL(gitUrl);\n // eslint-disable-next-line no-empty\n } catch (e) {}\n\n if (!parsed) {\n return '';\n }\n\n const { protocol, hostname, pathname, username, password } = parsed;\n if (!RE_PROTOCOL.test(protocol)) {\n return '';\n }\n\n // pathname shouldn't be empty or URL malformed\n if (!pathname || !canBeDecoded(pathname)) {\n return '';\n }\n\n // without protocol, there should have auth info\n if (RE_NO_PROTOCOL.test(oriGitUrl) && !username && !password) {\n return '';\n }\n\n if (!PROTOCOLS_FOR_SHORT.includes(protocol.toLowerCase())) {\n if (!RE_HOSTNAME.test(hostname)) {\n return '';\n }\n\n const commithash = getCommithash(parsed);\n return getVersionFromHash(commithash) || commithash;\n }\n\n // for protocol short\n return getVersionFromHash(gitUrl);\n}\n\n/**\n * @param {string} str maybe required version\n * @returns {boolean} true, if it looks like a version\n */\nfunction isRequiredVersion(str: string): boolean {\n return VERSION_PATTERN_REGEXP.test(str);\n}\n\nexport { isRequiredVersion };\n\n/**\n * @see https://docs.npmjs.com/cli/v7/configuring-npm/package-json#urls-as-dependencies\n * @param {string} versionDesc version to be normalized\n * @returns {string} normalized version\n */\nfunction normalizeVersion(versionDesc: string): string {\n versionDesc = (versionDesc && versionDesc.trim()) || '';\n\n if (isRequiredVersion(versionDesc)) {\n return versionDesc;\n }\n\n // add handle for URL Dependencies\n return getGitUrlVersion(versionDesc.toLowerCase());\n}\n\nexport { normalizeVersion };\n\n/**\n *\n * @param {InputFileSystem} fs file system\n * @param {string} directory directory to start looking into\n * @param {string[]} descriptionFiles possible description filenames\n * @param {function((Error | null)=, {data: object, path: string}=): void} callback callback\n */\nconst getDescriptionFile = (\n fs: InputFileSystem,\n directory: string,\n descriptionFiles: string[],\n callback: (err: Error | null, data?: { data: object; path: string }) => void,\n) => {\n let i = 0;\n const tryLoadCurrent = () => {\n if (i >= descriptionFiles.length) {\n const parentDirectory = dirname(fs, directory);\n if (!parentDirectory || parentDirectory === directory) {\n //@ts-ignore\n return callback();\n }\n return getDescriptionFile(\n fs,\n parentDirectory,\n descriptionFiles,\n callback,\n );\n }\n const filePath = join(fs, directory, descriptionFiles[i]);\n readJson(fs, filePath, (err, data: object) => {\n if (err) {\n if ('code' in err && err.code === 'ENOENT') {\n i++;\n return tryLoadCurrent();\n }\n return callback(err);\n }\n if (!data || typeof data !== 'object' || Array.isArray(data)) {\n return callback(\n new Error(`Description file ${filePath} is not an object`),\n );\n }\n callback(null, { data, path: filePath });\n });\n };\n tryLoadCurrent();\n};\nexport { getDescriptionFile };\n/**\n * Get required version from description file\n * @param {Record<string, any>} data - The data object\n * @param {string} packageName - The package name\n * @returns {string | undefined} The normalized version\n */\nexport function getRequiredVersionFromDescriptionFile(\n data: Record<string, any>,\n packageName: string,\n): string | undefined | void {\n if (\n data['optionalDependencies'] &&\n typeof data['optionalDependencies'] === 'object' &&\n packageName in data['optionalDependencies']\n ) {\n return normalizeVersion(data['optionalDependencies'][packageName]);\n }\n if (\n data['dependencies'] &&\n typeof data['dependencies'] === 'object' &&\n packageName in data['dependencies']\n ) {\n return normalizeVersion(data['dependencies'][packageName]);\n }\n if (\n data['peerDependencies'] &&\n typeof data['peerDependencies'] === 'object' &&\n packageName in data['peerDependencies']\n ) {\n return normalizeVersion(data['peerDependencies'][packageName]);\n }\n if (\n data['devDependencies'] &&\n typeof data['devDependencies'] === 'object' &&\n packageName in data['devDependencies']\n ) {\n return normalizeVersion(data['devDependencies'][packageName]);\n }\n}\n"],"names":["isRequiredVersion","normalizeVersion","getDescriptionFile","getRequiredVersionFromDescriptionFile","RE_URL_GITHUB_EXTREME_SHORT","RE_GIT_URL_SHORT","RE_PROTOCOL","RE_CUSTOM_PROTOCOL","RE_URL_HASH_VERSION","RE_HOSTNAME","RE_HOSTNAME_WITH_COLON","RE_NO_PROTOCOL","VERSION_PATTERN_REGEXP","PROTOCOLS_FOR_SHORT","DEF_GIT_PROTOCOL","extractCommithashByDomain","pathname","hash","user","project","type","commithash","split","commithashResult","projectResult","endsWith","slice","path","includes","segments","pop","join","aux","getCommithash","urlParsed","hostname","hostnameResult","replace","hashResult","decodeURIComponent","e","correctUrl","gitUrl","correctProtocol","test","getVersionFromHash","matched","match","canBeDecoded","str","getGitUrlVersion","oriGitUrl","parsed","URL","protocol","username","password","toLowerCase","versionDesc","trim","fs","directory","descriptionFiles","callback","i","tryLoadCurrent","length","parentDirectory","dirname","filePath","readJson","err","data","code","Array","isArray","Error","packageName"],"mappings":"AAAA;;;AAGA;;;;;;;;;;;IA4TSA,iBAAiB;eAAjBA;;IAkBAC,gBAAgB;eAAhBA;;IAiDAC,kBAAkB;eAAlBA;;IAOOC,qC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BAC1CT;oBACA,OAAOC;gBACT;gBACA,OAAOF,SAASQ;YAClB;YACA,IAAI,CAACC,QAAQ,OAAOA,SAAS,YAAYE,MAAMC,OAAO,CAACH,OAAO;gBAC5D,OAAOT,SACL,IAAIa,MAAM,CAAC,iBAAiB,EAAEP,SAAS,iBAAiB,CAAC;YAE7D;YACAN,SAAS,MAAM;gBAAES;gBAAM7C,MAAM0C;YAAS;QACxC;IACF;IACAJ;AACF;AAQO,SAAS9D,sCACdqE,IAAyB,EACzBK,WAAmB;IAEnB,IACEL,IAAI,CAAC,uBAAuB,IAC5B,OAAOA,IAAI,CAAC,uBAAuB,KAAK,YACxCK,eAAeL,IAAI,CAAC,uBAAuB,EAC3C;QACA,OAAOvE,iBAAiBuE,IAAI,CAAC,uBAAuB,CAACK,YAAY;IACnE;IACA,IACEL,IAAI,CAAC,eAAe,IACpB,OAAOA,IAAI,CAAC,eAAe,KAAK,YAChCK,eAAeL,IAAI,CAAC,eAAe,EACnC;QACA,OAAOvE,iBAAiBuE,IAAI,CAAC,eAAe,CAACK,YAAY;IAC3D;IACA,IACEL,IAAI,CAAC,mBAAmB,IACxB,OAAOA,IAAI,CAAC,mBAAmB,KAAK,YACpCK,eAAeL,IAAI,CAAC,mBAAmB,EACvC;QACA,OAAOvE,iBAAiBuE,IAAI,CAAC,mBAAmB,CAACK,YAAY;IAC/D;IACA,IACEL,IAAI,CAAC,kBAAkB,IACvB,OAAOA,IAAI,CAAC,kBAAkB,KAAK,YACnCK,eAAeL,IAAI,CAAC,kBAAkB,EACtC;QACA,OAAOvE,iBAAiBuE,IAAI,CAAC,kBAAkB,CAACK,YAAY;IAC9D;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/enhanced/src/lib/sharing/utils.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra\n*/\n\nimport { join, dirname, readJson, InputFileSystem } from 'webpack/lib/util/fs';\n\n// Extreme shorthand only for github. eg: foo/bar\nconst RE_URL_GITHUB_EXTREME_SHORT: RegExp =\n /^[^/@:.\\s][^/@:\\s]*\\/[^@:\\s]*[^/@:\\s]#\\S+/;\n\n// Short url with specific protocol. eg: github:foo/bar\nconst RE_GIT_URL_SHORT: RegExp =\n /^(github|gitlab|bitbucket|gist):\\/?[^/.]+\\/?/i;\n\n// Currently supported protocols\nconst RE_PROTOCOL: RegExp =\n /^((git\\+)?(ssh|https?|file)|git|github|gitlab|bitbucket|gist):$/i;\n\n// Has custom protocol\nconst RE_CUSTOM_PROTOCOL: RegExp = /^((git\\+)?(ssh|https?|file)|git):\\/\\//i;\n\n// Valid hash format for npm / yarn ...\nconst RE_URL_HASH_VERSION: RegExp = /#(?:semver:)?(.+)/;\n\n// Simple hostname validate\nconst RE_HOSTNAME: RegExp = /^(?:[^/.]+(\\.[^/]+)+|localhost)$/;\n\n// For hostname with colon. eg: ssh://user@github.com:foo/bar\nconst RE_HOSTNAME_WITH_COLON: RegExp =\n /([^/@#:.]+(?:\\.[^/@#:.]+)+|localhost):([^#/0-9]+)/;\n\n// Reg for url without protocol\nconst RE_NO_PROTOCOL: RegExp = /^([^/@#:.]+(?:\\.[^/@#:.]+)+)/;\n\n// RegExp for version string\nconst VERSION_PATTERN_REGEXP: RegExp = /^([\\d^=v<>~]|[*xX]$)/;\n\n// Specific protocol for short url without normal hostname\nconst PROTOCOLS_FOR_SHORT: string[] = [\n 'github:',\n 'gitlab:',\n 'bitbucket:',\n 'gist:',\n 'file:',\n];\n\n// Default protocol for git url\nconst DEF_GIT_PROTOCOL: string = 'git+ssh://';\n\n// thanks to https://github.com/npm/hosted-git-info/blob/latest/git-host-info.js\nconst extractCommithashByDomain: {\n [key: string]: (pathname: string, hash: string) => string | undefined;\n} = {\n /**\n * @param {string} pathname pathname\n * @param {string} hash hash\n * @returns {string | undefined} hash\n */\n 'github.com': (pathname: string, hash: string) => {\n const [, user, project, type, commithash] = pathname.split('/', 5);\n if (type && type !== 'tree') {\n return;\n }\n\n let commithashResult = commithash;\n if (!type) {\n commithashResult = hash;\n } else {\n commithashResult = '#' + commithash;\n }\n\n let projectResult = project;\n if (project && project.endsWith('.git')) {\n projectResult = project.slice(0, -4);\n }\n\n if (!user || !projectResult) {\n return;\n }\n\n return commithashResult;\n },\n /**\n * @param {string} pathname pathname\n * @param {string} hash hash\n * @returns {string | undefined} hash\n */\n 'gitlab.com': (pathname: string, hash: string) => {\n const path = pathname.slice(1);\n if (path.includes('/-/') || path.includes('/archive.tar.gz')) {\n return;\n }\n\n const segments = path.split('/');\n let project = segments.pop();\n if (project && project.endsWith('.git')) {\n project = project.slice(0, -4);\n }\n\n const user = segments.join('/');\n if (!user || !project) {\n return;\n }\n\n return hash;\n },\n /**\n * @param {string} pathname pathname\n * @param {string} hash hash\n * @returns {string | undefined} hash\n */\n 'bitbucket.org': (pathname: string, hash: string) => {\n const [, user, project, aux] = pathname.split('/', 4);\n if (['get'].includes(aux)) {\n return;\n }\n\n let projectResult = project;\n if (project && project.endsWith('.git')) {\n projectResult = project.slice(0, -4);\n }\n\n if (!user || !projectResult) {\n return;\n }\n\n return hash;\n },\n /**\n * @param {string} pathname pathname\n * @param {string} hash hash\n * @returns {string | undefined} hash\n */\n 'gist.github.com': (pathname: string, hash: string) => {\n const [, user, project, aux] = pathname.split('/', 4);\n if (aux === 'raw') {\n return;\n }\n\n let projectResult = project;\n if (!projectResult) {\n if (!user) {\n return;\n }\n\n projectResult = user;\n }\n\n if (projectResult.endsWith('.git')) {\n projectResult = projectResult.slice(0, -4);\n }\n\n return hash;\n },\n};\n\n/**\n * extract commit hash from parsed url\n *\n * @inner\n * @param {URL} urlParsed parsed url\n * @returns {string} commithash\n */\nfunction getCommithash(urlParsed: URL): string {\n const { hostname, pathname, hash } = urlParsed;\n const hostnameResult = hostname.replace(/^www\\./, '');\n\n let hashResult = hash;\n try {\n hashResult = decodeURIComponent(hash);\n // eslint-disable-next-line no-empty\n } catch (e) {}\n\n if (\n /** @type {keyof extractCommithashByDomain} */ extractCommithashByDomain[\n hostnameResult\n ]\n ) {\n return (\n extractCommithashByDomain\n /** @type {keyof extractCommithashByDomain} */ [hostnameResult](\n pathname,\n hashResult,\n ) || ''\n );\n }\n\n return hashResult;\n}\n\n/**\n * make url right for URL parse\n *\n * @inner\n * @param {string} gitUrl git url\n * @returns {string} fixed url\n */\nfunction correctUrl(gitUrl: string): string {\n // like:\n // proto://hostname.com:user/repo -> proto://hostname.com/user/repo\n return gitUrl.replace(RE_HOSTNAME_WITH_COLON, '$1/$2');\n}\n\n/**\n * make url protocol right for URL parse\n *\n * @inner\n * @param {string} gitUrl git url\n * @returns {string} fixed url\n */\nfunction correctProtocol(gitUrl: string): string {\n // eg: github:foo/bar#v1.0. Should not add double slash, in case of error parsed `pathname`\n if (RE_GIT_URL_SHORT.test(gitUrl)) {\n return gitUrl;\n }\n\n // eg: user@github.com:foo/bar\n if (!RE_CUSTOM_PROTOCOL.test(gitUrl)) {\n return `${DEF_GIT_PROTOCOL}${gitUrl}`;\n }\n\n return gitUrl;\n}\n\n/**\n * extract git dep version from hash\n *\n * @inner\n * @param {string} hash hash\n * @returns {string} git dep version\n */\nfunction getVersionFromHash(hash: string): string {\n const matched = hash.match(RE_URL_HASH_VERSION);\n\n return (matched && matched[1]) || '';\n}\n\n/**\n * if string can be decoded\n *\n * @inner\n * @param {string} str str to be checked\n * @returns {boolean} if can be decoded\n */\nfunction canBeDecoded(str: string): boolean {\n try {\n decodeURIComponent(str);\n } catch (e) {\n return false;\n }\n\n return true;\n}\n\n/**\n * get right dep version from git url\n *\n * @inner\n * @param {string} gitUrl git url\n * @returns {string} dep version\n */\nfunction getGitUrlVersion(gitUrl: string): string {\n const oriGitUrl = gitUrl;\n // github extreme shorthand\n if (RE_URL_GITHUB_EXTREME_SHORT.test(gitUrl)) {\n gitUrl = 'github:' + gitUrl;\n } else {\n gitUrl = correctProtocol(gitUrl);\n }\n\n gitUrl = correctUrl(gitUrl);\n\n let parsed;\n try {\n parsed = new URL(gitUrl);\n // eslint-disable-next-line no-empty\n } catch (e) {}\n\n if (!parsed) {\n return '';\n }\n\n const { protocol, hostname, pathname, username, password } = parsed;\n if (!RE_PROTOCOL.test(protocol)) {\n return '';\n }\n\n // pathname shouldn't be empty or URL malformed\n if (!pathname || !canBeDecoded(pathname)) {\n return '';\n }\n\n // without protocol, there should have auth info\n if (RE_NO_PROTOCOL.test(oriGitUrl) && !username && !password) {\n return '';\n }\n\n if (!PROTOCOLS_FOR_SHORT.includes(protocol.toLowerCase())) {\n if (!RE_HOSTNAME.test(hostname)) {\n return '';\n }\n\n const commithash = getCommithash(parsed);\n return getVersionFromHash(commithash) || commithash;\n }\n\n // for protocol short\n return getVersionFromHash(gitUrl);\n}\n\n/**\n * @param {string} str maybe required version\n * @returns {boolean} true, if it looks like a version\n */\nfunction isRequiredVersion(str: string): boolean {\n return VERSION_PATTERN_REGEXP.test(str);\n}\n\nexport { isRequiredVersion };\n\n/**\n * @see https://docs.npmjs.com/cli/v7/configuring-npm/package-json#urls-as-dependencies\n * @param {string} versionDesc version to be normalized\n * @returns {string} normalized version\n */\nfunction normalizeVersion(versionDesc: string): string {\n versionDesc = (versionDesc && versionDesc.trim()) || '';\n\n if (isRequiredVersion(versionDesc)) {\n return versionDesc;\n }\n\n // add handle for URL Dependencies\n return getGitUrlVersion(versionDesc.toLowerCase());\n}\n\nexport { normalizeVersion };\n\n/**\n *\n * @param {InputFileSystem} fs file system\n * @param {string} directory directory to start looking into\n * @param {string[]} descriptionFiles possible description filenames\n * @param {function((Error | null)=, {data: object, path: string}=): void} callback callback\n */\nconst getDescriptionFile = (\n fs: InputFileSystem,\n directory: string,\n descriptionFiles: string[],\n callback: (err: Error | null, data?: { data: object; path: string }) => void,\n) => {\n let i = 0;\n const tryLoadCurrent = () => {\n if (i >= descriptionFiles.length) {\n const parentDirectory = dirname(fs, directory);\n if (!parentDirectory || parentDirectory === directory) {\n //@ts-ignore\n return callback();\n }\n return getDescriptionFile(\n fs,\n parentDirectory,\n descriptionFiles,\n callback,\n );\n }\n const filePath = join(fs, directory, descriptionFiles[i]);\n readJson(fs, filePath, (err, data: object) => {\n if (err) {\n if ('code' in err && err.code === 'ENOENT') {\n i++;\n return tryLoadCurrent();\n }\n return callback(err);\n }\n if (!data || typeof data !== 'object' || Array.isArray(data)) {\n return callback(\n new Error(`Description file ${filePath} is not an object`),\n );\n }\n callback(null, { data, path: filePath });\n });\n };\n tryLoadCurrent();\n};\nexport { getDescriptionFile };\n/**\n * Get required version from description file\n * @param {Record<string, any>} data - The data object\n * @param {string} packageName - The package name\n * @returns {string | undefined} The normalized version\n */\nexport function getRequiredVersionFromDescriptionFile(\n data: Record<string, any>,\n packageName: string,\n): string | undefined | void {\n if (\n data['optionalDependencies'] &&\n typeof data['optionalDependencies'] === 'object' &&\n packageName in data['optionalDependencies']\n ) {\n return normalizeVersion(data['optionalDependencies'][packageName]);\n }\n if (\n data['dependencies'] &&\n typeof data['dependencies'] === 'object' &&\n packageName in data['dependencies']\n ) {\n return normalizeVersion(data['dependencies'][packageName]);\n }\n if (\n data['peerDependencies'] &&\n typeof data['peerDependencies'] === 'object' &&\n packageName in data['peerDependencies']\n ) {\n return normalizeVersion(data['peerDependencies'][packageName]);\n }\n if (\n data['devDependencies'] &&\n typeof data['devDependencies'] === 'object' &&\n packageName in data['devDependencies']\n ) {\n return normalizeVersion(data['devDependencies'][packageName]);\n }\n}\n"],"names":["getDescriptionFile","getRequiredVersionFromDescriptionFile","isRequiredVersion","normalizeVersion","RE_URL_GITHUB_EXTREME_SHORT","RE_GIT_URL_SHORT","RE_PROTOCOL","RE_CUSTOM_PROTOCOL","RE_URL_HASH_VERSION","RE_HOSTNAME","RE_HOSTNAME_WITH_COLON","RE_NO_PROTOCOL","VERSION_PATTERN_REGEXP","PROTOCOLS_FOR_SHORT","DEF_GIT_PROTOCOL","extractCommithashByDomain","pathname","hash","user","project","type","commithash","split","commithashResult","projectResult","endsWith","slice","path","includes","segments","pop","join","aux","getCommithash","urlParsed","hostname","hostnameResult","replace","hashResult","decodeURIComponent","e","correctUrl","gitUrl","correctProtocol","test","getVersionFromHash","matched","match","canBeDecoded","str","getGitUrlVersion","oriGitUrl","parsed","URL","protocol","username","password","toLowerCase","versionDesc","trim","fs","directory","descriptionFiles","callback","i","tryLoadCurrent","length","parentDirectory","dirname","filePath","readJson","err","data","code","Array","isArray","Error","packageName"],"mappings":"AAAA;;;AAGA;;;;;;;;;;;IA+XSA,kBAAkB;eAAlBA;;IAOOC,qCAAqC;eAArCA;;IA1EPC,iBAAiB;eAAjBA;;IAkBAC,gBAAgB;eAAhBA;;;oBA5UgD;AAEzD,iDAAiD;AACjD,MAAMC,8BACJ;AAEF,uDAAuD;AACvD,MAAMC,mBACJ;AAEF,gCAAgC;AAChC,MAAMC,cACJ;AAEF,sBAAsB;AACtB,MAAMC,qBAA6B;AAEnC,uCAAuC;AACvC,MAAMC,sBAA8B;AAEpC,2BAA2B;AAC3B,MAAMC,cAAsB;AAE5B,6DAA6D;AAC7D,MAAMC,yBACJ;AAEF,+BAA+B;AAC/B,MAAMC,iBAAyB;AAE/B,4BAA4B;AAC5B,MAAMC,yBAAiC;AAEvC,0DAA0D;AAC1D,MAAMC,sBAAgC;IACpC;IACA;IACA;IACA;IACA;CACD;AAED,+BAA+B;AAC/B,MAAMC,mBAA2B;AAEjC,gFAAgF;AAChF,MAAMC,4BAEF;IACF;;;;GAIC,GACD,cAAc,CAACC,UAAkBC;QAC/B,MAAM,GAAGC,MAAMC,SAASC,MAAMC,WAAW,GAAGL,SAASM,KAAK,CAAC,KAAK;QAChE,IAAIF,QAAQA,SAAS,QAAQ;YAC3B;QACF;QAEA,IAAIG,mBAAmBF;QACvB,IAAI,CAACD,MAAM;YACTG,mBAAmBN;QACrB,OAAO;YACLM,mBAAmB,MAAMF;QAC3B;QAEA,IAAIG,gBAAgBL;QACpB,IAAIA,WAAWA,QAAQM,QAAQ,CAAC,SAAS;YACvCD,gBAAgBL,QAAQO,KAAK,CAAC,GAAG,C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,IACvB,OAAOA,IAAI,CAAC,kBAAkB,KAAK,YACnCK,eAAeL,IAAI,CAAC,kBAAkB,EACtC;QACA,OAAOrE,iBAAiBqE,IAAI,CAAC,kBAAkB,CAACK,YAAY;IAC9D;AACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
AddRuntimeRequirementToPromiseExternal: function() {
|
|
13
|
+
return AddRuntimeRequirementToPromiseExternal;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
let AddRuntimeRequirementToPromiseExternal = class AddRuntimeRequirementToPromiseExternal {
|
|
20
|
+
apply(compiler) {
|
|
21
|
+
compiler.hooks.compilation.tap('AddRuntimeRequirementToPromiseExternal', (compilation)=>{
|
|
22
|
+
const { RuntimeGlobals } = compiler.webpack;
|
|
23
|
+
compilation.hooks.additionalModuleRuntimeRequirements.tap('AddRuntimeRequirementToPromiseExternal', (module, set)=>{
|
|
24
|
+
if (module.externalType === 'promise') {
|
|
25
|
+
set.add(RuntimeGlobals.loadScript);
|
|
26
|
+
set.add(RuntimeGlobals.require);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const _default = AddRuntimeRequirementToPromiseExternal;
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=AddRuntimeRequirementToPromiseExternalPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/enhanced/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.ts"],"sourcesContent":["import { Compiler } from 'webpack';\n\nexport class AddRuntimeRequirementToPromiseExternal {\n apply(compiler: Compiler) {\n compiler.hooks.compilation.tap(\n 'AddRuntimeRequirementToPromiseExternal',\n (compilation) => {\n const { RuntimeGlobals } = compiler.webpack;\n compilation.hooks.additionalModuleRuntimeRequirements.tap(\n 'AddRuntimeRequirementToPromiseExternal',\n (module, set) => {\n if ((module as any).externalType === 'promise') {\n set.add(RuntimeGlobals.loadScript);\n set.add(RuntimeGlobals.require);\n }\n },\n );\n },\n );\n }\n}\n\nexport default AddRuntimeRequirementToPromiseExternal;\n"],"names":["AddRuntimeRequirementToPromiseExternal","apply","compiler","hooks","compilation","tap","RuntimeGlobals","webpack","additionalModuleRuntimeRequirements","module","set","externalType","add","loadScript","require"],"mappings":";;;;;;;;;;;IAEaA,sCAAsC;eAAtCA;;IAoBb,OAAsD;eAAtD;;;AApBO,IAAA,AAAMA,yCAAN,MAAMA;IACXC,MAAMC,QAAkB,EAAE;QACxBA,SAASC,KAAK,CAACC,WAAW,CAACC,GAAG,CAC5B,0CACA,CAACD;YACC,MAAM,EAAEE,cAAc,EAAE,GAAGJ,SAASK,OAAO;YAC3CH,YAAYD,KAAK,CAACK,mCAAmC,CAACH,GAAG,CACvD,0CACA,CAACI,QAAQC;gBACP,IAAI,AAACD,OAAeE,YAAY,KAAK,WAAW;oBAC9CD,IAAIE,GAAG,CAACN,eAAeO,UAAU;oBACjCH,IAAIE,GAAG,CAACN,eAAeQ,OAAO;gBAChC;YACF;QAEJ;IAEJ;AACF;MAEA,WAAed"}
|