@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
|
@@ -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,34 +38,6 @@ 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 stdin_exports = {};
|
|
25
|
-
__export(stdin_exports, {
|
|
26
|
-
walk: () => walk
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(stdin_exports);
|
|
29
|
-
var path = __toESM(require("path"));
|
|
30
|
-
var import_utils = require("@modern-js/utils");
|
|
31
|
-
var import_constants = require("./constants");
|
|
32
|
-
var import_utils2 = require("./utils");
|
|
33
|
-
var __defProp2 = Object.defineProperty;
|
|
34
|
-
var __defProps = Object.defineProperties;
|
|
35
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
36
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
37
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
38
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
39
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
40
|
-
var __spreadValues = (a, b) => {
|
|
41
|
-
for (var prop in b || (b = {}))
|
|
42
|
-
if (__hasOwnProp2.call(b, prop))
|
|
43
|
-
__defNormalProp(a, prop, b[prop]);
|
|
44
|
-
if (__getOwnPropSymbols)
|
|
45
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
46
|
-
if (__propIsEnum.call(b, prop))
|
|
47
|
-
__defNormalProp(a, prop, b[prop]);
|
|
48
|
-
}
|
|
49
|
-
return a;
|
|
50
|
-
};
|
|
51
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
52
41
|
var __async = (__this, __arguments, generator) => {
|
|
53
42
|
return new Promise((resolve, reject) => {
|
|
54
43
|
var fulfilled = (value) => {
|
|
@@ -69,18 +58,16 @@ var __async = (__this, __arguments, generator) => {
|
|
|
69
58
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
70
59
|
});
|
|
71
60
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
LOADER_FILE
|
|
83
|
-
];
|
|
61
|
+
var nestedRoutes_exports = {};
|
|
62
|
+
__export(nestedRoutes_exports, {
|
|
63
|
+
walk: () => walk
|
|
64
|
+
});
|
|
65
|
+
module.exports = __toCommonJS(nestedRoutes_exports);
|
|
66
|
+
var path = __toESM(require("path"));
|
|
67
|
+
var import_utils = require("@modern-js/utils");
|
|
68
|
+
var import_constants = require("./constants");
|
|
69
|
+
var import_utils2 = require("./utils");
|
|
70
|
+
const conventionNames = Object.values(import_constants.NESTED_ROUTE);
|
|
84
71
|
const getLoaderPath = (filename) => __async(void 0, null, function* () {
|
|
85
72
|
if (yield (0, import_utils2.hasLoader)(filename)) {
|
|
86
73
|
return filename;
|
|
@@ -133,6 +120,8 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
|
|
|
133
120
|
children: [],
|
|
134
121
|
isRoot
|
|
135
122
|
};
|
|
123
|
+
let pageLoaderFile = "";
|
|
124
|
+
let pageRoute = null;
|
|
136
125
|
const items = yield import_utils.fs.readdir(dirname);
|
|
137
126
|
for (const item of items) {
|
|
138
127
|
const itemPath = path.join(dirname, item);
|
|
@@ -148,12 +137,23 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
|
|
|
148
137
|
if (extname && (!import_constants.JS_EXTENSIONS.includes(extname) || !conventionNames.includes(itemWithoutExt))) {
|
|
149
138
|
continue;
|
|
150
139
|
}
|
|
151
|
-
if (itemWithoutExt ===
|
|
140
|
+
if (itemWithoutExt === import_constants.NESTED_ROUTE.LAYOUT_LOADER_FILE) {
|
|
141
|
+
if (!route.loader) {
|
|
142
|
+
route.loader = itemPath;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (itemWithoutExt === import_constants.NESTED_ROUTE.LAYOUT_FILE) {
|
|
152
146
|
route._component = (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name);
|
|
153
|
-
|
|
147
|
+
const loaderPath = yield getLoaderPath(itemPath);
|
|
148
|
+
if (loaderPath) {
|
|
149
|
+
route.loader = loaderPath;
|
|
150
|
+
}
|
|
154
151
|
}
|
|
155
|
-
if (itemWithoutExt ===
|
|
156
|
-
|
|
152
|
+
if (itemWithoutExt === import_constants.NESTED_ROUTE.PAGE_LOADER_FILE) {
|
|
153
|
+
pageLoaderFile = itemPath;
|
|
154
|
+
}
|
|
155
|
+
if (itemWithoutExt === import_constants.NESTED_ROUTE.PAGE_FILE) {
|
|
156
|
+
pageRoute = createIndexRoute(
|
|
157
157
|
{
|
|
158
158
|
_component: (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name)
|
|
159
159
|
},
|
|
@@ -161,20 +161,25 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
|
|
|
161
161
|
itemPath,
|
|
162
162
|
entryName
|
|
163
163
|
);
|
|
164
|
-
|
|
165
|
-
(
|
|
164
|
+
const loaderPath = yield getLoaderPath(itemPath);
|
|
165
|
+
if (loaderPath) {
|
|
166
|
+
pageRoute.loader = loaderPath;
|
|
167
|
+
} else if (pageLoaderFile) {
|
|
168
|
+
pageRoute.loader = pageLoaderFile;
|
|
169
|
+
}
|
|
170
|
+
(_b = route.children) == null ? void 0 : _b.push(pageRoute);
|
|
166
171
|
}
|
|
167
|
-
if (itemWithoutExt === LOADING_FILE) {
|
|
172
|
+
if (itemWithoutExt === import_constants.NESTED_ROUTE.LOADING_FILE) {
|
|
168
173
|
route.loading = (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name);
|
|
169
174
|
}
|
|
170
|
-
if (itemWithoutExt === ERROR_FILE) {
|
|
175
|
+
if (itemWithoutExt === import_constants.NESTED_ROUTE.ERROR_FILE) {
|
|
171
176
|
route.error = (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name);
|
|
172
177
|
}
|
|
173
178
|
}
|
|
174
179
|
const finalRoute = createRoute(
|
|
175
180
|
route,
|
|
176
181
|
rootDir,
|
|
177
|
-
path.join(dirname, `${LAYOUT_FILE}.ts`),
|
|
182
|
+
path.join(dirname, `${import_constants.NESTED_ROUTE.LAYOUT_FILE}.ts`),
|
|
178
183
|
entryName
|
|
179
184
|
);
|
|
180
185
|
if (isPathlessLayout) {
|
|
@@ -182,3 +187,7 @@ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, funct
|
|
|
182
187
|
}
|
|
183
188
|
return finalRoute;
|
|
184
189
|
});
|
|
190
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
191
|
+
0 && (module.exports = {
|
|
192
|
+
walk
|
|
193
|
+
});
|
|
@@ -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,37 +38,6 @@ 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 stdin_exports = {};
|
|
25
|
-
__export(stdin_exports, {
|
|
26
|
-
fileSystemRoutes: () => fileSystemRoutes,
|
|
27
|
-
html: () => html,
|
|
28
|
-
index: () => index,
|
|
29
|
-
renderFunction: () => renderFunction,
|
|
30
|
-
routesForServer: () => routesForServer
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(stdin_exports);
|
|
33
|
-
var import_path = __toESM(require("path"));
|
|
34
|
-
var import_utils = require("@modern-js/utils");
|
|
35
|
-
var import_constants = require("./constants");
|
|
36
|
-
var __defProp2 = Object.defineProperty;
|
|
37
|
-
var __defProps = Object.defineProperties;
|
|
38
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
39
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
40
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
41
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
42
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
43
|
-
var __spreadValues = (a, b) => {
|
|
44
|
-
for (var prop in b || (b = {}))
|
|
45
|
-
if (__hasOwnProp2.call(b, prop))
|
|
46
|
-
__defNormalProp(a, prop, b[prop]);
|
|
47
|
-
if (__getOwnPropSymbols)
|
|
48
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
49
|
-
if (__propIsEnum.call(b, prop))
|
|
50
|
-
__defNormalProp(a, prop, b[prop]);
|
|
51
|
-
}
|
|
52
|
-
return a;
|
|
53
|
-
};
|
|
54
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
55
41
|
var __async = (__this, __arguments, generator) => {
|
|
56
42
|
return new Promise((resolve, reject) => {
|
|
57
43
|
var fulfilled = (value) => {
|
|
@@ -72,6 +58,18 @@ var __async = (__this, __arguments, generator) => {
|
|
|
72
58
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
73
59
|
});
|
|
74
60
|
};
|
|
61
|
+
var templates_exports = {};
|
|
62
|
+
__export(templates_exports, {
|
|
63
|
+
fileSystemRoutes: () => fileSystemRoutes,
|
|
64
|
+
html: () => html,
|
|
65
|
+
index: () => index,
|
|
66
|
+
renderFunction: () => renderFunction,
|
|
67
|
+
routesForServer: () => routesForServer
|
|
68
|
+
});
|
|
69
|
+
module.exports = __toCommonJS(templates_exports);
|
|
70
|
+
var import_path = __toESM(require("path"));
|
|
71
|
+
var import_utils = require("@modern-js/utils");
|
|
72
|
+
var import_constants = require("./constants");
|
|
75
73
|
const index = ({
|
|
76
74
|
mountId,
|
|
77
75
|
imports,
|
|
@@ -100,21 +98,34 @@ const renderFunction = ({
|
|
|
100
98
|
plugins,
|
|
101
99
|
customBootstrap,
|
|
102
100
|
fileSystemRoutes: fileSystemRoutes2
|
|
103
|
-
}) =>
|
|
101
|
+
}) => {
|
|
102
|
+
return `
|
|
103
|
+
const finalAppConfig = {
|
|
104
|
+
...App.config,
|
|
105
|
+
...typeof ${import_constants.APP_CONFIG_NAME} === 'object' ? ${import_constants.APP_CONFIG_NAME} : {},
|
|
106
|
+
}
|
|
107
|
+
|
|
104
108
|
AppWrapper = createApp({
|
|
105
109
|
plugins: [
|
|
106
110
|
${plugins.map(
|
|
107
|
-
|
|
108
|
-
).join("\n")}
|
|
111
|
+
({ name, options, args }) => `${name}({...${options}, ...finalAppConfig?.${args || name}}),`
|
|
112
|
+
).join("\n")}
|
|
109
113
|
]
|
|
110
114
|
})(${fileSystemRoutes2 ? "" : `App`})
|
|
111
115
|
|
|
116
|
+
|
|
117
|
+
if(!AppWrapper.init && typeof appInit !== 'undefined') {
|
|
118
|
+
AppWrapper.init = appInit;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
112
122
|
if (IS_BROWSER) {
|
|
113
123
|
${customBootstrap ? `customBootstrap(AppWrapper);` : `bootstrap(AppWrapper, MOUNT_ID, root, ReactDOM);`}
|
|
114
124
|
}
|
|
115
125
|
|
|
116
126
|
return AppWrapper
|
|
117
127
|
`;
|
|
128
|
+
};
|
|
118
129
|
const html = (partials) => `
|
|
119
130
|
<!DOCTYPE html>
|
|
120
131
|
<html>
|
|
@@ -209,14 +220,15 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
|
|
|
209
220
|
ssrMode,
|
|
210
221
|
nestedRoutesEntry,
|
|
211
222
|
entryName,
|
|
212
|
-
internalDirectory
|
|
223
|
+
internalDirectory,
|
|
224
|
+
internalDirAlias
|
|
213
225
|
}) {
|
|
214
226
|
const loadings = [];
|
|
215
227
|
const errors = [];
|
|
216
228
|
const loaders = [];
|
|
217
229
|
const loadersMap = {};
|
|
218
230
|
const loadersIndexFile = import_path.default.join(
|
|
219
|
-
|
|
231
|
+
internalDirAlias,
|
|
220
232
|
entryName,
|
|
221
233
|
import_constants.TEMP_LOADERS_DIR,
|
|
222
234
|
"index.js"
|
|
@@ -346,9 +358,16 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
|
|
|
346
358
|
import_constants.TEMP_LOADERS_DIR,
|
|
347
359
|
`${name}.js`
|
|
348
360
|
);
|
|
349
|
-
|
|
361
|
+
let code = "";
|
|
362
|
+
if (loader.includes(".loader.")) {
|
|
363
|
+
code = `
|
|
364
|
+
export { default as ${name} } from '${(0, import_utils.slash)(loader)}'
|
|
365
|
+
`;
|
|
366
|
+
} else {
|
|
367
|
+
code = `
|
|
350
368
|
export { loader as ${name} } from '${(0, import_utils.slash)(loader)}'
|
|
351
369
|
`;
|
|
370
|
+
}
|
|
352
371
|
yield import_utils.fs.ensureFile(filename);
|
|
353
372
|
yield import_utils.fs.writeFile(filename, code);
|
|
354
373
|
}))
|
|
@@ -363,3 +382,11 @@ const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
|
|
|
363
382
|
${routeComponentsCode}
|
|
364
383
|
`;
|
|
365
384
|
});
|
|
385
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
386
|
+
0 && (module.exports = {
|
|
387
|
+
fileSystemRoutes,
|
|
388
|
+
html,
|
|
389
|
+
index,
|
|
390
|
+
renderFunction,
|
|
391
|
+
routesForServer
|
|
392
|
+
});
|
|
@@ -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
|
-
getDefaultImports: () => getDefaultImports,
|
|
27
|
-
hasLoader: () => hasLoader,
|
|
28
|
-
isRouteComponentFile: () => isRouteComponentFile,
|
|
29
|
-
parseModule: () => parseModule,
|
|
30
|
-
replaceWithAlias: () => replaceWithAlias,
|
|
31
|
-
walkDirectory: () => walkDirectory
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(stdin_exports);
|
|
34
|
-
var import_fs = __toESM(require("fs"));
|
|
35
|
-
var import_path = __toESM(require("path"));
|
|
36
|
-
var import_utils = require("@modern-js/utils");
|
|
37
|
-
var import_esbuild = require("esbuild");
|
|
38
|
-
var import_es_module_lexer = require("es-module-lexer");
|
|
39
|
-
var import_constants = require("./constants");
|
|
40
24
|
var __async = (__this, __arguments, generator) => {
|
|
41
25
|
return new Promise((resolve, reject) => {
|
|
42
26
|
var fulfilled = (value) => {
|
|
@@ -57,6 +41,23 @@ var __async = (__this, __arguments, generator) => {
|
|
|
57
41
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
58
42
|
});
|
|
59
43
|
};
|
|
44
|
+
var utils_exports = {};
|
|
45
|
+
__export(utils_exports, {
|
|
46
|
+
getDefaultImports: () => getDefaultImports,
|
|
47
|
+
hasLoader: () => hasLoader,
|
|
48
|
+
isNestedRouteComponent: () => isNestedRouteComponent,
|
|
49
|
+
isPageComponentFile: () => isPageComponentFile,
|
|
50
|
+
parseModule: () => parseModule,
|
|
51
|
+
replaceWithAlias: () => replaceWithAlias,
|
|
52
|
+
walkDirectory: () => walkDirectory
|
|
53
|
+
});
|
|
54
|
+
module.exports = __toCommonJS(utils_exports);
|
|
55
|
+
var import_fs = __toESM(require("fs"));
|
|
56
|
+
var import_path = __toESM(require("path"));
|
|
57
|
+
var import_utils = require("@modern-js/utils");
|
|
58
|
+
var import_esbuild = require("esbuild");
|
|
59
|
+
var import_es_module_lexer = require("es-module-lexer");
|
|
60
|
+
var import_constants = require("./constants");
|
|
60
61
|
const walkDirectory = (dir) => import_fs.default.readdirSync(dir).reduce((previous, filename) => {
|
|
61
62
|
const filePath = import_path.default.join(dir, filename);
|
|
62
63
|
if (import_fs.default.statSync(filePath).isDirectory()) {
|
|
@@ -124,7 +125,7 @@ const getDefaultImports = ({
|
|
|
124
125
|
}
|
|
125
126
|
return imports;
|
|
126
127
|
};
|
|
127
|
-
const
|
|
128
|
+
const isPageComponentFile = (filePath) => {
|
|
128
129
|
if (/\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/.test(filePath)) {
|
|
129
130
|
return false;
|
|
130
131
|
}
|
|
@@ -133,13 +134,24 @@ const isRouteComponentFile = (filePath) => {
|
|
|
133
134
|
}
|
|
134
135
|
return false;
|
|
135
136
|
};
|
|
137
|
+
const isNestedRouteComponent = (nestedRouteEntries, absoluteFilePath) => {
|
|
138
|
+
const reg = new RegExp(
|
|
139
|
+
`(${import_constants.NESTED_ROUTE.LAYOUT_FILE}|${import_constants.NESTED_ROUTE.PAGE_FILE}})\\.tsx?$`
|
|
140
|
+
);
|
|
141
|
+
return nestedRouteEntries.some((nestedRoutesEntry) => {
|
|
142
|
+
if (absoluteFilePath.includes(nestedRoutesEntry) && reg.test(absoluteFilePath)) {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
146
|
+
});
|
|
147
|
+
};
|
|
136
148
|
const replaceWithAlias = (base, filePath, alias) => (0, import_utils.normalizeToPosixPath)(import_path.default.join(alias, import_path.default.relative(base, filePath)));
|
|
137
149
|
const parseModule = (_0) => __async(void 0, [_0], function* ({
|
|
138
150
|
source,
|
|
139
151
|
filename
|
|
140
152
|
}) {
|
|
141
153
|
let content = source;
|
|
142
|
-
if (
|
|
154
|
+
if (import_constants.JS_EXTENSIONS.some((ext) => filename.endsWith(ext))) {
|
|
143
155
|
const result = yield (0, import_esbuild.transform)(content, {
|
|
144
156
|
loader: import_path.default.extname(filename).slice(1),
|
|
145
157
|
format: "esm"
|
|
@@ -156,3 +168,13 @@ const hasLoader = (filename) => __async(void 0, null, function* () {
|
|
|
156
168
|
});
|
|
157
169
|
return moduleExports.some((e) => e.n === import_constants.LOADER_EXPORT_NAME);
|
|
158
170
|
});
|
|
171
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
172
|
+
0 && (module.exports = {
|
|
173
|
+
getDefaultImports,
|
|
174
|
+
hasLoader,
|
|
175
|
+
isNestedRouteComponent,
|
|
176
|
+
isPageComponentFile,
|
|
177
|
+
parseModule,
|
|
178
|
+
replaceWithAlias,
|
|
179
|
+
walkDirectory
|
|
180
|
+
});
|
|
@@ -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,11 +38,11 @@ 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 compatModern_exports = {};
|
|
42
|
+
__export(compatModern_exports, {
|
|
26
43
|
PluginCompatModern: () => PluginCompatModern
|
|
27
44
|
});
|
|
28
|
-
module.exports = __toCommonJS(
|
|
45
|
+
module.exports = __toCommonJS(compatModern_exports);
|
|
29
46
|
var import_path = require("path");
|
|
30
47
|
var import_builder_shared = require("@modern-js/builder-shared");
|
|
31
48
|
var import_lodash = require("@modern-js/utils/lodash");
|
|
@@ -35,25 +52,6 @@ var import_htmlBottomTemplate = require("../webpackPlugins/htmlBottomTemplate");
|
|
|
35
52
|
var import_htmlAsyncChunkPlugin = require("../webpackPlugins/htmlAsyncChunkPlugin");
|
|
36
53
|
var import_share = require("../share");
|
|
37
54
|
var import_routerPlugin = __toESM(require("../webpackPlugins/routerPlugin"));
|
|
38
|
-
var __defProp2 = Object.defineProperty;
|
|
39
|
-
var __defProps = Object.defineProperties;
|
|
40
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
41
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
42
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
43
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
44
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
45
|
-
var __spreadValues = (a, b) => {
|
|
46
|
-
for (var prop in b || (b = {}))
|
|
47
|
-
if (__hasOwnProp2.call(b, prop))
|
|
48
|
-
__defNormalProp(a, prop, b[prop]);
|
|
49
|
-
if (__getOwnPropSymbols)
|
|
50
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
51
|
-
if (__propIsEnum.call(b, prop))
|
|
52
|
-
__defNormalProp(a, prop, b[prop]);
|
|
53
|
-
}
|
|
54
|
-
return a;
|
|
55
|
-
};
|
|
56
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
57
55
|
const PluginCompatModern = (appContext, modernConfig, options) => ({
|
|
58
56
|
name: "builder-plugin-compat-modern",
|
|
59
57
|
setup(api) {
|
|
@@ -68,6 +66,7 @@ const PluginCompatModern = (appContext, modernConfig, options) => ({
|
|
|
68
66
|
return config;
|
|
69
67
|
});
|
|
70
68
|
api.modifyWebpackChain((chain, { target, CHAIN_ID, isProd }) => {
|
|
69
|
+
var _a;
|
|
71
70
|
const builderNormalizedConfig = api.getNormalizedConfig();
|
|
72
71
|
if (target === "node") {
|
|
73
72
|
chain.name("server");
|
|
@@ -102,10 +101,10 @@ const PluginCompatModern = (appContext, modernConfig, options) => ({
|
|
|
102
101
|
chain
|
|
103
102
|
);
|
|
104
103
|
chain.plugin(CHAIN_ID.PLUGIN.COPY).tap((args) => {
|
|
105
|
-
var
|
|
104
|
+
var _a2;
|
|
106
105
|
return [
|
|
107
106
|
{
|
|
108
|
-
patterns: [...((
|
|
107
|
+
patterns: [...((_a2 = args[0]) == null ? void 0 : _a2.patterns) || [], defaultCopyPattern]
|
|
109
108
|
}
|
|
110
109
|
];
|
|
111
110
|
});
|
|
@@ -114,7 +113,8 @@ const PluginCompatModern = (appContext, modernConfig, options) => ({
|
|
|
114
113
|
const existNestedRoutes = entrypoints.some(
|
|
115
114
|
(entrypoint) => entrypoint.nestedRoutesEntry
|
|
116
115
|
);
|
|
117
|
-
const
|
|
116
|
+
const routerConfig = (_a = modernConfig == null ? void 0 : modernConfig.runtime) == null ? void 0 : _a.router;
|
|
117
|
+
const routerManifest = Boolean(routerConfig == null ? void 0 : routerConfig.manifest);
|
|
118
118
|
if (existNestedRoutes || routerManifest) {
|
|
119
119
|
chain.plugin("route-plugin").use(import_routerPlugin.default);
|
|
120
120
|
}
|
|
@@ -124,8 +124,8 @@ const PluginCompatModern = (appContext, modernConfig, options) => ({
|
|
|
124
124
|
chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
|
|
125
125
|
}
|
|
126
126
|
function isHtmlEnabled(config, target2) {
|
|
127
|
-
var
|
|
128
|
-
return ((
|
|
127
|
+
var _a2;
|
|
128
|
+
return ((_a2 = config.tools) == null ? void 0 : _a2.htmlPlugin) !== false && target2 !== "node" && target2 !== "web-worker";
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
131
|
if (options) {
|
|
@@ -168,6 +168,11 @@ function applyNodeCompat(chain, modernConfig, isProd) {
|
|
|
168
168
|
if (isProd2 && ((outputConfig == null ? void 0 : outputConfig.ssg) === true || typeof ((_a = outputConfig == null ? void 0 : outputConfig.ssg) == null ? void 0 : _a[0]) === "function")) {
|
|
169
169
|
return;
|
|
170
170
|
}
|
|
171
|
+
if (typeof entries === "undefined") {
|
|
172
|
+
throw new Error(
|
|
173
|
+
"No entry found, one of src/routes/layout.tsx, src/App.tsx, src/index.tsx is required"
|
|
174
|
+
);
|
|
175
|
+
}
|
|
171
176
|
const entryNames = Object.keys(entries);
|
|
172
177
|
if (isProd2 && entryNames.length === 1 && (outputConfig == null ? void 0 : outputConfig.ssg)) {
|
|
173
178
|
return;
|
|
@@ -247,3 +252,7 @@ function applyAsyncChunkHtmlPlugin({
|
|
|
247
252
|
chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(import_htmlAsyncChunkPlugin.HtmlAsyncChunkPlugin, [import_html_webpack_plugin.default]);
|
|
248
253
|
}
|
|
249
254
|
}
|
|
255
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
256
|
+
0 && (module.exports = {
|
|
257
|
+
PluginCompatModern
|
|
258
|
+
});
|