@modern-js/app-tools 2.0.0-canary.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +724 -0
- package/bin/modern.js +3 -0
- package/dist/js/modern/analyze/Builder.js +39 -0
- package/dist/js/modern/analyze/constants.js +16 -0
- package/dist/js/modern/analyze/generateCode.js +14 -15
- package/dist/js/modern/analyze/getBundleEntry.js +5 -1
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +9 -6
- package/dist/js/modern/analyze/getFileSystemEntry.js +11 -3
- package/dist/js/modern/analyze/index.js +79 -8
- package/dist/js/modern/analyze/nestedRoutes.js +29 -22
- package/dist/js/modern/analyze/templates.js +28 -7
- package/dist/js/modern/analyze/utils.js +21 -4
- package/dist/js/modern/builder/builderPlugins/compatModern.js +12 -5
- package/dist/js/modern/builder/index.js +14 -16
- package/dist/js/modern/builder/share.js +4 -4
- package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +3 -1
- package/dist/js/modern/commands/dev.js +6 -9
- package/dist/js/modern/commands/index.js +1 -1
- package/dist/js/modern/commands/{start.js → serve.js} +3 -1
- package/dist/js/modern/config/default.js +38 -61
- package/dist/js/modern/config/initial/createOutputConfig.js +1 -3
- package/dist/js/modern/config/initial/createSourceConfig.js +5 -1
- package/dist/js/modern/config/initial/inits.js +7 -0
- package/dist/js/modern/config/initial/transformNormalizedConfig.js +5 -1
- package/dist/js/modern/hooks.js +6 -1
- package/dist/js/modern/index.js +96 -59
- package/dist/js/modern/initialize/index.js +5 -4
- package/dist/js/modern/locale/en.js +1 -1
- package/dist/js/modern/locale/zh.js +1 -1
- package/dist/js/modern/schema/index.js +6 -8
- package/dist/js/modern/schema/legacy.js +2 -3
- package/dist/js/modern/utils/commands.js +6 -1
- package/dist/js/modern/utils/env.js +15 -0
- package/dist/js/modern/utils/getServerInternalPlugins.js +58 -0
- package/dist/js/node/analyze/Builder.js +64 -0
- package/dist/js/node/analyze/constants.js +44 -3
- package/dist/js/node/analyze/generateCode.js +33 -29
- package/dist/js/node/analyze/getBundleEntry.js +12 -4
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +33 -28
- package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +24 -22
- package/dist/js/node/analyze/getClientRoutes/index.js +8 -3
- package/dist/js/node/analyze/getClientRoutes/utils.js +10 -3
- package/dist/js/node/analyze/getFileSystemEntry.js +18 -6
- package/dist/js/node/analyze/getHtmlTemplate.js +18 -14
- package/dist/js/node/analyze/getServerRoutes.js +36 -34
- package/dist/js/node/analyze/index.js +105 -59
- package/dist/js/node/analyze/isDefaultExportFunction.js +7 -3
- package/dist/js/node/analyze/makeLegalIdentifier.js +7 -3
- package/dist/js/node/analyze/nestedRoutes.js +58 -49
- package/dist/js/node/analyze/templates.js +64 -37
- package/dist/js/node/analyze/utils.js +40 -18
- package/dist/js/node/builder/builderPlugins/compatModern.js +36 -27
- package/dist/js/node/builder/index.js +42 -55
- package/dist/js/node/builder/loaders/routerLoader.js +5 -3
- package/dist/js/node/builder/loaders/serverModuleLoader.js +5 -3
- package/dist/js/node/builder/share.js +11 -7
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +7 -3
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +7 -3
- package/dist/js/node/builder/webpackPlugins/routerPlugin.js +12 -8
- package/dist/js/node/commands/build.js +30 -28
- package/dist/js/node/commands/deploy.js +9 -5
- package/dist/js/node/commands/dev.js +39 -40
- package/dist/js/node/commands/index.js +5 -5
- package/dist/js/node/commands/inspect.js +10 -6
- package/dist/js/node/commands/{start.js → serve.js} +16 -10
- package/dist/js/node/config/default.js +44 -64
- package/dist/js/node/config/index.js +10 -3
- package/dist/js/node/config/initial/createHtmlConfig.js +7 -3
- package/dist/js/node/config/initial/createOutputConfig.js +8 -6
- package/dist/js/node/config/initial/createSourceConfig.js +12 -4
- package/dist/js/node/config/initial/createToolsConfig.js +7 -3
- package/dist/js/node/config/initial/index.js +9 -3
- package/dist/js/node/config/initial/inits.js +33 -22
- package/dist/js/node/config/initial/transformNormalizedConfig.js +12 -4
- package/dist/js/node/defineConfig.js +25 -22
- package/dist/js/node/exports/server.js +7 -3
- package/dist/js/node/hooks.js +13 -4
- package/dist/js/node/index.js +135 -111
- package/dist/js/node/initialize/index.js +33 -32
- package/dist/js/node/locale/en.js +8 -4
- package/dist/js/node/locale/index.js +8 -3
- package/dist/js/node/locale/zh.js +8 -4
- package/dist/js/node/schema/Schema.js +7 -3
- package/dist/js/node/schema/index.js +14 -11
- package/dist/js/node/schema/legacy.js +7 -6
- package/dist/js/node/types/config/deploy.js +15 -0
- package/dist/js/node/types/config/dev.js +15 -0
- package/dist/js/node/types/config/experiments.js +15 -0
- package/dist/js/node/types/config/html.js +15 -0
- package/dist/js/node/types/config/index.js +3 -3
- package/dist/js/node/types/config/output.js +15 -0
- package/dist/js/node/types/config/performance.js +15 -0
- package/dist/js/node/types/config/security.js +15 -0
- package/dist/js/node/types/config/source.js +15 -0
- package/dist/js/node/types/config/tools.js +15 -0
- package/dist/js/node/types/hooks.js +15 -0
- package/dist/js/node/types/index.js +5 -5
- package/dist/js/node/types/legacyConfig/deploy.js +15 -0
- package/dist/js/node/types/legacyConfig/dev.js +15 -0
- package/dist/js/node/types/legacyConfig/index.js +15 -0
- package/dist/js/node/types/legacyConfig/output.js +15 -0
- package/dist/js/node/types/legacyConfig/source.js +15 -0
- package/dist/js/node/types/legacyConfig/tools.js +15 -0
- package/dist/js/node/utils/commands.js +14 -4
- package/dist/js/node/utils/config.js +35 -30
- package/dist/js/node/utils/createFileWatcher.js +15 -10
- package/dist/js/node/utils/createServer.js +35 -29
- package/dist/js/node/utils/env.js +38 -0
- package/dist/js/node/utils/getServerInternalPlugins.js +79 -0
- package/dist/js/node/utils/getSpecifiedEntries.js +10 -6
- package/dist/js/node/utils/language.js +7 -3
- package/dist/js/node/utils/printInstructions.js +10 -6
- package/dist/js/node/utils/restart.js +11 -7
- package/dist/js/node/utils/routes.js +11 -7
- package/dist/js/node/utils/types.js +15 -0
- package/dist/js/treeshaking/analyze/Builder.js +199 -0
- package/dist/js/treeshaking/analyze/constants.js +13 -1
- package/dist/js/treeshaking/analyze/generateCode.js +14 -17
- package/dist/js/treeshaking/analyze/getBundleEntry.js +5 -1
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +9 -6
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +11 -3
- package/dist/js/treeshaking/analyze/index.js +110 -7
- package/dist/js/treeshaking/analyze/nestedRoutes.js +30 -23
- package/dist/js/treeshaking/analyze/templates.js +13 -8
- package/dist/js/treeshaking/analyze/utils.js +15 -4
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +6 -1
- package/dist/js/treeshaking/builder/index.js +13 -20
- package/dist/js/treeshaking/builder/share.js +1 -4
- package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +3 -1
- package/dist/js/treeshaking/commands/dev.js +19 -24
- package/dist/js/treeshaking/commands/index.js +1 -1
- package/dist/js/treeshaking/commands/{start.js → serve.js} +10 -3
- package/dist/js/treeshaking/config/default.js +53 -56
- package/dist/js/treeshaking/config/initial/createOutputConfig.js +1 -3
- package/dist/js/treeshaking/config/initial/createSourceConfig.js +5 -1
- package/dist/js/treeshaking/config/initial/inits.js +7 -0
- package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +5 -1
- package/dist/js/treeshaking/hooks.js +6 -1
- package/dist/js/treeshaking/index.js +349 -132
- package/dist/js/treeshaking/initialize/index.js +6 -5
- package/dist/js/treeshaking/locale/en.js +1 -1
- package/dist/js/treeshaking/locale/zh.js +1 -1
- package/dist/js/treeshaking/schema/index.js +11 -12
- package/dist/js/treeshaking/schema/legacy.js +1 -4
- package/dist/js/treeshaking/utils/commands.js +5 -1
- package/dist/js/treeshaking/utils/env.js +13 -0
- package/dist/js/treeshaking/utils/getServerInternalPlugins.js +210 -0
- package/dist/types/analyze/Builder.d.ts +8 -0
- package/dist/types/analyze/constants.d.ts +13 -1
- package/dist/types/analyze/templates.d.ts +3 -1
- package/dist/types/analyze/utils.d.ts +2 -1
- package/dist/types/builder/builderPlugins/compatModern.d.ts +3 -3
- package/dist/types/builder/index.d.ts +2 -2
- package/dist/types/commands/index.d.ts +1 -1
- package/dist/types/commands/{start.d.ts → serve.d.ts} +0 -0
- package/dist/types/index.d.ts +5 -1
- package/dist/types/locale/en.d.ts +1 -1
- package/dist/types/locale/index.d.ts +2 -2
- package/dist/types/locale/zh.d.ts +1 -1
- package/dist/types/schema/Schema.d.ts +1 -1
- package/dist/types/types/config/deploy.d.ts +1 -1
- package/dist/types/types/config/dev.d.ts +4 -4
- package/dist/types/types/config/experiments.d.ts +3 -3
- package/dist/types/types/config/html.d.ts +3 -3
- package/dist/types/types/config/index.d.ts +6 -3
- package/dist/types/types/config/output.d.ts +6 -6
- package/dist/types/types/config/performance.d.ts +3 -3
- package/dist/types/types/config/security.d.ts +3 -3
- package/dist/types/types/config/source.d.ts +6 -5
- package/dist/types/types/config/tools.d.ts +3 -3
- package/dist/types/types/hooks.d.ts +9 -1
- package/dist/types/types/index.d.ts +6 -6
- package/dist/types/types/legacyConfig/deploy.d.ts +1 -1
- package/dist/types/types/legacyConfig/dev.d.ts +2 -2
- package/dist/types/types/legacyConfig/index.d.ts +1 -1
- package/dist/types/types/legacyConfig/output.d.ts +2 -2
- package/dist/types/types/legacyConfig/source.d.ts +1 -2
- package/dist/types/types/legacyConfig/tools.d.ts +2 -2
- package/dist/types/utils/commands.d.ts +2 -1
- package/dist/types/utils/env.d.ts +2 -0
- package/dist/types/utils/getServerInternalPlugins.d.ts +2 -0
- package/dist/types/utils/types.d.ts +5 -5
- package/package.json +27 -24
|
@@ -221,26 +221,29 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
223
|
import * as path from "path";
|
|
224
|
-
import { createDebugger, fs, isApiOnly } from "@modern-js/utils";
|
|
224
|
+
import { createDebugger, findExists, fs, isApiOnly } from "@modern-js/utils";
|
|
225
225
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
226
|
-
import {
|
|
226
|
+
import { createBuilderForModern } from "../builder";
|
|
227
227
|
import { printInstructions } from "../utils/printInstructions";
|
|
228
228
|
import { generateRoutes } from "../utils/routes";
|
|
229
229
|
import { emitResolvedConfig } from "../utils/config";
|
|
230
230
|
import { getCommand } from "../utils/commands";
|
|
231
231
|
import { initialNormalizedConfig } from "../config";
|
|
232
|
-
import {
|
|
232
|
+
import { isNestedRouteComponent, isPageComponentFile, parseModule, replaceWithAlias } from "./utils";
|
|
233
|
+
import { loaderBuilder, serverLoaderBuilder } from "./Builder";
|
|
234
|
+
import { APP_CONFIG_NAME, APP_INIT_EXPORTED, APP_INIT_IMPORTED } from "./constants";
|
|
233
235
|
var debug = createDebugger("plugin-analyze");
|
|
234
236
|
var analyze_default = function() {
|
|
235
237
|
return {
|
|
236
238
|
name: "@modern-js/plugin-analyze",
|
|
237
239
|
setup: function(api) {
|
|
238
240
|
var pagesDir = [];
|
|
241
|
+
var nestedRouteEntries = [];
|
|
239
242
|
var originEntrypoints = [];
|
|
240
243
|
return {
|
|
241
244
|
prepare: function prepare() {
|
|
242
245
|
return _asyncToGenerator(function() {
|
|
243
|
-
var ref, appContext, resolvedConfig, hookRunners, apiOnly, ref1, routes2, ref2, getBundleEntry, getServerRoutes, generateCode, getHtmlTemplate, entrypoints, defaultChecked, initialRoutes, routes,
|
|
246
|
+
var ref, appContext, resolvedConfig, hookRunners, apiOnly, ref1, routes2, ref2, getBundleEntry, getServerRoutes, generateCode, getHtmlTemplate, entrypoints, defaultChecked, initialRoutes, routes, htmlTemplates, command, buildCommands, normalizedConfig, builder;
|
|
244
247
|
return __generator(this, function(_state) {
|
|
245
248
|
switch(_state.label){
|
|
246
249
|
case 0:
|
|
@@ -362,6 +365,7 @@ var analyze_default = function() {
|
|
|
362
365
|
command = getCommand();
|
|
363
366
|
buildCommands = [
|
|
364
367
|
"dev",
|
|
368
|
+
"start",
|
|
365
369
|
"build",
|
|
366
370
|
"inspect",
|
|
367
371
|
"deploy"
|
|
@@ -373,7 +377,7 @@ var analyze_default = function() {
|
|
|
373
377
|
normalizedConfig = api.useResolvedConfigContext();
|
|
374
378
|
return [
|
|
375
379
|
4,
|
|
376
|
-
|
|
380
|
+
createBuilderForModern({
|
|
377
381
|
normalizedConfig: normalizedConfig,
|
|
378
382
|
appContext: appContext,
|
|
379
383
|
compatPluginConfig: {
|
|
@@ -504,6 +508,7 @@ var analyze_default = function() {
|
|
|
504
508
|
];
|
|
505
509
|
case 10:
|
|
506
510
|
builder = _state.sent();
|
|
511
|
+
builder.addPlugins(resolvedConfig.builderPlugins);
|
|
507
512
|
appContext = _objectSpreadProps(_objectSpread({}, appContext), {
|
|
508
513
|
builder: builder
|
|
509
514
|
});
|
|
@@ -528,6 +533,104 @@ var analyze_default = function() {
|
|
|
528
533
|
resolved: config
|
|
529
534
|
};
|
|
530
535
|
},
|
|
536
|
+
modifyEntryImports: function modifyEntryImports(param) {
|
|
537
|
+
var entrypoint = param.entrypoint, imports = param.imports;
|
|
538
|
+
return _asyncToGenerator(function() {
|
|
539
|
+
var appContext, srcDirectory, fileSystemRoutes, nestedRoutesEntry, rootLayoutPath, rootLayoutFile, rootLayoutBuffer, rootLayout, ref, moduleExports, hasAppConfig, generateLayoutPath, hasAppInit;
|
|
540
|
+
return __generator(this, function(_state) {
|
|
541
|
+
switch(_state.label){
|
|
542
|
+
case 0:
|
|
543
|
+
appContext = api.useAppContext();
|
|
544
|
+
srcDirectory = appContext.srcDirectory;
|
|
545
|
+
fileSystemRoutes = entrypoint.fileSystemRoutes, nestedRoutesEntry = entrypoint.nestedRoutesEntry;
|
|
546
|
+
if (!(fileSystemRoutes && nestedRoutesEntry)) return [
|
|
547
|
+
3,
|
|
548
|
+
3
|
|
549
|
+
];
|
|
550
|
+
rootLayoutPath = path.join(nestedRoutesEntry, "layout");
|
|
551
|
+
rootLayoutFile = findExists([
|
|
552
|
+
".js",
|
|
553
|
+
".ts",
|
|
554
|
+
".jsx",
|
|
555
|
+
".tsx"
|
|
556
|
+
].map(function(ext) {
|
|
557
|
+
return "".concat(rootLayoutPath).concat(ext);
|
|
558
|
+
}));
|
|
559
|
+
if (!rootLayoutFile) return [
|
|
560
|
+
3,
|
|
561
|
+
3
|
|
562
|
+
];
|
|
563
|
+
return [
|
|
564
|
+
4,
|
|
565
|
+
fs.readFile(rootLayoutFile)
|
|
566
|
+
];
|
|
567
|
+
case 1:
|
|
568
|
+
rootLayoutBuffer = _state.sent();
|
|
569
|
+
rootLayout = rootLayoutBuffer.toString();
|
|
570
|
+
return [
|
|
571
|
+
4,
|
|
572
|
+
parseModule({
|
|
573
|
+
source: rootLayout.toString(),
|
|
574
|
+
filename: rootLayoutFile
|
|
575
|
+
})
|
|
576
|
+
];
|
|
577
|
+
case 2:
|
|
578
|
+
ref = _slicedToArray.apply(void 0, [
|
|
579
|
+
_state.sent(),
|
|
580
|
+
2
|
|
581
|
+
]), moduleExports = ref[1];
|
|
582
|
+
hasAppConfig = moduleExports.some(function(e) {
|
|
583
|
+
return e.n === APP_CONFIG_NAME;
|
|
584
|
+
});
|
|
585
|
+
generateLayoutPath = replaceWithAlias(srcDirectory, rootLayoutFile, "@_modern_js_src");
|
|
586
|
+
if (hasAppConfig) {
|
|
587
|
+
imports.push({
|
|
588
|
+
value: generateLayoutPath,
|
|
589
|
+
specifiers: [
|
|
590
|
+
{
|
|
591
|
+
imported: APP_CONFIG_NAME
|
|
592
|
+
}
|
|
593
|
+
]
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
hasAppInit = moduleExports.some(function(e) {
|
|
597
|
+
return e.n === APP_INIT_EXPORTED;
|
|
598
|
+
});
|
|
599
|
+
if (hasAppInit) {
|
|
600
|
+
imports.push({
|
|
601
|
+
value: generateLayoutPath,
|
|
602
|
+
specifiers: [
|
|
603
|
+
{
|
|
604
|
+
imported: APP_INIT_EXPORTED,
|
|
605
|
+
local: APP_INIT_IMPORTED
|
|
606
|
+
}
|
|
607
|
+
]
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
_state.label = 3;
|
|
611
|
+
case 3:
|
|
612
|
+
return [
|
|
613
|
+
2,
|
|
614
|
+
{
|
|
615
|
+
entrypoint: entrypoint,
|
|
616
|
+
imports: imports
|
|
617
|
+
}
|
|
618
|
+
];
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
})();
|
|
622
|
+
},
|
|
623
|
+
beforeRestart: function beforeRestart() {
|
|
624
|
+
return _asyncToGenerator(function() {
|
|
625
|
+
return __generator(this, function(_state) {
|
|
626
|
+
serverLoaderBuilder.stop();
|
|
627
|
+
loaderBuilder.stop();
|
|
628
|
+
return [
|
|
629
|
+
2
|
|
630
|
+
];
|
|
631
|
+
});
|
|
632
|
+
})();
|
|
633
|
+
},
|
|
531
634
|
fileChange: function fileChange(e) {
|
|
532
635
|
return _asyncToGenerator(function() {
|
|
533
636
|
var appContext, appDirectory, filename, eventType, isPageFile, absoluteFilePath, isRouteComponent, resolvedConfig, generateCode, entrypoints;
|
|
@@ -543,8 +646,8 @@ var analyze_default = function() {
|
|
|
543
646
|
});
|
|
544
647
|
};
|
|
545
648
|
absoluteFilePath = path.resolve(appDirectory, filename);
|
|
546
|
-
isRouteComponent = isPageFile(absoluteFilePath) &&
|
|
547
|
-
if (!(isRouteComponent && (eventType === "add" || eventType === "unlink"))) return [
|
|
649
|
+
isRouteComponent = isPageFile(absoluteFilePath) && isPageComponentFile(absoluteFilePath);
|
|
650
|
+
if (!(isRouteComponent && (eventType === "add" || eventType === "unlink") || isNestedRouteComponent(nestedRouteEntries, absoluteFilePath) && eventType === "change")) return [
|
|
548
651
|
3,
|
|
549
652
|
2
|
|
550
653
|
];
|
|
@@ -176,20 +176,9 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
176
176
|
};
|
|
177
177
|
import * as path from "path";
|
|
178
178
|
import { fs, getRouteId } from "@modern-js/utils";
|
|
179
|
-
import { JS_EXTENSIONS } from "./constants";
|
|
179
|
+
import { JS_EXTENSIONS, NESTED_ROUTE } from "./constants";
|
|
180
180
|
import { hasLoader, replaceWithAlias } from "./utils";
|
|
181
|
-
var
|
|
182
|
-
var PAGE_FILE = "page";
|
|
183
|
-
var LOADING_FILE = "loading";
|
|
184
|
-
var ERROR_FILE = "error";
|
|
185
|
-
var LOADER_FILE = "loader";
|
|
186
|
-
var conventionNames = [
|
|
187
|
-
LAYOUT_FILE,
|
|
188
|
-
PAGE_FILE,
|
|
189
|
-
LOADING_FILE,
|
|
190
|
-
ERROR_FILE,
|
|
191
|
-
LOADER_FILE
|
|
192
|
-
];
|
|
181
|
+
var conventionNames = Object.values(NESTED_ROUTE);
|
|
193
182
|
var getLoaderPath = function() {
|
|
194
183
|
var _ref = _asyncToGenerator(function(filename) {
|
|
195
184
|
return __generator(this, function(_state) {
|
|
@@ -235,7 +224,7 @@ var createRoute = function(routeInfo, rootDir, filename, entryName) {
|
|
|
235
224
|
};
|
|
236
225
|
var walk = function() {
|
|
237
226
|
var _ref = _asyncToGenerator(function(dirname, rootDir, alias, entryName) {
|
|
238
|
-
var isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, extname, itemWithoutExt, isDirectory2, childRoute, ref, ref1,
|
|
227
|
+
var isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, pageLoaderFile, pageRoute, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, extname, itemWithoutExt, isDirectory2, childRoute, ref, loaderPath, ref1, loaderPath1, err, finalRoute;
|
|
239
228
|
return __generator(this, function(_state) {
|
|
240
229
|
switch(_state.label){
|
|
241
230
|
case 0:
|
|
@@ -278,6 +267,8 @@ var walk = function() {
|
|
|
278
267
|
children: [],
|
|
279
268
|
isRoot: isRoot
|
|
280
269
|
};
|
|
270
|
+
pageLoaderFile = "";
|
|
271
|
+
pageRoute = null;
|
|
281
272
|
return [
|
|
282
273
|
4,
|
|
283
274
|
fs.readdir(dirname)
|
|
@@ -332,7 +323,12 @@ var walk = function() {
|
|
|
332
323
|
13
|
|
333
324
|
];
|
|
334
325
|
}
|
|
335
|
-
if (
|
|
326
|
+
if (itemWithoutExt === NESTED_ROUTE.LAYOUT_LOADER_FILE) {
|
|
327
|
+
if (!route.loader) {
|
|
328
|
+
route.loader = itemPath;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
if (!(itemWithoutExt === NESTED_ROUTE.LAYOUT_FILE)) return [
|
|
336
332
|
3,
|
|
337
333
|
10
|
|
338
334
|
];
|
|
@@ -342,14 +338,20 @@ var walk = function() {
|
|
|
342
338
|
getLoaderPath(itemPath)
|
|
343
339
|
];
|
|
344
340
|
case 9:
|
|
345
|
-
|
|
341
|
+
loaderPath = _state.sent();
|
|
342
|
+
if (loaderPath) {
|
|
343
|
+
route.loader = loaderPath;
|
|
344
|
+
}
|
|
346
345
|
_state.label = 10;
|
|
347
346
|
case 10:
|
|
348
|
-
if (
|
|
347
|
+
if (itemWithoutExt === NESTED_ROUTE.PAGE_LOADER_FILE) {
|
|
348
|
+
pageLoaderFile = itemPath;
|
|
349
|
+
}
|
|
350
|
+
if (!(itemWithoutExt === NESTED_ROUTE.PAGE_FILE)) return [
|
|
349
351
|
3,
|
|
350
352
|
12
|
|
351
353
|
];
|
|
352
|
-
|
|
354
|
+
pageRoute = createIndexRoute({
|
|
353
355
|
_component: replaceWithAlias(alias.basename, itemPath, alias.name)
|
|
354
356
|
}, rootDir, itemPath, entryName);
|
|
355
357
|
return [
|
|
@@ -357,14 +359,19 @@ var walk = function() {
|
|
|
357
359
|
getLoaderPath(itemPath)
|
|
358
360
|
];
|
|
359
361
|
case 11:
|
|
360
|
-
|
|
361
|
-
(
|
|
362
|
+
loaderPath1 = _state.sent();
|
|
363
|
+
if (loaderPath1) {
|
|
364
|
+
pageRoute.loader = loaderPath1;
|
|
365
|
+
} else if (pageLoaderFile) {
|
|
366
|
+
pageRoute.loader = pageLoaderFile;
|
|
367
|
+
}
|
|
368
|
+
(ref1 = route.children) === null || ref1 === void 0 ? void 0 : ref1.push(pageRoute);
|
|
362
369
|
_state.label = 12;
|
|
363
370
|
case 12:
|
|
364
|
-
if (itemWithoutExt === LOADING_FILE) {
|
|
371
|
+
if (itemWithoutExt === NESTED_ROUTE.LOADING_FILE) {
|
|
365
372
|
route.loading = replaceWithAlias(alias.basename, itemPath, alias.name);
|
|
366
373
|
}
|
|
367
|
-
if (itemWithoutExt === ERROR_FILE) {
|
|
374
|
+
if (itemWithoutExt === NESTED_ROUTE.ERROR_FILE) {
|
|
368
375
|
route.error = replaceWithAlias(alias.basename, itemPath, alias.name);
|
|
369
376
|
}
|
|
370
377
|
_state.label = 13;
|
|
@@ -401,7 +408,7 @@ var walk = function() {
|
|
|
401
408
|
7
|
|
402
409
|
];
|
|
403
410
|
case 17:
|
|
404
|
-
finalRoute = createRoute(route, rootDir, path.join(dirname, "".concat(LAYOUT_FILE, ".ts")), entryName);
|
|
411
|
+
finalRoute = createRoute(route, rootDir, path.join(dirname, "".concat(NESTED_ROUTE.LAYOUT_FILE, ".ts")), entryName);
|
|
405
412
|
if (isPathlessLayout) {
|
|
406
413
|
delete finalRoute.path;
|
|
407
414
|
}
|
|
@@ -176,17 +176,17 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
176
176
|
};
|
|
177
177
|
import path from "path";
|
|
178
178
|
import { fs, slash } from "@modern-js/utils";
|
|
179
|
-
import { TEMP_LOADERS_DIR } from "./constants";
|
|
179
|
+
import { APP_CONFIG_NAME, TEMP_LOADERS_DIR } from "./constants";
|
|
180
180
|
var index = function(param) {
|
|
181
181
|
var mountId = param.mountId, imports = param.imports, renderFunction2 = param.renderFunction, exportStatement = param.exportStatement;
|
|
182
182
|
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");
|
|
183
183
|
};
|
|
184
184
|
var renderFunction = function(param) {
|
|
185
185
|
var plugins = param.plugins, customBootstrap = param.customBootstrap, fileSystemRoutes2 = param.fileSystemRoutes;
|
|
186
|
-
return "\n AppWrapper = createApp({\n plugins: [\n ".concat(plugins.map(function(param) {
|
|
186
|
+
return "\n const finalAppConfig = {\n ...App.config,\n ...typeof ".concat(APP_CONFIG_NAME, " === 'object' ? ").concat(APP_CONFIG_NAME, " : {},\n }\n\n AppWrapper = createApp({\n plugins: [\n ").concat(plugins.map(function(param) {
|
|
187
187
|
var name = param.name, options = param.options, args = param.args;
|
|
188
|
-
return "".concat(name, "({...").concat(options, ", ...
|
|
189
|
-
}).join("\n"), "\n ]\n })(").concat(fileSystemRoutes2 ? "" : "App", ")\n\n if (IS_BROWSER) {\n ").concat(customBootstrap ? "customBootstrap(AppWrapper);" : "bootstrap(AppWrapper, MOUNT_ID, root, ReactDOM);", "\n }\n\n return AppWrapper\n");
|
|
188
|
+
return "".concat(name, "({...").concat(options, ", ...finalAppConfig?.").concat(args || name, "}),");
|
|
189
|
+
}).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");
|
|
190
190
|
};
|
|
191
191
|
var html = function(partials) {
|
|
192
192
|
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");
|
|
@@ -251,16 +251,16 @@ var routesForServer = function(param) {
|
|
|
251
251
|
};
|
|
252
252
|
var fileSystemRoutes = function() {
|
|
253
253
|
var _ref = _asyncToGenerator(function(param) {
|
|
254
|
-
var routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, loadings, errors, loaders, loadersMap, loadersIndexFile, loadersMapFile, importLazyCode, rootLayoutCode, dataLoaderPath, componentLoaderPath, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, component, finalRoute, importLoadingCode, importErrorComponentsCode, importLoadersCode, loaderEntryCode, loaderEntryFile;
|
|
254
|
+
var routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, internalDirAlias, loadings, errors, loaders, loadersMap, loadersIndexFile, loadersMapFile, importLazyCode, rootLayoutCode, dataLoaderPath, componentLoaderPath, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, component, finalRoute, importLoadingCode, importErrorComponentsCode, importLoadersCode, loaderEntryCode, loaderEntryFile;
|
|
255
255
|
return __generator(this, function(_state) {
|
|
256
256
|
switch(_state.label){
|
|
257
257
|
case 0:
|
|
258
|
-
routes = param.routes, ssrMode = param.ssrMode, nestedRoutesEntry = param.nestedRoutesEntry, entryName = param.entryName, internalDirectory = param.internalDirectory;
|
|
258
|
+
routes = param.routes, ssrMode = param.ssrMode, nestedRoutesEntry = param.nestedRoutesEntry, entryName = param.entryName, internalDirectory = param.internalDirectory, internalDirAlias = param.internalDirAlias;
|
|
259
259
|
loadings = [];
|
|
260
260
|
errors = [];
|
|
261
261
|
loaders = [];
|
|
262
262
|
loadersMap = {};
|
|
263
|
-
loadersIndexFile = path.join(
|
|
263
|
+
loadersIndexFile = path.join(internalDirAlias, entryName, TEMP_LOADERS_DIR, "index.js");
|
|
264
264
|
loadersMapFile = path.join(internalDirectory, entryName, TEMP_LOADERS_DIR, "map.json");
|
|
265
265
|
importLazyCode = '\n import { lazy } from "react";\n import loadable, { lazy as loadableLazy } from "@modern-js/runtime/loadable"\n ';
|
|
266
266
|
rootLayoutCode = "";
|
|
@@ -399,7 +399,12 @@ var fileSystemRoutes = function() {
|
|
|
399
399
|
case 0:
|
|
400
400
|
name = "loader_".concat(index2);
|
|
401
401
|
filename = path.join(internalDirectory, entryName, TEMP_LOADERS_DIR, "".concat(name, ".js"));
|
|
402
|
-
code = "
|
|
402
|
+
code = "";
|
|
403
|
+
if (loader.includes(".loader.")) {
|
|
404
|
+
code = "\n export { default as ".concat(name, " } from '").concat(slash(loader), "'\n ");
|
|
405
|
+
} else {
|
|
406
|
+
code = "\n export { loader as ".concat(name, " } from '").concat(slash(loader), "'\n ");
|
|
407
|
+
}
|
|
403
408
|
return [
|
|
404
409
|
4,
|
|
405
410
|
fs.ensureFile(filename)
|
|
@@ -185,7 +185,7 @@ import path from "path";
|
|
|
185
185
|
import { isReact18, normalizeToPosixPath, fs as fse } from "@modern-js/utils";
|
|
186
186
|
import { transform } from "esbuild";
|
|
187
187
|
import { parse } from "es-module-lexer";
|
|
188
|
-
import { FILE_SYSTEM_ROUTES_FILE_NAME, LOADER_EXPORT_NAME } from "./constants";
|
|
188
|
+
import { FILE_SYSTEM_ROUTES_FILE_NAME, JS_EXTENSIONS, LOADER_EXPORT_NAME, NESTED_ROUTE } from "./constants";
|
|
189
189
|
var walkDirectory = function(dir) {
|
|
190
190
|
return fs.readdirSync(dir).reduce(function(previous, filename) {
|
|
191
191
|
var filePath = path.join(dir, filename);
|
|
@@ -272,7 +272,7 @@ var getDefaultImports = function(param) {
|
|
|
272
272
|
}
|
|
273
273
|
return imports;
|
|
274
274
|
};
|
|
275
|
-
var
|
|
275
|
+
var isPageComponentFile = function(filePath) {
|
|
276
276
|
if (/\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/.test(filePath)) {
|
|
277
277
|
return false;
|
|
278
278
|
}
|
|
@@ -286,6 +286,15 @@ var isRouteComponentFile = function(filePath) {
|
|
|
286
286
|
}
|
|
287
287
|
return false;
|
|
288
288
|
};
|
|
289
|
+
var isNestedRouteComponent = function(nestedRouteEntries, absoluteFilePath) {
|
|
290
|
+
var reg = new RegExp("(".concat(NESTED_ROUTE.LAYOUT_FILE, "|").concat(NESTED_ROUTE.PAGE_FILE, "})\\.tsx?$"));
|
|
291
|
+
return nestedRouteEntries.some(function(nestedRoutesEntry) {
|
|
292
|
+
if (absoluteFilePath.includes(nestedRoutesEntry) && reg.test(absoluteFilePath)) {
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
return false;
|
|
296
|
+
});
|
|
297
|
+
};
|
|
289
298
|
var replaceWithAlias = function(base, filePath, alias) {
|
|
290
299
|
return normalizeToPosixPath(path.join(alias, path.relative(base, filePath)));
|
|
291
300
|
};
|
|
@@ -297,7 +306,9 @@ var parseModule = function() {
|
|
|
297
306
|
case 0:
|
|
298
307
|
source = param.source, filename = param.filename;
|
|
299
308
|
content = source;
|
|
300
|
-
if (!
|
|
309
|
+
if (!JS_EXTENSIONS.some(function(ext) {
|
|
310
|
+
return filename.endsWith(ext);
|
|
311
|
+
})) return [
|
|
301
312
|
3,
|
|
302
313
|
2
|
|
303
314
|
];
|
|
@@ -366,4 +377,4 @@ var hasLoader = function() {
|
|
|
366
377
|
return _ref.apply(this, arguments);
|
|
367
378
|
};
|
|
368
379
|
}();
|
|
369
|
-
export { getDefaultImports, hasLoader,
|
|
380
|
+
export { getDefaultImports, hasLoader, isNestedRouteComponent, isPageComponentFile, parseModule, replaceWithAlias, walkDirectory };
|
|
@@ -104,6 +104,7 @@ var PluginCompatModern = function(appContext, modernConfig, options) {
|
|
|
104
104
|
var ref;
|
|
105
105
|
return ((ref = config.tools) === null || ref === void 0 ? void 0 : ref.htmlPlugin) !== false && target2 !== "node" && target2 !== "web-worker";
|
|
106
106
|
};
|
|
107
|
+
var ref;
|
|
107
108
|
var builderNormalizedConfig = api.getNormalizedConfig();
|
|
108
109
|
if (target === "node") {
|
|
109
110
|
chain.name("server");
|
|
@@ -147,7 +148,8 @@ var PluginCompatModern = function(appContext, modernConfig, options) {
|
|
|
147
148
|
var existNestedRoutes = entrypoints.some(function(entrypoint) {
|
|
148
149
|
return entrypoint.nestedRoutesEntry;
|
|
149
150
|
});
|
|
150
|
-
var
|
|
151
|
+
var routerConfig = modernConfig === null || modernConfig === void 0 ? void 0 : (ref = modernConfig.runtime) === null || ref === void 0 ? void 0 : ref.router;
|
|
152
|
+
var routerManifest = Boolean(routerConfig === null || routerConfig === void 0 ? void 0 : routerConfig.manifest);
|
|
151
153
|
if (existNestedRoutes || routerManifest) {
|
|
152
154
|
chain.plugin("route-plugin").use(RouterPlugin);
|
|
153
155
|
}
|
|
@@ -180,6 +182,9 @@ function applyNodeCompat(chain, modernConfig, isProd) {
|
|
|
180
182
|
if (isProd2 && ((outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg) === true || typeof (outputConfig === null || outputConfig === void 0 ? void 0 : (ref = outputConfig.ssg) === null || ref === void 0 ? void 0 : ref[0]) === "function")) {
|
|
181
183
|
return;
|
|
182
184
|
}
|
|
185
|
+
if (typeof entries === "undefined") {
|
|
186
|
+
throw new Error("No entry found, one of src/routes/layout.tsx, src/App.tsx, src/index.tsx is required");
|
|
187
|
+
}
|
|
183
188
|
var entryNames = Object.keys(entries);
|
|
184
189
|
if (isProd2 && entryNames.length === 1 && (outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg)) {
|
|
185
190
|
return;
|
|
@@ -201,23 +201,24 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
201
201
|
};
|
|
202
202
|
import { createBuilder } from "@modern-js/builder";
|
|
203
203
|
import { builderWebpackProvider } from "@modern-js/builder-webpack-provider";
|
|
204
|
-
import { applyOptionsChain, isUseSSRBundle } from "@modern-js/utils";
|
|
204
|
+
import { applyOptionsChain, isProd, isSSR, isUseSSRBundle } from "@modern-js/utils";
|
|
205
205
|
import { PluginCompatModern } from "./builderPlugins/compatModern";
|
|
206
206
|
import { createCopyPattern } from "./share";
|
|
207
207
|
function getBuilderTargets(normalizedConfig) {
|
|
208
208
|
var targets = [
|
|
209
209
|
"web"
|
|
210
210
|
];
|
|
211
|
-
|
|
211
|
+
var useNodeTarget = isProd() ? isUseSSRBundle(normalizedConfig) : isSSR(normalizedConfig);
|
|
212
|
+
if (useNodeTarget) {
|
|
212
213
|
targets.push("node");
|
|
213
214
|
}
|
|
214
215
|
return targets;
|
|
215
216
|
}
|
|
216
|
-
function
|
|
217
|
-
return
|
|
217
|
+
function createBuilderForModern(_) {
|
|
218
|
+
return _createBuilderForModern.apply(this, arguments);
|
|
218
219
|
}
|
|
219
|
-
function
|
|
220
|
-
|
|
220
|
+
function _createBuilderForModern() {
|
|
221
|
+
_createBuilderForModern = _asyncToGenerator(function(param) {
|
|
221
222
|
var normalizedConfig, appContext, compatPluginConfig, builderConfig, webpackProvider, target, builderOptions, builder;
|
|
222
223
|
return __generator(this, function(_state) {
|
|
223
224
|
switch(_state.label){
|
|
@@ -248,7 +249,7 @@ function _createBuilderForEdenX() {
|
|
|
248
249
|
}
|
|
249
250
|
});
|
|
250
251
|
});
|
|
251
|
-
return
|
|
252
|
+
return _createBuilderForModern.apply(this, arguments);
|
|
252
253
|
}
|
|
253
254
|
function createBuilderProviderConfig(normalizedConfig, appContext) {
|
|
254
255
|
var createOutputConfig = function createOutputConfig(config, appContext2) {
|
|
@@ -270,19 +271,11 @@ function createBuilderProviderConfig(normalizedConfig, appContext) {
|
|
|
270
271
|
htmlConfig.templateByEntries = _objectSpread({}, htmlConfig.templateByEntries, appContext.htmlTemplates);
|
|
271
272
|
}
|
|
272
273
|
return _objectSpreadProps(_objectSpread({}, normalizedConfig), {
|
|
273
|
-
source: _objectSpreadProps(_objectSpread({}, normalizedConfig.source), {
|
|
274
|
-
resolveExtensionPrefix: ".web"
|
|
275
|
-
}),
|
|
276
274
|
output: output,
|
|
277
|
-
dev: {
|
|
278
|
-
port: (ref = normalizedConfig.server) === null || ref === void 0 ? void 0 : ref.port
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
},
|
|
282
|
-
html: htmlConfig,
|
|
283
|
-
performance: _objectSpreadProps(_objectSpread({}, normalizedConfig.performance), {
|
|
284
|
-
removeMomentLocale: true
|
|
285
|
-
})
|
|
275
|
+
dev: _objectSpreadProps(_objectSpread({}, normalizedConfig.dev), {
|
|
276
|
+
port: (ref = normalizedConfig.server) === null || ref === void 0 ? void 0 : ref.port
|
|
277
|
+
}),
|
|
278
|
+
html: htmlConfig
|
|
286
279
|
});
|
|
287
280
|
}
|
|
288
281
|
function createBuilderOptions(target, appContext) {
|
|
@@ -379,4 +372,4 @@ function _applyBuilderPlugins() {
|
|
|
379
372
|
});
|
|
380
373
|
return _applyBuilderPlugins.apply(this, arguments);
|
|
381
374
|
}
|
|
382
|
-
export {
|
|
375
|
+
export { createBuilderForModern, createBuilderOptions, createBuilderProviderConfig };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { template as lodashTemplate } from "@modern-js/utils/lodash";
|
|
3
2
|
import { removeTailSlash } from "@modern-js/utils";
|
|
4
3
|
function createCopyPattern(appContext, config, patternsType, chain) {
|
|
5
4
|
var configDir = path.resolve(appContext.appDirectory, config.source.configDir || "./config");
|
|
@@ -25,9 +24,7 @@ function createCopyPattern(appContext, config, patternsType, chain) {
|
|
|
25
24
|
if (!/\.html?$/.test(absoluteFrom)) {
|
|
26
25
|
return content;
|
|
27
26
|
}
|
|
28
|
-
return
|
|
29
|
-
assetPrefix: removeTailSlash(chain.output.get("publicPath"))
|
|
30
|
-
});
|
|
27
|
+
return content.toString("utf8").replace(/<%=\s*assetPrefix\s*%>/g, removeTailSlash(chain.output.get("publicPath")));
|
|
31
28
|
}
|
|
32
29
|
};
|
|
33
30
|
} else {
|
|
@@ -288,7 +288,9 @@ var RouterPlugin = /*#__PURE__*/ function() {
|
|
|
288
288
|
return entryChunkIds.includes(chunk.name);
|
|
289
289
|
});
|
|
290
290
|
entryChunkFiles = entryChunks.map(function(chunk) {
|
|
291
|
-
return _toConsumableArray(chunk.files)
|
|
291
|
+
return _toConsumableArray(chunk.files).find(function(fname) {
|
|
292
|
+
return fname.includes(".js");
|
|
293
|
+
});
|
|
292
294
|
});
|
|
293
295
|
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
294
296
|
try {
|
|
@@ -181,9 +181,10 @@ import { setServer, createServer, injectDataLoaderPlugin } from "../utils/create
|
|
|
181
181
|
import { generateRoutes } from "../utils/routes";
|
|
182
182
|
import { getSpecifiedEntries } from "../utils/getSpecifiedEntries";
|
|
183
183
|
import { buildServerConfig } from "../utils/config";
|
|
184
|
+
import { getServerInternalPlugins } from "../utils/getServerInternalPlugins";
|
|
184
185
|
var dev = function() {
|
|
185
186
|
var _ref = _asyncToGenerator(function(api, options) {
|
|
186
|
-
var ref, normalizedConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, entrypoints, serverConfigFile,
|
|
187
|
+
var ref, normalizedConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, entrypoints, serverConfigFile, checkedEntries, serverInternalPlugins, serverOptions, app, server;
|
|
187
188
|
return __generator(this, function(_state) {
|
|
188
189
|
switch(_state.label){
|
|
189
190
|
case 0:
|
|
@@ -197,7 +198,7 @@ var dev = function() {
|
|
|
197
198
|
cliOptions: options
|
|
198
199
|
});
|
|
199
200
|
ResolvedConfigContext.set(normalizedConfig);
|
|
200
|
-
appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, port = appContext.port, apiOnly = appContext.apiOnly, entrypoints = appContext.entrypoints, serverConfigFile = appContext.serverConfigFile
|
|
201
|
+
appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, port = appContext.port, apiOnly = appContext.apiOnly, entrypoints = appContext.entrypoints, serverConfigFile = appContext.serverConfigFile;
|
|
201
202
|
return [
|
|
202
203
|
4,
|
|
203
204
|
getSpecifiedEntries(options.entry || false, entrypoints)
|
|
@@ -232,30 +233,23 @@ var dev = function() {
|
|
|
232
233
|
if (!appContext.builder && !apiOnly) {
|
|
233
234
|
throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
|
|
234
235
|
}
|
|
235
|
-
if (!!apiOnly) return [
|
|
236
|
-
3,
|
|
237
|
-
5
|
|
238
|
-
];
|
|
239
236
|
return [
|
|
240
237
|
4,
|
|
241
|
-
appContext
|
|
238
|
+
generateRoutes(appContext)
|
|
242
239
|
];
|
|
243
240
|
case 4:
|
|
244
|
-
|
|
245
|
-
_state.label = 5;
|
|
246
|
-
case 5:
|
|
241
|
+
_state.sent();
|
|
247
242
|
return [
|
|
248
243
|
4,
|
|
249
|
-
|
|
244
|
+
getServerInternalPlugins(api)
|
|
250
245
|
];
|
|
251
|
-
case
|
|
252
|
-
_state.sent();
|
|
246
|
+
case 5:
|
|
247
|
+
serverInternalPlugins = _state.sent();
|
|
253
248
|
serverOptions = {
|
|
254
249
|
dev: _objectSpread({
|
|
255
250
|
port: port,
|
|
256
251
|
https: normalizedConfig.dev.https
|
|
257
252
|
}, (ref = normalizedConfig.tools) === null || ref === void 0 ? void 0 : ref.devServer),
|
|
258
|
-
compiler: compiler || null,
|
|
259
253
|
pwd: appDirectory,
|
|
260
254
|
config: normalizedConfig,
|
|
261
255
|
serverConfigFile: serverConfigFile,
|
|
@@ -263,13 +257,15 @@ var dev = function() {
|
|
|
263
257
|
};
|
|
264
258
|
if (!apiOnly) return [
|
|
265
259
|
3,
|
|
266
|
-
|
|
260
|
+
7
|
|
267
261
|
];
|
|
268
262
|
return [
|
|
269
263
|
4,
|
|
270
|
-
createServer(serverOptions)
|
|
264
|
+
createServer(_objectSpreadProps(_objectSpread({}, serverOptions), {
|
|
265
|
+
compiler: null
|
|
266
|
+
}))
|
|
271
267
|
];
|
|
272
|
-
case
|
|
268
|
+
case 6:
|
|
273
269
|
app = _state.sent();
|
|
274
270
|
app.listen(port, function() {
|
|
275
271
|
var _ref = _asyncToGenerator(function(err) {
|
|
@@ -289,27 +285,26 @@ var dev = function() {
|
|
|
289
285
|
}());
|
|
290
286
|
return [
|
|
291
287
|
3,
|
|
292
|
-
|
|
288
|
+
9
|
|
293
289
|
];
|
|
294
|
-
case
|
|
290
|
+
case 7:
|
|
295
291
|
return [
|
|
296
292
|
4,
|
|
297
293
|
appContext.builder.startDevServer({
|
|
298
|
-
compiler: compiler,
|
|
299
294
|
printURLs: false,
|
|
300
295
|
serverOptions: serverOptions
|
|
301
296
|
})
|
|
302
297
|
];
|
|
303
|
-
case
|
|
298
|
+
case 8:
|
|
304
299
|
server = _state.sent().server;
|
|
305
300
|
setServer(server);
|
|
306
|
-
_state.label =
|
|
307
|
-
case
|
|
301
|
+
_state.label = 9;
|
|
302
|
+
case 9:
|
|
308
303
|
return [
|
|
309
304
|
4,
|
|
310
305
|
createFileWatcher(appContext, normalizedConfig.source.configDir, hookRunners)
|
|
311
306
|
];
|
|
312
|
-
case
|
|
307
|
+
case 10:
|
|
313
308
|
_state.sent();
|
|
314
309
|
return [
|
|
315
310
|
2
|