@modern-js/app-tools 2.30.1-alpha.0 → 2.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +76 -0
- package/dist/cjs/analyze/getHtmlTemplate.js +6 -0
- package/dist/cjs/analyze/nestedRoutes.js +1 -2
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +13 -3
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +64 -82
- package/dist/cjs/config/default.js +2 -1
- package/dist/cjs/schema/index.js +3 -0
- package/dist/cjs/types/config/testing.js +4 -0
- package/dist/cjs/types/legacyConfig/testing.js +4 -0
- package/dist/esm/analyze/getHtmlTemplate.js +8 -1
- package/dist/esm/analyze/nestedRoutes.js +1 -4
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +13 -3
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +189 -249
- package/dist/esm/config/default.js +2 -1
- package/dist/esm/schema/index.js +3 -0
- package/dist/esm/types/config/testing.js +1 -0
- package/dist/esm/types/legacyConfig/testing.js +1 -0
- package/dist/esm-node/analyze/getHtmlTemplate.js +6 -0
- package/dist/esm-node/analyze/nestedRoutes.js +1 -2
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +13 -3
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +68 -85
- package/dist/esm-node/config/default.js +2 -1
- package/dist/esm-node/schema/index.js +3 -0
- package/dist/esm-node/types/config/testing.js +1 -0
- package/dist/esm-node/types/legacyConfig/testing.js +1 -0
- package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +24 -0
- package/dist/types/types/config/index.d.ts +4 -1
- package/dist/types/types/config/output.d.ts +1 -0
- package/dist/types/types/config/security.d.ts +3 -1
- package/dist/types/types/config/testing.d.ts +8 -0
- package/dist/types/types/config/tools.d.ts +1 -1
- package/dist/types/types/legacyConfig/index.d.ts +2 -0
- package/dist/types/types/legacyConfig/testing.d.ts +8 -0
- package/dist/types/types/legacyConfig/tools.d.ts +1 -2
- package/package.json +25 -25
- package/dist/js/modern/analyze/constants.js +0 -54
- package/dist/js/modern/analyze/generateCode.js +0 -247
- package/dist/js/modern/analyze/getBundleEntry.js +0 -71
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +0 -220
- package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +0 -216
- package/dist/js/modern/analyze/getClientRoutes/index.js +0 -6
- package/dist/js/modern/analyze/getClientRoutes/utils.js +0 -31
- package/dist/js/modern/analyze/getFileSystemEntry.js +0 -109
- package/dist/js/modern/analyze/getHtmlTemplate.js +0 -115
- package/dist/js/modern/analyze/getServerRoutes.js +0 -175
- package/dist/js/modern/analyze/index.js +0 -332
- package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -42
- package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -13
- package/dist/js/modern/analyze/nestedRoutes.js +0 -157
- package/dist/js/modern/analyze/templates.js +0 -334
- package/dist/js/modern/analyze/utils.js +0 -141
- package/dist/js/modern/builder/builderPlugins/compatModern.js +0 -233
- package/dist/js/modern/builder/index.js +0 -159
- package/dist/js/modern/builder/loaders/routerLoader.js +0 -17
- package/dist/js/modern/builder/loaders/serverModuleLoader.js +0 -7
- package/dist/js/modern/builder/share.js +0 -46
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -30
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +0 -37
- package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +0 -113
- package/dist/js/modern/commands/build.js +0 -91
- package/dist/js/modern/commands/deploy.js +0 -28
- package/dist/js/modern/commands/dev.js +0 -109
- package/dist/js/modern/commands/index.js +0 -3
- package/dist/js/modern/commands/inspect.js +0 -38
- package/dist/js/modern/commands/serve.js +0 -54
- package/dist/js/modern/config/default.js +0 -175
- package/dist/js/modern/config/index.js +0 -8
- package/dist/js/modern/config/initial/createHtmlConfig.js +0 -35
- package/dist/js/modern/config/initial/createOutputConfig.js +0 -68
- package/dist/js/modern/config/initial/createSourceConfig.js +0 -39
- package/dist/js/modern/config/initial/createToolsConfig.js +0 -42
- package/dist/js/modern/config/initial/index.js +0 -16
- package/dist/js/modern/config/initial/inits.js +0 -152
- package/dist/js/modern/config/initial/transformNormalizedConfig.js +0 -47
- package/dist/js/modern/defineConfig.js +0 -27
- package/dist/js/modern/exports/server.js +0 -4
- package/dist/js/modern/hooks.js +0 -35
- package/dist/js/modern/index.js +0 -211
- package/dist/js/modern/initialize/index.js +0 -124
- package/dist/js/modern/locale/en.js +0 -36
- package/dist/js/modern/locale/index.js +0 -9
- package/dist/js/modern/locale/zh.js +0 -36
- package/dist/js/modern/schema/Schema.js +0 -40
- package/dist/js/modern/schema/index.js +0 -88
- package/dist/js/modern/schema/legacy.js +0 -148
- package/dist/js/modern/types/config/deploy.js +0 -0
- package/dist/js/modern/types/config/dev.js +0 -0
- package/dist/js/modern/types/config/experiments.js +0 -0
- package/dist/js/modern/types/config/html.js +0 -0
- package/dist/js/modern/types/config/index.js +0 -1
- package/dist/js/modern/types/config/output.js +0 -0
- package/dist/js/modern/types/config/performance.js +0 -0
- package/dist/js/modern/types/config/security.js +0 -0
- package/dist/js/modern/types/config/source.js +0 -0
- package/dist/js/modern/types/config/tools.js +0 -0
- package/dist/js/modern/types/hooks.js +0 -0
- package/dist/js/modern/types/index.js +0 -3
- package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
- package/dist/js/modern/types/legacyConfig/dev.js +0 -0
- package/dist/js/modern/types/legacyConfig/index.js +0 -0
- package/dist/js/modern/types/legacyConfig/output.js +0 -0
- package/dist/js/modern/types/legacyConfig/source.js +0 -0
- package/dist/js/modern/types/legacyConfig/tools.js +0 -0
- package/dist/js/modern/utils/config.js +0 -128
- package/dist/js/modern/utils/createServer.js +0 -75
- package/dist/js/modern/utils/env.js +0 -15
- package/dist/js/modern/utils/generateWatchFiles.js +0 -55
- package/dist/js/modern/utils/getSelectedEntries.js +0 -58
- package/dist/js/modern/utils/getServerInternalPlugins.js +0 -58
- package/dist/js/modern/utils/language.js +0 -8
- package/dist/js/modern/utils/printInstructions.js +0 -31
- package/dist/js/modern/utils/restart.js +0 -44
- package/dist/js/modern/utils/routes.js +0 -30
- package/dist/js/modern/utils/types.js +0 -0
- package/dist/js/node/analyze/constants.js +0 -98
- package/dist/js/node/analyze/generateCode.js +0 -271
- package/dist/js/node/analyze/getBundleEntry.js +0 -95
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +0 -242
- package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +0 -238
- package/dist/js/node/analyze/getClientRoutes/index.js +0 -30
- package/dist/js/node/analyze/getClientRoutes/utils.js +0 -58
- package/dist/js/node/analyze/getFileSystemEntry.js +0 -131
- package/dist/js/node/analyze/getHtmlTemplate.js +0 -144
- package/dist/js/node/analyze/getServerRoutes.js +0 -194
- package/dist/js/node/analyze/index.js +0 -339
- package/dist/js/node/analyze/isDefaultExportFunction.js +0 -71
- package/dist/js/node/analyze/makeLegalIdentifier.js +0 -36
- package/dist/js/node/analyze/nestedRoutes.js +0 -184
- package/dist/js/node/analyze/templates.js +0 -365
- package/dist/js/node/analyze/utils.js +0 -172
- package/dist/js/node/builder/builderPlugins/compatModern.js +0 -258
- package/dist/js/node/builder/index.js +0 -177
- package/dist/js/node/builder/loaders/routerLoader.js +0 -38
- package/dist/js/node/builder/loaders/serverModuleLoader.js +0 -28
- package/dist/js/node/builder/share.js +0 -75
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -53
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +0 -60
- package/dist/js/node/builder/webpackPlugins/routerPlugin.js +0 -135
- package/dist/js/node/commands/build.js +0 -112
- package/dist/js/node/commands/deploy.js +0 -51
- package/dist/js/node/commands/dev.js +0 -126
- package/dist/js/node/commands/index.js +0 -19
- package/dist/js/node/commands/inspect.js +0 -61
- package/dist/js/node/commands/serve.js +0 -83
- package/dist/js/node/config/default.js +0 -197
- package/dist/js/node/config/index.js +0 -34
- package/dist/js/node/config/initial/createHtmlConfig.js +0 -58
- package/dist/js/node/config/initial/createOutputConfig.js +0 -91
- package/dist/js/node/config/initial/createSourceConfig.js +0 -62
- package/dist/js/node/config/initial/createToolsConfig.js +0 -65
- package/dist/js/node/config/initial/index.js +0 -41
- package/dist/js/node/config/initial/inits.js +0 -175
- package/dist/js/node/config/initial/transformNormalizedConfig.js +0 -70
- package/dist/js/node/defineConfig.js +0 -49
- package/dist/js/node/exports/server.js +0 -27
- package/dist/js/node/hooks.js +0 -54
- package/dist/js/node/index.js +0 -235
- package/dist/js/node/initialize/index.js +0 -134
- package/dist/js/node/locale/en.js +0 -59
- package/dist/js/node/locale/index.js +0 -33
- package/dist/js/node/locale/zh.js +0 -59
- package/dist/js/node/schema/Schema.js +0 -63
- package/dist/js/node/schema/index.js +0 -118
- package/dist/js/node/schema/legacy.js +0 -169
- package/dist/js/node/types/config/deploy.js +0 -15
- package/dist/js/node/types/config/dev.js +0 -15
- package/dist/js/node/types/config/experiments.js +0 -15
- package/dist/js/node/types/config/html.js +0 -15
- package/dist/js/node/types/config/index.js +0 -17
- package/dist/js/node/types/config/output.js +0 -15
- package/dist/js/node/types/config/performance.js +0 -15
- package/dist/js/node/types/config/security.js +0 -15
- package/dist/js/node/types/config/source.js +0 -15
- package/dist/js/node/types/config/tools.js +0 -15
- package/dist/js/node/types/hooks.js +0 -15
- package/dist/js/node/types/index.js +0 -19
- package/dist/js/node/types/legacyConfig/deploy.js +0 -15
- package/dist/js/node/types/legacyConfig/dev.js +0 -15
- package/dist/js/node/types/legacyConfig/index.js +0 -15
- package/dist/js/node/types/legacyConfig/output.js +0 -15
- package/dist/js/node/types/legacyConfig/source.js +0 -15
- package/dist/js/node/types/legacyConfig/tools.js +0 -15
- package/dist/js/node/utils/config.js +0 -153
- package/dist/js/node/utils/createServer.js +0 -106
- package/dist/js/node/utils/env.js +0 -38
- package/dist/js/node/utils/generateWatchFiles.js +0 -85
- package/dist/js/node/utils/getSelectedEntries.js +0 -81
- package/dist/js/node/utils/getServerInternalPlugins.js +0 -79
- package/dist/js/node/utils/language.js +0 -31
- package/dist/js/node/utils/printInstructions.js +0 -54
- package/dist/js/node/utils/restart.js +0 -67
- package/dist/js/node/utils/routes.js +0 -59
- package/dist/js/node/utils/types.js +0 -15
- package/dist/js/treeshaking/analyze/constants.js +0 -40
- package/dist/js/treeshaking/analyze/generateCode.js +0 -485
- package/dist/js/treeshaking/analyze/getBundleEntry.js +0 -62
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +0 -233
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +0 -231
- package/dist/js/treeshaking/analyze/getClientRoutes/index.js +0 -3
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +0 -23
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +0 -107
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +0 -302
- package/dist/js/treeshaking/analyze/getServerRoutes.js +0 -222
- package/dist/js/treeshaking/analyze/index.js +0 -697
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +0 -47
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +0 -13
- package/dist/js/treeshaking/analyze/nestedRoutes.js +0 -384
- package/dist/js/treeshaking/analyze/templates.js +0 -468
- package/dist/js/treeshaking/analyze/utils.js +0 -374
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +0 -304
- package/dist/js/treeshaking/builder/index.js +0 -374
- package/dist/js/treeshaking/builder/loaders/routerLoader.js +0 -13
- package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +0 -5
- package/dist/js/treeshaking/builder/share.js +0 -40
- package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -110
- package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +0 -72
- package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +0 -343
- package/dist/js/treeshaking/commands/build.js +0 -291
- package/dist/js/treeshaking/commands/deploy.js +0 -154
- package/dist/js/treeshaking/commands/dev.js +0 -301
- package/dist/js/treeshaking/commands/index.js +0 -3
- package/dist/js/treeshaking/commands/inspect.js +0 -149
- package/dist/js/treeshaking/commands/serve.js +0 -199
- package/dist/js/treeshaking/config/default.js +0 -210
- package/dist/js/treeshaking/config/index.js +0 -3
- package/dist/js/treeshaking/config/initial/createHtmlConfig.js +0 -19
- package/dist/js/treeshaking/config/initial/createOutputConfig.js +0 -41
- package/dist/js/treeshaking/config/initial/createSourceConfig.js +0 -42
- package/dist/js/treeshaking/config/initial/createToolsConfig.js +0 -23
- package/dist/js/treeshaking/config/initial/index.js +0 -12
- package/dist/js/treeshaking/config/initial/inits.js +0 -209
- package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +0 -35
- package/dist/js/treeshaking/defineConfig.js +0 -61
- package/dist/js/treeshaking/exports/server.js +0 -2
- package/dist/js/treeshaking/hooks.js +0 -29
- package/dist/js/treeshaking/index.js +0 -706
- package/dist/js/treeshaking/initialize/index.js +0 -276
- package/dist/js/treeshaking/locale/en.js +0 -38
- package/dist/js/treeshaking/locale/index.js +0 -9
- package/dist/js/treeshaking/locale/zh.js +0 -38
- package/dist/js/treeshaking/schema/Schema.js +0 -273
- package/dist/js/treeshaking/schema/index.js +0 -181
- package/dist/js/treeshaking/schema/legacy.js +0 -337
- package/dist/js/treeshaking/types/config/deploy.js +0 -1
- package/dist/js/treeshaking/types/config/dev.js +0 -1
- package/dist/js/treeshaking/types/config/experiments.js +0 -1
- package/dist/js/treeshaking/types/config/html.js +0 -1
- package/dist/js/treeshaking/types/config/index.js +0 -1
- package/dist/js/treeshaking/types/config/output.js +0 -1
- package/dist/js/treeshaking/types/config/performance.js +0 -1
- package/dist/js/treeshaking/types/config/security.js +0 -1
- package/dist/js/treeshaking/types/config/source.js +0 -1
- package/dist/js/treeshaking/types/config/tools.js +0 -1
- package/dist/js/treeshaking/types/hooks.js +0 -1
- package/dist/js/treeshaking/types/index.js +0 -3
- package/dist/js/treeshaking/types/legacyConfig/deploy.js +0 -1
- package/dist/js/treeshaking/types/legacyConfig/dev.js +0 -1
- package/dist/js/treeshaking/types/legacyConfig/index.js +0 -1
- package/dist/js/treeshaking/types/legacyConfig/output.js +0 -1
- package/dist/js/treeshaking/types/legacyConfig/source.js +0 -1
- package/dist/js/treeshaking/types/legacyConfig/tools.js +0 -1
- package/dist/js/treeshaking/utils/config.js +0 -302
- package/dist/js/treeshaking/utils/createServer.js +0 -258
- package/dist/js/treeshaking/utils/env.js +0 -13
- package/dist/js/treeshaking/utils/generateWatchFiles.js +0 -214
- package/dist/js/treeshaking/utils/getSelectedEntries.js +0 -186
- package/dist/js/treeshaking/utils/getServerInternalPlugins.js +0 -210
- package/dist/js/treeshaking/utils/language.js +0 -6
- package/dist/js/treeshaking/utils/printInstructions.js +0 -152
- package/dist/js/treeshaking/utils/restart.js +0 -187
- package/dist/js/treeshaking/utils/routes.js +0 -153
- package/dist/js/treeshaking/utils/types.js +0 -1
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
|
|
3
3
|
import { _ as _create_class } from "@swc/helpers/_/_create_class";
|
|
4
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
4
5
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
5
6
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
6
7
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
7
|
-
import {
|
|
8
|
-
import path from "path";
|
|
8
|
+
import { createHash } from "crypto";
|
|
9
9
|
import { mergeWith } from "@modern-js/utils/lodash";
|
|
10
10
|
import { ROUTE_MANIFEST_FILE } from "@modern-js/utils";
|
|
11
11
|
import { ROUTE_MANIFEST } from "@modern-js/utils/universal/constants";
|
|
12
|
-
import { transform } from "esbuild";
|
|
13
12
|
var PLUGIN_NAME = "ModernjsRoutePlugin";
|
|
13
|
+
var generateContentHash = function(content) {
|
|
14
|
+
return createHash("md5").update(content).digest("hex").slice(0, 8);
|
|
15
|
+
};
|
|
14
16
|
export var RouterPlugin = /* @__PURE__ */ function() {
|
|
15
17
|
"use strict";
|
|
16
|
-
function RouterPlugin2() {
|
|
18
|
+
function RouterPlugin2(param) {
|
|
19
|
+
var _param_staticJsDir = param.staticJsDir, staticJsDir = _param_staticJsDir === void 0 ? "static/js" : _param_staticJsDir, HtmlBundlerPlugin = param.HtmlBundlerPlugin, enableInlineRouteManifests = param.enableInlineRouteManifests, _param_disableFilenameHash = param.disableFilenameHash, disableFilenameHash = _param_disableFilenameHash === void 0 ? false : _param_disableFilenameHash, _param_scriptLoading = param.scriptLoading, scriptLoading = _param_scriptLoading === void 0 ? "defer" : _param_scriptLoading, nonce = param.nonce;
|
|
17
20
|
_class_call_check(this, RouterPlugin2);
|
|
21
|
+
_define_property(this, "HtmlBundlerPlugin", void 0);
|
|
22
|
+
_define_property(this, "enableInlineRouteManifests", void 0);
|
|
23
|
+
_define_property(this, "staticJsDir", void 0);
|
|
24
|
+
_define_property(this, "disableFilenameHash", void 0);
|
|
25
|
+
_define_property(this, "scriptLoading", void 0);
|
|
26
|
+
_define_property(this, "nonce", void 0);
|
|
27
|
+
this.HtmlBundlerPlugin = HtmlBundlerPlugin;
|
|
28
|
+
this.enableInlineRouteManifests = enableInlineRouteManifests;
|
|
29
|
+
this.staticJsDir = staticJsDir;
|
|
30
|
+
this.disableFilenameHash = disableFilenameHash;
|
|
31
|
+
this.scriptLoading = scriptLoading;
|
|
32
|
+
this.nonce = nonce;
|
|
18
33
|
}
|
|
19
34
|
_create_class(RouterPlugin2, [
|
|
20
35
|
{
|
|
@@ -65,282 +80,207 @@ export var RouterPlugin = /* @__PURE__ */ function() {
|
|
|
65
80
|
}
|
|
66
81
|
var webpack = compiler.webpack;
|
|
67
82
|
var Compilation = webpack.Compilation, sources = webpack.sources;
|
|
68
|
-
var RawSource = sources.RawSource
|
|
69
|
-
var normalizePath = function(
|
|
70
|
-
if (!
|
|
71
|
-
return "".concat(
|
|
83
|
+
var RawSource = sources.RawSource;
|
|
84
|
+
var normalizePath = function(path) {
|
|
85
|
+
if (!path.endsWith("/")) {
|
|
86
|
+
return "".concat(path, "/");
|
|
72
87
|
}
|
|
73
|
-
return
|
|
88
|
+
return path;
|
|
74
89
|
};
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
var
|
|
90
|
+
var chunksToHtmlName = /* @__PURE__ */ new Map();
|
|
91
|
+
var ROUTE_MANIFEST_HOLDER = "route-manifest";
|
|
92
|
+
var placeholder = "<!--<?- ".concat(ROUTE_MANIFEST_HOLDER, " ?>-->");
|
|
78
93
|
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, function(compilation) {
|
|
94
|
+
_this.HtmlBundlerPlugin.getHooks(compilation).beforeEmit.tapAsync("RouterManifestPlugin", function(data, callback) {
|
|
95
|
+
var outputName = data.outputName;
|
|
96
|
+
var chunks = data.plugin.options.chunks;
|
|
97
|
+
chunksToHtmlName.set(chunks, outputName);
|
|
98
|
+
data.html = data.html.replace("</script>", "</script>".concat(placeholder));
|
|
99
|
+
callback(null, data);
|
|
100
|
+
});
|
|
79
101
|
var _this1 = _this;
|
|
80
102
|
compilation.hooks.processAssets.tapPromise({
|
|
81
103
|
name: PLUGIN_NAME,
|
|
82
|
-
stage: Compilation.
|
|
104
|
+
stage: Compilation.PROCESS_ASSETS_STAGE_REPORT
|
|
83
105
|
}, /* @__PURE__ */ _async_to_generator(function() {
|
|
84
|
-
var stats, _stats_chunks, chunks, namedChunkGroups,
|
|
106
|
+
var _loop, stats, publicPath, _stats_chunks, chunks, namedChunkGroups, routeAssets, prevManifestAsset, prevManifestStr, prevManifest, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, name, chunkGroup, assets, referenceCssAssets, manifest, entryNames, entryChunks, entryChunkFiles, entryChunkFileIds, i;
|
|
85
107
|
return _ts_generator(this, function(_state) {
|
|
108
|
+
_loop = function(i2) {
|
|
109
|
+
var entryName = entryNames[i2];
|
|
110
|
+
var file = entryChunkFiles[i2];
|
|
111
|
+
var chunkNames = entryChunks[i2].names;
|
|
112
|
+
var chunkId = entryChunkFileIds[i2];
|
|
113
|
+
var asset = compilation.assets[file];
|
|
114
|
+
if (!asset || !chunkId) {
|
|
115
|
+
return "continue";
|
|
116
|
+
}
|
|
117
|
+
var relatedAssets = {};
|
|
118
|
+
if (entryChunkFiles.length > 1) {
|
|
119
|
+
Object.keys(routeAssets).forEach(function(routeId) {
|
|
120
|
+
var _chunkNames;
|
|
121
|
+
var segments = routeId.split("_");
|
|
122
|
+
var chunkName = segments[0];
|
|
123
|
+
if ((_chunkNames = chunkNames) === null || _chunkNames === void 0 ? void 0 : _chunkNames.includes(chunkName)) {
|
|
124
|
+
relatedAssets[routeId] = routeAssets[routeId];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
} else {
|
|
128
|
+
relatedAssets = routeAssets;
|
|
129
|
+
}
|
|
130
|
+
var manifest2 = {
|
|
131
|
+
routeAssets: relatedAssets
|
|
132
|
+
};
|
|
133
|
+
var injectedContent = "\n ;(function(){\n window.".concat(ROUTE_MANIFEST, " = ").concat(JSON.stringify(manifest2, function(k, v) {
|
|
134
|
+
if ((k === "assets" || k === "referenceCssAssets") && Array.isArray(v)) {
|
|
135
|
+
return v.map(function(item) {
|
|
136
|
+
return item.replace(publicPath, "");
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return v;
|
|
140
|
+
}), ";\n })();\n ");
|
|
141
|
+
var htmlName = void 0;
|
|
142
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
143
|
+
try {
|
|
144
|
+
var _loop2 = function() {
|
|
145
|
+
var _step_value2 = _sliced_to_array(_step2.value, 2), chunks2 = _step_value2[0], name2 = _step_value2[1];
|
|
146
|
+
if (Array.isArray(chunkNames) && Array.isArray(chunks2) && chunkNames.every(function(value, index) {
|
|
147
|
+
return value === chunks2[index];
|
|
148
|
+
})) {
|
|
149
|
+
htmlName = name2;
|
|
150
|
+
return "break";
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
for (var _iterator2 = chunksToHtmlName.entries()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
154
|
+
var _ret = _loop2();
|
|
155
|
+
if (_ret === "break")
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
} catch (err) {
|
|
159
|
+
_didIteratorError2 = true;
|
|
160
|
+
_iteratorError2 = err;
|
|
161
|
+
} finally {
|
|
162
|
+
try {
|
|
163
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
164
|
+
_iterator2.return();
|
|
165
|
+
}
|
|
166
|
+
} finally {
|
|
167
|
+
if (_didIteratorError2) {
|
|
168
|
+
throw _iteratorError2;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
var oldHtml = compilation.assets[htmlName];
|
|
173
|
+
var enableInlineRouteManifests = _this1.enableInlineRouteManifests, disableFilenameHash = _this1.disableFilenameHash, staticJsDir = _this1.staticJsDir, scriptLoading = _this1.scriptLoading, nonce = _this1.nonce;
|
|
174
|
+
var nonceAttr = nonce ? 'nonce="'.concat(nonce, '"') : "";
|
|
175
|
+
if (enableInlineRouteManifests) {
|
|
176
|
+
compilation.updateAsset(
|
|
177
|
+
htmlName,
|
|
178
|
+
new RawSource(oldHtml.source().toString().replace(placeholder, "<script ".concat(nonceAttr, ">").concat(injectedContent, "</script>"))),
|
|
179
|
+
// FIXME: The arguments third of updatgeAsset is a optional function in webpack.
|
|
180
|
+
void 0
|
|
181
|
+
);
|
|
182
|
+
} else {
|
|
183
|
+
var scriptPath = "".concat(staticJsDir, "/").concat(ROUTE_MANIFEST_HOLDER, "-").concat(entryName).concat(disableFilenameHash ? ".js" : ".".concat(generateContentHash(injectedContent), ".js"));
|
|
184
|
+
var scriptUrl = "".concat(publicPath).concat(scriptPath);
|
|
185
|
+
var scriptLoadingAttr = (
|
|
186
|
+
// eslint-disable-next-line no-nested-ternary
|
|
187
|
+
scriptLoading === "defer" ? scriptLoading : scriptLoading === "module" ? 'type="module"' : ""
|
|
188
|
+
);
|
|
189
|
+
var script = "<script ".concat(scriptLoadingAttr, " ").concat(nonceAttr, ' src="').concat(scriptUrl, '"></script>');
|
|
190
|
+
compilation.updateAsset(
|
|
191
|
+
htmlName,
|
|
192
|
+
new RawSource(oldHtml.source().toString().replace(placeholder, script)),
|
|
193
|
+
// FIXME: The arguments third of updatgeAsset is a optional function in webpack.
|
|
194
|
+
void 0
|
|
195
|
+
);
|
|
196
|
+
compilation.emitAsset(scriptPath, new RawSource(injectedContent));
|
|
197
|
+
}
|
|
198
|
+
};
|
|
86
199
|
stats = compilation.getStats().toJson({
|
|
87
200
|
all: false,
|
|
201
|
+
publicPath: true,
|
|
202
|
+
assets: true,
|
|
88
203
|
chunkGroups: true,
|
|
89
204
|
chunks: true,
|
|
90
205
|
ids: true
|
|
91
206
|
});
|
|
92
|
-
_stats_chunks = stats.chunks, chunks = _stats_chunks === void 0 ? [] : _stats_chunks, namedChunkGroups = stats.namedChunkGroups;
|
|
207
|
+
publicPath = stats.publicPath, _stats_chunks = stats.chunks, chunks = _stats_chunks === void 0 ? [] : _stats_chunks, namedChunkGroups = stats.namedChunkGroups;
|
|
208
|
+
routeAssets = {};
|
|
93
209
|
if (!namedChunkGroups) {
|
|
94
210
|
return [
|
|
95
211
|
2
|
|
96
212
|
];
|
|
97
213
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return fname.includes(".js");
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
entryChunkFileIds = entryChunks.map(function(chunk) {
|
|
105
|
-
return chunk.id;
|
|
214
|
+
prevManifestAsset = compilation.getAsset(ROUTE_MANIFEST_FILE);
|
|
215
|
+
prevManifestStr = prevManifestAsset ? prevManifestAsset.source.source().toString() : JSON.stringify({
|
|
216
|
+
routeAssets: {}
|
|
106
217
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
218
|
+
prevManifest = JSON.parse(prevManifestStr);
|
|
219
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
220
|
+
try {
|
|
221
|
+
for (_iterator = Object.entries(namedChunkGroups)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
222
|
+
_step_value = _sliced_to_array(_step.value, 2), name = _step_value[0], chunkGroup = _step_value[1];
|
|
223
|
+
assets = chunkGroup.assets.map(function(asset) {
|
|
224
|
+
var filename = asset.name;
|
|
225
|
+
return publicPath ? normalizePath(publicPath) + filename : filename;
|
|
226
|
+
});
|
|
227
|
+
referenceCssAssets = assets.filter(function(asset) {
|
|
228
|
+
return /\.css$/.test(asset);
|
|
229
|
+
});
|
|
230
|
+
routeAssets[name] = {
|
|
231
|
+
chunkIds: chunkGroup.chunks,
|
|
232
|
+
assets: assets,
|
|
233
|
+
referenceCssAssets: referenceCssAssets
|
|
234
|
+
};
|
|
235
|
+
if (prevManifest.routeAssets[name]) {
|
|
236
|
+
mergeWith(routeAssets[name], prevManifest.routeAssets[name], function(obj, source) {
|
|
237
|
+
if (Array.isArray(obj)) {
|
|
238
|
+
return obj.concat(source);
|
|
239
|
+
}
|
|
240
|
+
return Object.assign(source, obj);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
} catch (err) {
|
|
245
|
+
_didIteratorError = true;
|
|
246
|
+
_iteratorError = err;
|
|
247
|
+
} finally {
|
|
248
|
+
try {
|
|
249
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
250
|
+
_iterator.return();
|
|
251
|
+
}
|
|
252
|
+
} finally {
|
|
253
|
+
if (_didIteratorError) {
|
|
254
|
+
throw _iteratorError;
|
|
255
|
+
}
|
|
113
256
|
}
|
|
114
|
-
map = asset.sourceAndMap().map;
|
|
115
|
-
chunkToMap.set(chunkId, map);
|
|
116
|
-
}
|
|
117
|
-
return [
|
|
118
|
-
2
|
|
119
|
-
];
|
|
120
|
-
});
|
|
121
|
-
}));
|
|
122
|
-
var _this2 = _this;
|
|
123
|
-
compilation.hooks.processAssets.tapPromise({
|
|
124
|
-
name: PLUGIN_NAME,
|
|
125
|
-
stage: Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
126
|
-
}, /* @__PURE__ */ _async_to_generator(function() {
|
|
127
|
-
var stats, _stats_chunks, chunks, namedChunkGroups, entryChunks, entryChunkFiles, entryChunkFileIds, i, file, chunkId, asset, source;
|
|
128
|
-
return _ts_generator(this, function(_state) {
|
|
129
|
-
stats = compilation.getStats().toJson({
|
|
130
|
-
all: false,
|
|
131
|
-
chunkGroups: true,
|
|
132
|
-
chunks: true,
|
|
133
|
-
ids: true
|
|
134
|
-
});
|
|
135
|
-
_stats_chunks = stats.chunks, chunks = _stats_chunks === void 0 ? [] : _stats_chunks, namedChunkGroups = stats.namedChunkGroups;
|
|
136
|
-
if (!namedChunkGroups) {
|
|
137
|
-
return [
|
|
138
|
-
2
|
|
139
|
-
];
|
|
140
257
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
258
|
+
manifest = {
|
|
259
|
+
routeAssets: routeAssets
|
|
260
|
+
};
|
|
261
|
+
entryNames = Array.from(compilation.entrypoints.keys());
|
|
262
|
+
entryChunks = _this1.getEntryChunks(compilation, chunks);
|
|
263
|
+
entryChunkFiles = _this1.getEntryChunkFiles(entryChunks);
|
|
147
264
|
entryChunkFileIds = entryChunks.map(function(chunk) {
|
|
148
265
|
return chunk.id;
|
|
149
266
|
});
|
|
150
|
-
for (i = 0; i
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
267
|
+
for (i = 0; i < entryChunkFiles.length; i++)
|
|
268
|
+
_loop(i);
|
|
269
|
+
if (prevManifestAsset) {
|
|
270
|
+
compilation.updateAsset(
|
|
271
|
+
ROUTE_MANIFEST_FILE,
|
|
272
|
+
new RawSource(JSON.stringify(manifest, null, 2)),
|
|
273
|
+
// FIXME: The arguments third of updatgeAsset is a optional function in webpack.
|
|
274
|
+
void 0
|
|
275
|
+
);
|
|
276
|
+
} else {
|
|
277
|
+
compilation.emitAsset(ROUTE_MANIFEST_FILE, new RawSource(JSON.stringify(manifest, null, 2)));
|
|
159
278
|
}
|
|
160
279
|
return [
|
|
161
280
|
2
|
|
162
281
|
];
|
|
163
282
|
});
|
|
164
283
|
}));
|
|
165
|
-
var _this3 = _this;
|
|
166
|
-
compilation.hooks.processAssets.tapPromise({
|
|
167
|
-
name: PLUGIN_NAME,
|
|
168
|
-
stage: Compilation.PROCESS_ASSETS_STAGE_REPORT
|
|
169
|
-
}, /* @__PURE__ */ _async_to_generator(function() {
|
|
170
|
-
var _loop, stats, publicPath, _stats_chunks, chunks, namedChunkGroups, routeAssets, prevManifestAsset, prevManifestStr, prevManifest, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, name, chunkGroup, assets, referenceCssAssets, manifest, entryChunks, entryChunkFiles, entryChunkFileIds, i;
|
|
171
|
-
return _ts_generator(this, function(_state) {
|
|
172
|
-
switch (_state.label) {
|
|
173
|
-
case 0:
|
|
174
|
-
_loop = function(i2) {
|
|
175
|
-
var _source, _source1, file, chunkNames, chunkId, asset, relatedAssets, manifest2, injectedContent, source, map, newContent, result, newSource;
|
|
176
|
-
return _ts_generator(this, function(_state2) {
|
|
177
|
-
switch (_state2.label) {
|
|
178
|
-
case 0:
|
|
179
|
-
file = entryChunkFiles[i2];
|
|
180
|
-
chunkNames = entryChunks[i2].names;
|
|
181
|
-
chunkId = entryChunkFileIds[i2];
|
|
182
|
-
asset = compilation.assets[file];
|
|
183
|
-
if (!asset || !chunkId) {
|
|
184
|
-
return [
|
|
185
|
-
2,
|
|
186
|
-
"continue"
|
|
187
|
-
];
|
|
188
|
-
}
|
|
189
|
-
relatedAssets = {};
|
|
190
|
-
if (entryChunkFiles.length > 1) {
|
|
191
|
-
Object.keys(routeAssets).forEach(function(routeId) {
|
|
192
|
-
var _chunkNames;
|
|
193
|
-
var segments = routeId.split("_");
|
|
194
|
-
var chunkName = segments[0];
|
|
195
|
-
if ((_chunkNames = chunkNames) === null || _chunkNames === void 0 ? void 0 : _chunkNames.includes(chunkName)) {
|
|
196
|
-
relatedAssets[routeId] = routeAssets[routeId];
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
} else {
|
|
200
|
-
relatedAssets = routeAssets;
|
|
201
|
-
}
|
|
202
|
-
manifest2 = {
|
|
203
|
-
routeAssets: relatedAssets
|
|
204
|
-
};
|
|
205
|
-
injectedContent = "\n ;(function(){\n window.".concat(ROUTE_MANIFEST, " = ").concat(JSON.stringify(manifest2, function(k, v) {
|
|
206
|
-
if ((k === "assets" || k === "referenceCssAssets") && Array.isArray(v)) {
|
|
207
|
-
return v.map(function(item) {
|
|
208
|
-
return item.replace(publicPath, "");
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
return v;
|
|
212
|
-
}), ";\n })();\n ");
|
|
213
|
-
source = chunkToSource.get(chunkId);
|
|
214
|
-
map = chunkToMap.get(chunkId);
|
|
215
|
-
newContent = "".concat(injectedContent).concat((_source = source) === null || _source === void 0 ? void 0 : _source.toString());
|
|
216
|
-
return [
|
|
217
|
-
4,
|
|
218
|
-
transform(newContent, {
|
|
219
|
-
loader: path.extname(file).slice(1),
|
|
220
|
-
sourcemap: true,
|
|
221
|
-
minify: minimize
|
|
222
|
-
})
|
|
223
|
-
];
|
|
224
|
-
case 1:
|
|
225
|
-
result = _state2.sent();
|
|
226
|
-
newSource = new SourceMapSource(result.code, file, result.map, (_source1 = source) === null || _source1 === void 0 ? void 0 : _source1.toString(), map);
|
|
227
|
-
compilation.updateAsset(
|
|
228
|
-
file,
|
|
229
|
-
newSource,
|
|
230
|
-
// FIXME: The arguments third of updatgeAsset is a optional function in webpack.
|
|
231
|
-
void 0
|
|
232
|
-
);
|
|
233
|
-
return [
|
|
234
|
-
2
|
|
235
|
-
];
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
};
|
|
239
|
-
stats = compilation.getStats().toJson({
|
|
240
|
-
all: false,
|
|
241
|
-
publicPath: true,
|
|
242
|
-
assets: true,
|
|
243
|
-
chunkGroups: true,
|
|
244
|
-
chunks: true,
|
|
245
|
-
ids: true
|
|
246
|
-
});
|
|
247
|
-
publicPath = stats.publicPath, _stats_chunks = stats.chunks, chunks = _stats_chunks === void 0 ? [] : _stats_chunks, namedChunkGroups = stats.namedChunkGroups;
|
|
248
|
-
routeAssets = {};
|
|
249
|
-
if (!namedChunkGroups) {
|
|
250
|
-
return [
|
|
251
|
-
2
|
|
252
|
-
];
|
|
253
|
-
}
|
|
254
|
-
prevManifestAsset = compilation.getAsset(ROUTE_MANIFEST_FILE);
|
|
255
|
-
prevManifestStr = prevManifestAsset ? prevManifestAsset.source.source().toString() : JSON.stringify({
|
|
256
|
-
routeAssets: {}
|
|
257
|
-
});
|
|
258
|
-
prevManifest = JSON.parse(prevManifestStr);
|
|
259
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
260
|
-
try {
|
|
261
|
-
for (_iterator = Object.entries(namedChunkGroups)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
262
|
-
_step_value = _sliced_to_array(_step.value, 2), name = _step_value[0], chunkGroup = _step_value[1];
|
|
263
|
-
assets = chunkGroup.assets.map(function(asset) {
|
|
264
|
-
var filename = asset.name;
|
|
265
|
-
return publicPath ? normalizePath(publicPath) + filename : filename;
|
|
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
|
-
if (prevManifest.routeAssets[name]) {
|
|
276
|
-
mergeWith(routeAssets[name], prevManifest.routeAssets[name], function(obj, source) {
|
|
277
|
-
if (Array.isArray(obj)) {
|
|
278
|
-
return obj.concat(source);
|
|
279
|
-
}
|
|
280
|
-
return Object.assign(source, obj);
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
} catch (err) {
|
|
285
|
-
_didIteratorError = true;
|
|
286
|
-
_iteratorError = err;
|
|
287
|
-
} finally {
|
|
288
|
-
try {
|
|
289
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
290
|
-
_iterator.return();
|
|
291
|
-
}
|
|
292
|
-
} finally {
|
|
293
|
-
if (_didIteratorError) {
|
|
294
|
-
throw _iteratorError;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
manifest = {
|
|
299
|
-
routeAssets: routeAssets
|
|
300
|
-
};
|
|
301
|
-
entryChunks = _this3.getEntryChunks(compilation, chunks);
|
|
302
|
-
entryChunkFiles = _this3.getEntryChunkFiles(entryChunks);
|
|
303
|
-
entryChunkFileIds = entryChunks.map(function(chunk) {
|
|
304
|
-
return chunk.id;
|
|
305
|
-
});
|
|
306
|
-
i = 0;
|
|
307
|
-
_state.label = 1;
|
|
308
|
-
case 1:
|
|
309
|
-
if (!(i < entryChunkFiles.length))
|
|
310
|
-
return [
|
|
311
|
-
3,
|
|
312
|
-
4
|
|
313
|
-
];
|
|
314
|
-
return [
|
|
315
|
-
5,
|
|
316
|
-
_ts_values(_loop(i))
|
|
317
|
-
];
|
|
318
|
-
case 2:
|
|
319
|
-
_state.sent();
|
|
320
|
-
_state.label = 3;
|
|
321
|
-
case 3:
|
|
322
|
-
i++;
|
|
323
|
-
return [
|
|
324
|
-
3,
|
|
325
|
-
1
|
|
326
|
-
];
|
|
327
|
-
case 4:
|
|
328
|
-
if (prevManifestAsset) {
|
|
329
|
-
compilation.updateAsset(
|
|
330
|
-
ROUTE_MANIFEST_FILE,
|
|
331
|
-
new RawSource(JSON.stringify(manifest, null, 2)),
|
|
332
|
-
// FIXME: The arguments third of updatgeAsset is a optional function in webpack.
|
|
333
|
-
void 0
|
|
334
|
-
);
|
|
335
|
-
} else {
|
|
336
|
-
compilation.emitAsset(ROUTE_MANIFEST_FILE, new RawSource(JSON.stringify(manifest, null, 2)));
|
|
337
|
-
}
|
|
338
|
-
return [
|
|
339
|
-
2
|
|
340
|
-
];
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
}));
|
|
344
284
|
});
|
|
345
285
|
}
|
|
346
286
|
}
|
|
@@ -12,7 +12,8 @@ export function createDefaultConfig(appContext, bundler) {
|
|
|
12
12
|
port: void 0
|
|
13
13
|
});
|
|
14
14
|
var output = _object_spread_props(_object_spread({}, defaultBuilderConfig.output), {
|
|
15
|
-
disableNodePolyfill: true
|
|
15
|
+
disableNodePolyfill: true,
|
|
16
|
+
enableInlineRouteManifests: true
|
|
16
17
|
});
|
|
17
18
|
var _obj;
|
|
18
19
|
var source = _object_spread_props(_object_spread({}, defaultBuilderConfig.source), {
|
package/dist/esm/schema/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -26,6 +26,7 @@ export const getHtmlTemplate = async (entrypoints, api, { appContext, config })
|
|
|
26
26
|
const { source: { configDir } } = config;
|
|
27
27
|
const htmlDir = path.resolve(appDirectory, configDir || "", HTML_PARTIALS_FOLDER);
|
|
28
28
|
const htmlTemplates = {};
|
|
29
|
+
const partialsByEntrypoint = {};
|
|
29
30
|
for (const entrypoint of entrypoints) {
|
|
30
31
|
const { entryName, isMainEntry } = entrypoint;
|
|
31
32
|
const name = entrypoints.length === 1 && isMainEntry ? "" : entryName;
|
|
@@ -55,11 +56,16 @@ export const getHtmlTemplate = async (entrypoints, api, { appContext, config })
|
|
|
55
56
|
const templatePath = path.resolve(internalDirectory, entryName, "index.html");
|
|
56
57
|
fs.outputFileSync(templatePath, templates.html(partials), "utf8");
|
|
57
58
|
htmlTemplates[entryName] = templatePath;
|
|
59
|
+
partialsByEntrypoint[entryName] = partials;
|
|
58
60
|
const bottomTemplate = findPartials(htmlDir, name, PartialPosition.BOTTOM);
|
|
59
61
|
if (bottomTemplate) {
|
|
60
62
|
htmlTemplates[`__${entryName}-bottom__`] = bottomTemplate.content;
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
}
|
|
66
|
+
api.setAppContext({
|
|
67
|
+
...api.useAppContext(),
|
|
68
|
+
partialsByEntrypoint
|
|
69
|
+
});
|
|
64
70
|
return htmlTemplates;
|
|
65
71
|
};
|
|
@@ -43,8 +43,7 @@ export const optimizeRoute = (routeTree) => {
|
|
|
43
43
|
];
|
|
44
44
|
}
|
|
45
45
|
const { children } = routeTree;
|
|
46
|
-
|
|
47
|
-
if (!routeTree._component && !routeTree.error && !routeTree.loading && !routeTree.config && !hasPage) {
|
|
46
|
+
if (!routeTree._component && !routeTree.error && !routeTree.loading && !routeTree.config) {
|
|
48
47
|
const newRoutes = children.map((child) => {
|
|
49
48
|
const routePath = `${routeTree.path ? routeTree.path : ""}${child.path ? `/${child.path}` : ""}`;
|
|
50
49
|
const newRoute = {
|
|
@@ -20,7 +20,7 @@ export const builderPluginAdapterSSR = (options) => ({
|
|
|
20
20
|
api.modifyBundlerChain(async (chain, { target, CHAIN_ID, isProd, HtmlPlugin: HtmlBundlerPlugin, isServer }) => {
|
|
21
21
|
const builderConfig = api.getNormalizedConfig();
|
|
22
22
|
const { normalizedConfig: normalizedConfig2 } = options;
|
|
23
|
-
applyRouterPlugin(chain, options);
|
|
23
|
+
applyRouterPlugin(chain, options, HtmlBundlerPlugin);
|
|
24
24
|
if (isSSR(normalizedConfig2)) {
|
|
25
25
|
await applySSRLoaderEntry(chain, options, isServer);
|
|
26
26
|
applySSRDataLoader(chain, options);
|
|
@@ -69,7 +69,7 @@ function applyAsyncChunkHtmlPlugin({ chain, modernConfig, CHAIN_ID, HtmlBundlerP
|
|
|
69
69
|
]);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
function applyRouterPlugin(chain, options) {
|
|
72
|
+
function applyRouterPlugin(chain, options, HtmlBundlerPlugin) {
|
|
73
73
|
var _normalizedConfig_runtime, _normalizedConfig, _routerConfig, _normalizedConfig_deploy_worker;
|
|
74
74
|
const { appContext, normalizedConfig } = options;
|
|
75
75
|
const { entrypoints } = appContext;
|
|
@@ -78,7 +78,17 @@ function applyRouterPlugin(chain, options) {
|
|
|
78
78
|
const routerManifest = Boolean((_routerConfig = routerConfig) === null || _routerConfig === void 0 ? void 0 : _routerConfig.manifest);
|
|
79
79
|
const workerSSR = Boolean((_normalizedConfig_deploy_worker = normalizedConfig.deploy.worker) === null || _normalizedConfig_deploy_worker === void 0 ? void 0 : _normalizedConfig_deploy_worker.ssr);
|
|
80
80
|
if (existNestedRoutes || routerManifest || workerSSR) {
|
|
81
|
-
|
|
81
|
+
var _normalizedConfig_output_distPath, _normalizedConfig_output, _normalizedConfig_output1, _normalizedConfig_html, _normalizedConfig_security;
|
|
82
|
+
chain.plugin("route-plugin").use(RouterPlugin, [
|
|
83
|
+
{
|
|
84
|
+
HtmlBundlerPlugin,
|
|
85
|
+
enableInlineRouteManifests: normalizedConfig.output.enableInlineRouteManifests,
|
|
86
|
+
staticJsDir: (_normalizedConfig_output = normalizedConfig.output) === null || _normalizedConfig_output === void 0 ? void 0 : (_normalizedConfig_output_distPath = _normalizedConfig_output.distPath) === null || _normalizedConfig_output_distPath === void 0 ? void 0 : _normalizedConfig_output_distPath.js,
|
|
87
|
+
disableFilenameHash: (_normalizedConfig_output1 = normalizedConfig.output) === null || _normalizedConfig_output1 === void 0 ? void 0 : _normalizedConfig_output1.disableFilenameHash,
|
|
88
|
+
scriptLoading: (_normalizedConfig_html = normalizedConfig.html) === null || _normalizedConfig_html === void 0 ? void 0 : _normalizedConfig_html.scriptLoading,
|
|
89
|
+
nonce: (_normalizedConfig_security = normalizedConfig.security) === null || _normalizedConfig_security === void 0 ? void 0 : _normalizedConfig_security.nonce
|
|
90
|
+
}
|
|
91
|
+
]);
|
|
82
92
|
}
|
|
83
93
|
}
|
|
84
94
|
function applyFilterEntriesBySSRConfig({ isProd, chain, appNormalizedConfig }) {
|