@modern-js/app-tools 2.0.0-beta.4 → 2.0.0-beta.7
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 +366 -0
- package/bin/modern.js +2 -0
- package/dist/js/modern/analyze/constants.js +10 -0
- package/dist/js/modern/analyze/generateCode.js +7 -9
- package/dist/js/modern/analyze/getBundleEntry.js +2 -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 +7 -5
- package/dist/js/modern/analyze/nestedRoutes.js +29 -22
- package/dist/js/modern/analyze/templates.js +8 -1
- package/dist/js/modern/analyze/utils.js +21 -4
- package/dist/js/modern/builder/builderPlugins/compatModern.js +8 -2
- package/dist/js/modern/builder/index.js +9 -9
- 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/transformNormalizedConfig.js +5 -1
- package/dist/js/modern/hooks.js +1 -0
- package/dist/js/modern/index.js +5 -5
- 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 +5 -7
- package/dist/js/modern/schema/legacy.js +1 -2
- package/dist/js/modern/utils/commands.js +6 -1
- package/dist/js/modern/utils/getServerInternalPlugins.js +58 -0
- package/dist/js/node/analyze/Builder.js +14 -8
- package/dist/js/node/analyze/constants.js +35 -3
- package/dist/js/node/analyze/generateCode.js +27 -24
- package/dist/js/node/analyze/getBundleEntry.js +9 -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 +45 -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 +45 -32
- package/dist/js/node/analyze/utils.js +41 -18
- package/dist/js/node/builder/builderPlugins/compatModern.js +32 -24
- package/dist/js/node/builder/index.js +38 -49
- 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 +7 -3
- 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 +9 -7
- 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 +26 -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 +8 -3
- package/dist/js/node/index.js +56 -69
- 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 +13 -10
- package/dist/js/node/schema/legacy.js +6 -5
- 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/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/constants.js +10 -1
- package/dist/js/treeshaking/analyze/generateCode.js +7 -11
- package/dist/js/treeshaking/analyze/getBundleEntry.js +2 -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 +7 -4
- package/dist/js/treeshaking/analyze/nestedRoutes.js +30 -23
- package/dist/js/treeshaking/analyze/templates.js +6 -1
- package/dist/js/treeshaking/analyze/utils.js +14 -4
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +6 -2
- package/dist/js/treeshaking/builder/index.js +4 -9
- 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/transformNormalizedConfig.js +5 -1
- package/dist/js/treeshaking/hooks.js +1 -0
- package/dist/js/treeshaking/index.js +5 -5
- 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 +10 -11
- package/dist/js/treeshaking/schema/legacy.js +0 -3
- package/dist/js/treeshaking/utils/commands.js +5 -1
- package/dist/js/treeshaking/utils/getServerInternalPlugins.js +210 -0
- package/dist/types/analyze/constants.d.ts +10 -1
- package/dist/types/analyze/utils.d.ts +2 -1
- 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 +1 -0
- 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/types/config/index.d.ts +3 -0
- package/dist/types/types/config/source.d.ts +2 -1
- package/dist/types/types/hooks.d.ts +3 -0
- package/dist/types/types/legacyConfig/source.d.ts +0 -1
- package/dist/types/utils/commands.d.ts +2 -1
- package/dist/types/utils/getServerInternalPlugins.d.ts +2 -0
- package/package.json +25 -22
|
@@ -10,8 +10,7 @@ const source = {
|
|
|
10
10
|
required: ["entry"],
|
|
11
11
|
properties: {
|
|
12
12
|
entry: { type: ["string", "array"] },
|
|
13
|
-
disableMount: { type: "boolean" }
|
|
14
|
-
enableFileSystemRoutes: { type: "boolean" }
|
|
13
|
+
disableMount: { type: "boolean" }
|
|
15
14
|
},
|
|
16
15
|
additionalProperties: false
|
|
17
16
|
},
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __async = (__this, __arguments, generator) => {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
var fulfilled = (value) => {
|
|
23
|
+
try {
|
|
24
|
+
step(generator.next(value));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
reject(e);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var rejected = (value) => {
|
|
30
|
+
try {
|
|
31
|
+
step(generator.throw(value));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
reject(e);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
function getServerInternalPlugins(api) {
|
|
41
|
+
return __async(this, null, function* () {
|
|
42
|
+
const hookRunners = api.useHookRunners();
|
|
43
|
+
const { plugins: serverPlugins } = yield hookRunners.collectServerPlugins({
|
|
44
|
+
plugins: []
|
|
45
|
+
});
|
|
46
|
+
const serverInternalPlugins = serverPlugins.reduce(
|
|
47
|
+
(result, plugin) => Object.assign(result, plugin),
|
|
48
|
+
{}
|
|
49
|
+
);
|
|
50
|
+
api.setAppContext(__spreadProps(__spreadValues({}, api.useAppContext()), {
|
|
51
|
+
serverInternalPlugins
|
|
52
|
+
}));
|
|
53
|
+
return serverInternalPlugins;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
getServerInternalPlugins
|
|
58
|
+
};
|
|
@@ -15,14 +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
|
-
Builder: () => Builder,
|
|
21
|
-
loaderBuilder: () => loaderBuilder,
|
|
22
|
-
serverLoaderBuilder: () => serverLoaderBuilder
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(stdin_exports);
|
|
25
|
-
var import_esbuild = require("esbuild");
|
|
26
18
|
var __async = (__this, __arguments, generator) => {
|
|
27
19
|
return new Promise((resolve, reject) => {
|
|
28
20
|
var fulfilled = (value) => {
|
|
@@ -43,6 +35,14 @@ var __async = (__this, __arguments, generator) => {
|
|
|
43
35
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
44
36
|
});
|
|
45
37
|
};
|
|
38
|
+
var Builder_exports = {};
|
|
39
|
+
__export(Builder_exports, {
|
|
40
|
+
Builder: () => Builder,
|
|
41
|
+
loaderBuilder: () => loaderBuilder,
|
|
42
|
+
serverLoaderBuilder: () => serverLoaderBuilder
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(Builder_exports);
|
|
45
|
+
var import_esbuild = require("esbuild");
|
|
46
46
|
class Builder {
|
|
47
47
|
build(options) {
|
|
48
48
|
return __async(this, null, function* () {
|
|
@@ -56,3 +56,9 @@ class Builder {
|
|
|
56
56
|
}
|
|
57
57
|
const loaderBuilder = new Builder();
|
|
58
58
|
const serverLoaderBuilder = new Builder();
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
Builder,
|
|
62
|
+
loaderBuilder,
|
|
63
|
+
serverLoaderBuilder
|
|
64
|
+
});
|
|
@@ -15,8 +15,8 @@ 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 constants_exports = {};
|
|
19
|
+
__export(constants_exports, {
|
|
20
20
|
APP_FILE_NAME: () => APP_FILE_NAME,
|
|
21
21
|
ENTRY_BOOTSTRAP_FILE_NAME: () => ENTRY_BOOTSTRAP_FILE_NAME,
|
|
22
22
|
ENTRY_POINT_FILE_NAME: () => ENTRY_POINT_FILE_NAME,
|
|
@@ -32,11 +32,12 @@ __export(stdin_exports, {
|
|
|
32
32
|
INDEX_FILE_NAME: () => INDEX_FILE_NAME,
|
|
33
33
|
JS_EXTENSIONS: () => JS_EXTENSIONS,
|
|
34
34
|
LOADER_EXPORT_NAME: () => LOADER_EXPORT_NAME,
|
|
35
|
+
NESTED_ROUTE: () => NESTED_ROUTE,
|
|
35
36
|
NESTED_ROUTES_DIR: () => NESTED_ROUTES_DIR,
|
|
36
37
|
PAGES_DIR_NAME: () => PAGES_DIR_NAME,
|
|
37
38
|
TEMP_LOADERS_DIR: () => TEMP_LOADERS_DIR
|
|
38
39
|
});
|
|
39
|
-
module.exports = __toCommonJS(
|
|
40
|
+
module.exports = __toCommonJS(constants_exports);
|
|
40
41
|
const JS_EXTENSIONS = [".js", ".ts", ".jsx", ".tsx"];
|
|
41
42
|
const INDEX_FILE_NAME = "index";
|
|
42
43
|
const APP_FILE_NAME = "App";
|
|
@@ -55,3 +56,34 @@ const FILE_SYSTEM_ROUTES_IGNORED_REGEX = /\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/
|
|
|
55
56
|
const HTML_PARTIALS_FOLDER = "html";
|
|
56
57
|
const HTML_PARTIALS_EXTENSIONS = [".htm", ".html", ".ejs"];
|
|
57
58
|
const FILE_SYSTEM_ROUTES_COMPONENTS_DIR = "internal_components";
|
|
59
|
+
const NESTED_ROUTE = {
|
|
60
|
+
LAYOUT_FILE: "layout",
|
|
61
|
+
LAYOUT_LOADER_FILE: "layout.loader",
|
|
62
|
+
PAGE_FILE: "page",
|
|
63
|
+
PAGE_LOADER_FILE: "page.loader",
|
|
64
|
+
LOADING_FILE: "loading",
|
|
65
|
+
ERROR_FILE: "error",
|
|
66
|
+
LOADER_FILE: "loader"
|
|
67
|
+
};
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
APP_FILE_NAME,
|
|
71
|
+
ENTRY_BOOTSTRAP_FILE_NAME,
|
|
72
|
+
ENTRY_POINT_FILE_NAME,
|
|
73
|
+
FILE_SYSTEM_ROUTES_COMPONENTS_DIR,
|
|
74
|
+
FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP,
|
|
75
|
+
FILE_SYSTEM_ROUTES_FILE_NAME,
|
|
76
|
+
FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT,
|
|
77
|
+
FILE_SYSTEM_ROUTES_IGNORED_REGEX,
|
|
78
|
+
FILE_SYSTEM_ROUTES_INDEX,
|
|
79
|
+
FILE_SYSTEM_ROUTES_LAYOUT,
|
|
80
|
+
HTML_PARTIALS_EXTENSIONS,
|
|
81
|
+
HTML_PARTIALS_FOLDER,
|
|
82
|
+
INDEX_FILE_NAME,
|
|
83
|
+
JS_EXTENSIONS,
|
|
84
|
+
LOADER_EXPORT_NAME,
|
|
85
|
+
NESTED_ROUTE,
|
|
86
|
+
NESTED_ROUTES_DIR,
|
|
87
|
+
PAGES_DIR_NAME,
|
|
88
|
+
TEMP_LOADERS_DIR
|
|
89
|
+
});
|
|
@@ -21,22 +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
|
-
createImportStatements: () => createImportStatements,
|
|
27
|
-
generateCode: () => generateCode
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(stdin_exports);
|
|
30
|
-
var import_path = __toESM(require("path"));
|
|
31
|
-
var import_utils = require("@modern-js/utils");
|
|
32
|
-
var import_core = require("@modern-js/core");
|
|
33
|
-
var import_commands = require("../utils/commands");
|
|
34
|
-
var templates = __toESM(require("./templates"));
|
|
35
|
-
var import_getClientRoutes = require("./getClientRoutes");
|
|
36
|
-
var import_constants = require("./constants");
|
|
37
|
-
var import_utils2 = require("./utils");
|
|
38
|
-
var import_nestedRoutes = require("./nestedRoutes");
|
|
39
|
-
var import_Builder = require("./Builder");
|
|
40
24
|
var __async = (__this, __arguments, generator) => {
|
|
41
25
|
return new Promise((resolve, reject) => {
|
|
42
26
|
var fulfilled = (value) => {
|
|
@@ -57,6 +41,22 @@ var __async = (__this, __arguments, generator) => {
|
|
|
57
41
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
58
42
|
});
|
|
59
43
|
};
|
|
44
|
+
var generateCode_exports = {};
|
|
45
|
+
__export(generateCode_exports, {
|
|
46
|
+
createImportStatements: () => createImportStatements,
|
|
47
|
+
generateCode: () => generateCode
|
|
48
|
+
});
|
|
49
|
+
module.exports = __toCommonJS(generateCode_exports);
|
|
50
|
+
var import_path = __toESM(require("path"));
|
|
51
|
+
var import_utils = require("@modern-js/utils");
|
|
52
|
+
var import_core = require("@modern-js/core");
|
|
53
|
+
var import_commands = require("../utils/commands");
|
|
54
|
+
var templates = __toESM(require("./templates"));
|
|
55
|
+
var import_getClientRoutes = require("./getClientRoutes");
|
|
56
|
+
var import_constants = require("./constants");
|
|
57
|
+
var import_utils2 = require("./utils");
|
|
58
|
+
var import_nestedRoutes = require("./nestedRoutes");
|
|
59
|
+
var import_Builder = require("./Builder");
|
|
60
60
|
const loader = {
|
|
61
61
|
".js": "jsx",
|
|
62
62
|
".ts": "tsx"
|
|
@@ -110,13 +110,12 @@ ${initialize || ""}`
|
|
|
110
110
|
).join("\n");
|
|
111
111
|
};
|
|
112
112
|
const buildLoader = (entry, outfile) => __async(void 0, null, function* () {
|
|
113
|
-
const command = (0, import_commands.getCommand)();
|
|
114
113
|
yield import_Builder.loaderBuilder.build({
|
|
115
114
|
format: "esm",
|
|
116
115
|
platform: "browser",
|
|
117
116
|
target: "esnext",
|
|
118
117
|
loader,
|
|
119
|
-
watch:
|
|
118
|
+
watch: (0, import_commands.isDevCommand)() && {},
|
|
120
119
|
bundle: true,
|
|
121
120
|
logLevel: "error",
|
|
122
121
|
entryPoints: [entry],
|
|
@@ -141,13 +140,12 @@ const buildLoader = (entry, outfile) => __async(void 0, null, function* () {
|
|
|
141
140
|
});
|
|
142
141
|
});
|
|
143
142
|
const buildServerLoader = (entry, outfile) => __async(void 0, null, function* () {
|
|
144
|
-
const command = (0, import_commands.getCommand)();
|
|
145
143
|
yield import_Builder.serverLoaderBuilder.build({
|
|
146
144
|
format: "cjs",
|
|
147
145
|
platform: "node",
|
|
148
146
|
target: "esnext",
|
|
149
147
|
loader,
|
|
150
|
-
watch:
|
|
148
|
+
watch: (0, import_commands.isDevCommand)() && {},
|
|
151
149
|
bundle: true,
|
|
152
150
|
logLevel: "error",
|
|
153
151
|
entryPoints: [entry],
|
|
@@ -155,7 +153,7 @@ const buildServerLoader = (entry, outfile) => __async(void 0, null, function* ()
|
|
|
155
153
|
});
|
|
156
154
|
});
|
|
157
155
|
const generateCode = (appContext, config, entrypoints, api) => __async(void 0, null, function* () {
|
|
158
|
-
var _a, _b;
|
|
156
|
+
var _a, _b, _c;
|
|
159
157
|
const {
|
|
160
158
|
internalDirectory,
|
|
161
159
|
distDirectory,
|
|
@@ -165,9 +163,9 @@ const generateCode = (appContext, config, entrypoints, api) => __async(void 0, n
|
|
|
165
163
|
packageName
|
|
166
164
|
} = appContext;
|
|
167
165
|
const hookRunners = api.useHookRunners();
|
|
168
|
-
const
|
|
166
|
+
const isV5 = typeof ((_a = config.runtime) == null ? void 0 : _a.router) !== "boolean" && ((_c = (_b = config == null ? void 0 : config.runtime) == null ? void 0 : _b.router) == null ? void 0 : _c.mode) === "react-router-5";
|
|
169
167
|
const { mountId } = config.html;
|
|
170
|
-
const getRoutes =
|
|
168
|
+
const getRoutes = isV5 ? import_getClientRoutes.getClientRoutesLegacy : import_getClientRoutes.getClientRoutes;
|
|
171
169
|
yield Promise.all(entrypoints.map(generateEntryCode));
|
|
172
170
|
function generateEntryCode(entrypoint) {
|
|
173
171
|
return __async(this, null, function* () {
|
|
@@ -186,7 +184,7 @@ const generateCode = (appContext, config, entrypoints, api) => __async(void 0, n
|
|
|
186
184
|
});
|
|
187
185
|
}
|
|
188
186
|
if (entrypoint.nestedRoutesEntry) {
|
|
189
|
-
if (!
|
|
187
|
+
if (!isV5) {
|
|
190
188
|
nestedRoute = yield (0, import_nestedRoutes.walk)(
|
|
191
189
|
entrypoint.nestedRoutesEntry,
|
|
192
190
|
entrypoint.nestedRoutesEntry,
|
|
@@ -345,3 +343,8 @@ const generateCode = (appContext, config, entrypoints, api) => __async(void 0, n
|
|
|
345
343
|
});
|
|
346
344
|
}
|
|
347
345
|
});
|
|
346
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
347
|
+
0 && (module.exports = {
|
|
348
|
+
createImportStatements,
|
|
349
|
+
generateCode
|
|
350
|
+
});
|
|
@@ -21,11 +21,11 @@ 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
|
|
25
|
-
__export(
|
|
24
|
+
var getBundleEntry_exports = {};
|
|
25
|
+
__export(getBundleEntry_exports, {
|
|
26
26
|
getBundleEntry: () => getBundleEntry
|
|
27
27
|
});
|
|
28
|
-
module.exports = __toCommonJS(
|
|
28
|
+
module.exports = __toCommonJS(getBundleEntry_exports);
|
|
29
29
|
var import_path = __toESM(require("path"));
|
|
30
30
|
var import_utils = require("@modern-js/utils");
|
|
31
31
|
var import_getFileSystemEntry = require("./getFileSystemEntry");
|
|
@@ -69,7 +69,8 @@ const getBundleEntry = (appContext, config) => {
|
|
|
69
69
|
entryName: name,
|
|
70
70
|
entry: (0, import_utils.ensureAbsolutePath)(appDirectory, value.entry),
|
|
71
71
|
isAutoMount: !value.disableMount,
|
|
72
|
-
|
|
72
|
+
customBootstrap: value.customBootstrap && (0, import_utils.ensureAbsolutePath)(appDirectory, value.customBootstrap),
|
|
73
|
+
fileSystemRoutes: import_utils.fs.statSync((0, import_utils.ensureAbsolutePath)(appDirectory, value.entry)).isDirectory() ? {} : void 0
|
|
73
74
|
};
|
|
74
75
|
if (entrypoint.fileSystemRoutes) {
|
|
75
76
|
entrypoint.nestedRoutesEntry = entrypoint.entry;
|
|
@@ -88,3 +89,7 @@ const getBundleEntry = (appContext, config) => {
|
|
|
88
89
|
}
|
|
89
90
|
return defaults;
|
|
90
91
|
};
|
|
92
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
93
|
+
0 && (module.exports = {
|
|
94
|
+
getBundleEntry
|
|
95
|
+
});
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
7
24
|
var __export = (target, all) => {
|
|
8
25
|
for (var name in all)
|
|
9
26
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -21,36 +38,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
38
|
mod
|
|
22
39
|
));
|
|
23
40
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
-
var
|
|
25
|
-
__export(
|
|
41
|
+
var getRoutes_exports = {};
|
|
42
|
+
__export(getRoutes_exports, {
|
|
26
43
|
getClientRoutes: () => getClientRoutes
|
|
27
44
|
});
|
|
28
|
-
module.exports = __toCommonJS(
|
|
45
|
+
module.exports = __toCommonJS(getRoutes_exports);
|
|
29
46
|
var import_path = __toESM(require("path"));
|
|
30
47
|
var import_utils = require("@modern-js/utils");
|
|
31
48
|
var import_makeLegalIdentifier = require("../makeLegalIdentifier");
|
|
32
49
|
var import_constants = require("../constants");
|
|
33
50
|
var import_utils2 = require("../utils");
|
|
34
51
|
var import_utils3 = require("./utils");
|
|
35
|
-
var __defProp2 = Object.defineProperty;
|
|
36
|
-
var __defProps = Object.defineProperties;
|
|
37
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
38
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
39
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
40
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
41
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
42
|
-
var __spreadValues = (a, b) => {
|
|
43
|
-
for (var prop in b || (b = {}))
|
|
44
|
-
if (__hasOwnProp2.call(b, prop))
|
|
45
|
-
__defNormalProp(a, prop, b[prop]);
|
|
46
|
-
if (__getOwnPropSymbols)
|
|
47
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
48
|
-
if (__propIsEnum.call(b, prop))
|
|
49
|
-
__defNormalProp(a, prop, b[prop]);
|
|
50
|
-
}
|
|
51
|
-
return a;
|
|
52
|
-
};
|
|
53
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
54
52
|
const compName = (srcDirectory, filePath) => {
|
|
55
53
|
const legalCompName = (0, import_makeLegalIdentifier.makeLegalIdentifier)(
|
|
56
54
|
import_path.default.relative(srcDirectory, filePath)
|
|
@@ -194,20 +192,23 @@ const getClientRoutes = ({
|
|
|
194
192
|
internalDirectory,
|
|
195
193
|
internalDirAlias
|
|
196
194
|
}) => {
|
|
197
|
-
const {
|
|
198
|
-
if (!
|
|
195
|
+
const { entryName, pageRoutesEntry } = entrypoint;
|
|
196
|
+
if (!pageRoutesEntry) {
|
|
197
|
+
return [];
|
|
198
|
+
}
|
|
199
|
+
if (!import_utils.fs.existsSync(pageRoutesEntry)) {
|
|
199
200
|
throw new Error(
|
|
200
|
-
`generate file system routes error, ${
|
|
201
|
+
`generate file system routes error, ${pageRoutesEntry} directory not found.`
|
|
201
202
|
);
|
|
202
203
|
}
|
|
203
|
-
if (!(import_utils.fs.existsSync(
|
|
204
|
+
if (!(import_utils.fs.existsSync(pageRoutesEntry) && import_utils.fs.statSync(pageRoutesEntry).isDirectory())) {
|
|
204
205
|
throw new Error(
|
|
205
|
-
`generate file system routes error, ${
|
|
206
|
+
`generate file system routes error, ${pageRoutesEntry} should be directory.`
|
|
206
207
|
);
|
|
207
208
|
}
|
|
208
209
|
let routes = [];
|
|
209
210
|
recursiveReadDir({
|
|
210
|
-
dir:
|
|
211
|
+
dir: pageRoutesEntry,
|
|
211
212
|
routes,
|
|
212
213
|
basePath: "/",
|
|
213
214
|
srcDirectory,
|
|
@@ -235,3 +236,7 @@ const getClientRoutes = ({
|
|
|
235
236
|
(0, import_utils3.debug)(`fileSystem routes: %o`, routes);
|
|
236
237
|
return routes;
|
|
237
238
|
};
|
|
239
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
240
|
+
0 && (module.exports = {
|
|
241
|
+
getClientRoutes
|
|
242
|
+
});
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
7
24
|
var __export = (target, all) => {
|
|
8
25
|
for (var name in all)
|
|
9
26
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -21,36 +38,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
38
|
mod
|
|
22
39
|
));
|
|
23
40
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
-
var
|
|
25
|
-
__export(
|
|
41
|
+
var getRoutesLegacy_exports = {};
|
|
42
|
+
__export(getRoutesLegacy_exports, {
|
|
26
43
|
getClientRoutes: () => getClientRoutes
|
|
27
44
|
});
|
|
28
|
-
module.exports = __toCommonJS(
|
|
45
|
+
module.exports = __toCommonJS(getRoutesLegacy_exports);
|
|
29
46
|
var import_path = __toESM(require("path"));
|
|
30
47
|
var import_utils = require("@modern-js/utils");
|
|
31
48
|
var import_makeLegalIdentifier = require("../makeLegalIdentifier");
|
|
32
49
|
var import_constants = require("../constants");
|
|
33
50
|
var import_utils2 = require("../utils");
|
|
34
51
|
var import_utils3 = require("./utils");
|
|
35
|
-
var __defProp2 = Object.defineProperty;
|
|
36
|
-
var __defProps = Object.defineProperties;
|
|
37
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
38
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
39
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
40
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
41
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
42
|
-
var __spreadValues = (a, b) => {
|
|
43
|
-
for (var prop in b || (b = {}))
|
|
44
|
-
if (__hasOwnProp2.call(b, prop))
|
|
45
|
-
__defNormalProp(a, prop, b[prop]);
|
|
46
|
-
if (__getOwnPropSymbols)
|
|
47
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
48
|
-
if (__propIsEnum.call(b, prop))
|
|
49
|
-
__defNormalProp(a, prop, b[prop]);
|
|
50
|
-
}
|
|
51
|
-
return a;
|
|
52
|
-
};
|
|
53
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
54
52
|
const compName = (srcDirectory, filePath) => {
|
|
55
53
|
const legalCompName = (0, import_makeLegalIdentifier.makeLegalIdentifier)(
|
|
56
54
|
import_path.default.relative(srcDirectory, filePath)
|
|
@@ -234,3 +232,7 @@ const getClientRoutes = ({
|
|
|
234
232
|
(0, import_utils3.debug)(`fileSystem routes: %o`, routes);
|
|
235
233
|
return routes;
|
|
236
234
|
};
|
|
235
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
236
|
+
0 && (module.exports = {
|
|
237
|
+
getClientRoutes
|
|
238
|
+
});
|
|
@@ -15,11 +15,16 @@ 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 getClientRoutes_exports = {};
|
|
19
|
+
__export(getClientRoutes_exports, {
|
|
20
20
|
getClientRoutes: () => import_getRoutes.getClientRoutes,
|
|
21
21
|
getClientRoutesLegacy: () => import_getRoutesLegacy.getClientRoutes
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(getClientRoutes_exports);
|
|
24
24
|
var import_getRoutes = require("./getRoutes");
|
|
25
25
|
var import_getRoutesLegacy = require("./getRoutesLegacy");
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
getClientRoutes,
|
|
29
|
+
getClientRoutesLegacy
|
|
30
|
+
});
|
|
@@ -21,14 +21,14 @@ 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
|
|
25
|
-
__export(
|
|
24
|
+
var utils_exports = {};
|
|
25
|
+
__export(utils_exports, {
|
|
26
26
|
debug: () => debug,
|
|
27
27
|
findLayout: () => findLayout,
|
|
28
28
|
getRouteWeight: () => getRouteWeight,
|
|
29
29
|
shouldSkip: () => shouldSkip
|
|
30
30
|
});
|
|
31
|
-
module.exports = __toCommonJS(
|
|
31
|
+
module.exports = __toCommonJS(utils_exports);
|
|
32
32
|
var import_path = __toESM(require("path"));
|
|
33
33
|
var import_utils = require("@modern-js/utils");
|
|
34
34
|
var import_constants = require("../constants");
|
|
@@ -49,3 +49,10 @@ const shouldSkip = (file) => {
|
|
|
49
49
|
}
|
|
50
50
|
return false;
|
|
51
51
|
};
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
debug,
|
|
55
|
+
findLayout,
|
|
56
|
+
getRouteWeight,
|
|
57
|
+
shouldSkip
|
|
58
|
+
});
|
|
@@ -21,11 +21,11 @@ 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
|
|
25
|
-
__export(
|
|
24
|
+
var getFileSystemEntry_exports = {};
|
|
25
|
+
__export(getFileSystemEntry_exports, {
|
|
26
26
|
getFileSystemEntry: () => getFileSystemEntry
|
|
27
27
|
});
|
|
28
|
-
module.exports = __toCommonJS(
|
|
28
|
+
module.exports = __toCommonJS(getFileSystemEntry_exports);
|
|
29
29
|
var import_fs = __toESM(require("fs"));
|
|
30
30
|
var import_path = __toESM(require("path"));
|
|
31
31
|
var import_utils = require("@modern-js/utils");
|
|
@@ -84,9 +84,11 @@ const scanDir = (dirs) => dirs.map((dir) => {
|
|
|
84
84
|
};
|
|
85
85
|
if (isHasPages) {
|
|
86
86
|
entrypoint.entry = import_path.default.join(dir, import_constants.PAGES_DIR_NAME);
|
|
87
|
+
entrypoint.pageRoutesEntry = entrypoint.entry;
|
|
87
88
|
}
|
|
88
89
|
if (isHasNestedRoutes) {
|
|
89
|
-
entrypoint.
|
|
90
|
+
entrypoint.entry = import_path.default.join(dir, import_constants.NESTED_ROUTES_DIR);
|
|
91
|
+
entrypoint.nestedRoutesEntry = entrypoint.entry;
|
|
90
92
|
}
|
|
91
93
|
return entrypoint;
|
|
92
94
|
}
|
|
@@ -100,14 +102,20 @@ const scanDir = (dirs) => dirs.map((dir) => {
|
|
|
100
102
|
const getFileSystemEntry = (appContext, config) => {
|
|
101
103
|
const { appDirectory } = appContext;
|
|
102
104
|
const {
|
|
103
|
-
source: { entriesDir }
|
|
105
|
+
source: { entriesDir, disableEntryDirs }
|
|
104
106
|
} = config;
|
|
107
|
+
let disabledDirs = [];
|
|
108
|
+
if (disableEntryDirs && Array.isArray(disableEntryDirs)) {
|
|
109
|
+
disabledDirs = disableEntryDirs == null ? void 0 : disableEntryDirs.map(
|
|
110
|
+
(dir) => (0, import_utils.ensureAbsolutePath)(appDirectory, dir)
|
|
111
|
+
);
|
|
112
|
+
}
|
|
105
113
|
const src = (0, import_utils.ensureAbsolutePath)(appDirectory, entriesDir || "");
|
|
106
114
|
if (import_fs.default.existsSync(src)) {
|
|
107
115
|
if (import_fs.default.statSync(src).isDirectory()) {
|
|
108
116
|
return scanDir(
|
|
109
117
|
isBundleEntry(src) ? [src] : import_fs.default.readdirSync(src).map((file) => import_path.default.join(src, file)).filter(
|
|
110
|
-
(file) => import_fs.default.statSync(file).isDirectory() && isBundleEntry(file)
|
|
118
|
+
(file) => import_fs.default.statSync(file).isDirectory() && isBundleEntry(file) && !disabledDirs.includes(file)
|
|
111
119
|
)
|
|
112
120
|
);
|
|
113
121
|
} else {
|
|
@@ -117,3 +125,7 @@ const getFileSystemEntry = (appContext, config) => {
|
|
|
117
125
|
throw Error(`src dir ${entriesDir} not found.`);
|
|
118
126
|
}
|
|
119
127
|
};
|
|
128
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
129
|
+
0 && (module.exports = {
|
|
130
|
+
getFileSystemEntry
|
|
131
|
+
});
|