@modern-js/app-tools 2.5.0-alpha.1 → 2.5.1-alpha.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/generateCode.js +15 -23
- package/dist/cjs/analyze/getBundleEntry.js +1 -1
- package/dist/cjs/analyze/index.js +0 -4
- package/dist/cjs/analyze/templates.js +1 -6
- package/dist/cjs/builder/builder-webpack/builderPlugins/compatModern.js +3 -3
- package/dist/cjs/builder/builder-webpack/index.js +5 -11
- package/dist/cjs/builder/generator/getBuilderTargets.js +1 -1
- package/dist/cjs/commands/dev.js +14 -6
- package/dist/cjs/config/legacy/createToolsConfig.js +4 -1
- package/dist/esm/analyze/generateCode.js +28 -40
- package/dist/esm/analyze/getBundleEntry.js +2 -2
- package/dist/esm/analyze/index.js +0 -1
- package/dist/esm/analyze/templates.js +2 -3
- package/dist/esm/builder/builder-webpack/builderPlugins/compatModern.js +2 -2
- package/dist/esm/builder/builder-webpack/index.js +7 -11
- package/dist/esm/builder/generator/getBuilderTargets.js +1 -1
- package/dist/esm/commands/dev.js +8 -3
- package/dist/esm/config/legacy/createToolsConfig.js +4 -1
- package/dist/esm-node/analyze/generateCode.js +16 -24
- package/dist/esm-node/analyze/getBundleEntry.js +3 -2
- package/dist/esm-node/analyze/index.js +0 -4
- package/dist/esm-node/analyze/templates.js +1 -6
- package/dist/esm-node/builder/builder-webpack/builderPlugins/compatModern.js +2 -2
- package/dist/esm-node/builder/builder-webpack/index.js +6 -12
- package/dist/esm-node/builder/generator/getBuilderTargets.js +1 -1
- package/dist/esm-node/commands/dev.js +14 -6
- package/dist/esm-node/config/legacy/createToolsConfig.js +4 -1
- package/dist/js/modern/analyze/constants.js +1 -3
- package/dist/js/modern/analyze/index.js +48 -45
- package/dist/js/modern/analyze/nestedRoutes.js +2 -22
- package/dist/js/modern/analyze/templates.js +9 -2
- package/dist/js/modern/builder/{shared/builderPlugins/adapterModern.js → builderPlugins/compatModern.js} +111 -81
- package/dist/js/modern/builder/index.js +133 -13
- package/dist/js/modern/builder/loaders/routerLoader.js +17 -0
- package/dist/js/modern/builder/{shared/loaders → loaders}/serverModuleLoader.js +0 -0
- package/dist/js/modern/builder/{shared/createCopyPattern.js → share.js} +0 -0
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +30 -0
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +37 -0
- package/dist/js/modern/builder/{builder-webpack/webpackPlugins/RouterPlugin.js → webpackPlugins/routerPlugin.js} +1 -1
- package/dist/js/modern/config/default.js +2 -2
- package/dist/js/modern/config/index.js +8 -3
- package/dist/js/modern/config/{legacy → initial}/createHtmlConfig.js +0 -0
- package/dist/js/modern/config/{legacy → initial}/createOutputConfig.js +0 -0
- package/dist/js/modern/config/{legacy → initial}/createSourceConfig.js +0 -0
- package/dist/js/modern/config/{legacy → initial}/createToolsConfig.js +0 -0
- package/dist/js/modern/config/initial/index.js +16 -0
- package/dist/js/modern/config/{initialize → initial}/inits.js +2 -4
- package/dist/js/modern/config/{legacy/index.js → initial/transformNormalizedConfig.js} +0 -4
- package/dist/js/modern/index.js +8 -18
- package/dist/js/modern/initialize/index.js +28 -36
- package/dist/js/modern/locale/zh.js +1 -1
- package/dist/js/node/analyze/constants.js +1 -3
- package/dist/js/node/analyze/index.js +49 -46
- package/dist/js/node/analyze/nestedRoutes.js +2 -22
- package/dist/js/node/analyze/templates.js +9 -2
- package/dist/js/node/builder/{shared/builderPlugins/adapterModern.js → builderPlugins/compatModern.js} +115 -86
- package/dist/js/node/builder/index.js +123 -14
- package/dist/js/node/builder/{generator/getBuilderTargets.js → loaders/routerLoader.js} +16 -13
- package/dist/js/node/builder/{shared/loaders → loaders}/serverModuleLoader.js +0 -0
- package/dist/js/node/builder/{shared/createCopyPattern.js → share.js} +3 -3
- package/dist/js/node/builder/{shared/bundlerPlugins/HtmlAsyncChunkPlugin.js → webpackPlugins/htmlAsyncChunkPlugin.js} +20 -17
- package/dist/js/node/builder/{shared/bundlerPlugins/HtmlBottomTemplate.js → webpackPlugins/htmlBottomTemplate.js} +24 -21
- package/dist/js/node/builder/{builder-webpack/webpackPlugins/RouterPlugin.js → webpackPlugins/routerPlugin.js} +5 -7
- package/dist/js/node/config/default.js +2 -2
- package/dist/js/node/config/index.js +19 -4
- package/dist/js/node/config/{legacy → initial}/createHtmlConfig.js +0 -0
- package/dist/js/node/config/{legacy → initial}/createOutputConfig.js +0 -0
- package/dist/js/node/config/{legacy → initial}/createSourceConfig.js +0 -0
- package/dist/js/node/config/{legacy → initial}/createToolsConfig.js +0 -0
- package/dist/js/node/config/{initialize → initial}/index.js +16 -10
- package/dist/js/node/config/{initialize → initial}/inits.js +2 -4
- package/dist/js/node/config/{legacy/index.js → initial/transformNormalizedConfig.js} +3 -8
- package/dist/js/node/index.js +8 -18
- package/dist/js/node/initialize/index.js +28 -35
- package/dist/js/node/locale/zh.js +1 -1
- package/dist/js/treeshaking/analyze/constants.js +1 -3
- package/dist/js/treeshaking/analyze/index.js +130 -135
- package/dist/js/treeshaking/analyze/nestedRoutes.js +1 -17
- package/dist/js/treeshaking/analyze/templates.js +7 -3
- package/dist/js/treeshaking/builder/{shared/builderPlugins/adapterModern.js → builderPlugins/compatModern.js} +156 -103
- package/dist/js/treeshaking/builder/index.js +228 -29
- package/dist/js/treeshaking/builder/loaders/routerLoader.js +13 -0
- package/dist/js/treeshaking/builder/{shared/loaders → loaders}/serverModuleLoader.js +0 -0
- package/dist/js/treeshaking/builder/{shared/createCopyPattern.js → share.js} +0 -0
- package/dist/js/treeshaking/builder/{shared/bundlerPlugins/HtmlAsyncChunkPlugin.js → webpackPlugins/htmlAsyncChunkPlugin.js} +0 -0
- package/dist/js/treeshaking/builder/{shared/bundlerPlugins/HtmlBottomTemplate.js → webpackPlugins/htmlBottomTemplate.js} +0 -0
- package/dist/js/treeshaking/builder/{builder-webpack/webpackPlugins/RouterPlugin.js → webpackPlugins/routerPlugin.js} +1 -1
- package/dist/js/treeshaking/config/default.js +2 -2
- package/dist/js/treeshaking/config/index.js +3 -3
- package/dist/js/treeshaking/config/{legacy → initial}/createHtmlConfig.js +0 -0
- package/dist/js/treeshaking/config/{legacy → initial}/createOutputConfig.js +0 -0
- package/dist/js/treeshaking/config/{legacy → initial}/createSourceConfig.js +0 -0
- package/dist/js/treeshaking/config/{legacy → initial}/createToolsConfig.js +0 -0
- package/dist/js/treeshaking/config/initial/index.js +12 -0
- package/dist/js/treeshaking/config/{initialize → initial}/inits.js +2 -4
- package/dist/js/treeshaking/config/{legacy/index.js → initial/transformNormalizedConfig.js} +1 -4
- package/dist/js/treeshaking/index.js +12 -19
- package/dist/js/treeshaking/initialize/index.js +26 -34
- package/dist/js/treeshaking/locale/zh.js +1 -1
- package/dist/types/analyze/templates.d.ts +1 -3
- package/dist/types/builder/builder-webpack/builderPlugins/compatModern.d.ts +1 -7
- package/package.json +14 -14
- package/dist/js/modern/builder/builder-rspack/index.js +0 -8
- package/dist/js/modern/builder/builder-webpack/builderPlugins/compatModern.js +0 -41
- package/dist/js/modern/builder/builder-webpack/index.js +0 -93
- package/dist/js/modern/builder/builder-webpack/webpackPlugins/index.js +0 -1
- package/dist/js/modern/builder/generator/createBuilderOptions.js +0 -24
- package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +0 -39
- package/dist/js/modern/builder/generator/getBuilderTargets.js +0 -12
- package/dist/js/modern/builder/generator/index.js +0 -53
- package/dist/js/modern/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -27
- package/dist/js/modern/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -34
- package/dist/js/modern/builder/shared/index.js +0 -3
- package/dist/js/modern/builder/shared/types.js +0 -0
- package/dist/js/modern/config/initialize/index.js +0 -12
- package/dist/js/modern/types/utils.js +0 -0
- package/dist/js/node/builder/builder-rspack/index.js +0 -31
- package/dist/js/node/builder/builder-webpack/builderPlugins/compatModern.js +0 -64
- package/dist/js/node/builder/builder-webpack/index.js +0 -118
- package/dist/js/node/builder/builder-webpack/webpackPlugins/index.js +0 -17
- package/dist/js/node/builder/generator/createBuilderOptions.js +0 -47
- package/dist/js/node/builder/generator/createBuilderProviderConfig.js +0 -60
- package/dist/js/node/builder/generator/index.js +0 -82
- package/dist/js/node/builder/shared/index.js +0 -19
- package/dist/js/node/builder/shared/types.js +0 -15
- package/dist/js/node/types/utils.js +0 -15
- package/dist/js/treeshaking/builder/builder-rspack/index.js +0 -6
- package/dist/js/treeshaking/builder/builder-webpack/builderPlugins/compatModern.js +0 -64
- package/dist/js/treeshaking/builder/builder-webpack/index.js +0 -301
- package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/index.js +0 -1
- package/dist/js/treeshaking/builder/generator/createBuilderOptions.js +0 -41
- package/dist/js/treeshaking/builder/generator/createBuilderProviderConfig.js +0 -70
- package/dist/js/treeshaking/builder/generator/getBuilderTargets.js +0 -12
- package/dist/js/treeshaking/builder/generator/index.js +0 -199
- package/dist/js/treeshaking/builder/shared/index.js +0 -3
- package/dist/js/treeshaking/builder/shared/types.js +0 -1
- package/dist/js/treeshaking/config/initialize/index.js +0 -10
- package/dist/js/treeshaking/types/utils.js +0 -1
|
@@ -59,16 +59,15 @@ __export(initialize_exports, {
|
|
|
59
59
|
module.exports = __toCommonJS(initialize_exports);
|
|
60
60
|
var import_utils = require("@modern-js/utils");
|
|
61
61
|
var import_schema = require("../schema");
|
|
62
|
+
var import_transformNormalizedConfig = require("../config/initial/transformNormalizedConfig");
|
|
62
63
|
var import_config = require("../config");
|
|
63
|
-
var initialize_default = ({
|
|
64
|
-
bundler
|
|
65
|
-
}) => ({
|
|
64
|
+
var initialize_default = () => ({
|
|
66
65
|
name: "@modern-js/plugin-initialize",
|
|
67
66
|
setup(api) {
|
|
68
67
|
const config = () => {
|
|
69
68
|
const appContext = api.useAppContext();
|
|
70
69
|
const userConfig = api.useConfigContext();
|
|
71
|
-
return (0, import_config.checkIsLegacyConfig)(userConfig) ? (0, import_config.createLegacyDefaultConfig)(appContext) : (0, import_config.createDefaultConfig)(appContext
|
|
70
|
+
return (0, import_config.checkIsLegacyConfig)(userConfig) ? (0, import_config.createLegacyDefaultConfig)(appContext) : (0, import_config.createDefaultConfig)(appContext);
|
|
72
71
|
};
|
|
73
72
|
const validateSchema = () => {
|
|
74
73
|
const userConfig = api.useConfigContext();
|
|
@@ -92,42 +91,36 @@ var initialize_default = ({
|
|
|
92
91
|
)
|
|
93
92
|
});
|
|
94
93
|
api.setAppContext(appContext);
|
|
95
|
-
const normalizedConfig = (0, import_config.checkIsLegacyConfig)(resolved) ? (0,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
return { resolved };
|
|
94
|
+
const normalizedConfig = (0, import_config.checkIsLegacyConfig)(resolved) ? (0, import_transformNormalizedConfig.transformNormalizedConfig)(resolved) : resolved;
|
|
95
|
+
return {
|
|
96
|
+
resolved: {
|
|
97
|
+
_raw: userConfig,
|
|
98
|
+
source: normalizedConfig.source || {},
|
|
99
|
+
server: __spreadProps(__spreadValues({}, normalizedConfig.server || {}), {
|
|
100
|
+
port
|
|
101
|
+
}),
|
|
102
|
+
bff: normalizedConfig.bff || {},
|
|
103
|
+
dev: normalizedConfig.dev || {},
|
|
104
|
+
html: normalizedConfig.html || {},
|
|
105
|
+
output: normalizedConfig.output || {},
|
|
106
|
+
security: normalizedConfig.security || {},
|
|
107
|
+
tools: normalizedConfig.tools || {},
|
|
108
|
+
testing: normalizedConfig.testing || {},
|
|
109
|
+
plugins: normalizedConfig.plugins || [],
|
|
110
|
+
builderPlugins: normalizedConfig.builderPlugins || [],
|
|
111
|
+
runtime: normalizedConfig.runtime || {},
|
|
112
|
+
runtimeByEntries: normalizedConfig.runtimeByEntries || {},
|
|
113
|
+
deploy: normalizedConfig.deploy || {},
|
|
114
|
+
performance: normalizedConfig.performance || {},
|
|
115
|
+
experiments: normalizedConfig.experiments || {},
|
|
116
|
+
autoLoadPlugins: normalizedConfig.autoLoadPlugins || false
|
|
117
|
+
}
|
|
118
|
+
};
|
|
121
119
|
});
|
|
122
120
|
}
|
|
123
121
|
};
|
|
124
122
|
}
|
|
125
123
|
});
|
|
126
|
-
function stabilizeConfig(resolve, config, keys) {
|
|
127
|
-
keys.forEach((key) => {
|
|
128
|
-
resolve[key] = config[key] || {};
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
124
|
function getServerPort(config) {
|
|
132
125
|
return __async(this, null, function* () {
|
|
133
126
|
const prodPort = config.server.port || 8080;
|
|
@@ -39,7 +39,7 @@ const ZH_LOCALE = {
|
|
|
39
39
|
serve: { describe: "应用启动命令" },
|
|
40
40
|
deploy: { describe: "部署应用命令" },
|
|
41
41
|
new: {
|
|
42
|
-
describe: "
|
|
42
|
+
describe: "MWA 项目中执行生成器",
|
|
43
43
|
debug: "开启 Debug 模式,打印调试日志信息",
|
|
44
44
|
config: "生成器运行默认配置(JSON 字符串)",
|
|
45
45
|
distTag: "生成器使用特殊的 npm Tag 版本",
|
|
@@ -32,9 +32,7 @@ var NESTED_ROUTE = {
|
|
|
32
32
|
PAGE_LOADER_FILE: "page.loader",
|
|
33
33
|
LOADING_FILE: "loading",
|
|
34
34
|
ERROR_FILE: "error",
|
|
35
|
-
LOADER_FILE: "loader"
|
|
36
|
-
SPLATE_FILE: "$",
|
|
37
|
-
SPLATE_LOADER_FILE: "$.loader"
|
|
35
|
+
LOADER_FILE: "loader"
|
|
38
36
|
};
|
|
39
37
|
var APP_CONFIG_NAME = "config";
|
|
40
38
|
var APP_INIT_EXPORTED = "init";
|
|
@@ -223,17 +223,16 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
223
223
|
import * as path from "path";
|
|
224
224
|
import { createDebugger, findExists, fs, getEntryOptions, isApiOnly, minimist, getCommand, isDevCommand } from "@modern-js/utils";
|
|
225
225
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
226
|
+
import { createBuilderForModern } from "../builder";
|
|
226
227
|
import { printInstructions } from "../utils/printInstructions";
|
|
227
228
|
import { generateRoutes } from "../utils/routes";
|
|
228
229
|
import { emitResolvedConfig } from "../utils/config";
|
|
229
230
|
import { getSelectedEntries } from "../utils/getSelectedEntries";
|
|
230
231
|
import { initialNormalizedConfig } from "../config";
|
|
231
|
-
import { createBuilderGenerator } from "../builder";
|
|
232
232
|
import { getServerLoadersFile, isPageComponentFile, parseModule, replaceWithAlias } from "./utils";
|
|
233
233
|
import { APP_CONFIG_NAME, APP_INIT_EXPORTED, APP_INIT_IMPORTED } from "./constants";
|
|
234
234
|
var debug = createDebugger("plugin-analyze");
|
|
235
|
-
var analyze_default = function(
|
|
236
|
-
var bundler = param.bundler;
|
|
235
|
+
var analyze_default = function() {
|
|
237
236
|
return {
|
|
238
237
|
name: "@modern-js/plugin-analyze",
|
|
239
238
|
setup: function(api) {
|
|
@@ -243,7 +242,7 @@ var analyze_default = function(param) {
|
|
|
243
242
|
return {
|
|
244
243
|
prepare: function prepare() {
|
|
245
244
|
return _asyncToGenerator(function() {
|
|
246
|
-
var ref, appContext, resolvedConfig, hookRunners, apiOnly, ref1, routes2, ref2, getBundleEntry, getServerRoutes, generateCode, getHtmlTemplate, entrypoints, initialRoutes, routes, htmlTemplates, checkedEntries, entry, command, buildCommands, normalizedConfig,
|
|
245
|
+
var ref, appContext, resolvedConfig, hookRunners, apiOnly, ref1, routes2, ref2, getBundleEntry, getServerRoutes, generateCode, getHtmlTemplate, entrypoints, initialRoutes, routes, htmlTemplates, checkedEntries, entry, command, buildCommands, normalizedConfig, builder;
|
|
247
246
|
return __generator(this, function(_state) {
|
|
248
247
|
switch(_state.label){
|
|
249
248
|
case 0:
|
|
@@ -385,153 +384,149 @@ var analyze_default = function(param) {
|
|
|
385
384
|
];
|
|
386
385
|
if (!buildCommands.includes(command)) return [
|
|
387
386
|
3,
|
|
388
|
-
|
|
387
|
+
13
|
|
389
388
|
];
|
|
390
389
|
normalizedConfig = api.useResolvedConfigContext();
|
|
391
|
-
return [
|
|
392
|
-
4,
|
|
393
|
-
createBuilderGenerator(bundler)
|
|
394
|
-
];
|
|
395
|
-
case 12:
|
|
396
|
-
createBuilderForModern = _state.sent();
|
|
397
390
|
return [
|
|
398
391
|
4,
|
|
399
392
|
createBuilderForModern({
|
|
400
393
|
normalizedConfig: normalizedConfig,
|
|
401
394
|
appContext: appContext,
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
395
|
+
compatPluginConfig: {
|
|
396
|
+
onBeforeBuild: function onBeforeBuild(param) {
|
|
397
|
+
var bundlerConfigs = param.bundlerConfigs;
|
|
398
|
+
return _asyncToGenerator(function() {
|
|
399
|
+
var hookRunners2;
|
|
400
|
+
return __generator(this, function(_state) {
|
|
401
|
+
switch(_state.label){
|
|
402
|
+
case 0:
|
|
403
|
+
hookRunners2 = api.useHookRunners();
|
|
404
|
+
return [
|
|
405
|
+
4,
|
|
406
|
+
generateRoutes(appContext)
|
|
407
|
+
];
|
|
408
|
+
case 1:
|
|
409
|
+
_state.sent();
|
|
410
|
+
return [
|
|
411
|
+
4,
|
|
412
|
+
hookRunners2.beforeBuild({
|
|
413
|
+
bundlerConfigs: bundlerConfigs
|
|
414
|
+
})
|
|
415
|
+
];
|
|
416
|
+
case 2:
|
|
417
|
+
_state.sent();
|
|
418
|
+
return [
|
|
419
|
+
2
|
|
420
|
+
];
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
})();
|
|
424
|
+
},
|
|
425
|
+
onAfterBuild: function onAfterBuild(param) {
|
|
426
|
+
var stats = param.stats;
|
|
427
|
+
return _asyncToGenerator(function() {
|
|
428
|
+
var hookRunners2;
|
|
429
|
+
return __generator(this, function(_state) {
|
|
430
|
+
switch(_state.label){
|
|
431
|
+
case 0:
|
|
432
|
+
hookRunners2 = api.useHookRunners();
|
|
433
|
+
return [
|
|
434
|
+
4,
|
|
435
|
+
hookRunners2.afterBuild({
|
|
436
|
+
stats: stats
|
|
437
|
+
})
|
|
438
|
+
];
|
|
439
|
+
case 1:
|
|
440
|
+
_state.sent();
|
|
441
|
+
return [
|
|
442
|
+
4,
|
|
443
|
+
emitResolvedConfig(appContext.appDirectory, normalizedConfig)
|
|
444
|
+
];
|
|
445
|
+
case 2:
|
|
446
|
+
_state.sent();
|
|
447
|
+
return [
|
|
448
|
+
2
|
|
449
|
+
];
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
})();
|
|
453
|
+
},
|
|
454
|
+
onDevCompileDone: function onDevCompileDone(param) {
|
|
455
|
+
var isFirstCompile = param.isFirstCompile;
|
|
456
|
+
return _asyncToGenerator(function() {
|
|
457
|
+
var hookRunners2;
|
|
458
|
+
return __generator(this, function(_state) {
|
|
459
|
+
hookRunners2 = api.useHookRunners();
|
|
460
|
+
if (process.stdout.isTTY || isFirstCompile) {
|
|
461
|
+
hookRunners2.afterDev();
|
|
462
|
+
if (isFirstCompile) {
|
|
463
|
+
printInstructions(hookRunners2, appContext, normalizedConfig);
|
|
464
|
+
}
|
|
470
465
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
}
|
|
521
|
-
});
|
|
522
|
-
}
|
|
466
|
+
return [
|
|
467
|
+
2
|
|
468
|
+
];
|
|
469
|
+
});
|
|
470
|
+
})();
|
|
471
|
+
},
|
|
472
|
+
onBeforeCreateCompiler: function onBeforeCreateCompiler(param) {
|
|
473
|
+
var bundlerConfigs = param.bundlerConfigs;
|
|
474
|
+
return _asyncToGenerator(function() {
|
|
475
|
+
var hookRunners2;
|
|
476
|
+
return __generator(this, function(_state) {
|
|
477
|
+
switch(_state.label){
|
|
478
|
+
case 0:
|
|
479
|
+
hookRunners2 = api.useHookRunners();
|
|
480
|
+
return [
|
|
481
|
+
4,
|
|
482
|
+
hookRunners2.beforeCreateCompiler({
|
|
483
|
+
bundlerConfigs: bundlerConfigs
|
|
484
|
+
})
|
|
485
|
+
];
|
|
486
|
+
case 1:
|
|
487
|
+
_state.sent();
|
|
488
|
+
return [
|
|
489
|
+
2
|
|
490
|
+
];
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
})();
|
|
494
|
+
},
|
|
495
|
+
onAfterCreateCompiler: function onAfterCreateCompiler(param) {
|
|
496
|
+
var compiler = param.compiler;
|
|
497
|
+
return _asyncToGenerator(function() {
|
|
498
|
+
var hookRunners2;
|
|
499
|
+
return __generator(this, function(_state) {
|
|
500
|
+
switch(_state.label){
|
|
501
|
+
case 0:
|
|
502
|
+
hookRunners2 = api.useHookRunners();
|
|
503
|
+
return [
|
|
504
|
+
4,
|
|
505
|
+
hookRunners2.afterCreateCompiler({
|
|
506
|
+
compiler: compiler
|
|
507
|
+
})
|
|
508
|
+
];
|
|
509
|
+
case 1:
|
|
510
|
+
_state.sent();
|
|
511
|
+
return [
|
|
512
|
+
2
|
|
513
|
+
];
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
})();
|
|
517
|
+
}
|
|
523
518
|
}
|
|
524
519
|
})
|
|
525
520
|
];
|
|
526
|
-
case
|
|
521
|
+
case 12:
|
|
527
522
|
builder = _state.sent();
|
|
528
523
|
builder.addPlugins(resolvedConfig.builderPlugins);
|
|
529
524
|
appContext = _objectSpreadProps(_objectSpread({}, appContext), {
|
|
530
525
|
builder: builder
|
|
531
526
|
});
|
|
532
527
|
api.setAppContext(appContext);
|
|
533
|
-
_state.label =
|
|
534
|
-
case
|
|
528
|
+
_state.label = 13;
|
|
529
|
+
case 13:
|
|
535
530
|
return [
|
|
536
531
|
2
|
|
537
532
|
];
|
|
@@ -565,7 +560,7 @@ var analyze_default = function(param) {
|
|
|
565
560
|
resolvedConfig: function resolvedConfig(param) {
|
|
566
561
|
var resolved = param.resolved;
|
|
567
562
|
var appContext = api.useAppContext();
|
|
568
|
-
var config = initialNormalizedConfig(resolved, appContext
|
|
563
|
+
var config = initialNormalizedConfig(resolved, appContext);
|
|
569
564
|
return {
|
|
570
565
|
resolved: config
|
|
571
566
|
};
|
|
@@ -197,7 +197,7 @@ var createRoute = function(routeInfo, rootDir, filename, entryName) {
|
|
|
197
197
|
};
|
|
198
198
|
var walk = function() {
|
|
199
199
|
var _ref = _asyncToGenerator(function(dirname, rootDir, alias, entryName) {
|
|
200
|
-
var ref, isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, pageLoaderFile, pageRoute,
|
|
200
|
+
var ref, isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, pageLoaderFile, pageRoute, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, extname, itemWithoutExt, isDirectory2, childRoute, ref1, ref2, err, finalRoute;
|
|
201
201
|
return __generator(this, function(_state) {
|
|
202
202
|
switch(_state.label){
|
|
203
203
|
case 0:
|
|
@@ -242,8 +242,6 @@ var walk = function() {
|
|
|
242
242
|
};
|
|
243
243
|
pageLoaderFile = "";
|
|
244
244
|
pageRoute = null;
|
|
245
|
-
splatLoaderFile = "";
|
|
246
|
-
splatRoute = null;
|
|
247
245
|
return [
|
|
248
246
|
4,
|
|
249
247
|
fs.readdir(dirname)
|
|
@@ -319,20 +317,6 @@ var walk = function() {
|
|
|
319
317
|
}
|
|
320
318
|
(ref2 = route.children) === null || ref2 === void 0 ? void 0 : ref2.push(pageRoute);
|
|
321
319
|
}
|
|
322
|
-
if (itemWithoutExt === NESTED_ROUTE.SPLATE_LOADER_FILE) {
|
|
323
|
-
splatLoaderFile = itemPath;
|
|
324
|
-
}
|
|
325
|
-
if (itemWithoutExt === NESTED_ROUTE.SPLATE_FILE) {
|
|
326
|
-
;
|
|
327
|
-
splatRoute = createRoute({
|
|
328
|
-
_component: replaceWithAlias(alias.basename, itemPath, alias.name),
|
|
329
|
-
path: "*"
|
|
330
|
-
}, rootDir, itemPath, entryName);
|
|
331
|
-
if (splatLoaderFile) {
|
|
332
|
-
splatRoute.loader = splatLoaderFile;
|
|
333
|
-
}
|
|
334
|
-
(ref3 = route.children) === null || ref3 === void 0 ? void 0 : ref3.push(splatRoute);
|
|
335
|
-
}
|
|
336
320
|
if (itemWithoutExt === NESTED_ROUTE.LOADING_FILE) {
|
|
337
321
|
route.loading = replaceWithAlias(alias.basename, itemPath, alias.name);
|
|
338
322
|
}
|
|
@@ -296,7 +296,7 @@ var routesForServer = function(param) {
|
|
|
296
296
|
};
|
|
297
297
|
var fileSystemRoutes = function() {
|
|
298
298
|
var _ref = _asyncToGenerator(function(param) {
|
|
299
|
-
var routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, loadings, errors, loaders, loadersMap, loadersMapFile, importLazyCode, rootLayoutCode, getDataLoaderPath, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, component, finalRoute, importLoadingCode, importErrorComponentsCode, importLoadersCode, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _value, key, loaderInfo;
|
|
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
300
|
return __generator(this, function(_state) {
|
|
301
301
|
switch(_state.label){
|
|
302
302
|
case 0:
|
|
@@ -308,6 +308,7 @@ var fileSystemRoutes = function() {
|
|
|
308
308
|
loadersMapFile = path.join(internalDirectory, entryName, TEMP_LOADERS_DIR, "map.json");
|
|
309
309
|
importLazyCode = '\n import { lazy } from "react";\n import loadable, { lazy as loadableLazy } from "@modern-js/runtime/loadable"\n ';
|
|
310
310
|
rootLayoutCode = "";
|
|
311
|
+
componentLoaderPath = "";
|
|
311
312
|
getDataLoaderPath = function(loaderId) {
|
|
312
313
|
if (!ssrMode) {
|
|
313
314
|
return "";
|
|
@@ -318,6 +319,9 @@ var fileSystemRoutes = function() {
|
|
|
318
319
|
}
|
|
319
320
|
return dataLoaderPath;
|
|
320
321
|
};
|
|
322
|
+
if (ssrMode) {
|
|
323
|
+
componentLoaderPath = "".concat(path.join(__dirname, "../builder/loaders/routerLoader"), "!");
|
|
324
|
+
}
|
|
321
325
|
traverseRouteTree = function(route) {
|
|
322
326
|
var children;
|
|
323
327
|
if ("children" in route && route.children) {
|
|
@@ -353,10 +357,10 @@ var fileSystemRoutes = function() {
|
|
|
353
357
|
rootLayoutCode = "import RootLayout from '".concat(route._component, "'");
|
|
354
358
|
component = "RootLayout";
|
|
355
359
|
} else if (ssrMode === "string") {
|
|
356
|
-
lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(route._component, "')");
|
|
360
|
+
lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(componentLoaderPath).concat(route._component, "')");
|
|
357
361
|
component = "loadable(".concat(lazyImport, ")");
|
|
358
362
|
} else {
|
|
359
|
-
lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(route._component, "')");
|
|
363
|
+
lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(componentLoaderPath).concat(route._component, "')");
|
|
360
364
|
component = "lazy(".concat(lazyImport, ")");
|
|
361
365
|
}
|
|
362
366
|
}
|