@modern-js/app-tools 2.53.1-alpha.3 → 2.54.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/bin/modern.js +0 -2
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +2 -1
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +2 -2
- package/dist/cjs/commands/build.js +2 -0
- package/dist/cjs/commands/deploy.js +2 -2
- package/dist/cjs/commands/dev.js +19 -5
- package/dist/cjs/commands/index.js +113 -7
- package/dist/cjs/commands/serve.js +19 -5
- package/dist/cjs/hooks.js +5 -0
- package/dist/cjs/index.js +14 -83
- package/dist/cjs/plugins/analyze/constants.js +56 -0
- package/dist/cjs/{analyze → plugins/analyze}/generateCode.js +11 -84
- package/dist/cjs/{analyze → plugins/analyze}/getBundleEntry.js +11 -20
- package/dist/cjs/{analyze → plugins/analyze}/getFileSystemEntry.js +33 -47
- package/dist/cjs/{analyze → plugins/analyze}/getServerRoutes.js +1 -1
- package/dist/cjs/{analyze → plugins/analyze}/index.js +9 -24
- package/dist/cjs/plugins/analyze/templates.js +101 -0
- package/dist/cjs/{analyze → plugins/analyze}/utils.js +12 -55
- package/dist/cjs/plugins/deploy/dependencies/index.js +16 -25
- package/dist/cjs/plugins/deploy/dependencies/utils.js +1 -2
- package/dist/cjs/plugins/deploy/platforms/netlify.js +5 -9
- package/dist/cjs/plugins/deploy/platforms/node.js +5 -13
- package/dist/cjs/plugins/deploy/platforms/vercel.js +5 -9
- package/dist/cjs/{initialize → plugins/initialize}/index.js +1 -1
- package/dist/cjs/plugins/serverBuild.js +10 -4
- package/dist/cjs/utils/createServer.js +1 -1
- package/dist/cjs/utils/{getServerInternalPlugins.js → loadPlugins.js} +18 -11
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +4 -1
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +2 -2
- package/dist/esm/commands/build.js +16 -9
- package/dist/esm/commands/deploy.js +2 -2
- package/dist/esm/commands/dev.js +13 -9
- package/dist/esm/commands/index.js +411 -3
- package/dist/esm/commands/serve.js +12 -8
- package/dist/esm/hooks.js +5 -0
- package/dist/esm/index.js +12 -394
- package/dist/esm/plugins/analyze/constants.js +24 -0
- package/dist/esm/{analyze → plugins/analyze}/generateCode.js +27 -169
- package/dist/esm/plugins/analyze/getBundleEntry.js +101 -0
- package/dist/esm/plugins/analyze/getFileSystemEntry.js +195 -0
- package/dist/esm/{analyze → plugins/analyze}/getServerRoutes.js +1 -1
- package/dist/esm/{analyze → plugins/analyze}/index.js +42 -70
- package/dist/esm/plugins/analyze/templates.js +22 -0
- package/dist/esm/{analyze → plugins/analyze}/utils.js +13 -135
- package/dist/esm/plugins/deploy/dependencies/index.js +69 -94
- package/dist/esm/plugins/deploy/dependencies/utils.js +3 -4
- package/dist/esm/plugins/deploy/platforms/netlify.js +8 -10
- package/dist/esm/plugins/deploy/platforms/node.js +8 -14
- package/dist/esm/plugins/deploy/platforms/vercel.js +8 -10
- package/dist/esm/{initialize → plugins/initialize}/index.js +1 -1
- package/dist/esm/plugins/serverBuild.js +13 -6
- package/dist/esm/utils/createServer.js +2 -2
- package/dist/esm/utils/loadPlugins.js +64 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +2 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +2 -2
- package/dist/esm-node/commands/build.js +2 -0
- package/dist/esm-node/commands/deploy.js +2 -2
- package/dist/esm-node/commands/dev.js +11 -7
- package/dist/esm-node/commands/index.js +92 -3
- package/dist/esm-node/commands/serve.js +10 -6
- package/dist/esm-node/hooks.js +5 -0
- package/dist/esm-node/index.js +12 -79
- package/dist/esm-node/plugins/analyze/constants.js +24 -0
- package/dist/esm-node/{analyze → plugins/analyze}/generateCode.js +14 -87
- package/dist/esm-node/{analyze → plugins/analyze}/getBundleEntry.js +11 -20
- package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +75 -0
- package/dist/esm-node/{analyze → plugins/analyze}/getServerRoutes.js +1 -1
- package/dist/esm-node/{analyze → plugins/analyze}/index.js +10 -25
- package/dist/esm-node/plugins/analyze/templates.js +75 -0
- package/dist/esm-node/{analyze → plugins/analyze}/utils.js +13 -52
- package/dist/esm-node/plugins/deploy/dependencies/index.js +18 -27
- package/dist/esm-node/plugins/deploy/dependencies/utils.js +1 -2
- package/dist/esm-node/plugins/deploy/platforms/netlify.js +6 -10
- package/dist/esm-node/plugins/deploy/platforms/node.js +6 -14
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +6 -10
- package/dist/esm-node/{initialize → plugins/initialize}/index.js +1 -1
- package/dist/esm-node/plugins/serverBuild.js +11 -5
- package/dist/esm-node/utils/createServer.js +2 -2
- package/dist/esm-node/utils/loadPlugins.js +21 -0
- package/dist/types/builder/builder-webpack/createCopyPattern.d.ts +2 -2
- package/dist/types/commands/index.d.ts +10 -3
- package/dist/types/config/initialize/inits.d.ts +1 -1
- package/dist/types/exports/server.d.ts +4 -0
- package/dist/types/index.d.ts +2 -5
- package/dist/types/plugins/analyze/constants.d.ts +9 -0
- package/dist/types/{analyze → plugins/analyze}/generateCode.d.ts +1 -1
- package/dist/types/plugins/analyze/getBundleEntry.d.ts +4 -0
- package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +5 -0
- package/dist/types/{analyze → plugins/analyze}/getHtmlTemplate.d.ts +1 -1
- package/dist/types/{analyze → plugins/analyze}/getServerRoutes.d.ts +1 -1
- package/dist/types/{analyze → plugins/analyze}/index.d.ts +1 -1
- package/dist/types/plugins/analyze/templates.d.ts +19 -0
- package/dist/types/{analyze → plugins/analyze}/utils.d.ts +4 -6
- package/dist/types/plugins/deploy/dependencies/index.d.ts +1 -9
- package/dist/types/plugins/deploy/dependencies/utils.d.ts +1 -7
- package/dist/types/{initialize → plugins/initialize}/index.d.ts +1 -1
- package/dist/types/types/hooks.d.ts +11 -1
- package/dist/types/utils/loadPlugins.d.ts +5 -0
- package/package.json +22 -30
- package/dist/cjs/analyze/constants.js +0 -122
- package/dist/cjs/analyze/getClientRoutes/getRoutes.js +0 -197
- package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +0 -195
- package/dist/cjs/analyze/getClientRoutes/index.js +0 -31
- package/dist/cjs/analyze/getClientRoutes/utils.js +0 -59
- package/dist/cjs/analyze/makeLegalIdentifier.js +0 -37
- package/dist/cjs/analyze/nestedRoutes.js +0 -295
- package/dist/cjs/analyze/templates.js +0 -444
- package/dist/cjs/plugins/deploy/exports.js +0 -28
- package/dist/esm/analyze/constants.js +0 -76
- package/dist/esm/analyze/getBundleEntry.js +0 -75
- package/dist/esm/analyze/getClientRoutes/getRoutes.js +0 -185
- package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +0 -183
- package/dist/esm/analyze/getClientRoutes/index.js +0 -6
- package/dist/esm/analyze/getClientRoutes/utils.js +0 -28
- package/dist/esm/analyze/getFileSystemEntry.js +0 -113
- package/dist/esm/analyze/makeLegalIdentifier.js +0 -15
- package/dist/esm/analyze/nestedRoutes.js +0 -398
- package/dist/esm/analyze/templates.js +0 -435
- package/dist/esm/plugins/deploy/exports.js +0 -4
- package/dist/esm/utils/getServerInternalPlugins.js +0 -40
- package/dist/esm-node/analyze/constants.js +0 -76
- package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +0 -163
- package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +0 -161
- package/dist/esm-node/analyze/getClientRoutes/index.js +0 -6
- package/dist/esm-node/analyze/getClientRoutes/utils.js +0 -22
- package/dist/esm-node/analyze/getFileSystemEntry.js +0 -89
- package/dist/esm-node/analyze/makeLegalIdentifier.js +0 -13
- package/dist/esm-node/analyze/nestedRoutes.js +0 -259
- package/dist/esm-node/analyze/templates.js +0 -405
- package/dist/esm-node/plugins/deploy/exports.js +0 -4
- package/dist/esm-node/utils/getServerInternalPlugins.js +0 -15
- package/dist/js/modern/analyze/constants.js +0 -15
- package/dist/js/modern/analyze/generateCode.js +0 -179
- package/dist/js/modern/analyze/getBundleEntry.js +0 -75
- package/dist/js/modern/analyze/getClientRoutes.js +0 -219
- package/dist/js/modern/analyze/getFileSystemEntry.js +0 -74
- package/dist/js/modern/analyze/getHtmlTemplate.js +0 -82
- package/dist/js/modern/analyze/getServerRoutes.js +0 -192
- package/dist/js/modern/analyze/index.js +0 -148
- package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -32
- package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -16
- package/dist/js/modern/analyze/templates.js +0 -88
- package/dist/js/modern/analyze/utils.js +0 -92
- package/dist/js/modern/commands/build.js +0 -154
- package/dist/js/modern/commands/deploy.js +0 -5
- package/dist/js/modern/commands/dev.js +0 -95
- package/dist/js/modern/commands/index.js +0 -3
- package/dist/js/modern/commands/inspect.js +0 -69
- package/dist/js/modern/commands/start.js +0 -31
- package/dist/js/modern/exports/server.js +0 -1
- package/dist/js/modern/hooks.js +0 -21
- package/dist/js/modern/index.js +0 -109
- package/dist/js/modern/locale/en.js +0 -35
- package/dist/js/modern/locale/index.js +0 -9
- package/dist/js/modern/locale/zh.js +0 -35
- package/dist/js/modern/utils/config.js +0 -78
- package/dist/js/modern/utils/createCompiler.js +0 -61
- package/dist/js/modern/utils/createServer.js +0 -18
- package/dist/js/modern/utils/getSpecifiedEntries.js +0 -36
- package/dist/js/modern/utils/language.js +0 -5
- package/dist/js/modern/utils/printInstructions.js +0 -11
- package/dist/js/modern/utils/routes.js +0 -15
- package/dist/js/modern/utils/types.js +0 -0
- package/dist/js/node/analyze/constants.js +0 -36
- package/dist/js/node/analyze/generateCode.js +0 -208
- package/dist/js/node/analyze/getBundleEntry.js +0 -89
- package/dist/js/node/analyze/getClientRoutes.js +0 -241
- package/dist/js/node/analyze/getFileSystemEntry.js +0 -90
- package/dist/js/node/analyze/getHtmlTemplate.js +0 -106
- package/dist/js/node/analyze/getServerRoutes.js +0 -208
- package/dist/js/node/analyze/index.js +0 -178
- package/dist/js/node/analyze/isDefaultExportFunction.js +0 -50
- package/dist/js/node/analyze/makeLegalIdentifier.js +0 -24
- package/dist/js/node/analyze/templates.js +0 -106
- package/dist/js/node/analyze/utils.js +0 -113
- package/dist/js/node/commands/build.js +0 -174
- package/dist/js/node/commands/deploy.js +0 -14
- package/dist/js/node/commands/dev.js +0 -120
- package/dist/js/node/commands/index.js +0 -44
- package/dist/js/node/commands/inspect.js +0 -98
- package/dist/js/node/commands/start.js +0 -47
- package/dist/js/node/exports/server.js +0 -13
- package/dist/js/node/hooks.js +0 -39
- package/dist/js/node/index.js +0 -141
- package/dist/js/node/locale/en.js +0 -42
- package/dist/js/node/locale/index.js +0 -20
- package/dist/js/node/locale/zh.js +0 -42
- package/dist/js/node/utils/config.js +0 -103
- package/dist/js/node/utils/createCompiler.js +0 -81
- package/dist/js/node/utils/createServer.js +0 -35
- package/dist/js/node/utils/getSpecifiedEntries.js +0 -46
- package/dist/js/node/utils/language.js +0 -13
- package/dist/js/node/utils/printInstructions.js +0 -22
- package/dist/js/node/utils/routes.js +0 -25
- package/dist/js/node/utils/types.js +0 -0
- package/dist/types/analyze/constants.d.ts +0 -42
- package/dist/types/analyze/getBundleEntry.d.ts +0 -3
- package/dist/types/analyze/getClientRoutes/getRoutes.d.ts +0 -8
- package/dist/types/analyze/getClientRoutes/getRoutesLegacy.d.ts +0 -9
- package/dist/types/analyze/getClientRoutes/index.d.ts +0 -2
- package/dist/types/analyze/getClientRoutes/utils.d.ts +0 -5
- package/dist/types/analyze/getFileSystemEntry.d.ts +0 -4
- package/dist/types/analyze/makeLegalIdentifier.d.ts +0 -1
- package/dist/types/analyze/nestedRoutes.d.ts +0 -7
- package/dist/types/analyze/templates.d.ts +0 -30
- package/dist/types/plugins/deploy/exports.d.ts +0 -1
- package/dist/types/utils/getServerInternalPlugins.d.ts +0 -2
- /package/dist/cjs/{analyze → plugins/analyze}/getHtmlTemplate.js +0 -0
- /package/dist/cjs/{analyze → plugins/analyze}/isDefaultExportFunction.js +0 -0
- /package/dist/esm/{analyze → plugins/analyze}/getHtmlTemplate.js +0 -0
- /package/dist/esm/{analyze → plugins/analyze}/isDefaultExportFunction.js +0 -0
- /package/dist/esm-node/{analyze → plugins/analyze}/getHtmlTemplate.js +0 -0
- /package/dist/esm-node/{analyze → plugins/analyze}/isDefaultExportFunction.js +0 -0
- /package/dist/types/{analyze → plugins/analyze}/isDefaultExportFunction.d.ts +0 -0
|
@@ -5,14 +5,13 @@ import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
|
5
5
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
6
6
|
import * as path from "path";
|
|
7
7
|
import { createDebugger, findExists, fs, isApiOnly, minimist, isDevCommand, getArgv } from "@modern-js/utils";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { checkIsBuildCommands, isPageComponentFile, parseModule, replaceWithAlias } from "./utils";
|
|
8
|
+
import { printInstructions } from "../../utils/printInstructions";
|
|
9
|
+
import { generateRoutes, getPathWithoutExt } from "../../utils/routes";
|
|
10
|
+
import { emitResolvedConfig } from "../../utils/config";
|
|
11
|
+
import { getSelectedEntries } from "../../utils/getSelectedEntries";
|
|
12
|
+
import { initialNormalizedConfig } from "../../config";
|
|
13
|
+
import { createBuilderGenerator } from "../../builder";
|
|
14
|
+
import { checkIsBuildCommands, parseModule, replaceWithAlias } from "./utils";
|
|
16
15
|
import { APP_CONFIG_NAME, APP_INIT_EXPORTED, APP_INIT_IMPORTED } from "./constants";
|
|
17
16
|
import { generateIndexCode } from "./generateCode";
|
|
18
17
|
var debug = createDebugger("plugin-analyze");
|
|
@@ -23,11 +22,10 @@ function analyze_default(param) {
|
|
|
23
22
|
setup: function(api) {
|
|
24
23
|
var pagesDir = [];
|
|
25
24
|
var nestedRouteEntries = [];
|
|
26
|
-
var originEntrypoints = [];
|
|
27
25
|
return {
|
|
28
26
|
prepare: function prepare() {
|
|
29
27
|
return _async_to_generator(function() {
|
|
30
|
-
var _resolvedConfig_source, appContext, resolvedConfig, hookRunners, apiOnly, routes, _ref, getBundleEntry, getServerRoutes, generateCode, getHtmlTemplate, entrypoints, initialRoutes, routes1, importsStatemets, htmlTemplates, checkedEntries, entry, normalizedConfig, createBuilderForModern, builder;
|
|
28
|
+
var _resolvedConfig_source, appContext, resolvedConfig, hookRunners, apiOnly, routes, _ref, getBundleEntry, getServerRoutes, generateCode, getHtmlTemplate, entrypoints, _, _tmp, initialRoutes, routes1, importsStatemets, htmlTemplates, checkedEntries, entry, normalizedConfig, createBuilderForModern, builder;
|
|
31
29
|
return _ts_generator(this, function(_state) {
|
|
32
30
|
switch (_state.label) {
|
|
33
31
|
case 0:
|
|
@@ -89,7 +87,21 @@ function analyze_default(param) {
|
|
|
89
87
|
_state.sent(),
|
|
90
88
|
4
|
|
91
89
|
]), getBundleEntry = _ref[0].getBundleEntry, getServerRoutes = _ref[1].getServerRoutes, generateCode = _ref[2].generateCode, getHtmlTemplate = _ref[3].getHtmlTemplate;
|
|
92
|
-
|
|
90
|
+
_ = hookRunners.modifyEntrypoints;
|
|
91
|
+
_tmp = {};
|
|
92
|
+
return [
|
|
93
|
+
4,
|
|
94
|
+
getBundleEntry(hookRunners, appContext, resolvedConfig)
|
|
95
|
+
];
|
|
96
|
+
case 6:
|
|
97
|
+
return [
|
|
98
|
+
4,
|
|
99
|
+
_.apply(hookRunners, [
|
|
100
|
+
(_tmp.entrypoints = _state.sent(), _tmp)
|
|
101
|
+
])
|
|
102
|
+
];
|
|
103
|
+
case 7:
|
|
104
|
+
entrypoints = _state.sent().entrypoints;
|
|
93
105
|
debug("entrypoints: %o", entrypoints);
|
|
94
106
|
initialRoutes = getServerRoutes(entrypoints, {
|
|
95
107
|
appContext,
|
|
@@ -101,7 +113,7 @@ function analyze_default(param) {
|
|
|
101
113
|
routes: initialRoutes
|
|
102
114
|
})
|
|
103
115
|
];
|
|
104
|
-
case
|
|
116
|
+
case 8:
|
|
105
117
|
routes1 = _state.sent().routes;
|
|
106
118
|
debug("server routes: %o", routes1);
|
|
107
119
|
appContext = _object_spread_props(_object_spread({}, api.useAppContext()), {
|
|
@@ -117,12 +129,11 @@ function analyze_default(param) {
|
|
|
117
129
|
}).filter(function(entry2) {
|
|
118
130
|
return entry2 && !path.extname(entry2);
|
|
119
131
|
}).concat(nestedRouteEntries);
|
|
120
|
-
originEntrypoints = cloneDeep(entrypoints);
|
|
121
132
|
return [
|
|
122
133
|
4,
|
|
123
134
|
generateCode(appContext, resolvedConfig, entrypoints, api)
|
|
124
135
|
];
|
|
125
|
-
case
|
|
136
|
+
case 9:
|
|
126
137
|
importsStatemets = _state.sent().importsStatemets;
|
|
127
138
|
return [
|
|
128
139
|
4,
|
|
@@ -131,14 +142,14 @@ function analyze_default(param) {
|
|
|
131
142
|
config: resolvedConfig
|
|
132
143
|
})
|
|
133
144
|
];
|
|
134
|
-
case
|
|
145
|
+
case 10:
|
|
135
146
|
htmlTemplates = _state.sent();
|
|
136
147
|
debug("html templates: %o", htmlTemplates);
|
|
137
148
|
return [
|
|
138
149
|
4,
|
|
139
150
|
hookRunners.addDefineTypes()
|
|
140
151
|
];
|
|
141
|
-
case
|
|
152
|
+
case 11:
|
|
142
153
|
_state.sent();
|
|
143
154
|
debug("add Define Types");
|
|
144
155
|
checkedEntries = entrypoints.map(function(point) {
|
|
@@ -147,17 +158,17 @@ function analyze_default(param) {
|
|
|
147
158
|
if (!isDevCommand())
|
|
148
159
|
return [
|
|
149
160
|
3,
|
|
150
|
-
|
|
161
|
+
13
|
|
151
162
|
];
|
|
152
163
|
entry = minimist(getArgv()).entry;
|
|
153
164
|
return [
|
|
154
165
|
4,
|
|
155
166
|
getSelectedEntries(typeof entry === "string" ? entry.split(",") : entry, entrypoints)
|
|
156
167
|
];
|
|
157
|
-
case
|
|
168
|
+
case 12:
|
|
158
169
|
checkedEntries = _state.sent();
|
|
159
|
-
_state.label =
|
|
160
|
-
case
|
|
170
|
+
_state.label = 13;
|
|
171
|
+
case 13:
|
|
161
172
|
appContext = _object_spread_props(_object_spread({}, api.useAppContext()), {
|
|
162
173
|
entrypoints,
|
|
163
174
|
checkedEntries,
|
|
@@ -169,14 +180,14 @@ function analyze_default(param) {
|
|
|
169
180
|
if (!checkIsBuildCommands())
|
|
170
181
|
return [
|
|
171
182
|
3,
|
|
172
|
-
|
|
183
|
+
16
|
|
173
184
|
];
|
|
174
185
|
normalizedConfig = api.useResolvedConfigContext();
|
|
175
186
|
return [
|
|
176
187
|
4,
|
|
177
188
|
createBuilderGenerator(bundler)
|
|
178
189
|
];
|
|
179
|
-
case
|
|
190
|
+
case 14:
|
|
180
191
|
createBuilderForModern = _state.sent();
|
|
181
192
|
return [
|
|
182
193
|
4,
|
|
@@ -185,7 +196,7 @@ function analyze_default(param) {
|
|
|
185
196
|
appContext
|
|
186
197
|
})
|
|
187
198
|
];
|
|
188
|
-
case
|
|
199
|
+
case 15:
|
|
189
200
|
builder = _state.sent();
|
|
190
201
|
builder.onBeforeBuild(function() {
|
|
191
202
|
var _ref2 = _async_to_generator(function(param2) {
|
|
@@ -215,7 +226,7 @@ function analyze_default(param) {
|
|
|
215
226
|
}
|
|
216
227
|
});
|
|
217
228
|
});
|
|
218
|
-
return function(
|
|
229
|
+
return function(_2) {
|
|
219
230
|
return _ref2.apply(this, arguments);
|
|
220
231
|
};
|
|
221
232
|
}());
|
|
@@ -247,7 +258,7 @@ function analyze_default(param) {
|
|
|
247
258
|
}
|
|
248
259
|
});
|
|
249
260
|
});
|
|
250
|
-
return function(
|
|
261
|
+
return function(_2) {
|
|
251
262
|
return _ref2.apply(this, arguments);
|
|
252
263
|
};
|
|
253
264
|
}());
|
|
@@ -268,7 +279,7 @@ function analyze_default(param) {
|
|
|
268
279
|
];
|
|
269
280
|
});
|
|
270
281
|
});
|
|
271
|
-
return function(
|
|
282
|
+
return function(_2) {
|
|
272
283
|
return _ref2.apply(this, arguments);
|
|
273
284
|
};
|
|
274
285
|
}());
|
|
@@ -307,7 +318,7 @@ function analyze_default(param) {
|
|
|
307
318
|
}
|
|
308
319
|
});
|
|
309
320
|
});
|
|
310
|
-
return function(
|
|
321
|
+
return function(_2) {
|
|
311
322
|
return _ref2.apply(this, arguments);
|
|
312
323
|
};
|
|
313
324
|
}());
|
|
@@ -333,7 +344,7 @@ function analyze_default(param) {
|
|
|
333
344
|
}
|
|
334
345
|
});
|
|
335
346
|
});
|
|
336
|
-
return function(
|
|
347
|
+
return function(_2) {
|
|
337
348
|
return _ref2.apply(this, arguments);
|
|
338
349
|
};
|
|
339
350
|
}());
|
|
@@ -342,8 +353,8 @@ function analyze_default(param) {
|
|
|
342
353
|
builder
|
|
343
354
|
});
|
|
344
355
|
api.setAppContext(appContext);
|
|
345
|
-
_state.label =
|
|
346
|
-
case
|
|
356
|
+
_state.label = 16;
|
|
357
|
+
case 16:
|
|
347
358
|
return [
|
|
348
359
|
2
|
|
349
360
|
];
|
|
@@ -456,46 +467,7 @@ function analyze_default(param) {
|
|
|
456
467
|
});
|
|
457
468
|
})();
|
|
458
469
|
}
|
|
459
|
-
)
|
|
460
|
-
fileChange: function fileChange(e) {
|
|
461
|
-
return _async_to_generator(function() {
|
|
462
|
-
var appContext, appDirectory, filename, eventType, isPageFile, absoluteFilePath, isRouteComponent, resolvedConfig, generateCode, entrypoints;
|
|
463
|
-
return _ts_generator(this, function(_state) {
|
|
464
|
-
switch (_state.label) {
|
|
465
|
-
case 0:
|
|
466
|
-
appContext = api.useAppContext();
|
|
467
|
-
appDirectory = appContext.appDirectory;
|
|
468
|
-
filename = e.filename, eventType = e.eventType;
|
|
469
|
-
isPageFile = function(name) {
|
|
470
|
-
return pagesDir.some(function(pageDir) {
|
|
471
|
-
return name.includes(pageDir);
|
|
472
|
-
});
|
|
473
|
-
};
|
|
474
|
-
absoluteFilePath = path.resolve(appDirectory, filename);
|
|
475
|
-
isRouteComponent = isPageFile(absoluteFilePath) && isPageComponentFile(absoluteFilePath);
|
|
476
|
-
if (!(isRouteComponent && (eventType === "add" || eventType === "unlink")))
|
|
477
|
-
return [
|
|
478
|
-
3,
|
|
479
|
-
2
|
|
480
|
-
];
|
|
481
|
-
resolvedConfig = api.useResolvedConfigContext();
|
|
482
|
-
return [
|
|
483
|
-
4,
|
|
484
|
-
import("./generateCode")
|
|
485
|
-
];
|
|
486
|
-
case 1:
|
|
487
|
-
generateCode = _state.sent().generateCode;
|
|
488
|
-
entrypoints = cloneDeep(originEntrypoints);
|
|
489
|
-
generateCode(appContext, resolvedConfig, entrypoints, api);
|
|
490
|
-
_state.label = 2;
|
|
491
|
-
case 2:
|
|
492
|
-
return [
|
|
493
|
-
2
|
|
494
|
-
];
|
|
495
|
-
}
|
|
496
|
-
});
|
|
497
|
-
})();
|
|
498
|
-
}
|
|
470
|
+
)
|
|
499
471
|
};
|
|
500
472
|
}
|
|
501
473
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { APP_CONFIG_NAME } from "./constants";
|
|
2
|
+
var index = function(param) {
|
|
3
|
+
var mountId = param.mountId, imports = param.imports, renderFunction2 = param.renderFunction, exportStatement = param.exportStatement;
|
|
4
|
+
return "\nconst IS_BROWSER = typeof window !== 'undefined' && window.name !== 'nodejs';\nconst IS_REACT18 = process.env.IS_REACT18 === 'true';\nconst MOUNT_ID = '".concat(mountId, "';\n\n").concat(imports, "\n\nlet AppWrapper = null;\n\nlet root = null;\n\nfunction render() {\n ").concat(renderFunction2, "\n}\n\nAppWrapper = render();\n\n").concat(exportStatement, ";\n");
|
|
5
|
+
};
|
|
6
|
+
var renderFunction = function(param) {
|
|
7
|
+
var plugins = param.plugins, customBootstrap = param.customBootstrap, fileSystemRoutes = param.fileSystemRoutes, customRuntimeConfig = param.customRuntimeConfig;
|
|
8
|
+
var bootstrap = "bootstrap(AppWrapper, MOUNT_ID, root, ReactDOM)";
|
|
9
|
+
var runtimePlugins = "...(runtimeConfig?.plugins || []),";
|
|
10
|
+
return "\n const finalAppConfig = {\n ...App.config,\n ...typeof ".concat(APP_CONFIG_NAME, " === 'function' ? ").concat(APP_CONFIG_NAME, "() : {},\n }\n\n AppWrapper = createApp({\n plugins: [\n ").concat(plugins.map(function(param2) {
|
|
11
|
+
var name = param2.name, options = param2.options, args = param2.args;
|
|
12
|
+
return "".concat(name, "({...").concat(options, ", ...finalAppConfig?.").concat(args || name, "}),");
|
|
13
|
+
}).join("\n"), "\n ").concat(customRuntimeConfig ? runtimePlugins : "", "\n ]\n })(").concat(fileSystemRoutes ? "" : "App", ")\n\n\n if(!AppWrapper.init && typeof appInit !== 'undefined') {\n AppWrapper.init = appInit;\n }\n\n\n if (IS_BROWSER) {\n ").concat(customBootstrap ? "customBootstrap(AppWrapper, () => ".concat(bootstrap, ");") : "".concat(bootstrap, ";"), "\n }\n\n return AppWrapper\n");
|
|
14
|
+
};
|
|
15
|
+
var html = function(partials) {
|
|
16
|
+
return "\n<!DOCTYPE html>\n<html>\n<head>\n\n ".concat(partials.top.join("\n"), "\n\n ").concat(partials.head.join("\n"), '\n\n</head>\n\n<body>\n <div id="<%= mountId %>"><!--<?- html ?>--></div>\n ').concat(partials.body.join("\n"), "\n <!--<?- chunksMap.js ?>-->\n <!--<?- SSRDataScript ?>-->\n <!--<?- bottomTemplate ?>-->\n</body>\n\n</html>\n");
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
html,
|
|
20
|
+
index,
|
|
21
|
+
renderFunction
|
|
22
|
+
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
-
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
3
2
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
4
3
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
5
4
|
import fs from "fs";
|
|
6
5
|
import path from "path";
|
|
7
|
-
import { isReact18, normalizeToPosixPath,
|
|
6
|
+
import { isReact18, normalizeToPosixPath, getCommand, JS_EXTENSIONS } from "@modern-js/utils";
|
|
8
7
|
import { transform } from "esbuild";
|
|
9
8
|
import { parse } from "es-module-lexer";
|
|
10
|
-
import {
|
|
9
|
+
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "./constants";
|
|
11
10
|
var walkDirectory = function(dir) {
|
|
12
11
|
return fs.readdirSync(dir).reduce(function(previous, filename) {
|
|
13
12
|
var filePath = path.join(dir, filename);
|
|
@@ -21,7 +20,7 @@ var walkDirectory = function(dir) {
|
|
|
21
20
|
}, []);
|
|
22
21
|
};
|
|
23
22
|
var getDefaultImports = function(param) {
|
|
24
|
-
var entrypoint = param.entrypoint, srcDirectory = param.srcDirectory, appDirectory = param.appDirectory, internalSrcAlias = param.internalSrcAlias, internalDirAlias = param.internalDirAlias;
|
|
23
|
+
var entrypoint = param.entrypoint, srcDirectory = param.srcDirectory, appDirectory = param.appDirectory, internalSrcAlias = param.internalSrcAlias, internalDirAlias = param.internalDirAlias, runtimeConfigFile = param.runtimeConfigFile, customRuntimeConfig = param.customRuntimeConfig;
|
|
25
24
|
var entryName = entrypoint.entryName, fileSystemRoutes = entrypoint.fileSystemRoutes, customBootstrap = entrypoint.customBootstrap, entry = entrypoint.entry;
|
|
26
25
|
var imports = [
|
|
27
26
|
{
|
|
@@ -92,21 +91,17 @@ var getDefaultImports = function(param) {
|
|
|
92
91
|
value: normalizeToPosixPath(entry.replace(srcDirectory, internalSrcAlias))
|
|
93
92
|
});
|
|
94
93
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
".ts",
|
|
105
|
-
".tsx"
|
|
106
|
-
].includes(path.extname(filePath))) {
|
|
107
|
-
return true;
|
|
94
|
+
if (customRuntimeConfig) {
|
|
95
|
+
imports.push({
|
|
96
|
+
specifiers: [
|
|
97
|
+
{
|
|
98
|
+
local: "runtimeConfig"
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
value: path.join(internalSrcAlias, runtimeConfigFile || "")
|
|
102
|
+
});
|
|
108
103
|
}
|
|
109
|
-
return
|
|
104
|
+
return imports;
|
|
110
105
|
};
|
|
111
106
|
var replaceWithAlias = function(base, filePath, alias) {
|
|
112
107
|
if (filePath.includes(base)) {
|
|
@@ -158,119 +153,6 @@ var parseModule = function() {
|
|
|
158
153
|
return _ref.apply(this, arguments);
|
|
159
154
|
};
|
|
160
155
|
}();
|
|
161
|
-
var hasLoader = function() {
|
|
162
|
-
var _ref = _async_to_generator(function(filename, source) {
|
|
163
|
-
var content, _ref2, moduleExports;
|
|
164
|
-
return _ts_generator(this, function(_state) {
|
|
165
|
-
switch (_state.label) {
|
|
166
|
-
case 0:
|
|
167
|
-
content = source;
|
|
168
|
-
if (!!source)
|
|
169
|
-
return [
|
|
170
|
-
3,
|
|
171
|
-
2
|
|
172
|
-
];
|
|
173
|
-
return [
|
|
174
|
-
4,
|
|
175
|
-
fse.readFile(filename, "utf-8")
|
|
176
|
-
];
|
|
177
|
-
case 1:
|
|
178
|
-
content = _state.sent().toString();
|
|
179
|
-
_state.label = 2;
|
|
180
|
-
case 2:
|
|
181
|
-
if (!content)
|
|
182
|
-
return [
|
|
183
|
-
3,
|
|
184
|
-
4
|
|
185
|
-
];
|
|
186
|
-
return [
|
|
187
|
-
4,
|
|
188
|
-
parseModule({
|
|
189
|
-
source: content.toString(),
|
|
190
|
-
filename
|
|
191
|
-
})
|
|
192
|
-
];
|
|
193
|
-
case 3:
|
|
194
|
-
_ref2 = _sliced_to_array.apply(void 0, [
|
|
195
|
-
_state.sent(),
|
|
196
|
-
2
|
|
197
|
-
]), moduleExports = _ref2[1];
|
|
198
|
-
return [
|
|
199
|
-
2,
|
|
200
|
-
moduleExports.some(function(e) {
|
|
201
|
-
return e.n === LOADER_EXPORT_NAME;
|
|
202
|
-
})
|
|
203
|
-
];
|
|
204
|
-
case 4:
|
|
205
|
-
return [
|
|
206
|
-
2,
|
|
207
|
-
false
|
|
208
|
-
];
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
return function hasLoader2(filename, source) {
|
|
213
|
-
return _ref.apply(this, arguments);
|
|
214
|
-
};
|
|
215
|
-
}();
|
|
216
|
-
var hasAction = function() {
|
|
217
|
-
var _ref = _async_to_generator(function(filename, source) {
|
|
218
|
-
var content, _ref2, moduleExports;
|
|
219
|
-
return _ts_generator(this, function(_state) {
|
|
220
|
-
switch (_state.label) {
|
|
221
|
-
case 0:
|
|
222
|
-
content = source;
|
|
223
|
-
if (!!source)
|
|
224
|
-
return [
|
|
225
|
-
3,
|
|
226
|
-
2
|
|
227
|
-
];
|
|
228
|
-
return [
|
|
229
|
-
4,
|
|
230
|
-
fse.readFile(filename, "utf-8")
|
|
231
|
-
];
|
|
232
|
-
case 1:
|
|
233
|
-
content = _state.sent().toString();
|
|
234
|
-
_state.label = 2;
|
|
235
|
-
case 2:
|
|
236
|
-
if (!content)
|
|
237
|
-
return [
|
|
238
|
-
3,
|
|
239
|
-
4
|
|
240
|
-
];
|
|
241
|
-
return [
|
|
242
|
-
4,
|
|
243
|
-
parseModule({
|
|
244
|
-
source: content.toString(),
|
|
245
|
-
filename
|
|
246
|
-
})
|
|
247
|
-
];
|
|
248
|
-
case 3:
|
|
249
|
-
_ref2 = _sliced_to_array.apply(void 0, [
|
|
250
|
-
_state.sent(),
|
|
251
|
-
2
|
|
252
|
-
]), moduleExports = _ref2[1];
|
|
253
|
-
return [
|
|
254
|
-
2,
|
|
255
|
-
moduleExports.some(function(e) {
|
|
256
|
-
return e.n === ACTION_EXPORT_NAME;
|
|
257
|
-
})
|
|
258
|
-
];
|
|
259
|
-
case 4:
|
|
260
|
-
return [
|
|
261
|
-
2,
|
|
262
|
-
false
|
|
263
|
-
];
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
return function hasAction2(filename, source) {
|
|
268
|
-
return _ref.apply(this, arguments);
|
|
269
|
-
};
|
|
270
|
-
}();
|
|
271
|
-
var getServerLoadersFile = function(internalDirectory, entryName) {
|
|
272
|
-
return path.join(internalDirectory, entryName, "route-server-loaders.js");
|
|
273
|
-
};
|
|
274
156
|
var getServerCombinedModueFile = function(internalDirectory, entryName) {
|
|
275
157
|
return path.join(internalDirectory, entryName, "server-loader-combined.js");
|
|
276
158
|
};
|
|
@@ -298,10 +180,6 @@ export {
|
|
|
298
180
|
checkIsBuildCommands,
|
|
299
181
|
getDefaultImports,
|
|
300
182
|
getServerCombinedModueFile,
|
|
301
|
-
getServerLoadersFile,
|
|
302
|
-
hasAction,
|
|
303
|
-
hasLoader,
|
|
304
|
-
isPageComponentFile,
|
|
305
183
|
isSubDirOrEqual,
|
|
306
184
|
parseModule,
|
|
307
185
|
replaceWithAlias,
|