@modern-js/app-tools 2.0.0-beta.1 → 2.0.0-beta.2
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 +194 -0
- package/dist/js/modern/analyze/generateCode.js +1 -1
- package/dist/js/modern/analyze/getBundleEntry.js +1 -1
- package/dist/js/modern/analyze/getFileSystemEntry.js +1 -1
- package/dist/js/modern/analyze/getHtmlTemplate.js +1 -1
- package/dist/js/modern/analyze/getServerRoutes.js +10 -6
- package/dist/js/modern/analyze/index.js +12 -27
- package/dist/js/modern/builder/builderPlugins/compatModern.js +12 -11
- package/dist/js/modern/builder/index.js +33 -16
- package/dist/js/modern/builder/share.js +1 -1
- package/dist/js/modern/commands/build.js +8 -2
- package/dist/js/modern/commands/dev.js +18 -9
- package/dist/js/modern/commands/inspect.js +4 -2
- package/dist/js/modern/commands/start.js +1 -0
- package/dist/js/modern/config/default.js +207 -0
- package/dist/js/modern/config/index.js +2 -0
- package/dist/js/modern/config/initial/createHtmlConfig.js +32 -0
- package/dist/js/modern/{builder → config/initial}/createOutputConfig.js +14 -16
- package/dist/js/modern/config/initial/createSourceConfig.js +32 -0
- package/dist/js/modern/config/initial/createToolsConfig.js +41 -0
- package/dist/js/modern/config/initial/index.js +11 -0
- package/dist/js/modern/config/initial/inits.js +117 -0
- package/dist/js/modern/config/initial/transformNormalizedConfig.js +40 -0
- package/dist/js/modern/defineConfig.js +12 -0
- package/dist/js/modern/hooks.js +23 -19
- package/dist/js/modern/index.js +7 -5
- package/dist/js/modern/initialize/index.js +72 -0
- package/dist/js/modern/schema/Schema.js +39 -0
- package/dist/js/modern/schema/index.js +139 -0
- package/dist/js/modern/schema/legacy.js +284 -0
- 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 +2 -0
- 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 +4 -0
- 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 +1 -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 +1 -1
- package/dist/js/modern/utils/createFileWatcher.js +82 -0
- package/dist/js/modern/utils/restart.js +17 -0
- package/dist/js/node/analyze/generateCode.js +1 -1
- package/dist/js/node/analyze/getBundleEntry.js +1 -1
- package/dist/js/node/analyze/getFileSystemEntry.js +1 -1
- package/dist/js/node/analyze/getHtmlTemplate.js +1 -1
- package/dist/js/node/analyze/getServerRoutes.js +10 -6
- package/dist/js/node/analyze/index.js +13 -39
- package/dist/js/node/builder/builderPlugins/compatModern.js +12 -11
- package/dist/js/node/builder/index.js +34 -16
- package/dist/js/node/builder/share.js +1 -1
- package/dist/js/node/commands/build.js +8 -2
- package/dist/js/node/commands/dev.js +18 -9
- package/dist/js/node/commands/inspect.js +4 -2
- package/dist/js/node/commands/start.js +1 -0
- package/dist/js/node/config/default.js +214 -0
- package/dist/js/node/config/index.js +31 -0
- package/dist/js/node/config/initial/createHtmlConfig.js +38 -0
- package/dist/js/node/{builder → config/initial}/createOutputConfig.js +14 -16
- package/dist/js/node/config/initial/createSourceConfig.js +38 -0
- package/dist/js/node/config/initial/createToolsConfig.js +47 -0
- package/dist/js/node/config/initial/index.js +24 -0
- package/dist/js/node/config/initial/inits.js +127 -0
- package/dist/js/node/config/initial/transformNormalizedConfig.js +46 -0
- package/dist/js/node/defineConfig.js +20 -0
- package/dist/js/node/hooks.js +23 -28
- package/dist/js/node/index.js +30 -16
- package/dist/js/node/initialize/index.js +79 -0
- package/dist/js/node/schema/Schema.js +46 -0
- package/dist/js/node/schema/index.js +152 -0
- package/dist/js/node/schema/legacy.js +291 -0
- package/dist/js/node/types/config/deploy.js +0 -0
- package/dist/js/node/types/config/dev.js +0 -0
- package/dist/js/node/types/config/experiments.js +0 -0
- package/dist/js/node/types/config/html.js +0 -0
- package/dist/js/node/types/config/index.js +16 -0
- package/dist/js/node/types/config/output.js +0 -0
- package/dist/js/node/types/config/performance.js +0 -0
- package/dist/js/node/types/config/security.js +0 -0
- package/dist/js/node/types/config/source.js +0 -0
- package/dist/js/node/types/config/tools.js +0 -0
- package/dist/js/node/types/hooks.js +0 -0
- package/dist/js/node/types/index.js +38 -0
- package/dist/js/node/types/legacyConfig/deploy.js +0 -0
- package/dist/js/node/types/legacyConfig/dev.js +0 -0
- package/dist/js/node/types/legacyConfig/index.js +0 -0
- package/dist/js/node/types/legacyConfig/output.js +5 -0
- package/dist/js/node/types/legacyConfig/source.js +0 -0
- package/dist/js/node/types/legacyConfig/tools.js +0 -0
- package/dist/js/node/utils/config.js +1 -1
- package/dist/js/node/utils/createFileWatcher.js +90 -0
- package/dist/js/node/utils/restart.js +23 -0
- package/dist/js/treeshaking/analyze/generateCode.js +1 -1
- package/dist/js/treeshaking/analyze/getBundleEntry.js +1 -1
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +1 -1
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +1 -1
- package/dist/js/treeshaking/analyze/getServerRoutes.js +8 -7
- package/dist/js/treeshaking/analyze/index.js +10 -26
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +12 -11
- package/dist/js/treeshaking/builder/index.js +31 -16
- package/dist/js/treeshaking/builder/share.js +1 -1
- package/dist/js/treeshaking/commands/build.js +33 -23
- package/dist/js/treeshaking/commands/dev.js +36 -22
- package/dist/js/treeshaking/commands/inspect.js +8 -3
- package/dist/js/treeshaking/commands/start.js +1 -0
- package/dist/js/treeshaking/config/default.js +200 -0
- package/dist/js/treeshaking/config/index.js +2 -0
- package/dist/js/treeshaking/config/initial/createHtmlConfig.js +31 -0
- package/dist/js/treeshaking/config/initial/createOutputConfig.js +67 -0
- package/dist/js/treeshaking/config/initial/createSourceConfig.js +41 -0
- package/dist/js/treeshaking/config/initial/createToolsConfig.js +38 -0
- package/dist/js/treeshaking/config/initial/index.js +11 -0
- package/dist/js/treeshaking/config/initial/inits.js +114 -0
- package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +38 -0
- package/dist/js/treeshaking/defineConfig.js +14 -0
- package/dist/js/treeshaking/hooks.js +23 -19
- package/dist/js/treeshaking/index.js +7 -5
- package/dist/js/treeshaking/initialize/index.js +121 -0
- package/dist/js/treeshaking/schema/Schema.js +75 -0
- package/dist/js/treeshaking/schema/index.js +138 -0
- package/dist/js/treeshaking/schema/legacy.js +273 -0
- package/dist/js/treeshaking/types/config/deploy.js +0 -0
- package/dist/js/treeshaking/types/config/dev.js +0 -0
- package/dist/js/treeshaking/types/config/experiments.js +0 -0
- package/dist/js/treeshaking/types/config/html.js +0 -0
- package/dist/js/treeshaking/types/config/index.js +2 -0
- package/dist/js/treeshaking/types/config/output.js +0 -0
- package/dist/js/treeshaking/types/config/performance.js +0 -0
- package/dist/js/treeshaking/types/config/security.js +0 -0
- package/dist/js/treeshaking/types/config/source.js +0 -0
- package/dist/js/treeshaking/types/config/tools.js +0 -0
- package/dist/js/treeshaking/types/hooks.js +0 -0
- package/dist/js/treeshaking/types/index.js +4 -0
- package/dist/js/treeshaking/types/legacyConfig/deploy.js +0 -0
- package/dist/js/treeshaking/types/legacyConfig/dev.js +0 -0
- package/dist/js/treeshaking/types/legacyConfig/index.js +0 -0
- package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/source.js +0 -0
- package/dist/js/treeshaking/types/legacyConfig/tools.js +0 -0
- package/dist/js/treeshaking/utils/config.js +1 -1
- package/dist/js/treeshaking/utils/createFileWatcher.js +123 -0
- package/dist/js/treeshaking/utils/restart.js +45 -0
- package/dist/types/analyze/generateCode.d.ts +3 -2
- package/dist/types/analyze/getBundleEntry.d.ts +2 -2
- package/dist/types/analyze/getFileSystemEntry.d.ts +2 -2
- package/dist/types/analyze/getHtmlTemplate.d.ts +3 -3
- package/dist/types/analyze/getServerRoutes.d.ts +3 -2
- package/dist/types/analyze/index.d.ts +3 -41
- package/dist/types/analyze/templates.d.ts +1 -1
- package/dist/types/analyze/utils.d.ts +1 -1
- package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -2
- package/dist/types/builder/index.d.ts +5 -2
- package/dist/types/builder/share.d.ts +2 -2
- package/dist/types/commands/build.d.ts +2 -2
- package/dist/types/commands/deploy.d.ts +2 -2
- package/dist/types/commands/dev.d.ts +2 -2
- package/dist/types/commands/inspect.d.ts +9 -1
- package/dist/types/commands/start.d.ts +2 -2
- package/dist/types/config/default.d.ts +3 -0
- package/dist/types/config/index.d.ts +2 -0
- package/dist/types/config/initial/createHtmlConfig.d.ts +2 -0
- package/dist/types/config/initial/createOutputConfig.d.ts +2 -0
- package/dist/types/config/initial/createSourceConfig.d.ts +2 -0
- package/dist/types/config/initial/createToolsConfig.d.ts +2 -0
- package/dist/types/config/initial/index.d.ts +4 -0
- package/dist/types/config/initial/inits.d.ts +4 -0
- package/dist/types/config/initial/transformNormalizedConfig.d.ts +2 -0
- package/dist/types/defineConfig.d.ts +7 -0
- package/dist/types/hooks.d.ts +2 -42
- package/dist/types/index.d.ts +5 -5
- package/dist/types/initialize/index.d.ts +3 -0
- package/dist/types/schema/Schema.d.ts +14 -0
- package/dist/types/schema/index.d.ts +4 -0
- package/dist/types/schema/legacy.d.ts +3 -0
- package/dist/types/types/config/deploy.d.ts +9 -0
- package/dist/types/types/config/dev.d.ts +13 -0
- package/dist/types/types/config/experiments.d.ts +4 -0
- package/dist/types/types/config/html.d.ts +4 -0
- package/dist/types/types/config/index.d.ts +62 -0
- package/dist/types/types/config/output.d.ts +23 -0
- package/dist/types/types/config/performance.d.ts +4 -0
- package/dist/types/types/config/security.d.ts +4 -0
- package/dist/types/types/config/source.d.ts +22 -0
- package/dist/types/types/config/tools.d.ts +15 -0
- package/dist/types/types/hooks.d.ts +80 -0
- package/dist/types/types/index.d.ts +23 -0
- package/dist/types/types/legacyConfig/deploy.d.ts +8 -0
- package/dist/types/types/legacyConfig/dev.d.ts +12 -0
- package/dist/types/types/legacyConfig/index.d.ts +33 -0
- package/dist/types/types/legacyConfig/output.d.ts +51 -0
- package/dist/types/types/legacyConfig/source.d.ts +25 -0
- package/dist/types/types/legacyConfig/tools.d.ts +16 -0
- package/dist/types/utils/config.d.ts +2 -2
- package/dist/types/utils/createFileWatcher.d.ts +3 -0
- package/dist/types/utils/printInstructions.d.ts +3 -3
- package/dist/types/utils/restart.d.ts +3 -0
- package/package.json +24 -24
- package/dist/js/modern/builder/createHtmlConfig.js +0 -58
- package/dist/js/modern/builder/createSourceConfig.js +0 -74
- package/dist/js/modern/builder/createToolsConfig.js +0 -87
- package/dist/js/node/builder/createHtmlConfig.js +0 -68
- package/dist/js/node/builder/createSourceConfig.js +0 -82
- package/dist/js/node/builder/createToolsConfig.js +0 -94
- package/dist/js/treeshaking/builder/createHtmlConfig.js +0 -59
- package/dist/js/treeshaking/builder/createOutputConfig.js +0 -70
- package/dist/js/treeshaking/builder/createSourceConfig.js +0 -88
- package/dist/js/treeshaking/builder/createToolsConfig.js +0 -85
- package/dist/types/builder/createHtmlConfig.d.ts +0 -6
- package/dist/types/builder/createOutputConfig.d.ts +0 -3
- package/dist/types/builder/createSourceConfig.d.ts +0 -5
- package/dist/types/builder/createToolsConfig.d.ts +0 -13
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.restart = restart;
|
|
7
|
+
var _core = require("@modern-js/core");
|
|
8
|
+
var _utils = require("@modern-js/utils");
|
|
9
|
+
async function restart(hooksRunner) {
|
|
10
|
+
_utils.logger.info('Restart...\n');
|
|
11
|
+
let hasGetError = false;
|
|
12
|
+
await hooksRunner.beforeRestart();
|
|
13
|
+
try {
|
|
14
|
+
await _core.cli.init(_core.cli.initOptions);
|
|
15
|
+
} catch (err) {
|
|
16
|
+
console.error(err);
|
|
17
|
+
hasGetError = true;
|
|
18
|
+
} finally {
|
|
19
|
+
if (!hasGetError) {
|
|
20
|
+
_utils.program.parse(process.argv);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -352,7 +352,7 @@ export var generateCode = /*#__PURE__*/function () {
|
|
|
352
352
|
internalDirectory = appContext.internalDirectory, distDirectory = appContext.distDirectory, srcDirectory = appContext.srcDirectory, internalDirAlias = appContext.internalDirAlias, internalSrcAlias = appContext.internalSrcAlias;
|
|
353
353
|
hookRunners = api.useHookRunners();
|
|
354
354
|
islegacy = Boolean(config === null || config === void 0 ? void 0 : (_config$runtime = config.runtime) === null || _config$runtime === void 0 ? void 0 : (_config$runtime$route = _config$runtime.router) === null || _config$runtime$route === void 0 ? void 0 : _config$runtime$route.legacy);
|
|
355
|
-
mountId = config.
|
|
355
|
+
mountId = config.html.mountId;
|
|
356
356
|
getRoutes = islegacy ? getClientRoutesLegacy : getClientRoutes;
|
|
357
357
|
_context3.next = 9;
|
|
358
358
|
return Promise.all(entrypoints.map(generateEntryCode));
|
|
@@ -55,7 +55,7 @@ export var getBundleEntry = function getBundleEntry(appContext, config) {
|
|
|
55
55
|
}
|
|
56
56
|
if (!disableDefaultEntries) {
|
|
57
57
|
// find main entry point which server route is '/'.
|
|
58
|
-
var entriesDirAbs = ensureAbsolutePath(appDirectory, entriesDir);
|
|
58
|
+
var entriesDirAbs = ensureAbsolutePath(appDirectory, entriesDir || '');
|
|
59
59
|
var found = defaults.find(function (_ref) {
|
|
60
60
|
var entryName = _ref.entryName,
|
|
61
61
|
entry = _ref.entry,
|
|
@@ -79,7 +79,7 @@ var scanDir = function scanDir(dirs) {
|
|
|
79
79
|
export var getFileSystemEntry = function getFileSystemEntry(appContext, config) {
|
|
80
80
|
var appDirectory = appContext.appDirectory;
|
|
81
81
|
var entriesDir = config.source.entriesDir;
|
|
82
|
-
var src = ensureAbsolutePath(appDirectory, entriesDir);
|
|
82
|
+
var src = ensureAbsolutePath(appDirectory, entriesDir || '');
|
|
83
83
|
if (fs.existsSync(src)) {
|
|
84
84
|
if (fs.statSync(src).isDirectory()) {
|
|
85
85
|
return scanDir(isBundleEntry(src) ? [src] : fs.readdirSync(src).map(function (file) {
|
|
@@ -40,7 +40,7 @@ export var getHtmlTemplate = /*#__PURE__*/function () {
|
|
|
40
40
|
appContext = _ref.appContext, config = _ref.config;
|
|
41
41
|
appDirectory = appContext.appDirectory, internalDirectory = appContext.internalDirectory;
|
|
42
42
|
configDir = config.source.configDir;
|
|
43
|
-
htmlDir = path.resolve(appDirectory, configDir, HTML_PARTIALS_FOLDER);
|
|
43
|
+
htmlDir = path.resolve(appDirectory, configDir || '', HTML_PARTIALS_FOLDER);
|
|
44
44
|
htmlTemplates = {};
|
|
45
45
|
_iterator = _createForOfIteratorHelper(entrypoints);
|
|
46
46
|
_context2.prev = 6;
|
|
@@ -87,10 +87,10 @@ var applyRouteOptions = function applyRouteOptions(original, routeOptions) {
|
|
|
87
87
|
* @returns entrypoint Routes
|
|
88
88
|
*/
|
|
89
89
|
var collectHtmlRoutes = function collectHtmlRoutes(entrypoints, appContext, config) {
|
|
90
|
-
var
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
var disableHtmlFolder = config.html.disableHtmlFolder,
|
|
91
|
+
_config$output$distPa = config.output.distPath;
|
|
92
|
+
_config$output$distPa = _config$output$distPa === void 0 ? {} : _config$output$distPa;
|
|
93
|
+
var htmlPath = _config$output$distPa.html,
|
|
94
94
|
_config$server = config.server,
|
|
95
95
|
baseUrl = _config$server.baseUrl,
|
|
96
96
|
routes = _config$server.routes,
|
|
@@ -110,7 +110,8 @@ var collectHtmlRoutes = function collectHtmlRoutes(entrypoints, appContext, conf
|
|
|
110
110
|
isSPA: true,
|
|
111
111
|
isSSR: isSSR,
|
|
112
112
|
responseHeaders: resHeaders,
|
|
113
|
-
|
|
113
|
+
// FIXME: remove the config.enableModernMode
|
|
114
|
+
// enableModernMode: Boolean(enableModernMode),
|
|
114
115
|
bundle: isSSR ? "".concat(SERVER_BUNDLE_DIRECTORY, "/").concat(entryName, ".js") : undefined
|
|
115
116
|
};
|
|
116
117
|
if (routes !== null && routes !== void 0 && routes.hasOwnProperty(entryName)) {
|
|
@@ -136,14 +137,14 @@ var collectStaticRoutes = function collectStaticRoutes(appContext, config) {
|
|
|
136
137
|
var configDir = config.source.configDir,
|
|
137
138
|
_config$server$public = config.server.publicRoutes,
|
|
138
139
|
publicRoutes = _config$server$public === void 0 ? {} : _config$server$public;
|
|
139
|
-
var publicFolder = path.resolve(appDirectory, configDir, 'public');
|
|
140
|
+
var publicFolder = path.resolve(appDirectory, configDir || '', 'public');
|
|
140
141
|
return fs.existsSync(publicFolder) ? walkDirectory(publicFolder).map(function (filePath) {
|
|
141
142
|
var urlPath = "".concat(urlJoin(toPosix(filePath).slice(toPosix(publicFolder).length)));
|
|
142
143
|
return {
|
|
143
144
|
urlPath: publicRoutes[removeLeadingSlash(urlPath)] || urlPath,
|
|
144
145
|
isSPA: true,
|
|
145
146
|
isSSR: false,
|
|
146
|
-
entryPath: toPosix(path.relative(path.resolve(appDirectory, configDir), filePath))
|
|
147
|
+
entryPath: toPosix(path.relative(path.resolve(appDirectory, configDir || ''), filePath))
|
|
147
148
|
};
|
|
148
149
|
}) : [];
|
|
149
150
|
};
|
|
@@ -3,7 +3,6 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
3
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
4
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
5
|
import * as path from 'path';
|
|
6
|
-
import { createAsyncWaterfall } from '@modern-js/plugin';
|
|
7
6
|
import { createDebugger, fs, isApiOnly } from '@modern-js/utils';
|
|
8
7
|
import { cloneDeep } from '@modern-js/utils/lodash';
|
|
9
8
|
import { createBuilderForEdenX } from "../builder";
|
|
@@ -11,35 +10,12 @@ import { printInstructions } from "../utils/printInstructions";
|
|
|
11
10
|
import { generateRoutes } from "../utils/routes";
|
|
12
11
|
import { emitResolvedConfig } from "../utils/config";
|
|
13
12
|
import { getCommand } from "../utils/commands";
|
|
13
|
+
import { initialNormalizedConfig } from "../config";
|
|
14
14
|
import { isRouteComponentFile } from "./utils";
|
|
15
15
|
var debug = createDebugger('plugin-analyze');
|
|
16
|
-
export var modifyEntryImports = createAsyncWaterfall();
|
|
17
|
-
export var modifyEntryExport = createAsyncWaterfall();
|
|
18
|
-
export var addRuntimeExports = createAsyncWaterfall();
|
|
19
|
-
export var modifyEntryRuntimePlugins = createAsyncWaterfall();
|
|
20
|
-
export var modifyEntryRenderFunction = createAsyncWaterfall();
|
|
21
|
-
export var modifyAsyncEntry = createAsyncWaterfall();
|
|
22
|
-
export var modifyFileSystemRoutes = createAsyncWaterfall();
|
|
23
|
-
export var modifyServerRoutes = createAsyncWaterfall();
|
|
24
|
-
export var htmlPartials = createAsyncWaterfall();
|
|
25
|
-
export var beforeGenerateRoutes = createAsyncWaterfall();
|
|
26
|
-
export var addDefineTypes = createAsyncWaterfall();
|
|
27
16
|
export default (function () {
|
|
28
17
|
return {
|
|
29
18
|
name: '@modern-js/plugin-analyze',
|
|
30
|
-
registerHook: {
|
|
31
|
-
modifyAsyncEntry: modifyAsyncEntry,
|
|
32
|
-
modifyEntryImports: modifyEntryImports,
|
|
33
|
-
modifyEntryExport: modifyEntryExport,
|
|
34
|
-
modifyEntryRuntimePlugins: modifyEntryRuntimePlugins,
|
|
35
|
-
modifyEntryRenderFunction: modifyEntryRenderFunction,
|
|
36
|
-
modifyFileSystemRoutes: modifyFileSystemRoutes,
|
|
37
|
-
modifyServerRoutes: modifyServerRoutes,
|
|
38
|
-
htmlPartials: htmlPartials,
|
|
39
|
-
addRuntimeExports: addRuntimeExports,
|
|
40
|
-
beforeGenerateRoutes: beforeGenerateRoutes,
|
|
41
|
-
addDefineTypes: addDefineTypes
|
|
42
|
-
},
|
|
43
19
|
setup: function setup(api) {
|
|
44
20
|
var pagesDir = [];
|
|
45
21
|
var originEntrypoints = [];
|
|
@@ -61,7 +37,7 @@ export default (function () {
|
|
|
61
37
|
// FIXME:
|
|
62
38
|
}
|
|
63
39
|
_context6.next = 6;
|
|
64
|
-
return isApiOnly(appContext.appDirectory,
|
|
40
|
+
return isApiOnly(appContext.appDirectory, (_resolvedConfig$sourc = resolvedConfig.source) === null || _resolvedConfig$sourc === void 0 ? void 0 : _resolvedConfig$sourc.entriesDir);
|
|
65
41
|
case 6:
|
|
66
42
|
apiOnly = _context6.sent;
|
|
67
43
|
_context6.next = 9;
|
|
@@ -291,6 +267,14 @@ export default (function () {
|
|
|
291
267
|
watchFiles: function watchFiles() {
|
|
292
268
|
return pagesDir;
|
|
293
269
|
},
|
|
270
|
+
resolvedConfig: function resolvedConfig(_ref6) {
|
|
271
|
+
var resolved = _ref6.resolved;
|
|
272
|
+
var appContext = api.useAppContext();
|
|
273
|
+
var config = initialNormalizedConfig(resolved, appContext);
|
|
274
|
+
return {
|
|
275
|
+
resolved: config
|
|
276
|
+
};
|
|
277
|
+
},
|
|
294
278
|
fileChange: function fileChange(e) {
|
|
295
279
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
296
280
|
var appContext, appDirectory, filename, eventType, isPageFile, absoluteFilePath, isRouteComponent, resolvedConfig, _yield$import, generateCode, entrypoints;
|
|
@@ -62,14 +62,15 @@ export var PluginCompatModern = function PluginCompatModern(appContext, modernCo
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
// apply copy plugin
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
|
|
66
|
+
var defaultCopyPattern = createCopyPattern(appContext, modernConfig, 'public', chain);
|
|
67
|
+
chain.plugin(CHAIN_ID.PLUGIN.COPY).tap(function (args) {
|
|
68
|
+
var _args$;
|
|
69
|
+
return [{
|
|
70
|
+
patterns: [].concat(_toConsumableArray(((_args$ = args[0]) === null || _args$ === void 0 ? void 0 : _args$.patterns) || []), [defaultCopyPattern])
|
|
71
|
+
}];
|
|
72
|
+
});
|
|
73
|
+
}
|
|
73
74
|
var entrypoints = appContext.entrypoints;
|
|
74
75
|
var existNestedRoutes = entrypoints.some(function (entrypoint) {
|
|
75
76
|
return entrypoint.nestedRoutesEntry;
|
|
@@ -165,9 +166,9 @@ function applyBottomHtmlWebpackPlugin(_ref3) {
|
|
|
165
166
|
// FIXME: the only need necessary
|
|
166
167
|
var baseTemplateParams = _objectSpread({
|
|
167
168
|
entryName: entryName,
|
|
168
|
-
title: getEntryOptions(entryName, modernConfig.
|
|
169
|
-
mountId: modernConfig.
|
|
170
|
-
}, getEntryOptions(entryName, modernConfig.
|
|
169
|
+
title: getEntryOptions(entryName, modernConfig.html.title, modernConfig.html.titleByEntries, appContext.packageName),
|
|
170
|
+
mountId: modernConfig.html.mountId
|
|
171
|
+
}, getEntryOptions(entryName, modernConfig.html.templateParameters, modernConfig.html.templateParametersByEntries, appContext.packageName));
|
|
171
172
|
chain.plugin("".concat(CHAIN_ID.PLUGIN.HTML, "-").concat(entryName)).tap(function (args) {
|
|
172
173
|
return [_objectSpread(_objectSpread({}, args[0] || {}), {}, {
|
|
173
174
|
__internal__: true,
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
2
|
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
5
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
6
|
import { createBuilder } from '@modern-js/builder';
|
|
5
7
|
import { builderWebpackProvider } from '@modern-js/builder-webpack-provider';
|
|
6
8
|
import { applyOptionsChain, isUseSSRBundle } from '@modern-js/utils';
|
|
7
9
|
import { PluginCompatModern } from "./builderPlugins/compatModern";
|
|
8
|
-
import {
|
|
9
|
-
import { createOutputConfig } from "./createOutputConfig";
|
|
10
|
-
import { createSourceConfig } from "./createSourceConfig";
|
|
11
|
-
import { createToolsConfig } from "./createToolsConfig";
|
|
10
|
+
import { createCopyPattern } from "./share";
|
|
12
11
|
function getBuilderTargets(normalizedConfig) {
|
|
13
12
|
var targets = ['web'];
|
|
14
13
|
if (normalizedConfig.output.enableModernMode && !targets.includes('modern-web')) {
|
|
@@ -30,7 +29,8 @@ function _createBuilderForEdenX() {
|
|
|
30
29
|
switch (_context.prev = _context.next) {
|
|
31
30
|
case 0:
|
|
32
31
|
normalizedConfig = _ref.normalizedConfig, appContext = _ref.appContext, compatPluginConfig = _ref.compatPluginConfig;
|
|
33
|
-
|
|
32
|
+
// create webpack provider
|
|
33
|
+
builderConfig = createBuilderProviderConfig(normalizedConfig, appContext);
|
|
34
34
|
webpackProvider = builderWebpackProvider({
|
|
35
35
|
builderConfig: builderConfig
|
|
36
36
|
});
|
|
@@ -53,25 +53,40 @@ function _createBuilderForEdenX() {
|
|
|
53
53
|
}));
|
|
54
54
|
return _createBuilderForEdenX.apply(this, arguments);
|
|
55
55
|
}
|
|
56
|
-
function createBuilderProviderConfig(normalizedConfig, appContext) {
|
|
57
|
-
var source = createSourceConfig(normalizedConfig, appContext);
|
|
58
|
-
var html = createHtmlConfig(normalizedConfig, appContext);
|
|
56
|
+
export function createBuilderProviderConfig(normalizedConfig, appContext) {
|
|
59
57
|
var output = createOutputConfig(normalizedConfig, appContext);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
return _objectSpread(_objectSpread({}, normalizedConfig), {}, {
|
|
59
|
+
source: _objectSpread(_objectSpread({}, normalizedConfig.source), {}, {
|
|
60
|
+
resolveExtensionPrefix: '.web'
|
|
61
|
+
}),
|
|
64
62
|
output: output,
|
|
65
|
-
tools: tools,
|
|
66
63
|
dev: {
|
|
67
64
|
https: normalizedConfig.dev.https,
|
|
68
65
|
assetPrefix: normalizedConfig.dev.assetPrefix
|
|
69
66
|
},
|
|
70
|
-
|
|
67
|
+
html: _objectSpread(_objectSpread({}, normalizedConfig.html), {}, {
|
|
68
|
+
templateByEntries: normalizedConfig.html.templateByEntries || appContext.htmlTemplates
|
|
69
|
+
}),
|
|
70
|
+
performance: _objectSpread(_objectSpread({}, normalizedConfig.performance), {}, {
|
|
71
71
|
// `@modern-js/webpack` used to remove moment locale by default
|
|
72
72
|
removeMomentLocale: true
|
|
73
|
-
}
|
|
74
|
-
};
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
function createOutputConfig(config, appContext) {
|
|
76
|
+
var defaultCopyPattern = createCopyPattern(appContext, config, 'upload');
|
|
77
|
+
var copy = config.output.copy;
|
|
78
|
+
var copyOptions = Array.isArray(copy) ? copy : copy === null || copy === void 0 ? void 0 : copy.patterns;
|
|
79
|
+
var builderCopy = [].concat(_toConsumableArray(copyOptions || []), [defaultCopyPattern]);
|
|
80
|
+
return _objectSpread(_objectSpread({}, config.output), {}, {
|
|
81
|
+
copy: builderCopy,
|
|
82
|
+
// We need to do this in the app-tools prepare hook because some files will be generated into the dist directory in the analyze process
|
|
83
|
+
cleanDistPath: false,
|
|
84
|
+
// `@modern-js/webpack` used to generate asset manifest by default
|
|
85
|
+
enableAssetManifest: true,
|
|
86
|
+
// compatible the modern-js with fallback behavior
|
|
87
|
+
enableAssetFallback: true
|
|
88
|
+
});
|
|
89
|
+
}
|
|
75
90
|
}
|
|
76
91
|
export function createBuilderOptions(target, appContext) {
|
|
77
92
|
// create entries
|
|
@@ -2,7 +2,7 @@ import path from 'path';
|
|
|
2
2
|
import { template as lodashTemplate } from '@modern-js/utils/lodash';
|
|
3
3
|
import { removeTailSlash } from '@modern-js/utils';
|
|
4
4
|
export function createCopyPattern(appContext, config, patternsType, chain) {
|
|
5
|
-
var configDir = path.resolve(appContext.appDirectory, config.source.configDir);
|
|
5
|
+
var configDir = path.resolve(appContext.appDirectory, config.source.configDir || './config');
|
|
6
6
|
var uploadDir = path.posix.join(configDir.replace(/\\/g, '/'), 'upload');
|
|
7
7
|
var publicDir = path.posix.join(configDir.replace(/\\/g, '/'), 'public');
|
|
8
8
|
var minifiedJsRexExp = /\.min\.js/;
|
|
@@ -7,75 +7,85 @@ import { generateRoutes } from "../utils/routes";
|
|
|
7
7
|
import { buildServerConfig } from "../utils/config";
|
|
8
8
|
export var build = /*#__PURE__*/function () {
|
|
9
9
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, options) {
|
|
10
|
-
var resolvedConfig, appContext, hookRunners, apiOnly, _appDirectory, _distDirectory, _serverConfigFile, distDirectory, appDirectory, serverConfigFile
|
|
10
|
+
var resolvedConfig, appContext, hookRunners, apiOnly, _appDirectory, _distDirectory, _serverConfigFile, distDirectory, appDirectory, serverConfigFile;
|
|
11
11
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12
12
|
while (1) {
|
|
13
13
|
switch (_context.prev = _context.next) {
|
|
14
14
|
case 0:
|
|
15
|
+
if (options !== null && options !== void 0 && options.analyze) {
|
|
16
|
+
// Builder will read this env var to enable bundle analyzer
|
|
17
|
+
process.env.BUNDLE_ANALYZE = 'true';
|
|
18
|
+
}
|
|
15
19
|
resolvedConfig = api.useResolvedConfigContext();
|
|
16
20
|
appContext = api.useAppContext();
|
|
17
21
|
hookRunners = api.useHookRunners();
|
|
18
22
|
apiOnly = appContext.apiOnly;
|
|
19
23
|
if (!apiOnly) {
|
|
20
|
-
_context.next =
|
|
24
|
+
_context.next = 16;
|
|
21
25
|
break;
|
|
22
26
|
}
|
|
23
27
|
_appDirectory = appContext.appDirectory, _distDirectory = appContext.distDirectory, _serverConfigFile = appContext.serverConfigFile;
|
|
24
|
-
_context.next =
|
|
28
|
+
_context.next = 9;
|
|
25
29
|
return hookRunners.beforeBuild({
|
|
26
30
|
// "null" bundlerConfigs
|
|
27
31
|
bundlerConfigs: undefined
|
|
28
32
|
});
|
|
29
|
-
case
|
|
30
|
-
_context.next =
|
|
33
|
+
case 9:
|
|
34
|
+
_context.next = 11;
|
|
31
35
|
return buildServerConfig({
|
|
32
36
|
appDirectory: _appDirectory,
|
|
33
37
|
distDirectory: _distDirectory,
|
|
34
38
|
configFile: _serverConfigFile
|
|
35
39
|
});
|
|
36
|
-
case
|
|
37
|
-
_context.next =
|
|
40
|
+
case 11:
|
|
41
|
+
_context.next = 13;
|
|
38
42
|
return generateRoutes(appContext);
|
|
39
|
-
case
|
|
40
|
-
_context.next =
|
|
43
|
+
case 13:
|
|
44
|
+
_context.next = 15;
|
|
41
45
|
return hookRunners.afterBuild({
|
|
42
46
|
// "null" stats
|
|
43
47
|
stats: undefined
|
|
44
48
|
});
|
|
45
|
-
case 14:
|
|
46
|
-
return _context.abrupt("return");
|
|
47
49
|
case 15:
|
|
50
|
+
return _context.abrupt("return");
|
|
51
|
+
case 16:
|
|
48
52
|
resolvedConfig = _objectSpread(_objectSpread({}, resolvedConfig), {}, {
|
|
49
53
|
cliOptions: options
|
|
50
54
|
});
|
|
51
55
|
ResolvedConfigContext.set(resolvedConfig);
|
|
52
56
|
distDirectory = appContext.distDirectory, appDirectory = appContext.appDirectory, serverConfigFile = appContext.serverConfigFile;
|
|
53
|
-
_context.next =
|
|
57
|
+
_context.next = 21;
|
|
54
58
|
return buildServerConfig({
|
|
55
59
|
appDirectory: appDirectory,
|
|
56
60
|
distDirectory: distDirectory,
|
|
57
61
|
configFile: serverConfigFile
|
|
58
62
|
});
|
|
59
|
-
case
|
|
60
|
-
_context.prev =
|
|
63
|
+
case 21:
|
|
64
|
+
_context.prev = 21;
|
|
61
65
|
logger.info('Create a production build...\n');
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
if (appContext.builder) {
|
|
67
|
+
_context.next = 25;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
throw new Error('Expect the Builder to have been initialized, But the appContext.builder received `undefined`');
|
|
71
|
+
case 25:
|
|
72
|
+
_context.next = 27;
|
|
73
|
+
return appContext.builder.build();
|
|
74
|
+
case 27:
|
|
75
|
+
_context.next = 33;
|
|
66
76
|
break;
|
|
67
|
-
case
|
|
68
|
-
_context.prev =
|
|
69
|
-
_context.t0 = _context["catch"](
|
|
77
|
+
case 29:
|
|
78
|
+
_context.prev = 29;
|
|
79
|
+
_context.t0 = _context["catch"](21);
|
|
70
80
|
printBuildError(_context.t0);
|
|
71
81
|
// eslint-disable-next-line no-process-exit
|
|
72
82
|
process.exit(1);
|
|
73
|
-
case
|
|
83
|
+
case 33:
|
|
74
84
|
case "end":
|
|
75
85
|
return _context.stop();
|
|
76
86
|
}
|
|
77
87
|
}
|
|
78
|
-
}, _callee, null, [[
|
|
88
|
+
}, _callee, null, [[21, 29]]);
|
|
79
89
|
}));
|
|
80
90
|
return function build(_x, _x2) {
|
|
81
91
|
return _ref.apply(this, arguments);
|
|
@@ -3,6 +3,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
3
3
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
4
|
import { logger } from '@modern-js/utils';
|
|
5
5
|
import { ResolvedConfigContext } from '@modern-js/core';
|
|
6
|
+
import { createFileWatcher } from "../utils/createFileWatcher";
|
|
6
7
|
import { printInstructions } from "../utils/printInstructions";
|
|
7
8
|
import { createServer, injectDataLoaderPlugin } from "../utils/createServer";
|
|
8
9
|
import { generateRoutes } from "../utils/routes";
|
|
@@ -10,28 +11,33 @@ import { getSpecifiedEntries } from "../utils/getSpecifiedEntries";
|
|
|
10
11
|
import { buildServerConfig } from "../utils/config";
|
|
11
12
|
export var dev = /*#__PURE__*/function () {
|
|
12
13
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(api, options) {
|
|
13
|
-
var
|
|
14
|
+
var _normalizedConfig$too;
|
|
15
|
+
var normalizedConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, entrypoints, serverConfigFile, serverInternalPlugins, checkedEntries, compiler, app;
|
|
14
16
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
15
17
|
while (1) {
|
|
16
18
|
switch (_context2.prev = _context2.next) {
|
|
17
19
|
case 0:
|
|
18
|
-
|
|
20
|
+
if (options.analyze) {
|
|
21
|
+
// Builder will read this env var to enable bundle analyzer
|
|
22
|
+
process.env.BUNDLE_ANALYZE = 'true';
|
|
23
|
+
}
|
|
24
|
+
normalizedConfig = api.useResolvedConfigContext();
|
|
19
25
|
appContext = api.useAppContext();
|
|
20
26
|
hookRunners = api.useHookRunners();
|
|
21
|
-
|
|
27
|
+
normalizedConfig = _objectSpread(_objectSpread({}, normalizedConfig), {}, {
|
|
22
28
|
cliOptions: options
|
|
23
29
|
});
|
|
24
|
-
ResolvedConfigContext.set(
|
|
30
|
+
ResolvedConfigContext.set(normalizedConfig);
|
|
25
31
|
appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, port = appContext.port, apiOnly = appContext.apiOnly, entrypoints = appContext.entrypoints, serverConfigFile = appContext.serverConfigFile, serverInternalPlugins = appContext.serverInternalPlugins;
|
|
26
|
-
_context2.next =
|
|
32
|
+
_context2.next = 9;
|
|
27
33
|
return getSpecifiedEntries(options.entry || false, entrypoints);
|
|
28
|
-
case
|
|
34
|
+
case 9:
|
|
29
35
|
checkedEntries = _context2.sent;
|
|
30
36
|
api.setAppContext(_objectSpread(_objectSpread({}, appContext), {}, {
|
|
31
37
|
checkedEntries: checkedEntries
|
|
32
38
|
}));
|
|
33
39
|
appContext.checkedEntries = checkedEntries;
|
|
34
|
-
_context2.next =
|
|
40
|
+
_context2.next = 14;
|
|
35
41
|
return buildServerConfig({
|
|
36
42
|
appDirectory: appDirectory,
|
|
37
43
|
distDirectory: distDirectory,
|
|
@@ -42,24 +48,30 @@ export var dev = /*#__PURE__*/function () {
|
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
});
|
|
45
|
-
case
|
|
46
|
-
_context2.next =
|
|
51
|
+
case 14:
|
|
52
|
+
_context2.next = 16;
|
|
47
53
|
return hookRunners.beforeDev();
|
|
48
|
-
case
|
|
54
|
+
case 16:
|
|
49
55
|
compiler = null;
|
|
50
56
|
if (apiOnly) {
|
|
57
|
+
_context2.next = 23;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
if (appContext.builder) {
|
|
51
61
|
_context2.next = 20;
|
|
52
62
|
break;
|
|
53
63
|
}
|
|
54
|
-
|
|
55
|
-
return (_appContext$builder = appContext.builder) === null || _appContext$builder === void 0 ? void 0 : _appContext$builder.createCompiler();
|
|
56
|
-
case 19:
|
|
57
|
-
compiler = _context2.sent;
|
|
64
|
+
throw new Error('Expect the Builder to have been initialized, But the appContext.builder received `undefined`');
|
|
58
65
|
case 20:
|
|
59
66
|
_context2.next = 22;
|
|
60
|
-
return
|
|
67
|
+
return appContext.builder.createCompiler();
|
|
61
68
|
case 22:
|
|
62
|
-
|
|
69
|
+
compiler = _context2.sent;
|
|
70
|
+
case 23:
|
|
71
|
+
_context2.next = 25;
|
|
72
|
+
return generateRoutes(appContext);
|
|
73
|
+
case 25:
|
|
74
|
+
_context2.next = 27;
|
|
63
75
|
return createServer({
|
|
64
76
|
dev: _objectSpread(_objectSpread({}, {
|
|
65
77
|
client: {
|
|
@@ -73,15 +85,15 @@ export var dev = /*#__PURE__*/function () {
|
|
|
73
85
|
hot: true,
|
|
74
86
|
liveReload: true,
|
|
75
87
|
port: port,
|
|
76
|
-
https:
|
|
77
|
-
}),
|
|
88
|
+
https: normalizedConfig.dev.https
|
|
89
|
+
}), (_normalizedConfig$too = normalizedConfig.tools) === null || _normalizedConfig$too === void 0 ? void 0 : _normalizedConfig$too.devServer),
|
|
78
90
|
compiler: compiler,
|
|
79
91
|
pwd: appDirectory,
|
|
80
|
-
config:
|
|
92
|
+
config: normalizedConfig,
|
|
81
93
|
serverConfigFile: serverConfigFile,
|
|
82
94
|
internalPlugins: injectDataLoaderPlugin(serverInternalPlugins)
|
|
83
95
|
});
|
|
84
|
-
case
|
|
96
|
+
case 27:
|
|
85
97
|
app = _context2.sent;
|
|
86
98
|
app.listen(port, /*#__PURE__*/function () {
|
|
87
99
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(err) {
|
|
@@ -98,7 +110,7 @@ export var dev = /*#__PURE__*/function () {
|
|
|
98
110
|
if (!apiOnly) {
|
|
99
111
|
logger.info("Starting dev server...\n");
|
|
100
112
|
} else {
|
|
101
|
-
printInstructions(hookRunners, appContext,
|
|
113
|
+
printInstructions(hookRunners, appContext, normalizedConfig);
|
|
102
114
|
}
|
|
103
115
|
case 3:
|
|
104
116
|
case "end":
|
|
@@ -111,7 +123,9 @@ export var dev = /*#__PURE__*/function () {
|
|
|
111
123
|
return _ref2.apply(this, arguments);
|
|
112
124
|
};
|
|
113
125
|
}());
|
|
114
|
-
|
|
126
|
+
_context2.next = 31;
|
|
127
|
+
return createFileWatcher(appContext, normalizedConfig.source.configDir, hookRunners);
|
|
128
|
+
case 31:
|
|
115
129
|
case "end":
|
|
116
130
|
return _context2.stop();
|
|
117
131
|
}
|
|
@@ -3,20 +3,25 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
3
3
|
import { join } from 'path';
|
|
4
4
|
export var inspect = /*#__PURE__*/function () {
|
|
5
5
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, options) {
|
|
6
|
-
var _appContext$builder;
|
|
7
6
|
var appContext;
|
|
8
7
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9
8
|
while (1) {
|
|
10
9
|
switch (_context.prev = _context.next) {
|
|
11
10
|
case 0:
|
|
12
11
|
appContext = api.useAppContext();
|
|
13
|
-
|
|
12
|
+
if (appContext.builder) {
|
|
13
|
+
_context.next = 3;
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
throw new Error('Expect the Builder to have been initialized, But the appContext.builder received `undefined`');
|
|
17
|
+
case 3:
|
|
18
|
+
return _context.abrupt("return", appContext.builder.inspectConfig({
|
|
14
19
|
env: options.env,
|
|
15
20
|
verbose: options.verbose,
|
|
16
21
|
outputPath: join(appContext === null || appContext === void 0 ? void 0 : appContext.builder.context.distPath, options.output),
|
|
17
22
|
writeToDisk: true
|
|
18
23
|
}));
|
|
19
|
-
case
|
|
24
|
+
case 4:
|
|
20
25
|
case "end":
|
|
21
26
|
return _context.stop();
|
|
22
27
|
}
|
|
@@ -24,6 +24,7 @@ export var start = /*#__PURE__*/function () {
|
|
|
24
24
|
_context2.next = 10;
|
|
25
25
|
return server({
|
|
26
26
|
pwd: appDirectory,
|
|
27
|
+
// FIXME: remove the `any` type
|
|
27
28
|
config: userConfig,
|
|
28
29
|
serverConfigFile: serverConfigFile,
|
|
29
30
|
internalPlugins: injectDataLoaderPlugin(appContext.serverInternalPlugins),
|