@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
|
@@ -15,12 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var stdin_exports = {};
|
|
19
|
-
__export(stdin_exports, {
|
|
20
|
-
getSpecifiedEntries: () => getSpecifiedEntries
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(stdin_exports);
|
|
23
|
-
var import_utils = require("@modern-js/utils");
|
|
24
18
|
var __async = (__this, __arguments, generator) => {
|
|
25
19
|
return new Promise((resolve, reject) => {
|
|
26
20
|
var fulfilled = (value) => {
|
|
@@ -41,6 +35,12 @@ var __async = (__this, __arguments, generator) => {
|
|
|
41
35
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
36
|
});
|
|
43
37
|
};
|
|
38
|
+
var getSpecifiedEntries_exports = {};
|
|
39
|
+
__export(getSpecifiedEntries_exports, {
|
|
40
|
+
getSpecifiedEntries: () => getSpecifiedEntries
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(getSpecifiedEntries_exports);
|
|
43
|
+
var import_utils = require("@modern-js/utils");
|
|
44
44
|
const getSpecifiedEntries = (entry, entrypoints) => __async(void 0, null, function* () {
|
|
45
45
|
const entryNames = entrypoints.map((e) => e.entryName);
|
|
46
46
|
if (!entry) {
|
|
@@ -74,3 +74,7 @@ const getSpecifiedEntries = (entry, entrypoints) => __async(void 0, null, functi
|
|
|
74
74
|
});
|
|
75
75
|
return entry;
|
|
76
76
|
});
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
getSpecifiedEntries
|
|
80
|
+
});
|
|
@@ -15,13 +15,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
18
|
+
var language_exports = {};
|
|
19
|
+
__export(language_exports, {
|
|
20
20
|
getLocaleLanguage: () => getLocaleLanguage
|
|
21
21
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
22
|
+
module.exports = __toCommonJS(language_exports);
|
|
23
23
|
var import_language_detector = require("@modern-js/plugin-i18n/language-detector");
|
|
24
24
|
function getLocaleLanguage() {
|
|
25
25
|
const detector = new import_language_detector.I18CLILanguageDetector();
|
|
26
26
|
return detector.detect();
|
|
27
27
|
}
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
getLocaleLanguage
|
|
31
|
+
});
|
|
@@ -15,12 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var stdin_exports = {};
|
|
19
|
-
__export(stdin_exports, {
|
|
20
|
-
printInstructions: () => printInstructions
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(stdin_exports);
|
|
23
|
-
var import_utils = require("@modern-js/utils");
|
|
24
18
|
var __async = (__this, __arguments, generator) => {
|
|
25
19
|
return new Promise((resolve, reject) => {
|
|
26
20
|
var fulfilled = (value) => {
|
|
@@ -41,6 +35,12 @@ var __async = (__this, __arguments, generator) => {
|
|
|
41
35
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
36
|
});
|
|
43
37
|
};
|
|
38
|
+
var printInstructions_exports = {};
|
|
39
|
+
__export(printInstructions_exports, {
|
|
40
|
+
printInstructions: () => printInstructions
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(printInstructions_exports);
|
|
43
|
+
var import_utils = require("@modern-js/utils");
|
|
44
44
|
const printInstructions = (hookRunners, appContext, config) => __async(void 0, null, function* () {
|
|
45
45
|
const message = (0, import_utils.prettyInstructions)(appContext, config);
|
|
46
46
|
const { instructions } = yield hookRunners.beforePrintInstructions({
|
|
@@ -48,3 +48,7 @@ const printInstructions = (hookRunners, appContext, config) => __async(void 0, n
|
|
|
48
48
|
});
|
|
49
49
|
import_utils.logger.info(instructions);
|
|
50
50
|
});
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
printInstructions
|
|
54
|
+
});
|
|
@@ -15,13 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var stdin_exports = {};
|
|
19
|
-
__export(stdin_exports, {
|
|
20
|
-
restart: () => restart
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(stdin_exports);
|
|
23
|
-
var import_core = require("@modern-js/core");
|
|
24
|
-
var import_utils = require("@modern-js/utils");
|
|
25
18
|
var __async = (__this, __arguments, generator) => {
|
|
26
19
|
return new Promise((resolve, reject) => {
|
|
27
20
|
var fulfilled = (value) => {
|
|
@@ -42,6 +35,13 @@ var __async = (__this, __arguments, generator) => {
|
|
|
42
35
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
43
36
|
});
|
|
44
37
|
};
|
|
38
|
+
var restart_exports = {};
|
|
39
|
+
__export(restart_exports, {
|
|
40
|
+
restart: () => restart
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(restart_exports);
|
|
43
|
+
var import_core = require("@modern-js/core");
|
|
44
|
+
var import_utils = require("@modern-js/utils");
|
|
45
45
|
function restart(hooksRunner, filename) {
|
|
46
46
|
return __async(this, null, function* () {
|
|
47
47
|
(0, import_utils.clearConsole)();
|
|
@@ -61,3 +61,7 @@ function restart(hooksRunner, filename) {
|
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
restart
|
|
67
|
+
});
|
|
@@ -21,13 +21,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
mod
|
|
22
22
|
));
|
|
23
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
-
var stdin_exports = {};
|
|
25
|
-
__export(stdin_exports, {
|
|
26
|
-
generateRoutes: () => generateRoutes
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(stdin_exports);
|
|
29
|
-
var import_path = __toESM(require("path"));
|
|
30
|
-
var import_utils = require("@modern-js/utils");
|
|
31
24
|
var __async = (__this, __arguments, generator) => {
|
|
32
25
|
return new Promise((resolve, reject) => {
|
|
33
26
|
var fulfilled = (value) => {
|
|
@@ -48,8 +41,19 @@ var __async = (__this, __arguments, generator) => {
|
|
|
48
41
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
49
42
|
});
|
|
50
43
|
};
|
|
44
|
+
var routes_exports = {};
|
|
45
|
+
__export(routes_exports, {
|
|
46
|
+
generateRoutes: () => generateRoutes
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(routes_exports);
|
|
49
|
+
var import_path = __toESM(require("path"));
|
|
50
|
+
var import_utils = require("@modern-js/utils");
|
|
51
51
|
const generateRoutes = (appContext) => __async(void 0, null, function* () {
|
|
52
52
|
const { serverRoutes, distDirectory } = appContext;
|
|
53
53
|
const output = JSON.stringify({ routes: serverRoutes }, null, 2);
|
|
54
54
|
yield import_utils.fs.outputFile(import_path.default.join(distDirectory, import_utils.ROUTE_SPEC_FILE), output);
|
|
55
55
|
});
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
generateRoutes
|
|
59
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var types_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _asyncToGenerator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _classCallCheck(instance, Constructor) {
|
|
31
|
+
if (!(instance instanceof Constructor)) {
|
|
32
|
+
throw new TypeError("Cannot call a class as a function");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function _defineProperties(target, props) {
|
|
36
|
+
for(var i = 0; i < props.length; i++){
|
|
37
|
+
var descriptor = props[i];
|
|
38
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
39
|
+
descriptor.configurable = true;
|
|
40
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
41
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
45
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
46
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
47
|
+
return Constructor;
|
|
48
|
+
}
|
|
49
|
+
function _defineProperty(obj, key, value) {
|
|
50
|
+
if (key in obj) {
|
|
51
|
+
Object.defineProperty(obj, key, {
|
|
52
|
+
value: value,
|
|
53
|
+
enumerable: true,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
obj[key] = value;
|
|
59
|
+
}
|
|
60
|
+
return obj;
|
|
61
|
+
}
|
|
62
|
+
var __generator = this && this.__generator || function(thisArg, body) {
|
|
63
|
+
var f, y, t, g, _ = {
|
|
64
|
+
label: 0,
|
|
65
|
+
sent: function() {
|
|
66
|
+
if (t[0] & 1) throw t[1];
|
|
67
|
+
return t[1];
|
|
68
|
+
},
|
|
69
|
+
trys: [],
|
|
70
|
+
ops: []
|
|
71
|
+
};
|
|
72
|
+
return g = {
|
|
73
|
+
next: verb(0),
|
|
74
|
+
"throw": verb(1),
|
|
75
|
+
"return": verb(2)
|
|
76
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
77
|
+
return this;
|
|
78
|
+
}), g;
|
|
79
|
+
function verb(n) {
|
|
80
|
+
return function(v) {
|
|
81
|
+
return step([
|
|
82
|
+
n,
|
|
83
|
+
v
|
|
84
|
+
]);
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function step(op) {
|
|
88
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
89
|
+
while(_)try {
|
|
90
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
91
|
+
if (y = 0, t) op = [
|
|
92
|
+
op[0] & 2,
|
|
93
|
+
t.value
|
|
94
|
+
];
|
|
95
|
+
switch(op[0]){
|
|
96
|
+
case 0:
|
|
97
|
+
case 1:
|
|
98
|
+
t = op;
|
|
99
|
+
break;
|
|
100
|
+
case 4:
|
|
101
|
+
_.label++;
|
|
102
|
+
return {
|
|
103
|
+
value: op[1],
|
|
104
|
+
done: false
|
|
105
|
+
};
|
|
106
|
+
case 5:
|
|
107
|
+
_.label++;
|
|
108
|
+
y = op[1];
|
|
109
|
+
op = [
|
|
110
|
+
0
|
|
111
|
+
];
|
|
112
|
+
continue;
|
|
113
|
+
case 7:
|
|
114
|
+
op = _.ops.pop();
|
|
115
|
+
_.trys.pop();
|
|
116
|
+
continue;
|
|
117
|
+
default:
|
|
118
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
119
|
+
_ = 0;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
123
|
+
_.label = op[1];
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
127
|
+
_.label = t[1];
|
|
128
|
+
t = op;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
if (t && _.label < t[2]) {
|
|
132
|
+
_.label = t[2];
|
|
133
|
+
_.ops.push(op);
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
if (t[2]) _.ops.pop();
|
|
137
|
+
_.trys.pop();
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
op = body.call(thisArg, _);
|
|
141
|
+
} catch (e) {
|
|
142
|
+
op = [
|
|
143
|
+
6,
|
|
144
|
+
e
|
|
145
|
+
];
|
|
146
|
+
y = 0;
|
|
147
|
+
} finally{
|
|
148
|
+
f = t = 0;
|
|
149
|
+
}
|
|
150
|
+
if (op[0] & 5) throw op[1];
|
|
151
|
+
return {
|
|
152
|
+
value: op[0] ? op[1] : void 0,
|
|
153
|
+
done: true
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
import { build } from "esbuild";
|
|
158
|
+
var Builder = /*#__PURE__*/ function() {
|
|
159
|
+
"use strict";
|
|
160
|
+
function Builder() {
|
|
161
|
+
_classCallCheck(this, Builder);
|
|
162
|
+
_defineProperty(this, "buildRes", void 0);
|
|
163
|
+
}
|
|
164
|
+
_createClass(Builder, [
|
|
165
|
+
{
|
|
166
|
+
key: "build",
|
|
167
|
+
value: function build1(options) {
|
|
168
|
+
var _this = this;
|
|
169
|
+
return _asyncToGenerator(function() {
|
|
170
|
+
return __generator(this, function(_state) {
|
|
171
|
+
switch(_state.label){
|
|
172
|
+
case 0:
|
|
173
|
+
return [
|
|
174
|
+
4,
|
|
175
|
+
build(options)
|
|
176
|
+
];
|
|
177
|
+
case 1:
|
|
178
|
+
_this.buildRes = _state.sent();
|
|
179
|
+
return [
|
|
180
|
+
2
|
|
181
|
+
];
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
})();
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
key: "stop",
|
|
189
|
+
value: function stop() {
|
|
190
|
+
var ref, ref1;
|
|
191
|
+
((ref = this.buildRes) === null || ref === void 0 ? void 0 : ref.stop) && ((ref1 = this.buildRes) === null || ref1 === void 0 ? void 0 : ref1.stop());
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
]);
|
|
195
|
+
return Builder;
|
|
196
|
+
}();
|
|
197
|
+
var loaderBuilder = new Builder();
|
|
198
|
+
var serverLoaderBuilder = new Builder();
|
|
199
|
+
export { Builder, loaderBuilder, serverLoaderBuilder };
|
|
@@ -25,4 +25,16 @@ var HTML_PARTIALS_EXTENSIONS = [
|
|
|
25
25
|
".ejs"
|
|
26
26
|
];
|
|
27
27
|
var FILE_SYSTEM_ROUTES_COMPONENTS_DIR = "internal_components";
|
|
28
|
-
|
|
28
|
+
var NESTED_ROUTE = {
|
|
29
|
+
LAYOUT_FILE: "layout",
|
|
30
|
+
LAYOUT_LOADER_FILE: "layout.loader",
|
|
31
|
+
PAGE_FILE: "page",
|
|
32
|
+
PAGE_LOADER_FILE: "page.loader",
|
|
33
|
+
LOADING_FILE: "loading",
|
|
34
|
+
ERROR_FILE: "error",
|
|
35
|
+
LOADER_FILE: "loader"
|
|
36
|
+
};
|
|
37
|
+
var APP_CONFIG_NAME = "appConfig";
|
|
38
|
+
var APP_INIT_EXPORTED = "init";
|
|
39
|
+
var APP_INIT_IMPORTED = "appInit";
|
|
40
|
+
export { APP_CONFIG_NAME, APP_FILE_NAME, APP_INIT_EXPORTED, APP_INIT_IMPORTED, ENTRY_BOOTSTRAP_FILE_NAME, ENTRY_POINT_FILE_NAME, FILE_SYSTEM_ROUTES_COMPONENTS_DIR, FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP, FILE_SYSTEM_ROUTES_FILE_NAME, FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT, FILE_SYSTEM_ROUTES_IGNORED_REGEX, FILE_SYSTEM_ROUTES_INDEX, FILE_SYSTEM_ROUTES_LAYOUT, HTML_PARTIALS_EXTENSIONS, HTML_PARTIALS_FOLDER, INDEX_FILE_NAME, JS_EXTENSIONS, LOADER_EXPORT_NAME, NESTED_ROUTE, NESTED_ROUTES_DIR, PAGES_DIR_NAME, TEMP_LOADERS_DIR };
|
|
@@ -150,13 +150,13 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
150
150
|
import path from "path";
|
|
151
151
|
import { fs, getEntryOptions, LOADER_ROUTES_DIR, logger } from "@modern-js/utils";
|
|
152
152
|
import { useResolvedConfigContext } from "@modern-js/core";
|
|
153
|
-
import {
|
|
154
|
-
import { getCommand } from "../utils/commands";
|
|
153
|
+
import { isDevCommand } from "../utils/commands";
|
|
155
154
|
import * as templates from "./templates";
|
|
156
155
|
import { getClientRoutes, getClientRoutesLegacy } from "./getClientRoutes";
|
|
157
156
|
import { FILE_SYSTEM_ROUTES_FILE_NAME, ENTRY_POINT_FILE_NAME, ENTRY_BOOTSTRAP_FILE_NAME, TEMP_LOADERS_DIR } from "./constants";
|
|
158
157
|
import { getDefaultImports } from "./utils";
|
|
159
158
|
import { walk } from "./nestedRoutes";
|
|
159
|
+
import { loaderBuilder, serverLoaderBuilder } from "./Builder";
|
|
160
160
|
var loader = {
|
|
161
161
|
".js": "jsx",
|
|
162
162
|
".ts": "tsx"
|
|
@@ -247,19 +247,17 @@ var createImportStatements = function(statements) {
|
|
|
247
247
|
};
|
|
248
248
|
var buildLoader = function() {
|
|
249
249
|
var _ref = _asyncToGenerator(function(entry, outfile) {
|
|
250
|
-
var command;
|
|
251
250
|
return __generator(this, function(_state) {
|
|
252
251
|
switch(_state.label){
|
|
253
252
|
case 0:
|
|
254
|
-
command = getCommand();
|
|
255
253
|
return [
|
|
256
254
|
4,
|
|
257
|
-
build({
|
|
255
|
+
loaderBuilder.build({
|
|
258
256
|
format: "esm",
|
|
259
257
|
platform: "browser",
|
|
260
258
|
target: "esnext",
|
|
261
259
|
loader: loader,
|
|
262
|
-
watch:
|
|
260
|
+
watch: isDevCommand() && {},
|
|
263
261
|
bundle: true,
|
|
264
262
|
logLevel: "error",
|
|
265
263
|
entryPoints: [
|
|
@@ -269,8 +267,8 @@ var buildLoader = function() {
|
|
|
269
267
|
plugins: [
|
|
270
268
|
{
|
|
271
269
|
name: "make-all-packages-external",
|
|
272
|
-
setup: function setup(
|
|
273
|
-
|
|
270
|
+
setup: function setup(build) {
|
|
271
|
+
build.onResolve({
|
|
274
272
|
filter: EXTERNAL_REGEXP
|
|
275
273
|
}, function(args) {
|
|
276
274
|
var external = true;
|
|
@@ -301,19 +299,17 @@ var buildLoader = function() {
|
|
|
301
299
|
}();
|
|
302
300
|
var buildServerLoader = function() {
|
|
303
301
|
var _ref = _asyncToGenerator(function(entry, outfile) {
|
|
304
|
-
var command;
|
|
305
302
|
return __generator(this, function(_state) {
|
|
306
303
|
switch(_state.label){
|
|
307
304
|
case 0:
|
|
308
|
-
command = getCommand();
|
|
309
305
|
return [
|
|
310
306
|
4,
|
|
311
|
-
build({
|
|
307
|
+
serverLoaderBuilder.build({
|
|
312
308
|
format: "cjs",
|
|
313
309
|
platform: "node",
|
|
314
310
|
target: "esnext",
|
|
315
311
|
loader: loader,
|
|
316
|
-
watch:
|
|
312
|
+
watch: isDevCommand() && {},
|
|
317
313
|
bundle: true,
|
|
318
314
|
logLevel: "error",
|
|
319
315
|
entryPoints: [
|
|
@@ -336,7 +332,7 @@ var buildServerLoader = function() {
|
|
|
336
332
|
}();
|
|
337
333
|
var generateCode = function() {
|
|
338
334
|
var _ref = _asyncToGenerator(function(appContext, config, entrypoints, api) {
|
|
339
|
-
var ref, ref1, internalDirectory, distDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName, hookRunners,
|
|
335
|
+
var ref, ref1, ref2, internalDirectory, distDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName, hookRunners, isV5, mountId, getRoutes;
|
|
340
336
|
function generateEntryCode(entrypoint) {
|
|
341
337
|
return _generateEntryCode.apply(this, arguments);
|
|
342
338
|
}
|
|
@@ -370,7 +366,7 @@ var generateCode = function() {
|
|
|
370
366
|
3,
|
|
371
367
|
3
|
|
372
368
|
];
|
|
373
|
-
if (!!
|
|
369
|
+
if (!!isV5) return [
|
|
374
370
|
3,
|
|
375
371
|
2
|
|
376
372
|
];
|
|
@@ -431,7 +427,8 @@ var generateCode = function() {
|
|
|
431
427
|
ssrMode: mode,
|
|
432
428
|
nestedRoutesEntry: entrypoint.nestedRoutesEntry,
|
|
433
429
|
entryName: entrypoint.entryName,
|
|
434
|
-
internalDirectory: internalDirectory
|
|
430
|
+
internalDirectory: internalDirectory,
|
|
431
|
+
internalDirAlias: internalDirAlias
|
|
435
432
|
})
|
|
436
433
|
];
|
|
437
434
|
case 5:
|
|
@@ -596,9 +593,9 @@ var generateCode = function() {
|
|
|
596
593
|
case 0:
|
|
597
594
|
internalDirectory = appContext.internalDirectory, distDirectory = appContext.distDirectory, srcDirectory = appContext.srcDirectory, internalDirAlias = appContext.internalDirAlias, internalSrcAlias = appContext.internalSrcAlias, packageName = appContext.packageName;
|
|
598
595
|
hookRunners = api.useHookRunners();
|
|
599
|
-
|
|
596
|
+
isV5 = typeof ((ref = config.runtime) === null || ref === void 0 ? void 0 : ref.router) !== "boolean" && (config === null || config === void 0 ? void 0 : (ref1 = config.runtime) === null || ref1 === void 0 ? void 0 : (ref2 = ref1.router) === null || ref2 === void 0 ? void 0 : ref2.mode) === "react-router-5";
|
|
600
597
|
mountId = config.html.mountId;
|
|
601
|
-
getRoutes =
|
|
598
|
+
getRoutes = isV5 ? getClientRoutesLegacy : getClientRoutes;
|
|
602
599
|
return [
|
|
603
600
|
4,
|
|
604
601
|
Promise.all(entrypoints.map(generateEntryCode))
|
|
@@ -38,8 +38,12 @@ var getBundleEntry = function(appContext, config) {
|
|
|
38
38
|
entryName: name,
|
|
39
39
|
entry: ensureAbsolutePath(appDirectory, value.entry),
|
|
40
40
|
isAutoMount: !value.disableMount,
|
|
41
|
-
|
|
41
|
+
customBootstrap: value.customBootstrap && ensureAbsolutePath(appDirectory, value.customBootstrap),
|
|
42
|
+
fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, value.entry)).isDirectory() ? {} : void 0
|
|
42
43
|
};
|
|
44
|
+
if (entrypoint.fileSystemRoutes) {
|
|
45
|
+
entrypoint.nestedRoutesEntry = entrypoint.entry;
|
|
46
|
+
}
|
|
43
47
|
if (!ifAlreadyExists(defaults, entrypoint)) {
|
|
44
48
|
defaults.push(entrypoint);
|
|
45
49
|
}
|
|
@@ -198,16 +198,19 @@ var normalizeNestedRoutes = function(nested, internalComponentsDir, internalDire
|
|
|
198
198
|
};
|
|
199
199
|
var getClientRoutes = function(param) {
|
|
200
200
|
var entrypoint = param.entrypoint, srcDirectory = param.srcDirectory, srcAlias = param.srcAlias, internalDirectory = param.internalDirectory, internalDirAlias = param.internalDirAlias;
|
|
201
|
-
var
|
|
202
|
-
if (!
|
|
203
|
-
|
|
201
|
+
var entryName = entrypoint.entryName, pageRoutesEntry = entrypoint.pageRoutesEntry;
|
|
202
|
+
if (!pageRoutesEntry) {
|
|
203
|
+
return [];
|
|
204
204
|
}
|
|
205
|
-
if (!
|
|
206
|
-
throw new Error("generate file system routes error, ".concat(
|
|
205
|
+
if (!fs.existsSync(pageRoutesEntry)) {
|
|
206
|
+
throw new Error("generate file system routes error, ".concat(pageRoutesEntry, " directory not found."));
|
|
207
|
+
}
|
|
208
|
+
if (!(fs.existsSync(pageRoutesEntry) && fs.statSync(pageRoutesEntry).isDirectory())) {
|
|
209
|
+
throw new Error("generate file system routes error, ".concat(pageRoutesEntry, " should be directory."));
|
|
207
210
|
}
|
|
208
211
|
var routes = [];
|
|
209
212
|
recursiveReadDir({
|
|
210
|
-
dir:
|
|
213
|
+
dir: pageRoutesEntry,
|
|
211
214
|
routes: routes,
|
|
212
215
|
basePath: "/",
|
|
213
216
|
srcDirectory: srcDirectory,
|
|
@@ -62,9 +62,11 @@ var scanDir = function(dirs) {
|
|
|
62
62
|
};
|
|
63
63
|
if (isHasPages) {
|
|
64
64
|
entrypoint.entry = path.join(dir, PAGES_DIR_NAME);
|
|
65
|
+
entrypoint.pageRoutesEntry = entrypoint.entry;
|
|
65
66
|
}
|
|
66
67
|
if (isHasNestedRoutes) {
|
|
67
|
-
entrypoint.
|
|
68
|
+
entrypoint.entry = path.join(dir, NESTED_ROUTES_DIR);
|
|
69
|
+
entrypoint.nestedRoutesEntry = entrypoint.entry;
|
|
68
70
|
}
|
|
69
71
|
return entrypoint;
|
|
70
72
|
}
|
|
@@ -78,7 +80,13 @@ var scanDir = function(dirs) {
|
|
|
78
80
|
};
|
|
79
81
|
var getFileSystemEntry = function(appContext, config) {
|
|
80
82
|
var appDirectory = appContext.appDirectory;
|
|
81
|
-
var
|
|
83
|
+
var _source = config.source, entriesDir = _source.entriesDir, disableEntryDirs = _source.disableEntryDirs;
|
|
84
|
+
var disabledDirs = [];
|
|
85
|
+
if (disableEntryDirs && Array.isArray(disableEntryDirs)) {
|
|
86
|
+
disabledDirs = disableEntryDirs === null || disableEntryDirs === void 0 ? void 0 : disableEntryDirs.map(function(dir) {
|
|
87
|
+
return ensureAbsolutePath(appDirectory, dir);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
82
90
|
var src = ensureAbsolutePath(appDirectory, entriesDir || "");
|
|
83
91
|
if (fs.existsSync(src)) {
|
|
84
92
|
if (fs.statSync(src).isDirectory()) {
|
|
@@ -87,7 +95,7 @@ var getFileSystemEntry = function(appContext, config) {
|
|
|
87
95
|
] : fs.readdirSync(src).map(function(file) {
|
|
88
96
|
return path.join(src, file);
|
|
89
97
|
}).filter(function(file) {
|
|
90
|
-
return fs.statSync(file).isDirectory() && isBundleEntry(file);
|
|
98
|
+
return fs.statSync(file).isDirectory() && isBundleEntry(file) && !disabledDirs.includes(file);
|
|
91
99
|
}));
|
|
92
100
|
} else {
|
|
93
101
|
throw Error("source.entriesDir accept a directory.");
|