@modern-js/app-tools 2.35.2-alpha.0 → 2.36.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/dist/cjs/analyze/index.js +5 -7
- package/dist/cjs/analyze/nestedRoutes.js +3 -0
- package/dist/cjs/analyze/templates.js +1 -1
- package/dist/cjs/builder/builder-rspack/adapterCopy.js +14 -10
- package/dist/cjs/builder/builder-webpack/adapterModern.js +0 -2
- package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +2 -0
- package/dist/cjs/config/initialize/inits.js +0 -16
- package/dist/esm/analyze/index.js +5 -7
- package/dist/esm/analyze/nestedRoutes.js +3 -0
- package/dist/esm/analyze/templates.js +1 -1
- package/dist/esm/builder/builder-rspack/adapterCopy.js +12 -8
- package/dist/esm/builder/builder-webpack/adapterModern.js +0 -2
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +2 -0
- package/dist/esm/config/initialize/inits.js +2 -17
- package/dist/esm-node/analyze/index.js +5 -7
- package/dist/esm-node/analyze/nestedRoutes.js +3 -0
- package/dist/esm-node/analyze/templates.js +1 -1
- package/dist/esm-node/builder/builder-rspack/adapterCopy.js +14 -10
- package/dist/esm-node/builder/builder-webpack/adapterModern.js +0 -2
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +2 -0
- package/dist/esm-node/config/initialize/inits.js +2 -18
- package/package.json +24 -24
- 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,468 +0,0 @@
|
|
1
|
-
function _arrayLikeToArray(arr, len) {
|
2
|
-
if (len == null || len > arr.length) len = arr.length;
|
3
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
4
|
-
return arr2;
|
5
|
-
}
|
6
|
-
function _arrayWithHoles(arr) {
|
7
|
-
if (Array.isArray(arr)) return arr;
|
8
|
-
}
|
9
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
10
|
-
try {
|
11
|
-
var info = gen[key](arg);
|
12
|
-
var value = info.value;
|
13
|
-
} catch (error) {
|
14
|
-
reject(error);
|
15
|
-
return;
|
16
|
-
}
|
17
|
-
if (info.done) {
|
18
|
-
resolve(value);
|
19
|
-
} else {
|
20
|
-
Promise.resolve(value).then(_next, _throw);
|
21
|
-
}
|
22
|
-
}
|
23
|
-
function _asyncToGenerator(fn) {
|
24
|
-
return function() {
|
25
|
-
var self = this, args = arguments;
|
26
|
-
return new Promise(function(resolve, reject) {
|
27
|
-
var gen = fn.apply(self, args);
|
28
|
-
function _next(value) {
|
29
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
30
|
-
}
|
31
|
-
function _throw(err) {
|
32
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
33
|
-
}
|
34
|
-
_next(undefined);
|
35
|
-
});
|
36
|
-
};
|
37
|
-
}
|
38
|
-
function _defineProperty(obj, key, value) {
|
39
|
-
if (key in obj) {
|
40
|
-
Object.defineProperty(obj, key, {
|
41
|
-
value: value,
|
42
|
-
enumerable: true,
|
43
|
-
configurable: true,
|
44
|
-
writable: true
|
45
|
-
});
|
46
|
-
} else {
|
47
|
-
obj[key] = value;
|
48
|
-
}
|
49
|
-
return obj;
|
50
|
-
}
|
51
|
-
function _iterableToArrayLimit(arr, i) {
|
52
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
53
|
-
if (_i == null) return;
|
54
|
-
var _arr = [];
|
55
|
-
var _n = true;
|
56
|
-
var _d = false;
|
57
|
-
var _s, _e;
|
58
|
-
try {
|
59
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
60
|
-
_arr.push(_s.value);
|
61
|
-
if (i && _arr.length === i) break;
|
62
|
-
}
|
63
|
-
} catch (err) {
|
64
|
-
_d = true;
|
65
|
-
_e = err;
|
66
|
-
} finally{
|
67
|
-
try {
|
68
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
69
|
-
} finally{
|
70
|
-
if (_d) throw _e;
|
71
|
-
}
|
72
|
-
}
|
73
|
-
return _arr;
|
74
|
-
}
|
75
|
-
function _nonIterableRest() {
|
76
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
77
|
-
}
|
78
|
-
function _objectSpread(target) {
|
79
|
-
for(var i = 1; i < arguments.length; i++){
|
80
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
81
|
-
var ownKeys = Object.keys(source);
|
82
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
83
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
84
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
85
|
-
}));
|
86
|
-
}
|
87
|
-
ownKeys.forEach(function(key) {
|
88
|
-
_defineProperty(target, key, source[key]);
|
89
|
-
});
|
90
|
-
}
|
91
|
-
return target;
|
92
|
-
}
|
93
|
-
function ownKeys(object, enumerableOnly) {
|
94
|
-
var keys = Object.keys(object);
|
95
|
-
if (Object.getOwnPropertySymbols) {
|
96
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
97
|
-
if (enumerableOnly) {
|
98
|
-
symbols = symbols.filter(function(sym) {
|
99
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
100
|
-
});
|
101
|
-
}
|
102
|
-
keys.push.apply(keys, symbols);
|
103
|
-
}
|
104
|
-
return keys;
|
105
|
-
}
|
106
|
-
function _objectSpreadProps(target, source) {
|
107
|
-
source = source != null ? source : {};
|
108
|
-
if (Object.getOwnPropertyDescriptors) {
|
109
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
110
|
-
} else {
|
111
|
-
ownKeys(Object(source)).forEach(function(key) {
|
112
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
113
|
-
});
|
114
|
-
}
|
115
|
-
return target;
|
116
|
-
}
|
117
|
-
function _slicedToArray(arr, i) {
|
118
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
119
|
-
}
|
120
|
-
function _unsupportedIterableToArray(o, minLen) {
|
121
|
-
if (!o) return;
|
122
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
123
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
124
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
125
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
126
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
127
|
-
}
|
128
|
-
var __generator = this && this.__generator || function(thisArg, body) {
|
129
|
-
var f, y, t, g, _ = {
|
130
|
-
label: 0,
|
131
|
-
sent: function() {
|
132
|
-
if (t[0] & 1) throw t[1];
|
133
|
-
return t[1];
|
134
|
-
},
|
135
|
-
trys: [],
|
136
|
-
ops: []
|
137
|
-
};
|
138
|
-
return(g = {
|
139
|
-
next: verb(0),
|
140
|
-
"throw": verb(1),
|
141
|
-
"return": verb(2)
|
142
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
143
|
-
return this;
|
144
|
-
}), g);
|
145
|
-
function verb(n) {
|
146
|
-
return function(v) {
|
147
|
-
return step([
|
148
|
-
n,
|
149
|
-
v
|
150
|
-
]);
|
151
|
-
};
|
152
|
-
}
|
153
|
-
function step(op) {
|
154
|
-
if (f) throw new TypeError("Generator is already executing.");
|
155
|
-
while(_)try {
|
156
|
-
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) return t;
|
157
|
-
if (y = 0, t) op = [
|
158
|
-
op[0] & 2,
|
159
|
-
t.value
|
160
|
-
];
|
161
|
-
switch(op[0]){
|
162
|
-
case 0:
|
163
|
-
case 1:
|
164
|
-
t = op;
|
165
|
-
break;
|
166
|
-
case 4:
|
167
|
-
_.label++;
|
168
|
-
return {
|
169
|
-
value: op[1],
|
170
|
-
done: false
|
171
|
-
};
|
172
|
-
case 5:
|
173
|
-
_.label++;
|
174
|
-
y = op[1];
|
175
|
-
op = [
|
176
|
-
0
|
177
|
-
];
|
178
|
-
continue;
|
179
|
-
case 7:
|
180
|
-
op = _.ops.pop();
|
181
|
-
_.trys.pop();
|
182
|
-
continue;
|
183
|
-
default:
|
184
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
185
|
-
_ = 0;
|
186
|
-
continue;
|
187
|
-
}
|
188
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
189
|
-
_.label = op[1];
|
190
|
-
break;
|
191
|
-
}
|
192
|
-
if (op[0] === 6 && _.label < t[1]) {
|
193
|
-
_.label = t[1];
|
194
|
-
t = op;
|
195
|
-
break;
|
196
|
-
}
|
197
|
-
if (t && _.label < t[2]) {
|
198
|
-
_.label = t[2];
|
199
|
-
_.ops.push(op);
|
200
|
-
break;
|
201
|
-
}
|
202
|
-
if (t[2]) _.ops.pop();
|
203
|
-
_.trys.pop();
|
204
|
-
continue;
|
205
|
-
}
|
206
|
-
op = body.call(thisArg, _);
|
207
|
-
} catch (e) {
|
208
|
-
op = [
|
209
|
-
6,
|
210
|
-
e
|
211
|
-
];
|
212
|
-
y = 0;
|
213
|
-
} finally{
|
214
|
-
f = t = 0;
|
215
|
-
}
|
216
|
-
if (op[0] & 5) throw op[1];
|
217
|
-
return {
|
218
|
-
value: op[0] ? op[1] : void 0,
|
219
|
-
done: true
|
220
|
-
};
|
221
|
-
}
|
222
|
-
};
|
223
|
-
import path from "path";
|
224
|
-
import { fs, slash } from "@modern-js/utils";
|
225
|
-
import { APP_CONFIG_NAME, TEMP_LOADERS_DIR } from "./constants";
|
226
|
-
var index = function(param) {
|
227
|
-
var mountId = param.mountId, imports = param.imports, renderFunction2 = param.renderFunction, exportStatement = param.exportStatement;
|
228
|
-
return "\nconst IS_BROWSER = typeof window !== 'undefined' && window.name !== 'nodejs';\nconst IS_REACT18 = process.env.IS_REACT18 === 'true';\nconst MOUNT_ID = '".concat(mountId, "';\n\n").concat(imports, "\n\nlet AppWrapper = null;\n\nlet root = null;\n\nfunction render() {\n ").concat(renderFunction2, "\n}\n\nAppWrapper = render();\n\n").concat(exportStatement, ";\n");
|
229
|
-
};
|
230
|
-
var renderFunction = function(param) {
|
231
|
-
var plugins = param.plugins, customBootstrap = param.customBootstrap, fileSystemRoutes2 = param.fileSystemRoutes;
|
232
|
-
return "\n const finalAppConfig = {\n ...App.config,\n ...typeof ".concat(APP_CONFIG_NAME, " === 'function' ? ").concat(APP_CONFIG_NAME, "() : {},\n }\n\n AppWrapper = createApp({\n plugins: [\n ").concat(plugins.map(function(param) {
|
233
|
-
var name = param.name, options = param.options, args = param.args;
|
234
|
-
return "".concat(name, "({...").concat(options, ", ...finalAppConfig?.").concat(args || name, "}),");
|
235
|
-
}).join("\n"), "\n ]\n })(").concat(fileSystemRoutes2 ? "" : "App", ")\n\n\n if(!AppWrapper.init && typeof appInit !== 'undefined') {\n AppWrapper.init = appInit;\n }\n\n\n if (IS_BROWSER) {\n ").concat(customBootstrap ? "customBootstrap(AppWrapper);" : "bootstrap(AppWrapper, MOUNT_ID, root, ReactDOM);", "\n }\n\n return AppWrapper\n");
|
236
|
-
};
|
237
|
-
var html = function(partials) {
|
238
|
-
return "\n<!DOCTYPE html>\n<html>\n<head>\n <%= meta %>\n <title><%= title %></title>\n\n ".concat(partials.top.join("\n"), "\n\n <script>\n window.__assetPrefix__ = '<%= assetPrefix %>';\n </script>\n ").concat(partials.head.join("\n"), "\n\n <!--<?- chunksMap.css ?>-->\n</head>\n\n<body>\n <noscript>\n We're sorry but react app doesn't work properly without JavaScript enabled. Please enable it to continue.\n </noscript>\n <div id=\"<%= mountId %>\"><!--<?- html ?>--></div>\n ").concat(partials.body.join("\n"), "\n <!--<?- chunksMap.js ?>-->\n <!--<?- SSRDataScript ?>-->\n <!--<?- bottomTemplate ?>-->\n</body>\n\n</html>\n");
|
239
|
-
};
|
240
|
-
var routesForServer = function(param) {
|
241
|
-
var routes = param.routes;
|
242
|
-
var loaders = [];
|
243
|
-
var traverseRouteTree = function(route) {
|
244
|
-
var children;
|
245
|
-
if ("children" in route && route.children) {
|
246
|
-
var ref;
|
247
|
-
children = route === null || route === void 0 ? void 0 : (ref = route.children) === null || ref === void 0 ? void 0 : ref.map(traverseRouteTree);
|
248
|
-
}
|
249
|
-
var loader;
|
250
|
-
if (route.type === "nested") {
|
251
|
-
if (route.loader) {
|
252
|
-
loaders.push(route.loader);
|
253
|
-
loader = "loader_".concat(loaders.length - 1);
|
254
|
-
}
|
255
|
-
}
|
256
|
-
var finalRoute = _objectSpreadProps(_objectSpread({}, route), {
|
257
|
-
loader: loader,
|
258
|
-
children: children
|
259
|
-
});
|
260
|
-
return finalRoute;
|
261
|
-
};
|
262
|
-
var routesCode = "\n export const routes = [\n ";
|
263
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
264
|
-
try {
|
265
|
-
for(var _iterator = routes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
266
|
-
var route = _step.value;
|
267
|
-
if ("type" in route) {
|
268
|
-
var newRoute = traverseRouteTree(route);
|
269
|
-
routesCode += "".concat(JSON.stringify(newRoute, null, 2).replace(/"(loader_[^"])"/g, "$1"), ",");
|
270
|
-
} else {
|
271
|
-
routesCode += "".concat(JSON.stringify(route, null, 2));
|
272
|
-
}
|
273
|
-
}
|
274
|
-
} catch (err) {
|
275
|
-
_didIteratorError = true;
|
276
|
-
_iteratorError = err;
|
277
|
-
} finally{
|
278
|
-
try {
|
279
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
280
|
-
_iterator.return();
|
281
|
-
}
|
282
|
-
} finally{
|
283
|
-
if (_didIteratorError) {
|
284
|
-
throw _iteratorError;
|
285
|
-
}
|
286
|
-
}
|
287
|
-
}
|
288
|
-
routesCode += "\n];";
|
289
|
-
var importLoadersCode = "";
|
290
|
-
if (loaders.length > 0) {
|
291
|
-
importLoadersCode = loaders.map(function(loader, index2) {
|
292
|
-
return "import loader_".concat(index2, ' from "').concat(slash(loader), '"');
|
293
|
-
}).join("\n");
|
294
|
-
}
|
295
|
-
return "\n ".concat(importLoadersCode, "\n ").concat(routesCode, "\n ");
|
296
|
-
};
|
297
|
-
var fileSystemRoutes = function() {
|
298
|
-
var _ref = _asyncToGenerator(function(param) {
|
299
|
-
var routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, loadings, errors, loaders, loadersMap, loadersMapFile, importLazyCode, rootLayoutCode, componentLoaderPath, getDataLoaderPath, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, component, finalRoute, importLoadingCode, importErrorComponentsCode, importLoadersCode, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _value, key, loaderInfo;
|
300
|
-
return __generator(this, function(_state) {
|
301
|
-
switch(_state.label){
|
302
|
-
case 0:
|
303
|
-
routes = param.routes, ssrMode = param.ssrMode, nestedRoutesEntry = param.nestedRoutesEntry, entryName = param.entryName, internalDirectory = param.internalDirectory;
|
304
|
-
loadings = [];
|
305
|
-
errors = [];
|
306
|
-
loaders = [];
|
307
|
-
loadersMap = {};
|
308
|
-
loadersMapFile = path.join(internalDirectory, entryName, TEMP_LOADERS_DIR, "map.json");
|
309
|
-
importLazyCode = '\n import { lazy } from "react";\n import loadable, { lazy as loadableLazy } from "@modern-js/runtime/loadable"\n ';
|
310
|
-
rootLayoutCode = "";
|
311
|
-
componentLoaderPath = "";
|
312
|
-
getDataLoaderPath = function(loaderId) {
|
313
|
-
if (!ssrMode) {
|
314
|
-
return "";
|
315
|
-
}
|
316
|
-
var dataLoaderPath = require.resolve("@modern-js/plugin-data-loader/loader");
|
317
|
-
if (nestedRoutesEntry) {
|
318
|
-
dataLoaderPath = "".concat(slash(dataLoaderPath), "?mapFile=").concat(slash(loadersMapFile), "&loaderId=").concat(loaderId, "!");
|
319
|
-
}
|
320
|
-
return dataLoaderPath;
|
321
|
-
};
|
322
|
-
if (ssrMode) {
|
323
|
-
componentLoaderPath = "".concat(path.join(__dirname, "../builder/loaders/routerLoader"), "!");
|
324
|
-
}
|
325
|
-
traverseRouteTree = function(route) {
|
326
|
-
var children;
|
327
|
-
if ("children" in route && route.children) {
|
328
|
-
var ref;
|
329
|
-
children = route === null || route === void 0 ? void 0 : (ref = route.children) === null || ref === void 0 ? void 0 : ref.map(traverseRouteTree);
|
330
|
-
}
|
331
|
-
var loading;
|
332
|
-
var error;
|
333
|
-
var loader;
|
334
|
-
var component = "";
|
335
|
-
var lazyImport = null;
|
336
|
-
if (route.type === "nested") {
|
337
|
-
if (route.loading) {
|
338
|
-
loadings.push(route.loading);
|
339
|
-
loading = "loading_".concat(loadings.length - 1);
|
340
|
-
}
|
341
|
-
if (route.error) {
|
342
|
-
errors.push(route.error);
|
343
|
-
error = "error_".concat(errors.length - 1);
|
344
|
-
}
|
345
|
-
if (route.loader) {
|
346
|
-
loaders.push(route.loader);
|
347
|
-
var loaderId = loaders.length - 1;
|
348
|
-
loader = "loader_".concat(loaderId);
|
349
|
-
loadersMap[loader] = {
|
350
|
-
routeId: route.id,
|
351
|
-
filePath: route.loader,
|
352
|
-
inline: false
|
353
|
-
};
|
354
|
-
}
|
355
|
-
if (route._component) {
|
356
|
-
if (route.isRoot) {
|
357
|
-
rootLayoutCode = "import RootLayout from '".concat(route._component, "'");
|
358
|
-
component = "RootLayout";
|
359
|
-
} else if (ssrMode === "string") {
|
360
|
-
lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(componentLoaderPath).concat(route._component, "')");
|
361
|
-
component = "loadable(".concat(lazyImport, ")");
|
362
|
-
} else {
|
363
|
-
lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(componentLoaderPath).concat(route._component, "')");
|
364
|
-
component = "lazy(".concat(lazyImport, ")");
|
365
|
-
}
|
366
|
-
}
|
367
|
-
} else if (route._component) {
|
368
|
-
lazyImport = "() => import('".concat(route._component, "')");
|
369
|
-
component = "loadable(".concat(lazyImport, ")");
|
370
|
-
}
|
371
|
-
var finalRoute = _objectSpreadProps(_objectSpread({}, route), {
|
372
|
-
lazyImport: lazyImport,
|
373
|
-
loading: loading,
|
374
|
-
loader: loader,
|
375
|
-
error: error,
|
376
|
-
children: children
|
377
|
-
});
|
378
|
-
if (route._component) {
|
379
|
-
finalRoute.component = component;
|
380
|
-
}
|
381
|
-
return finalRoute;
|
382
|
-
};
|
383
|
-
routeComponentsCode = "\n export const routes = [\n ";
|
384
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
385
|
-
try {
|
386
|
-
for(_iterator = routes[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
387
|
-
route = _step.value;
|
388
|
-
if ("type" in route) {
|
389
|
-
newRoute = traverseRouteTree(route);
|
390
|
-
routeComponentsCode += "".concat(JSON.stringify(newRoute, null, 2).replace(/"(loadable.*\))"/g, "$1").replace(/"(loadableLazy.*\))"/g, "$1").replace(/"(\(\)[^,]+)",/g, "$1,").replace(/"(lazy\(.*\))"/g, "$1").replace(/"(loading_[^"])"/g, "$1").replace(/"(loader_[^"])"/g, "$1").replace(/"(RootLayout)"/g, "$1").replace(/"(error_[^"])"/g, "$1").replace(/\\"/g, '"'), ",");
|
391
|
-
} else {
|
392
|
-
component = "loadable(() => import('".concat(route._component, "'))");
|
393
|
-
finalRoute = _objectSpreadProps(_objectSpread({}, route), {
|
394
|
-
component: component
|
395
|
-
});
|
396
|
-
routeComponentsCode += "".concat(JSON.stringify(finalRoute, null, 2).replace(/"(loadable[^"]*)"/g, "$1").replace(/"(lazy[^"]*)"/g, "$1"), ",");
|
397
|
-
}
|
398
|
-
}
|
399
|
-
} catch (err) {
|
400
|
-
_didIteratorError = true;
|
401
|
-
_iteratorError = err;
|
402
|
-
} finally{
|
403
|
-
try {
|
404
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
405
|
-
_iterator.return();
|
406
|
-
}
|
407
|
-
} finally{
|
408
|
-
if (_didIteratorError) {
|
409
|
-
throw _iteratorError;
|
410
|
-
}
|
411
|
-
}
|
412
|
-
}
|
413
|
-
routeComponentsCode += "\n];";
|
414
|
-
importLoadingCode = loadings.map(function(loading, index2) {
|
415
|
-
return "import loading_".concat(index2, " from '").concat(loading, "';\n");
|
416
|
-
}).join("");
|
417
|
-
importErrorComponentsCode = errors.map(function(error, index2) {
|
418
|
-
return "import error_".concat(index2, " from '").concat(error, "';\n");
|
419
|
-
}).join("");
|
420
|
-
importLoadersCode = "";
|
421
|
-
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
422
|
-
try {
|
423
|
-
for(_iterator1 = Object.entries(loadersMap)[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
424
|
-
_value = _slicedToArray(_step1.value, 2), key = _value[0], loaderInfo = _value[1];
|
425
|
-
if (loaderInfo.inline) {
|
426
|
-
importLoadersCode += "import { loader as ".concat(key, ' } from "').concat(getDataLoaderPath(key)).concat(slash(loaderInfo.filePath), '";\n');
|
427
|
-
} else {
|
428
|
-
importLoadersCode += "import ".concat(key, ' from "').concat(getDataLoaderPath(key)).concat(slash(loaderInfo.filePath), '";\n');
|
429
|
-
}
|
430
|
-
}
|
431
|
-
} catch (err) {
|
432
|
-
_didIteratorError1 = true;
|
433
|
-
_iteratorError1 = err;
|
434
|
-
} finally{
|
435
|
-
try {
|
436
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
437
|
-
_iterator1.return();
|
438
|
-
}
|
439
|
-
} finally{
|
440
|
-
if (_didIteratorError1) {
|
441
|
-
throw _iteratorError1;
|
442
|
-
}
|
443
|
-
}
|
444
|
-
}
|
445
|
-
return [
|
446
|
-
4,
|
447
|
-
fs.ensureFile(loadersMapFile)
|
448
|
-
];
|
449
|
-
case 1:
|
450
|
-
_state.sent();
|
451
|
-
return [
|
452
|
-
4,
|
453
|
-
fs.writeJSON(loadersMapFile, loadersMap)
|
454
|
-
];
|
455
|
-
case 2:
|
456
|
-
_state.sent();
|
457
|
-
return [
|
458
|
-
2,
|
459
|
-
"\n ".concat(importLazyCode, "\n ").concat(rootLayoutCode, "\n ").concat(importLoadingCode, "\n ").concat(importErrorComponentsCode, "\n ").concat(importLoadersCode, "\n ").concat(routeComponentsCode, "\n ")
|
460
|
-
];
|
461
|
-
}
|
462
|
-
});
|
463
|
-
});
|
464
|
-
return function fileSystemRoutes(_) {
|
465
|
-
return _ref.apply(this, arguments);
|
466
|
-
};
|
467
|
-
}();
|
468
|
-
export { fileSystemRoutes, html, index, renderFunction, routesForServer };
|