@modern-js/app-tools 2.14.0 → 2.16.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 +74 -0
- package/dist/cjs/analyze/constants.js +37 -61
- package/dist/cjs/analyze/generateCode.js +102 -127
- package/dist/cjs/analyze/getBundleEntry.js +33 -66
- package/dist/cjs/analyze/getClientRoutes/getRoutes.js +61 -117
- package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +61 -115
- package/dist/cjs/analyze/getClientRoutes/index.js +15 -28
- package/dist/cjs/analyze/getClientRoutes/utils.js +24 -48
- package/dist/cjs/analyze/getFileSystemEntry.js +39 -79
- package/dist/cjs/analyze/getHtmlTemplate.js +88 -98
- package/dist/cjs/analyze/getServerRoutes.js +67 -110
- package/dist/cjs/analyze/index.js +265 -257
- package/dist/cjs/analyze/isDefaultExportFunction.js +66 -44
- package/dist/cjs/analyze/makeLegalIdentifier.js +7 -25
- package/dist/cjs/analyze/nestedRoutes.js +99 -104
- package/dist/cjs/analyze/templates.js +49 -110
- package/dist/cjs/analyze/utils.js +98 -102
- package/dist/cjs/builder/builder-rspack/adapterCopy.js +58 -100
- package/dist/cjs/builder/builder-rspack/index.js +14 -30
- package/dist/cjs/builder/builder-webpack/adapterModern.js +33 -50
- package/dist/cjs/builder/builder-webpack/createCopyPattern.js +16 -32
- package/dist/cjs/builder/builder-webpack/index.js +65 -46
- package/dist/cjs/builder/generator/createBuilderOptions.js +10 -26
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +11 -27
- package/dist/cjs/builder/generator/getBuilderTargets.js +13 -29
- package/dist/cjs/builder/generator/index.js +61 -55
- package/dist/cjs/builder/index.js +53 -43
- package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +13 -36
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +90 -90
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +108 -111
- package/dist/cjs/builder/shared/builderPlugins/index.js +20 -19
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +30 -30
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +32 -38
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +86 -116
- package/dist/cjs/builder/shared/bundlerPlugins/index.js +20 -19
- package/dist/cjs/builder/shared/createCopyInfo.js +16 -42
- package/dist/cjs/builder/shared/index.js +20 -19
- package/dist/cjs/builder/shared/loaders/serverModuleLoader.js +8 -24
- package/dist/cjs/builder/shared/types.js +4 -15
- package/dist/cjs/commands/build.js +23 -40
- package/dist/cjs/commands/deploy.js +7 -25
- package/dist/cjs/commands/dev.js +38 -57
- package/dist/cjs/commands/index.js +20 -19
- package/dist/cjs/commands/inspect.js +10 -30
- package/dist/cjs/commands/serve.js +28 -66
- package/dist/cjs/config/default.js +34 -34
- package/dist/cjs/config/index.js +20 -19
- package/dist/cjs/config/initialize/index.js +11 -29
- package/dist/cjs/config/initialize/inits.js +103 -82
- package/dist/cjs/config/legacy/createHtmlConfig.js +8 -40
- package/dist/cjs/config/legacy/createOutputConfig.js +8 -51
- package/dist/cjs/config/legacy/createSourceConfig.js +8 -38
- package/dist/cjs/config/legacy/createToolsConfig.js +8 -43
- package/dist/cjs/config/legacy/index.js +22 -46
- package/dist/cjs/defineConfig.js +16 -31
- package/dist/cjs/exports/server.js +7 -25
- package/dist/cjs/hooks.js +33 -51
- package/dist/cjs/index.js +185 -166
- package/dist/cjs/initialize/index.js +84 -100
- package/dist/cjs/locale/en.js +13 -27
- package/dist/cjs/locale/index.js +18 -28
- package/dist/cjs/locale/zh.js +13 -27
- package/dist/cjs/schema/Schema.js +27 -31
- package/dist/cjs/schema/index.js +141 -71
- package/dist/cjs/schema/legacy.js +273 -96
- package/dist/cjs/types/config/deploy.js +4 -15
- package/dist/cjs/types/config/dev.js +4 -15
- package/dist/cjs/types/config/experiments.js +4 -15
- package/dist/cjs/types/config/html.js +4 -15
- package/dist/cjs/types/config/index.js +18 -17
- package/dist/cjs/types/config/output.js +4 -15
- package/dist/cjs/types/config/performance.js +4 -15
- package/dist/cjs/types/config/security.js +4 -15
- package/dist/cjs/types/config/source.js +4 -15
- package/dist/cjs/types/config/tools.js +4 -15
- package/dist/cjs/types/hooks.js +4 -15
- package/dist/cjs/types/index.js +20 -19
- package/dist/cjs/types/legacyConfig/deploy.js +4 -15
- package/dist/cjs/types/legacyConfig/dev.js +4 -15
- package/dist/cjs/types/legacyConfig/index.js +4 -15
- package/dist/cjs/types/legacyConfig/output.js +4 -15
- package/dist/cjs/types/legacyConfig/source.js +4 -15
- package/dist/cjs/types/legacyConfig/tools.js +4 -15
- package/dist/cjs/types/utils.js +4 -15
- package/dist/cjs/utils/config.js +74 -79
- package/dist/cjs/utils/createServer.js +16 -42
- package/dist/cjs/utils/env.js +7 -25
- package/dist/cjs/utils/generateWatchFiles.js +31 -52
- package/dist/cjs/utils/getSelectedEntries.js +13 -35
- package/dist/cjs/utils/getServerInternalPlugins.js +8 -29
- package/dist/cjs/utils/printInstructions.js +10 -28
- package/dist/cjs/utils/restart.js +13 -31
- package/dist/cjs/utils/routes.js +18 -39
- package/dist/cjs/utils/types.js +4 -15
- package/dist/esm/analyze/constants.js +40 -41
- package/dist/esm/analyze/generateCode.js +477 -455
- package/dist/esm/analyze/getBundleEntry.js +53 -54
- package/dist/esm/analyze/getClientRoutes/getRoutes.js +201 -202
- package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +199 -200
- package/dist/esm/analyze/getClientRoutes/index.js +2 -3
- package/dist/esm/analyze/getClientRoutes/utils.js +15 -15
- package/dist/esm/analyze/getFileSystemEntry.js +86 -87
- package/dist/esm/analyze/getHtmlTemplate.js +289 -278
- package/dist/esm/analyze/getServerRoutes.js +203 -190
- package/dist/esm/analyze/index.js +679 -651
- package/dist/esm/analyze/isDefaultExportFunction.js +38 -39
- package/dist/esm/analyze/makeLegalIdentifier.js +8 -9
- package/dist/esm/analyze/nestedRoutes.js +400 -392
- package/dist/esm/analyze/templates.js +536 -509
- package/dist/esm/analyze/utils.js +357 -336
- package/dist/esm/builder/builder-rspack/adapterCopy.js +347 -330
- package/dist/esm/builder/builder-rspack/index.js +8 -9
- package/dist/esm/builder/builder-webpack/adapterModern.js +51 -43
- package/dist/esm/builder/builder-webpack/createCopyPattern.js +31 -32
- package/dist/esm/builder/builder-webpack/index.js +266 -249
- package/dist/esm/builder/generator/createBuilderOptions.js +37 -38
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +62 -63
- package/dist/esm/builder/generator/getBuilderTargets.js +13 -14
- package/dist/esm/builder/generator/index.js +203 -196
- package/dist/esm/builder/index.js +183 -176
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +90 -91
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +300 -291
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +337 -329
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +108 -97
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +66 -64
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +364 -337
- package/dist/esm/builder/shared/createCopyInfo.js +9 -10
- package/dist/esm/builder/shared/loaders/serverModuleLoader.js +2 -3
- package/dist/esm/builder/shared/types.js +1 -1
- package/dist/esm/commands/build.js +279 -272
- package/dist/esm/commands/deploy.js +150 -144
- package/dist/esm/commands/dev.js +296 -289
- package/dist/esm/commands/inspect.js +144 -138
- package/dist/esm/commands/serve.js +241 -235
- package/dist/esm/config/default.js +202 -203
- package/dist/esm/config/initialize/index.js +7 -8
- package/dist/esm/config/initialize/inits.js +189 -181
- package/dist/esm/config/legacy/createHtmlConfig.js +17 -18
- package/dist/esm/config/legacy/createOutputConfig.js +41 -42
- package/dist/esm/config/legacy/createSourceConfig.js +38 -39
- package/dist/esm/config/legacy/createToolsConfig.js +24 -25
- package/dist/esm/config/legacy/index.js +31 -32
- package/dist/esm/defineConfig.js +52 -53
- package/dist/esm/exports/server.js +1 -2
- package/dist/esm/hooks.js +26 -27
- package/dist/esm/index.js +685 -671
- package/dist/esm/initialize/index.js +276 -269
- package/dist/esm/locale/en.js +36 -37
- package/dist/esm/locale/index.js +2 -2
- package/dist/esm/locale/zh.js +36 -37
- package/dist/esm/schema/Schema.js +255 -244
- package/dist/esm/schema/index.js +165 -165
- package/dist/esm/schema/legacy.js +316 -317
- package/dist/esm/types/config/deploy.js +1 -1
- package/dist/esm/types/config/dev.js +1 -1
- package/dist/esm/types/config/experiments.js +1 -1
- package/dist/esm/types/config/html.js +1 -1
- package/dist/esm/types/config/output.js +1 -1
- package/dist/esm/types/config/performance.js +1 -1
- package/dist/esm/types/config/security.js +1 -1
- package/dist/esm/types/config/source.js +1 -1
- package/dist/esm/types/config/tools.js +1 -1
- package/dist/esm/types/hooks.js +1 -1
- package/dist/esm/types/legacyConfig/deploy.js +1 -1
- package/dist/esm/types/legacyConfig/dev.js +1 -1
- package/dist/esm/types/legacyConfig/index.js +1 -1
- package/dist/esm/types/legacyConfig/output.js +1 -1
- package/dist/esm/types/legacyConfig/source.js +1 -1
- package/dist/esm/types/legacyConfig/tools.js +1 -1
- package/dist/esm/types/utils.js +1 -1
- package/dist/esm/utils/config.js +285 -278
- package/dist/esm/utils/createServer.js +242 -234
- package/dist/esm/utils/env.js +11 -12
- package/dist/esm/utils/generateWatchFiles.js +205 -190
- package/dist/esm/utils/getSelectedEntries.js +180 -173
- package/dist/esm/utils/getServerInternalPlugins.js +197 -191
- package/dist/esm/utils/printInstructions.js +147 -141
- package/dist/esm/utils/restart.js +179 -173
- package/dist/esm/utils/routes.js +146 -139
- package/dist/esm/utils/types.js +1 -1
- package/dist/esm-node/analyze/constants.js +31 -46
- package/dist/esm-node/analyze/generateCode.js +28 -94
- package/dist/esm-node/analyze/getBundleEntry.js +8 -27
- package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +24 -65
- package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +24 -63
- package/dist/esm-node/analyze/getClientRoutes/index.js +2 -6
- package/dist/esm-node/analyze/getClientRoutes/utils.js +5 -19
- package/dist/esm-node/analyze/getFileSystemEntry.js +10 -37
- package/dist/esm-node/analyze/getHtmlTemplate.js +29 -59
- package/dist/esm-node/analyze/getServerRoutes.js +43 -75
- package/dist/esm-node/analyze/index.js +208 -230
- package/dist/esm-node/analyze/isDefaultExportFunction.js +7 -5
- package/dist/esm-node/analyze/makeLegalIdentifier.js +1 -4
- package/dist/esm-node/analyze/nestedRoutes.js +23 -43
- package/dist/esm-node/analyze/templates.js +22 -69
- package/dist/esm-node/analyze/utils.js +66 -60
- package/dist/esm-node/builder/builder-rspack/adapterCopy.js +40 -62
- package/dist/esm-node/builder/builder-rspack/index.js +4 -5
- package/dist/esm-node/builder/builder-webpack/adapterModern.js +24 -26
- package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +3 -10
- package/dist/esm-node/builder/builder-webpack/index.js +13 -11
- package/dist/esm-node/builder/generator/createBuilderOptions.js +4 -5
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +5 -6
- package/dist/esm-node/builder/generator/getBuilderTargets.js +5 -11
- package/dist/esm-node/builder/generator/index.js +7 -16
- package/dist/esm-node/builder/index.js +2 -7
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +2 -6
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +34 -60
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +54 -74
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +23 -8
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +25 -16
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +66 -76
- package/dist/esm-node/builder/shared/createCopyInfo.js +2 -8
- package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +1 -4
- package/dist/esm-node/builder/shared/types.js +1 -0
- package/dist/esm-node/commands/build.js +7 -9
- package/dist/esm-node/commands/deploy.js +1 -4
- package/dist/esm-node/commands/dev.js +19 -27
- package/dist/esm-node/commands/inspect.js +3 -8
- package/dist/esm-node/commands/serve.js +7 -25
- package/dist/esm-node/config/default.js +20 -11
- package/dist/esm-node/config/initialize/index.js +1 -4
- package/dist/esm-node/config/initialize/inits.js +48 -54
- package/dist/esm-node/config/legacy/createHtmlConfig.js +2 -19
- package/dist/esm-node/config/legacy/createOutputConfig.js +2 -30
- package/dist/esm-node/config/legacy/createSourceConfig.js +2 -17
- package/dist/esm-node/config/legacy/createToolsConfig.js +2 -22
- package/dist/esm-node/config/legacy/index.js +3 -18
- package/dist/esm-node/defineConfig.js +7 -13
- package/dist/esm-node/exports/server.js +1 -4
- package/dist/esm-node/hooks.js +2 -9
- package/dist/esm-node/index.js +95 -120
- package/dist/esm-node/initialize/index.js +74 -87
- package/dist/esm-node/locale/en.js +7 -6
- package/dist/esm-node/locale/index.js +5 -5
- package/dist/esm-node/locale/zh.js +7 -6
- package/dist/esm-node/schema/Schema.js +19 -8
- package/dist/esm-node/schema/index.js +121 -36
- package/dist/esm-node/schema/legacy.js +262 -72
- package/dist/esm-node/types/config/deploy.js +1 -0
- package/dist/esm-node/types/config/dev.js +1 -0
- package/dist/esm-node/types/config/experiments.js +1 -0
- package/dist/esm-node/types/config/html.js +1 -0
- package/dist/esm-node/types/config/output.js +1 -0
- package/dist/esm-node/types/config/performance.js +1 -0
- package/dist/esm-node/types/config/security.js +1 -0
- package/dist/esm-node/types/config/source.js +1 -0
- package/dist/esm-node/types/config/tools.js +1 -0
- package/dist/esm-node/types/hooks.js +1 -0
- package/dist/esm-node/types/legacyConfig/deploy.js +1 -0
- package/dist/esm-node/types/legacyConfig/dev.js +1 -0
- package/dist/esm-node/types/legacyConfig/index.js +1 -0
- package/dist/esm-node/types/legacyConfig/output.js +1 -0
- package/dist/esm-node/types/legacyConfig/source.js +1 -0
- package/dist/esm-node/types/legacyConfig/tools.js +1 -0
- package/dist/esm-node/types/utils.js +1 -0
- package/dist/esm-node/utils/config.js +16 -47
- package/dist/esm-node/utils/createServer.js +5 -12
- package/dist/esm-node/utils/env.js +1 -4
- package/dist/esm-node/utils/generateWatchFiles.js +13 -20
- package/dist/esm-node/utils/getSelectedEntries.js +2 -9
- package/dist/esm-node/utils/getServerInternalPlugins.js +2 -8
- package/dist/esm-node/utils/printInstructions.js +1 -4
- package/dist/esm-node/utils/restart.js +2 -11
- package/dist/esm-node/utils/routes.js +4 -4
- package/dist/esm-node/utils/types.js +1 -0
- package/dist/types/index.d.ts +2 -2
- package/lib/types.d.ts +1 -0
- package/package.json +29 -25
|
@@ -1,368 +1,395 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length)
|
|
3
|
+
len = arr.length;
|
|
4
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
5
|
+
arr2[i] = arr[i];
|
|
6
|
+
return arr2;
|
|
5
7
|
}
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
+
function _array_with_holes(arr) {
|
|
9
|
+
if (Array.isArray(arr))
|
|
10
|
+
return arr;
|
|
8
11
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
12
|
+
function _array_without_holes(arr) {
|
|
13
|
+
if (Array.isArray(arr))
|
|
14
|
+
return _array_like_to_array(arr);
|
|
11
15
|
}
|
|
12
16
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
try {
|
|
18
|
+
var info = gen[key](arg);
|
|
19
|
+
var value = info.value;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
reject(error);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (info.done) {
|
|
25
|
+
resolve(value);
|
|
26
|
+
} else {
|
|
27
|
+
Promise.resolve(value).then(_next, _throw);
|
|
28
|
+
}
|
|
25
29
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
function _async_to_generator(fn) {
|
|
31
|
+
return function() {
|
|
32
|
+
var self = this, args = arguments;
|
|
33
|
+
return new Promise(function(resolve, reject) {
|
|
34
|
+
var gen = fn.apply(self, args);
|
|
35
|
+
function _next(value) {
|
|
36
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
37
|
+
}
|
|
38
|
+
function _throw(err) {
|
|
39
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
40
|
+
}
|
|
41
|
+
_next(void 0);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
40
44
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
function _class_call_check(instance, Constructor) {
|
|
46
|
+
if (!(instance instanceof Constructor)) {
|
|
47
|
+
throw new TypeError("Cannot call a class as a function");
|
|
48
|
+
}
|
|
45
49
|
}
|
|
46
50
|
function _defineProperties(target, props) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
for (var i = 0; i < props.length; i++) {
|
|
52
|
+
var descriptor = props[i];
|
|
53
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
54
|
+
descriptor.configurable = true;
|
|
55
|
+
if ("value" in descriptor)
|
|
56
|
+
descriptor.writable = true;
|
|
57
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
58
|
+
}
|
|
54
59
|
}
|
|
55
|
-
function
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
61
|
+
if (protoProps)
|
|
62
|
+
_defineProperties(Constructor.prototype, protoProps);
|
|
63
|
+
if (staticProps)
|
|
64
|
+
_defineProperties(Constructor, staticProps);
|
|
65
|
+
return Constructor;
|
|
59
66
|
}
|
|
60
|
-
function
|
|
61
|
-
|
|
67
|
+
function _iterable_to_array(iter) {
|
|
68
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
69
|
+
return Array.from(iter);
|
|
62
70
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
function _iterable_to_array_limit(arr, i) {
|
|
72
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
73
|
+
if (_i == null)
|
|
74
|
+
return;
|
|
75
|
+
var _arr = [];
|
|
76
|
+
var _n = true;
|
|
77
|
+
var _d = false;
|
|
78
|
+
var _s, _e;
|
|
79
|
+
try {
|
|
80
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
81
|
+
_arr.push(_s.value);
|
|
82
|
+
if (i && _arr.length === i)
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
} catch (err) {
|
|
86
|
+
_d = true;
|
|
87
|
+
_e = err;
|
|
88
|
+
} finally {
|
|
70
89
|
try {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
_d = true;
|
|
77
|
-
_e = err;
|
|
78
|
-
} finally{
|
|
79
|
-
try {
|
|
80
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
81
|
-
} finally{
|
|
82
|
-
if (_d) throw _e;
|
|
83
|
-
}
|
|
90
|
+
if (!_n && _i["return"] != null)
|
|
91
|
+
_i["return"]();
|
|
92
|
+
} finally {
|
|
93
|
+
if (_d)
|
|
94
|
+
throw _e;
|
|
84
95
|
}
|
|
85
|
-
|
|
96
|
+
}
|
|
97
|
+
return _arr;
|
|
86
98
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
99
|
+
function _non_iterable_rest() {
|
|
100
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
89
101
|
}
|
|
90
|
-
function
|
|
91
|
-
|
|
102
|
+
function _non_iterable_spread() {
|
|
103
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
92
104
|
}
|
|
93
|
-
function
|
|
94
|
-
|
|
105
|
+
function _sliced_to_array(arr, i) {
|
|
106
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
95
107
|
}
|
|
96
|
-
function
|
|
97
|
-
|
|
108
|
+
function _to_consumable_array(arr) {
|
|
109
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
98
110
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
111
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
112
|
+
if (!o)
|
|
113
|
+
return;
|
|
114
|
+
if (typeof o === "string")
|
|
115
|
+
return _array_like_to_array(o, minLen);
|
|
116
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
117
|
+
if (n === "Object" && o.constructor)
|
|
118
|
+
n = o.constructor.name;
|
|
119
|
+
if (n === "Map" || n === "Set")
|
|
120
|
+
return Array.from(n);
|
|
121
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
122
|
+
return _array_like_to_array(o, minLen);
|
|
106
123
|
}
|
|
107
|
-
var __generator =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
124
|
+
var __generator = function(thisArg, body) {
|
|
125
|
+
var f, y, t, g, _ = {
|
|
126
|
+
label: 0,
|
|
127
|
+
sent: function() {
|
|
128
|
+
if (t[0] & 1)
|
|
129
|
+
throw t[1];
|
|
130
|
+
return t[1];
|
|
131
|
+
},
|
|
132
|
+
trys: [],
|
|
133
|
+
ops: []
|
|
134
|
+
};
|
|
135
|
+
return g = {
|
|
136
|
+
next: verb(0),
|
|
137
|
+
"throw": verb(1),
|
|
138
|
+
"return": verb(2)
|
|
139
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
140
|
+
return this;
|
|
141
|
+
}), g;
|
|
142
|
+
function verb(n) {
|
|
143
|
+
return function(v) {
|
|
144
|
+
return step([
|
|
145
|
+
n,
|
|
146
|
+
v
|
|
147
|
+
]);
|
|
116
148
|
};
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
break;
|
|
145
|
-
case 4:
|
|
146
|
-
_.label++;
|
|
147
|
-
return {
|
|
148
|
-
value: op[1],
|
|
149
|
-
done: false
|
|
150
|
-
};
|
|
151
|
-
case 5:
|
|
152
|
-
_.label++;
|
|
153
|
-
y = op[1];
|
|
154
|
-
op = [
|
|
155
|
-
0
|
|
156
|
-
];
|
|
157
|
-
continue;
|
|
158
|
-
case 7:
|
|
159
|
-
op = _.ops.pop();
|
|
160
|
-
_.trys.pop();
|
|
161
|
-
continue;
|
|
162
|
-
default:
|
|
163
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
164
|
-
_ = 0;
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
168
|
-
_.label = op[1];
|
|
169
|
-
break;
|
|
170
|
-
}
|
|
171
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
172
|
-
_.label = t[1];
|
|
173
|
-
t = op;
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
if (t && _.label < t[2]) {
|
|
177
|
-
_.label = t[2];
|
|
178
|
-
_.ops.push(op);
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
if (t[2]) _.ops.pop();
|
|
182
|
-
_.trys.pop();
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
op = body.call(thisArg, _);
|
|
186
|
-
} catch (e) {
|
|
149
|
+
}
|
|
150
|
+
function step(op) {
|
|
151
|
+
if (f)
|
|
152
|
+
throw new TypeError("Generator is already executing.");
|
|
153
|
+
while (_)
|
|
154
|
+
try {
|
|
155
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
156
|
+
return t;
|
|
157
|
+
if (y = 0, t)
|
|
158
|
+
op = [
|
|
159
|
+
op[0] & 2,
|
|
160
|
+
t.value
|
|
161
|
+
];
|
|
162
|
+
switch (op[0]) {
|
|
163
|
+
case 0:
|
|
164
|
+
case 1:
|
|
165
|
+
t = op;
|
|
166
|
+
break;
|
|
167
|
+
case 4:
|
|
168
|
+
_.label++;
|
|
169
|
+
return {
|
|
170
|
+
value: op[1],
|
|
171
|
+
done: false
|
|
172
|
+
};
|
|
173
|
+
case 5:
|
|
174
|
+
_.label++;
|
|
175
|
+
y = op[1];
|
|
187
176
|
op = [
|
|
188
|
-
|
|
189
|
-
e
|
|
177
|
+
0
|
|
190
178
|
];
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
179
|
+
continue;
|
|
180
|
+
case 7:
|
|
181
|
+
op = _.ops.pop();
|
|
182
|
+
_.trys.pop();
|
|
183
|
+
continue;
|
|
184
|
+
default:
|
|
185
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
186
|
+
_ = 0;
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
190
|
+
_.label = op[1];
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
194
|
+
_.label = t[1];
|
|
195
|
+
t = op;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
if (t && _.label < t[2]) {
|
|
199
|
+
_.label = t[2];
|
|
200
|
+
_.ops.push(op);
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
if (t[2])
|
|
204
|
+
_.ops.pop();
|
|
205
|
+
_.trys.pop();
|
|
206
|
+
continue;
|
|
194
207
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
208
|
+
op = body.call(thisArg, _);
|
|
209
|
+
} catch (e) {
|
|
210
|
+
op = [
|
|
211
|
+
6,
|
|
212
|
+
e
|
|
213
|
+
];
|
|
214
|
+
y = 0;
|
|
215
|
+
} finally {
|
|
216
|
+
f = t = 0;
|
|
217
|
+
}
|
|
218
|
+
if (op[0] & 5)
|
|
219
|
+
throw op[1];
|
|
220
|
+
return {
|
|
221
|
+
value: op[0] ? op[1] : void 0,
|
|
222
|
+
done: true
|
|
223
|
+
};
|
|
224
|
+
}
|
|
201
225
|
};
|
|
202
226
|
import path from "path";
|
|
203
227
|
import { fs } from "@modern-js/utils";
|
|
204
228
|
import { ROUTE_MANIFEST_FILE } from "@modern-js/utils/constants";
|
|
205
229
|
import { ROUTE_MANIFEST } from "@modern-js/utils/universal/constants";
|
|
206
230
|
var PLUGIN_NAME = "ModernjsRoutePlugin";
|
|
207
|
-
var RouterPlugin =
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
var webpack = compiler.webpack;
|
|
224
|
-
var Compilation = webpack.Compilation, sources = webpack.sources;
|
|
225
|
-
var RawSource = sources.RawSource;
|
|
226
|
-
var PROCESS_ASSETS_STAGE_REPORT = Compilation.PROCESS_ASSETS_STAGE_REPORT;
|
|
227
|
-
var outputPath = compiler.options.output.path;
|
|
228
|
-
var newAssetsMap = /* @__PURE__ */ new Map();
|
|
229
|
-
var normalizePath = function(path2) {
|
|
230
|
-
if (!path2.endsWith("/")) {
|
|
231
|
-
return "".concat(path2, "/");
|
|
232
|
-
}
|
|
233
|
-
return path2;
|
|
234
|
-
};
|
|
235
|
-
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, function(compilation) {
|
|
236
|
-
compilation.hooks.processAssets.tapPromise({
|
|
237
|
-
name: PLUGIN_NAME,
|
|
238
|
-
stage: PROCESS_ASSETS_STAGE_REPORT
|
|
239
|
-
}, /*#__PURE__*/ _asyncToGenerator(function() {
|
|
240
|
-
var stats, publicPath, _stats_chunks, chunks, namedChunkGroups, routeAssets, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, name, chunkGroup, assets, referenceCssAssets, manifest, injectedContent, entrypointsArray, entryChunkIds, entryChunks, entryChunkFiles, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, file, asset, newContent, filename;
|
|
241
|
-
return __generator(this, function(_state) {
|
|
242
|
-
switch(_state.label){
|
|
243
|
-
case 0:
|
|
244
|
-
stats = compilation.getStats().toJson({
|
|
245
|
-
all: false,
|
|
246
|
-
publicPath: true,
|
|
247
|
-
assets: true,
|
|
248
|
-
chunkGroups: true,
|
|
249
|
-
chunks: true,
|
|
250
|
-
ids: true
|
|
251
|
-
});
|
|
252
|
-
publicPath = stats.publicPath, _stats_chunks = stats.chunks, chunks = _stats_chunks === void 0 ? [] : _stats_chunks, namedChunkGroups = stats.namedChunkGroups;
|
|
253
|
-
routeAssets = {};
|
|
254
|
-
if (!namedChunkGroups) {
|
|
255
|
-
return [
|
|
256
|
-
2
|
|
257
|
-
];
|
|
258
|
-
}
|
|
259
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
260
|
-
try {
|
|
261
|
-
for(_iterator = Object.entries(namedChunkGroups)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
262
|
-
_step_value = _slicedToArray(_step.value, 2), name = _step_value[0], chunkGroup = _step_value[1];
|
|
263
|
-
assets = chunkGroup.assets.map(function(asset) {
|
|
264
|
-
var filename2 = asset.name;
|
|
265
|
-
return publicPath ? normalizePath(publicPath) + filename2 : filename2;
|
|
266
|
-
});
|
|
267
|
-
referenceCssAssets = assets.filter(function(asset) {
|
|
268
|
-
return /\.css$/.test(asset);
|
|
269
|
-
});
|
|
270
|
-
routeAssets[name] = {
|
|
271
|
-
chunkIds: chunkGroup.chunks,
|
|
272
|
-
assets: assets,
|
|
273
|
-
referenceCssAssets: referenceCssAssets
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
} catch (err) {
|
|
277
|
-
_didIteratorError = true;
|
|
278
|
-
_iteratorError = err;
|
|
279
|
-
} finally{
|
|
280
|
-
try {
|
|
281
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
282
|
-
_iterator.return();
|
|
283
|
-
}
|
|
284
|
-
} finally{
|
|
285
|
-
if (_didIteratorError) {
|
|
286
|
-
throw _iteratorError;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
manifest = {
|
|
291
|
-
routeAssets: routeAssets
|
|
292
|
-
};
|
|
293
|
-
injectedContent = "\n ;(function(){\n window.".concat(ROUTE_MANIFEST, " = ").concat(JSON.stringify(manifest, function(k, v) {
|
|
294
|
-
if ((k === "assets" || k === "referenceCssAssets") && Array.isArray(v)) {
|
|
295
|
-
return v.map(function(item) {
|
|
296
|
-
return item.replace(publicPath, "");
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
return v;
|
|
300
|
-
}), ";\n })();\n ");
|
|
301
|
-
entrypointsArray = Array.from(compilation.entrypoints.entries());
|
|
302
|
-
entryChunkIds = entrypointsArray.map(function(entrypoint) {
|
|
303
|
-
return entrypoint[0];
|
|
304
|
-
});
|
|
305
|
-
entryChunks = _toConsumableArray(chunks).filter(function(chunk) {
|
|
306
|
-
var _chunk_names;
|
|
307
|
-
return (_chunk_names = chunk.names) === null || _chunk_names === void 0 ? void 0 : _chunk_names.some(function(name) {
|
|
308
|
-
return entryChunkIds.includes(name);
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
entryChunkFiles = entryChunks.map(function(chunk) {
|
|
312
|
-
return _toConsumableArray(chunk.files || []).find(function(fname) {
|
|
313
|
-
return fname.includes(".js");
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
|
-
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
317
|
-
try {
|
|
318
|
-
for(_iterator1 = entryChunkFiles[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
319
|
-
file = _step1.value;
|
|
320
|
-
asset = compilation.assets[file];
|
|
321
|
-
if (!asset) {
|
|
322
|
-
continue;
|
|
323
|
-
}
|
|
324
|
-
newContent = "".concat(injectedContent).concat(asset.source().toString());
|
|
325
|
-
newAssetsMap.set(path.join(outputPath, file), newContent);
|
|
326
|
-
compilation.updateAsset(file, new RawSource(newContent), // FIXME: The arguments third of updatgeAsset is a optional function in webpack.
|
|
327
|
-
void 0);
|
|
328
|
-
}
|
|
329
|
-
} catch (err) {
|
|
330
|
-
_didIteratorError1 = true;
|
|
331
|
-
_iteratorError1 = err;
|
|
332
|
-
} finally{
|
|
333
|
-
try {
|
|
334
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
335
|
-
_iterator1.return();
|
|
336
|
-
}
|
|
337
|
-
} finally{
|
|
338
|
-
if (_didIteratorError1) {
|
|
339
|
-
throw _iteratorError1;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
filename = path.join(outputPath, ROUTE_MANIFEST_FILE);
|
|
344
|
-
return [
|
|
345
|
-
4,
|
|
346
|
-
fs.ensureFile(filename)
|
|
347
|
-
];
|
|
348
|
-
case 1:
|
|
349
|
-
_state.sent();
|
|
350
|
-
return [
|
|
351
|
-
4,
|
|
352
|
-
fs.writeFile(filename, JSON.stringify(manifest, null, 2))
|
|
353
|
-
];
|
|
354
|
-
case 2:
|
|
355
|
-
_state.sent();
|
|
356
|
-
return [
|
|
357
|
-
2
|
|
358
|
-
];
|
|
359
|
-
}
|
|
360
|
-
});
|
|
361
|
-
}));
|
|
362
|
-
});
|
|
363
|
-
}
|
|
231
|
+
export var RouterPlugin = /* @__PURE__ */ function() {
|
|
232
|
+
"use strict";
|
|
233
|
+
function RouterPlugin2() {
|
|
234
|
+
_class_call_check(this, RouterPlugin2);
|
|
235
|
+
}
|
|
236
|
+
_create_class(RouterPlugin2, [
|
|
237
|
+
{
|
|
238
|
+
key: "apply",
|
|
239
|
+
value: function apply(compiler) {
|
|
240
|
+
var target = compiler.options.target;
|
|
241
|
+
if (target === "node" || Array.isArray(target) && target.includes("node")) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (target === "webworker" || Array.isArray(target) && target.includes("webworker")) {
|
|
245
|
+
return;
|
|
364
246
|
}
|
|
365
|
-
|
|
366
|
-
|
|
247
|
+
var webpack = compiler.webpack;
|
|
248
|
+
var Compilation = webpack.Compilation, sources = webpack.sources;
|
|
249
|
+
var RawSource = sources.RawSource;
|
|
250
|
+
var PROCESS_ASSETS_STAGE_REPORT = Compilation.PROCESS_ASSETS_STAGE_REPORT;
|
|
251
|
+
var outputPath = compiler.options.output.path;
|
|
252
|
+
var newAssetsMap = /* @__PURE__ */ new Map();
|
|
253
|
+
var normalizePath = function(path2) {
|
|
254
|
+
if (!path2.endsWith("/")) {
|
|
255
|
+
return "".concat(path2, "/");
|
|
256
|
+
}
|
|
257
|
+
return path2;
|
|
258
|
+
};
|
|
259
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, function(compilation) {
|
|
260
|
+
compilation.hooks.processAssets.tapPromise({
|
|
261
|
+
name: PLUGIN_NAME,
|
|
262
|
+
stage: PROCESS_ASSETS_STAGE_REPORT
|
|
263
|
+
}, /* @__PURE__ */ _async_to_generator(function() {
|
|
264
|
+
var stats, publicPath, _stats_chunks, chunks, namedChunkGroups, routeAssets, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, name, chunkGroup, assets, referenceCssAssets, manifest, injectedContent, entrypointsArray, entryChunkIds, entryChunks, entryChunkFiles, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, file, asset, newContent, filename;
|
|
265
|
+
return __generator(this, function(_state) {
|
|
266
|
+
switch (_state.label) {
|
|
267
|
+
case 0:
|
|
268
|
+
stats = compilation.getStats().toJson({
|
|
269
|
+
all: false,
|
|
270
|
+
publicPath: true,
|
|
271
|
+
assets: true,
|
|
272
|
+
chunkGroups: true,
|
|
273
|
+
chunks: true,
|
|
274
|
+
ids: true
|
|
275
|
+
});
|
|
276
|
+
publicPath = stats.publicPath, _stats_chunks = stats.chunks, chunks = _stats_chunks === void 0 ? [] : _stats_chunks, namedChunkGroups = stats.namedChunkGroups;
|
|
277
|
+
routeAssets = {};
|
|
278
|
+
if (!namedChunkGroups) {
|
|
279
|
+
return [
|
|
280
|
+
2
|
|
281
|
+
];
|
|
282
|
+
}
|
|
283
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
284
|
+
try {
|
|
285
|
+
for (_iterator = Object.entries(namedChunkGroups)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
286
|
+
_step_value = _sliced_to_array(_step.value, 2), name = _step_value[0], chunkGroup = _step_value[1];
|
|
287
|
+
assets = chunkGroup.assets.map(function(asset2) {
|
|
288
|
+
var filename2 = asset2.name;
|
|
289
|
+
return publicPath ? normalizePath(publicPath) + filename2 : filename2;
|
|
290
|
+
});
|
|
291
|
+
referenceCssAssets = assets.filter(function(asset2) {
|
|
292
|
+
return /\.css$/.test(asset2);
|
|
293
|
+
});
|
|
294
|
+
routeAssets[name] = {
|
|
295
|
+
chunkIds: chunkGroup.chunks,
|
|
296
|
+
assets,
|
|
297
|
+
referenceCssAssets
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
} catch (err) {
|
|
301
|
+
_didIteratorError = true;
|
|
302
|
+
_iteratorError = err;
|
|
303
|
+
} finally {
|
|
304
|
+
try {
|
|
305
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
306
|
+
_iterator.return();
|
|
307
|
+
}
|
|
308
|
+
} finally {
|
|
309
|
+
if (_didIteratorError) {
|
|
310
|
+
throw _iteratorError;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
manifest = {
|
|
315
|
+
routeAssets
|
|
316
|
+
};
|
|
317
|
+
injectedContent = "\n ;(function(){\n window.".concat(ROUTE_MANIFEST, " = ").concat(JSON.stringify(manifest, function(k, v) {
|
|
318
|
+
if ((k === "assets" || k === "referenceCssAssets") && Array.isArray(v)) {
|
|
319
|
+
return v.map(function(item) {
|
|
320
|
+
return item.replace(publicPath, "");
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
return v;
|
|
324
|
+
}), ";\n })();\n ");
|
|
325
|
+
entrypointsArray = Array.from(compilation.entrypoints.entries());
|
|
326
|
+
entryChunkIds = entrypointsArray.map(function(entrypoint) {
|
|
327
|
+
return entrypoint[0];
|
|
328
|
+
});
|
|
329
|
+
entryChunks = _to_consumable_array(chunks).filter(function(chunk) {
|
|
330
|
+
var _chunk_names;
|
|
331
|
+
return (_chunk_names = chunk.names) === null || _chunk_names === void 0 ? void 0 : _chunk_names.some(function(name2) {
|
|
332
|
+
return entryChunkIds.includes(name2);
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
entryChunkFiles = entryChunks.map(function(chunk) {
|
|
336
|
+
return _to_consumable_array(chunk.files || []).find(function(fname) {
|
|
337
|
+
return fname.includes(".js");
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
341
|
+
try {
|
|
342
|
+
for (_iterator1 = entryChunkFiles[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
343
|
+
file = _step1.value;
|
|
344
|
+
asset = compilation.assets[file];
|
|
345
|
+
if (!asset) {
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
newContent = "".concat(injectedContent).concat(asset.source().toString());
|
|
349
|
+
newAssetsMap.set(path.join(outputPath, file), newContent);
|
|
350
|
+
compilation.updateAsset(
|
|
351
|
+
file,
|
|
352
|
+
new RawSource(newContent),
|
|
353
|
+
// FIXME: The arguments third of updatgeAsset is a optional function in webpack.
|
|
354
|
+
void 0
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
} catch (err) {
|
|
358
|
+
_didIteratorError1 = true;
|
|
359
|
+
_iteratorError1 = err;
|
|
360
|
+
} finally {
|
|
361
|
+
try {
|
|
362
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
363
|
+
_iterator1.return();
|
|
364
|
+
}
|
|
365
|
+
} finally {
|
|
366
|
+
if (_didIteratorError1) {
|
|
367
|
+
throw _iteratorError1;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
filename = path.join(outputPath, ROUTE_MANIFEST_FILE);
|
|
372
|
+
return [
|
|
373
|
+
4,
|
|
374
|
+
fs.ensureFile(filename)
|
|
375
|
+
];
|
|
376
|
+
case 1:
|
|
377
|
+
_state.sent();
|
|
378
|
+
return [
|
|
379
|
+
4,
|
|
380
|
+
fs.writeFile(filename, JSON.stringify(manifest, null, 2))
|
|
381
|
+
];
|
|
382
|
+
case 2:
|
|
383
|
+
_state.sent();
|
|
384
|
+
return [
|
|
385
|
+
2
|
|
386
|
+
];
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
}));
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
]);
|
|
394
|
+
return RouterPlugin2;
|
|
367
395
|
}();
|
|
368
|
-
export { RouterPlugin };
|