@bleedingdev/modern-js-app-tools 3.9.0-ultramodern.19 → 3.9.0-ultramodern.20
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/dist/cjs/builder/shared/lazyCompilation.js +7 -4
- package/dist/cjs/commands/index.js +6 -2
- package/dist/cjs/index.js +91 -82
- package/dist/cjs/plugins/deploy/index.js +7 -28
- package/dist/cjs/plugins/initialize/index.js +1 -1
- package/dist/esm/builder/shared/lazyCompilation.mjs +7 -4
- package/dist/esm/commands/index.mjs +6 -2
- package/dist/esm/index.mjs +6 -0
- package/dist/esm/plugins/deploy/index.mjs +5 -21
- package/dist/esm/plugins/initialize/index.mjs +1 -1
- package/dist/esm-node/builder/shared/lazyCompilation.mjs +7 -4
- package/dist/esm-node/commands/index.mjs +6 -2
- package/dist/esm-node/index.mjs +6 -0
- package/dist/esm-node/plugins/deploy/index.mjs +5 -21
- package/dist/esm-node/plugins/initialize/index.mjs +1 -1
- package/dist/types/builder/shared/lazyCompilation.d.ts +12 -9
- package/dist/types/plugins/deploy/index.d.ts +1 -4
- package/dist/types/types/plugin.d.ts +2 -0
- package/docs/apis/app/commands.md +1 -0
- package/docs/guides/get-started/ultramodern.md +1 -1
- package/package.json +13 -13
|
@@ -68,13 +68,16 @@ function buildSSRLazyCompilationTest(eagerRouteFiles, userTest) {
|
|
|
68
68
|
return userTestFn(m);
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
function buildDefaultLazyCompilationTest(internalDirectory) {
|
|
72
|
-
let
|
|
71
|
+
function buildDefaultLazyCompilationTest(appDirectory, internalDirectory) {
|
|
72
|
+
let dirs;
|
|
73
73
|
return (m)=>{
|
|
74
74
|
if (!('resource' in m) || 'string' != typeof m.resource) return true;
|
|
75
|
-
|
|
75
|
+
dirs ??= {
|
|
76
|
+
app: (0, utils_namespaceObject.normalizeModulePath)(appDirectory),
|
|
77
|
+
internal: (0, utils_namespaceObject.normalizeModulePath)(internalDirectory)
|
|
78
|
+
};
|
|
76
79
|
const file = m.resource.split('?')[0].split(external_node_path_default().sep).join('/');
|
|
77
|
-
return
|
|
80
|
+
return file.startsWith(`${dirs.app}/`) && !file.startsWith(`${dirs.internal}/`) && !file.slice(dirs.app.length).includes('/node_modules/');
|
|
78
81
|
};
|
|
79
82
|
}
|
|
80
83
|
function planSSRLazyCompilation(current, info) {
|
|
@@ -36,6 +36,10 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
36
36
|
serverCommand: ()=>serverCommand
|
|
37
37
|
});
|
|
38
38
|
const index_js_namespaceObject = require("../locale/index.js");
|
|
39
|
+
const deployTargetOption = [
|
|
40
|
+
'--deploy-target <target>',
|
|
41
|
+
'deploy target; overrides deploy.target and MODERNJS_DEPLOY'
|
|
42
|
+
];
|
|
39
43
|
const devCommand = async (program, api)=>{
|
|
40
44
|
program.command('dev').alias('start').usage('[options]').description(index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.dev.describe)).option('-c --config <config>', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.config)).option('-e --entry [entry...]', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.dev.entry)).option('--analyze', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.analyze)).option('--api-only', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.dev.apiOnly)).option('--web-only', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.dev.webOnly)).action(async (options)=>{
|
|
41
45
|
const { dev } = await import("./dev.js");
|
|
@@ -43,7 +47,7 @@ const devCommand = async (program, api)=>{
|
|
|
43
47
|
});
|
|
44
48
|
};
|
|
45
49
|
const buildCommand = async (program, api)=>{
|
|
46
|
-
program.command('build').usage('[options]').description(index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.build.describe)).option('-c --config <config>', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.config)).option('--analyze', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.analyze)).option('-w --watch', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.build.watch)).action(async (options)=>{
|
|
50
|
+
program.command('build').usage('[options]').description(index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.build.describe)).option('-c --config <config>', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.config)).option('--analyze', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.analyze)).option('-w --watch', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.build.watch)).option(...deployTargetOption).action(async (options)=>{
|
|
47
51
|
const { build } = await import("./build.js");
|
|
48
52
|
await build(api, options);
|
|
49
53
|
});
|
|
@@ -55,7 +59,7 @@ const serverCommand = (program, api)=>{
|
|
|
55
59
|
});
|
|
56
60
|
};
|
|
57
61
|
const deployCommand = (program, api)=>{
|
|
58
|
-
program.command('deploy').usage('[options]').option('-c --config <config>', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.config)).option('-s --skip-build', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.skipBuild)).description(index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.deploy.describe)).action(async (options)=>{
|
|
62
|
+
program.command('deploy').usage('[options]').option('-c --config <config>', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.config)).option('-s --skip-build', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.skipBuild)).option(...deployTargetOption).description(index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.deploy.describe)).action(async (options)=>{
|
|
59
63
|
const { deploy } = await import("./deploy.js");
|
|
60
64
|
await deploy(api, options);
|
|
61
65
|
process.exit(0);
|
package/dist/cjs/index.js
CHANGED
|
@@ -60,6 +60,9 @@ var __webpack_modules__ = {
|
|
|
60
60
|
"./utils/restart" (module) {
|
|
61
61
|
module.exports = require("./utils/restart.js");
|
|
62
62
|
},
|
|
63
|
+
"@modern-js/app-tools-extensions/deploy-output/target" (module) {
|
|
64
|
+
module.exports = require("@modern-js/app-tools-extensions/deploy-output/target");
|
|
65
|
+
},
|
|
63
66
|
"@modern-js/app-tools-extensions/policy-defaults" (module) {
|
|
64
67
|
module.exports = require("@modern-js/app-tools-extensions/policy-defaults");
|
|
65
68
|
},
|
|
@@ -129,33 +132,34 @@ function __webpack_require__(moduleId) {
|
|
|
129
132
|
var __webpack_exports__ = {};
|
|
130
133
|
(()=>{
|
|
131
134
|
__webpack_require__.r(__webpack_exports__);
|
|
132
|
-
var
|
|
133
|
-
var
|
|
134
|
-
var
|
|
135
|
-
var
|
|
136
|
-
var
|
|
137
|
-
var
|
|
138
|
-
var
|
|
139
|
-
var
|
|
140
|
-
var
|
|
141
|
-
var
|
|
142
|
-
var
|
|
143
|
-
var
|
|
144
|
-
var
|
|
145
|
-
var
|
|
146
|
-
var
|
|
147
|
-
var
|
|
148
|
-
var
|
|
149
|
-
var
|
|
150
|
-
var
|
|
151
|
-
var
|
|
152
|
-
var
|
|
153
|
-
var
|
|
154
|
-
var
|
|
155
|
-
var
|
|
156
|
-
var
|
|
135
|
+
var _modern_js_app_tools_extensions_deploy_output_target__rspack_import_0 = __webpack_require__("@modern-js/app-tools-extensions/deploy-output/target");
|
|
136
|
+
var _modern_js_app_tools_extensions_policy_defaults__rspack_import_1 = __webpack_require__("@modern-js/app-tools-extensions/policy-defaults");
|
|
137
|
+
var _modern_js_builder__rspack_import_2 = __webpack_require__("@modern-js/builder");
|
|
138
|
+
var _modern_js_i18n_utils_language_detector__rspack_import_3 = __webpack_require__("@modern-js/i18n-utils/language-detector");
|
|
139
|
+
var _modern_js_plugin__rspack_import_4 = __webpack_require__("@modern-js/plugin");
|
|
140
|
+
var _modern_js_utils__rspack_import_5 = __webpack_require__("@modern-js/utils");
|
|
141
|
+
var path__rspack_import_6 = __webpack_require__("path");
|
|
142
|
+
var path__rspack_import_6_default = /*#__PURE__*/ __webpack_require__.n(path__rspack_import_6);
|
|
143
|
+
var _commands__rspack_import_7 = __webpack_require__("./commands");
|
|
144
|
+
var _compat__rspack_import_8 = __webpack_require__("./compat");
|
|
145
|
+
var _constants__rspack_import_9 = __webpack_require__("./constants");
|
|
146
|
+
var _locale__rspack_import_10 = __webpack_require__("./locale");
|
|
147
|
+
var _plugins_analyze__rspack_import_11 = __webpack_require__("./plugins/analyze");
|
|
148
|
+
var _plugins_analyze__rspack_import_11_default = /*#__PURE__*/ __webpack_require__.n(_plugins_analyze__rspack_import_11);
|
|
149
|
+
var _plugins_deploy__rspack_import_12 = __webpack_require__("./plugins/deploy");
|
|
150
|
+
var _plugins_deploy__rspack_import_12_default = /*#__PURE__*/ __webpack_require__.n(_plugins_deploy__rspack_import_12);
|
|
151
|
+
var _plugins_initialize__rspack_import_13 = __webpack_require__("./plugins/initialize");
|
|
152
|
+
var _plugins_initialize__rspack_import_13_default = /*#__PURE__*/ __webpack_require__.n(_plugins_initialize__rspack_import_13);
|
|
153
|
+
var _plugins_serverBuild__rspack_import_14 = __webpack_require__("./plugins/serverBuild");
|
|
154
|
+
var _plugins_serverBuild__rspack_import_14_default = /*#__PURE__*/ __webpack_require__.n(_plugins_serverBuild__rspack_import_14);
|
|
155
|
+
var _plugins_serverRuntime__rspack_import_15 = __webpack_require__("./plugins/serverRuntime");
|
|
156
|
+
var _plugins_serverRuntime__rspack_import_15_default = /*#__PURE__*/ __webpack_require__.n(_plugins_serverRuntime__rspack_import_15);
|
|
157
|
+
var _utils_generateWatchFiles__rspack_import_16 = __webpack_require__("./utils/generateWatchFiles");
|
|
158
|
+
var _utils_initAppContext__rspack_import_17 = __webpack_require__("./utils/initAppContext");
|
|
159
|
+
var _utils_restart__rspack_import_18 = __webpack_require__("./utils/restart");
|
|
160
|
+
var _defineConfig__rspack_import_19 = __webpack_require__("./defineConfig");
|
|
157
161
|
var __rspack_reexport = {};
|
|
158
|
-
for(const __rspack_import_key in
|
|
162
|
+
for(const __rspack_import_key in _defineConfig__rspack_import_19)if ([
|
|
159
163
|
"dev",
|
|
160
164
|
"resolveModernRsbuildConfig",
|
|
161
165
|
"mergeConfig",
|
|
@@ -168,16 +172,16 @@ var __webpack_exports__ = {};
|
|
|
168
172
|
"defineConfig",
|
|
169
173
|
"build",
|
|
170
174
|
"closeServer"
|
|
171
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
175
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_defineConfig__rspack_import_19[__rspack_import_key];
|
|
172
176
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
173
|
-
var
|
|
174
|
-
var
|
|
175
|
-
var
|
|
176
|
-
var
|
|
177
|
-
var
|
|
178
|
-
var
|
|
177
|
+
var _commands_build__rspack_import_20 = __webpack_require__("./commands/build");
|
|
178
|
+
var _commands_deploy__rspack_import_21 = __webpack_require__("./commands/deploy");
|
|
179
|
+
var _commands_dev__rspack_import_22 = __webpack_require__("./commands/dev");
|
|
180
|
+
var _commands_serve__rspack_import_23 = __webpack_require__("./commands/serve");
|
|
181
|
+
var _rsbuild__rspack_import_24 = __webpack_require__("./rsbuild");
|
|
182
|
+
var _types__rspack_import_25 = __webpack_require__("./types?6efa");
|
|
179
183
|
var __rspack_reexport = {};
|
|
180
|
-
for(const __rspack_import_key in
|
|
184
|
+
for(const __rspack_import_key in _types__rspack_import_25)if ([
|
|
181
185
|
"dev",
|
|
182
186
|
"resolveModernRsbuildConfig",
|
|
183
187
|
"mergeConfig",
|
|
@@ -190,20 +194,20 @@ var __webpack_exports__ = {};
|
|
|
190
194
|
"defineConfig",
|
|
191
195
|
"build",
|
|
192
196
|
"closeServer"
|
|
193
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
197
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_types__rspack_import_25[__rspack_import_key];
|
|
194
198
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
195
|
-
var
|
|
196
|
-
var
|
|
199
|
+
var _utils_createServer__rspack_import_26 = __webpack_require__("./utils/createServer");
|
|
200
|
+
var _modern_js_plugin_cli__rspack_import_27 = __webpack_require__("@modern-js/plugin/cli");
|
|
197
201
|
const appTools = (options = {})=>({
|
|
198
202
|
name: '@modern-js/app-tools',
|
|
199
203
|
usePlugins: [
|
|
200
|
-
|
|
201
|
-
(0,
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
(0,
|
|
204
|
+
_plugins_serverRuntime__rspack_import_15_default()(),
|
|
205
|
+
(0, _compat__rspack_import_8.compatPlugin)(),
|
|
206
|
+
_plugins_initialize__rspack_import_13_default()(),
|
|
207
|
+
_plugins_analyze__rspack_import_11_default()(),
|
|
208
|
+
_plugins_serverBuild__rspack_import_14_default()(),
|
|
209
|
+
_plugins_deploy__rspack_import_12_default()(),
|
|
210
|
+
(0, _modern_js_app_tools_extensions_policy_defaults__rspack_import_1.createPolicyDefaultsPlugin)(options)
|
|
207
211
|
],
|
|
208
212
|
post: [
|
|
209
213
|
'@modern-js/plugin-initialize',
|
|
@@ -214,48 +218,53 @@ var __webpack_exports__ = {};
|
|
|
214
218
|
'@modern-js/plugin-polyfill'
|
|
215
219
|
],
|
|
216
220
|
registryHooks: {
|
|
217
|
-
onAfterPrepare: (0,
|
|
218
|
-
deploy: (0,
|
|
219
|
-
checkEntryPoint: (0,
|
|
220
|
-
modifyEntrypoints: (0,
|
|
221
|
-
modifyBuilderEnvironments: (0,
|
|
222
|
-
modifyFileSystemRoutes: (0,
|
|
223
|
-
generateEntryCode: (0,
|
|
224
|
-
onBeforeGenerateRoutes: (0,
|
|
225
|
-
onBeforePrintInstructions: (0,
|
|
221
|
+
onAfterPrepare: (0, _modern_js_plugin__rspack_import_4.createAsyncHook)(),
|
|
222
|
+
deploy: (0, _modern_js_plugin__rspack_import_4.createAsyncHook)(),
|
|
223
|
+
checkEntryPoint: (0, _modern_js_plugin__rspack_import_4.createAsyncHook)(),
|
|
224
|
+
modifyEntrypoints: (0, _modern_js_plugin__rspack_import_4.createAsyncHook)(),
|
|
225
|
+
modifyBuilderEnvironments: (0, _modern_js_plugin__rspack_import_4.createAsyncHook)(),
|
|
226
|
+
modifyFileSystemRoutes: (0, _modern_js_plugin__rspack_import_4.createAsyncHook)(),
|
|
227
|
+
generateEntryCode: (0, _modern_js_plugin__rspack_import_4.createAsyncHook)(),
|
|
228
|
+
onBeforeGenerateRoutes: (0, _modern_js_plugin__rspack_import_4.createAsyncHook)(),
|
|
229
|
+
onBeforePrintInstructions: (0, _modern_js_plugin__rspack_import_4.createAsyncHook)()
|
|
226
230
|
},
|
|
227
231
|
setup: (api)=>{
|
|
228
232
|
const context = api.getAppContext();
|
|
229
233
|
const userConfig = api.getConfig();
|
|
230
|
-
const locale = (0,
|
|
231
|
-
|
|
234
|
+
const locale = (0, _modern_js_i18n_utils_language_detector__rspack_import_3.getLocaleLanguage)();
|
|
235
|
+
_locale__rspack_import_10.i18n.changeLanguage({
|
|
232
236
|
locale
|
|
233
237
|
});
|
|
234
|
-
api.updateAppContext((0,
|
|
238
|
+
api.updateAppContext((0, _utils_initAppContext__rspack_import_17.initAppContext)({
|
|
235
239
|
metaName: context.metaName,
|
|
236
240
|
appDirectory: context.appDirectory,
|
|
237
|
-
runtimeConfigFile:
|
|
241
|
+
runtimeConfigFile: _constants__rspack_import_9.DEFAULT_RUNTIME_CONFIG_FILE,
|
|
238
242
|
options: {
|
|
239
243
|
bffRuntimeFramework: userConfig.bff?.runtimeFramework
|
|
240
244
|
},
|
|
241
245
|
tempDir: userConfig.output?.tempDir
|
|
242
246
|
}));
|
|
243
247
|
api.addCommand(async ({ program })=>{
|
|
244
|
-
await (0,
|
|
245
|
-
await (0,
|
|
246
|
-
(0,
|
|
247
|
-
(0,
|
|
248
|
-
(0,
|
|
249
|
-
(0,
|
|
250
|
-
(0,
|
|
248
|
+
await (0, _commands__rspack_import_7.devCommand)(program, api);
|
|
249
|
+
await (0, _commands__rspack_import_7.buildCommand)(program, api);
|
|
250
|
+
(0, _commands__rspack_import_7.serverCommand)(program, api);
|
|
251
|
+
(0, _commands__rspack_import_7.deployCommand)(program, api);
|
|
252
|
+
(0, _commands__rspack_import_7.inspectCommand)(program, api);
|
|
253
|
+
(0, _commands__rspack_import_7.infoCommand)(program, api);
|
|
254
|
+
(0, _modern_js_utils__rspack_import_5.deprecatedCommands)(program);
|
|
251
255
|
});
|
|
252
256
|
api.onPrepare(async ()=>{
|
|
253
|
-
|
|
257
|
+
api.updateAppContext({
|
|
258
|
+
deployTarget: (0, _modern_js_app_tools_extensions_deploy_output_target__rspack_import_0.resolveDeployTarget)({
|
|
259
|
+
configTarget: api.getNormalizedConfig().deploy?.target
|
|
260
|
+
})
|
|
261
|
+
});
|
|
262
|
+
const command = (0, _modern_js_utils__rspack_import_5.getCommand)();
|
|
254
263
|
if ('deploy' === command) {
|
|
255
264
|
const isSkipBuild = [
|
|
256
265
|
'-s',
|
|
257
266
|
'--skip-build'
|
|
258
|
-
].some((tag)=>(0,
|
|
267
|
+
].some((tag)=>(0, _modern_js_utils__rspack_import_5.getArgv)().includes(tag));
|
|
259
268
|
if (isSkipBuild) return;
|
|
260
269
|
}
|
|
261
270
|
const { command: contextCommand } = api.getAppContext();
|
|
@@ -273,15 +282,15 @@ var __webpack_exports__ = {};
|
|
|
273
282
|
const resolvedConfig = api.getNormalizedConfig();
|
|
274
283
|
if (resolvedConfig.output.cleanDistPath) {
|
|
275
284
|
const appContext = api.getAppContext();
|
|
276
|
-
await (0,
|
|
285
|
+
await (0, _modern_js_utils__rspack_import_5.emptyDir)(appContext.distDirectory);
|
|
277
286
|
}
|
|
278
287
|
}
|
|
279
288
|
});
|
|
280
289
|
api.addWatchFiles(async ()=>{
|
|
281
290
|
const appContext = api.getAppContext();
|
|
282
291
|
const config = api.getNormalizedConfig();
|
|
283
|
-
const files = await (0,
|
|
284
|
-
const watchFiles = (0,
|
|
292
|
+
const files = await (0, _utils_generateWatchFiles__rspack_import_16.generateWatchFiles)(appContext, config.source.configDir);
|
|
293
|
+
const watchFiles = (0, _modern_js_builder__rspack_import_2.castArray)(config.dev.watchFiles);
|
|
285
294
|
watchFiles.forEach(({ type, paths })=>{
|
|
286
295
|
if ('reload-server' === type) files.push(...Array.isArray(paths) ? paths : [
|
|
287
296
|
paths
|
|
@@ -292,16 +301,16 @@ var __webpack_exports__ = {};
|
|
|
292
301
|
api.onFileChanged(async (e)=>{
|
|
293
302
|
const { filename, eventType, isPrivate } = e;
|
|
294
303
|
const { appDirectory, apiDirectory } = api.getAppContext();
|
|
295
|
-
const relativeApiPath =
|
|
304
|
+
const relativeApiPath = path__rspack_import_6_default().relative(appDirectory, apiDirectory);
|
|
296
305
|
const isApiProject = filename.startsWith(`${relativeApiPath}/`);
|
|
297
306
|
if (!isPrivate && ('change' === eventType || 'unlink' === eventType) && !isApiProject) {
|
|
298
307
|
const { closeServer } = await import("./utils/createServer.js");
|
|
299
308
|
await closeServer();
|
|
300
|
-
await (0,
|
|
309
|
+
await (0, _utils_restart__rspack_import_18.restart)(api.getHooks(), filename);
|
|
301
310
|
}
|
|
302
311
|
});
|
|
303
312
|
api.onBeforeRestart(()=>{
|
|
304
|
-
(0,
|
|
313
|
+
(0, _modern_js_utils__rspack_import_5.cleanRequireCache)([
|
|
305
314
|
require.resolve('./plugins/analyze')
|
|
306
315
|
]);
|
|
307
316
|
});
|
|
@@ -309,16 +318,16 @@ var __webpack_exports__ = {};
|
|
|
309
318
|
});
|
|
310
319
|
const __rspack_default_export = appTools;
|
|
311
320
|
__webpack_require__.d(__webpack_exports__, {
|
|
312
|
-
build: ()=>
|
|
313
|
-
closeServer: ()=>
|
|
314
|
-
defineConfig: ()=>
|
|
315
|
-
deploy: ()=>
|
|
316
|
-
dev: ()=>
|
|
317
|
-
generateWatchFiles: ()=>
|
|
318
|
-
initAppContext: ()=>
|
|
319
|
-
mergeConfig: ()=>
|
|
320
|
-
resolveModernRsbuildConfig: ()=>
|
|
321
|
-
serve: ()=>
|
|
321
|
+
build: ()=>_commands_build__rspack_import_20.build,
|
|
322
|
+
closeServer: ()=>_utils_createServer__rspack_import_26.closeServer,
|
|
323
|
+
defineConfig: ()=>_defineConfig__rspack_import_19.defineConfig,
|
|
324
|
+
deploy: ()=>_commands_deploy__rspack_import_21.deploy,
|
|
325
|
+
dev: ()=>_commands_dev__rspack_import_22.dev,
|
|
326
|
+
generateWatchFiles: ()=>_utils_generateWatchFiles__rspack_import_16.generateWatchFiles,
|
|
327
|
+
initAppContext: ()=>_utils_initAppContext__rspack_import_17.initAppContext,
|
|
328
|
+
mergeConfig: ()=>_modern_js_plugin_cli__rspack_import_27.mergeConfig,
|
|
329
|
+
resolveModernRsbuildConfig: ()=>_rsbuild__rspack_import_24.resolveModernRsbuildConfig,
|
|
330
|
+
serve: ()=>_commands_serve__rspack_import_23.serve
|
|
322
331
|
}, {
|
|
323
332
|
appTools: appTools,
|
|
324
333
|
default: __rspack_default_export
|
|
@@ -28,12 +28,10 @@ var __webpack_require__ = {};
|
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
default: ()=>deploy
|
|
32
|
-
getSupportedDeployTargets: ()=>getSupportedDeployTargets,
|
|
33
|
-
resolveDeployTarget: ()=>resolveDeployTarget
|
|
31
|
+
default: ()=>deploy
|
|
34
32
|
});
|
|
35
33
|
const cloudflare_namespaceObject = require("@modern-js/app-tools-extensions/cloudflare");
|
|
36
|
-
const
|
|
34
|
+
const target_namespaceObject = require("@modern-js/app-tools-extensions/deploy-output/target");
|
|
37
35
|
const gh_pages_js_namespaceObject = require("./platforms/gh-pages.js");
|
|
38
36
|
const netlify_js_namespaceObject = require("./platforms/netlify.js");
|
|
39
37
|
const node_js_namespaceObject = require("./platforms/node.js");
|
|
@@ -46,24 +44,11 @@ const deployPresets = {
|
|
|
46
44
|
ghPages: gh_pages_js_namespaceObject.createGhPagesPreset,
|
|
47
45
|
cloudflare: cloudflare_namespaceObject.createCloudflarePreset
|
|
48
46
|
};
|
|
49
|
-
const getSupportedDeployTargets = ()=>Object.keys(deployPresets);
|
|
50
|
-
const isDeployTarget = (target)=>Object.prototype.hasOwnProperty.call(deployPresets, target);
|
|
51
|
-
const providerDeployTargets = {
|
|
52
|
-
vercel: 'vercel',
|
|
53
|
-
netlify: 'netlify',
|
|
54
|
-
cloudflare: 'cloudflare',
|
|
55
|
-
cloudflare_pages: 'cloudflare',
|
|
56
|
-
cloudflare_workers: 'cloudflare'
|
|
57
|
-
};
|
|
58
|
-
const normalizeDetectedProvider = (value)=>value ? providerDeployTargets[value] : void 0;
|
|
59
|
-
const resolveDeployTarget = (modernConfig, envDeployTarget = process.env.MODERNJS_DEPLOY, detectedProvider = external_std_env_namespaceObject.provider)=>modernConfig.deploy?.target || envDeployTarget || normalizeDetectedProvider(detectedProvider) || 'node';
|
|
60
47
|
async function getDeployPreset(appContext, modernConfig, deployTarget, api) {
|
|
61
48
|
const { appDirectory, distDirectory, metaName } = appContext;
|
|
62
49
|
const { useSSR, useAPI, useWebServer } = (0, index_js_namespaceObject.getProjectUsage)(appDirectory, distDirectory, metaName);
|
|
63
50
|
const needModernServer = useSSR || useAPI || useWebServer;
|
|
64
|
-
|
|
65
|
-
const createPreset = deployPresets[deployTarget];
|
|
66
|
-
return createPreset({
|
|
51
|
+
return deployPresets[deployTarget]({
|
|
67
52
|
appContext,
|
|
68
53
|
modernConfig,
|
|
69
54
|
needModernServer,
|
|
@@ -75,11 +60,9 @@ const deploy = ()=>({
|
|
|
75
60
|
setup: (api)=>{
|
|
76
61
|
api.deploy(async ()=>{
|
|
77
62
|
const appContext = api.getAppContext();
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
if ('modern-js' !== metaName && !modernConfig.deploy?.target && !process.env.MODERNJS_DEPLOY) return;
|
|
82
|
-
const deployPreset = await getDeployPreset(appContext, modernConfig, deployTarget, api);
|
|
63
|
+
const deployTarget = (0, target_namespaceObject.getDeployingTarget)(appContext);
|
|
64
|
+
if (!deployTarget) return;
|
|
65
|
+
const deployPreset = await getDeployPreset(appContext, api.getNormalizedConfig(), deployTarget, api);
|
|
83
66
|
deployPreset?.prepare && await deployPreset?.prepare();
|
|
84
67
|
deployPreset?.writeOutput && await deployPreset?.writeOutput();
|
|
85
68
|
deployPreset?.genEntry && await deployPreset?.genEntry();
|
|
@@ -88,12 +71,8 @@ const deploy = ()=>({
|
|
|
88
71
|
}
|
|
89
72
|
});
|
|
90
73
|
exports["default"] = __webpack_exports__["default"];
|
|
91
|
-
exports.getSupportedDeployTargets = __webpack_exports__.getSupportedDeployTargets;
|
|
92
|
-
exports.resolveDeployTarget = __webpack_exports__.resolveDeployTarget;
|
|
93
74
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
94
|
-
"default"
|
|
95
|
-
"getSupportedDeployTargets",
|
|
96
|
-
"resolveDeployTarget"
|
|
75
|
+
"default"
|
|
97
76
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
98
77
|
Object.defineProperty(exports, '__esModule', {
|
|
99
78
|
value: true
|
|
@@ -51,7 +51,7 @@ const initialize = ()=>({
|
|
|
51
51
|
lazyCompilation: {
|
|
52
52
|
imports: true,
|
|
53
53
|
entries: false,
|
|
54
|
-
test: (0, lazyCompilation_js_namespaceObject.buildDefaultLazyCompilationTest)(appContext.internalDirectory)
|
|
54
|
+
test: (0, lazyCompilation_js_namespaceObject.buildDefaultLazyCompilationTest)(appContext.appDirectory, appContext.internalDirectory)
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
return defaultConfig;
|
|
@@ -21,13 +21,16 @@ function buildSSRLazyCompilationTest(eagerRouteFiles, userTest) {
|
|
|
21
21
|
return userTestFn(m);
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
function buildDefaultLazyCompilationTest(internalDirectory) {
|
|
25
|
-
let
|
|
24
|
+
function buildDefaultLazyCompilationTest(appDirectory, internalDirectory) {
|
|
25
|
+
let dirs;
|
|
26
26
|
return (m)=>{
|
|
27
27
|
if (!('resource' in m) || 'string' != typeof m.resource) return true;
|
|
28
|
-
|
|
28
|
+
dirs ??= {
|
|
29
|
+
app: normalizeModulePath(appDirectory),
|
|
30
|
+
internal: normalizeModulePath(internalDirectory)
|
|
31
|
+
};
|
|
29
32
|
const file = m.resource.split('?')[0].split(node_path.sep).join('/');
|
|
30
|
-
return
|
|
33
|
+
return file.startsWith(`${dirs.app}/`) && !file.startsWith(`${dirs.internal}/`) && !file.slice(dirs.app.length).includes('/node_modules/');
|
|
31
34
|
};
|
|
32
35
|
}
|
|
33
36
|
function planSSRLazyCompilation(current, info) {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { i18n, localeKeys } from "../locale/index.mjs";
|
|
2
|
+
const deployTargetOption = [
|
|
3
|
+
'--deploy-target <target>',
|
|
4
|
+
'deploy target; overrides deploy.target and MODERNJS_DEPLOY'
|
|
5
|
+
];
|
|
2
6
|
const devCommand = async (program, api)=>{
|
|
3
7
|
program.command('dev').alias('start').usage('[options]').description(i18n.t(localeKeys.command.dev.describe)).option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('-e --entry [entry...]', i18n.t(localeKeys.command.dev.entry)).option('--analyze', i18n.t(localeKeys.command.shared.analyze)).option('--api-only', i18n.t(localeKeys.command.dev.apiOnly)).option('--web-only', i18n.t(localeKeys.command.dev.webOnly)).action(async (options)=>{
|
|
4
8
|
const { dev } = await import("./dev.mjs");
|
|
@@ -6,7 +10,7 @@ const devCommand = async (program, api)=>{
|
|
|
6
10
|
});
|
|
7
11
|
};
|
|
8
12
|
const buildCommand = async (program, api)=>{
|
|
9
|
-
program.command('build').usage('[options]').description(i18n.t(localeKeys.command.build.describe)).option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('--analyze', i18n.t(localeKeys.command.shared.analyze)).option('-w --watch', i18n.t(localeKeys.command.build.watch)).action(async (options)=>{
|
|
13
|
+
program.command('build').usage('[options]').description(i18n.t(localeKeys.command.build.describe)).option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('--analyze', i18n.t(localeKeys.command.shared.analyze)).option('-w --watch', i18n.t(localeKeys.command.build.watch)).option(...deployTargetOption).action(async (options)=>{
|
|
10
14
|
const { build } = await import("./build.mjs");
|
|
11
15
|
await build(api, options);
|
|
12
16
|
});
|
|
@@ -18,7 +22,7 @@ const serverCommand = (program, api)=>{
|
|
|
18
22
|
});
|
|
19
23
|
};
|
|
20
24
|
const deployCommand = (program, api)=>{
|
|
21
|
-
program.command('deploy').usage('[options]').option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('-s --skip-build', i18n.t(localeKeys.command.shared.skipBuild)).description(i18n.t(localeKeys.command.deploy.describe)).action(async (options)=>{
|
|
25
|
+
program.command('deploy').usage('[options]').option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('-s --skip-build', i18n.t(localeKeys.command.shared.skipBuild)).option(...deployTargetOption).description(i18n.t(localeKeys.command.deploy.describe)).action(async (options)=>{
|
|
22
26
|
const { deploy } = await import("./deploy.mjs");
|
|
23
27
|
await deploy(api, options);
|
|
24
28
|
process.exit(0);
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveDeployTarget } from "@modern-js/app-tools-extensions/deploy-output/target";
|
|
1
2
|
import { createPolicyDefaultsPlugin } from "@modern-js/app-tools-extensions/policy-defaults";
|
|
2
3
|
import { castArray } from "@modern-js/builder";
|
|
3
4
|
import { getLocaleLanguage } from "@modern-js/i18n-utils/language-detector";
|
|
@@ -74,6 +75,11 @@ const appTools = (options = {})=>({
|
|
|
74
75
|
deprecatedCommands(program);
|
|
75
76
|
});
|
|
76
77
|
api.onPrepare(async ()=>{
|
|
78
|
+
api.updateAppContext({
|
|
79
|
+
deployTarget: resolveDeployTarget({
|
|
80
|
+
configTarget: api.getNormalizedConfig().deploy?.target
|
|
81
|
+
})
|
|
82
|
+
});
|
|
77
83
|
const command = getCommand();
|
|
78
84
|
if ('deploy' === command) {
|
|
79
85
|
const isSkipBuild = [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createCloudflarePreset } from "@modern-js/app-tools-extensions/cloudflare";
|
|
2
|
-
import {
|
|
2
|
+
import { getDeployingTarget } from "@modern-js/app-tools-extensions/deploy-output/target";
|
|
3
3
|
import { createGhPagesPreset } from "./platforms/gh-pages.mjs";
|
|
4
4
|
import { createNetlifyPreset } from "./platforms/netlify.mjs";
|
|
5
5
|
import { createNodePreset } from "./platforms/node.mjs";
|
|
@@ -12,24 +12,11 @@ const deployPresets = {
|
|
|
12
12
|
ghPages: createGhPagesPreset,
|
|
13
13
|
cloudflare: createCloudflarePreset
|
|
14
14
|
};
|
|
15
|
-
const getSupportedDeployTargets = ()=>Object.keys(deployPresets);
|
|
16
|
-
const isDeployTarget = (target)=>Object.prototype.hasOwnProperty.call(deployPresets, target);
|
|
17
|
-
const providerDeployTargets = {
|
|
18
|
-
vercel: 'vercel',
|
|
19
|
-
netlify: 'netlify',
|
|
20
|
-
cloudflare: 'cloudflare',
|
|
21
|
-
cloudflare_pages: 'cloudflare',
|
|
22
|
-
cloudflare_workers: 'cloudflare'
|
|
23
|
-
};
|
|
24
|
-
const normalizeDetectedProvider = (value)=>value ? providerDeployTargets[value] : void 0;
|
|
25
|
-
const resolveDeployTarget = (modernConfig, envDeployTarget = process.env.MODERNJS_DEPLOY, detectedProvider = provider)=>modernConfig.deploy?.target || envDeployTarget || normalizeDetectedProvider(detectedProvider) || 'node';
|
|
26
15
|
async function getDeployPreset(appContext, modernConfig, deployTarget, api) {
|
|
27
16
|
const { appDirectory, distDirectory, metaName } = appContext;
|
|
28
17
|
const { useSSR, useAPI, useWebServer } = getProjectUsage(appDirectory, distDirectory, metaName);
|
|
29
18
|
const needModernServer = useSSR || useAPI || useWebServer;
|
|
30
|
-
|
|
31
|
-
const createPreset = deployPresets[deployTarget];
|
|
32
|
-
return createPreset({
|
|
19
|
+
return deployPresets[deployTarget]({
|
|
33
20
|
appContext,
|
|
34
21
|
modernConfig,
|
|
35
22
|
needModernServer,
|
|
@@ -41,11 +28,9 @@ const deploy = ()=>({
|
|
|
41
28
|
setup: (api)=>{
|
|
42
29
|
api.deploy(async ()=>{
|
|
43
30
|
const appContext = api.getAppContext();
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
if ('modern-js' !== metaName && !modernConfig.deploy?.target && !process.env.MODERNJS_DEPLOY) return;
|
|
48
|
-
const deployPreset = await getDeployPreset(appContext, modernConfig, deployTarget, api);
|
|
31
|
+
const deployTarget = getDeployingTarget(appContext);
|
|
32
|
+
if (!deployTarget) return;
|
|
33
|
+
const deployPreset = await getDeployPreset(appContext, api.getNormalizedConfig(), deployTarget, api);
|
|
49
34
|
deployPreset?.prepare && await deployPreset?.prepare();
|
|
50
35
|
deployPreset?.writeOutput && await deployPreset?.writeOutput();
|
|
51
36
|
deployPreset?.genEntry && await deployPreset?.genEntry();
|
|
@@ -54,4 +39,3 @@ const deploy = ()=>({
|
|
|
54
39
|
}
|
|
55
40
|
});
|
|
56
41
|
export default deploy;
|
|
57
|
-
export { getSupportedDeployTargets, resolveDeployTarget };
|
|
@@ -19,7 +19,7 @@ const initialize = ()=>({
|
|
|
19
19
|
lazyCompilation: {
|
|
20
20
|
imports: true,
|
|
21
21
|
entries: false,
|
|
22
|
-
test: buildDefaultLazyCompilationTest(appContext.internalDirectory)
|
|
22
|
+
test: buildDefaultLazyCompilationTest(appContext.appDirectory, appContext.internalDirectory)
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
return defaultConfig;
|
|
@@ -22,13 +22,16 @@ function buildSSRLazyCompilationTest(eagerRouteFiles, userTest) {
|
|
|
22
22
|
return userTestFn(m);
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
function buildDefaultLazyCompilationTest(internalDirectory) {
|
|
26
|
-
let
|
|
25
|
+
function buildDefaultLazyCompilationTest(appDirectory, internalDirectory) {
|
|
26
|
+
let dirs;
|
|
27
27
|
return (m)=>{
|
|
28
28
|
if (!('resource' in m) || 'string' != typeof m.resource) return true;
|
|
29
|
-
|
|
29
|
+
dirs ??= {
|
|
30
|
+
app: normalizeModulePath(appDirectory),
|
|
31
|
+
internal: normalizeModulePath(internalDirectory)
|
|
32
|
+
};
|
|
30
33
|
const file = m.resource.split('?')[0].split(node_path.sep).join('/');
|
|
31
|
-
return
|
|
34
|
+
return file.startsWith(`${dirs.app}/`) && !file.startsWith(`${dirs.internal}/`) && !file.slice(dirs.app.length).includes('/node_modules/');
|
|
32
35
|
};
|
|
33
36
|
}
|
|
34
37
|
function planSSRLazyCompilation(current, info) {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { i18n, localeKeys } from "../locale/index.mjs";
|
|
3
|
+
const deployTargetOption = [
|
|
4
|
+
'--deploy-target <target>',
|
|
5
|
+
'deploy target; overrides deploy.target and MODERNJS_DEPLOY'
|
|
6
|
+
];
|
|
3
7
|
const devCommand = async (program, api)=>{
|
|
4
8
|
program.command('dev').alias('start').usage('[options]').description(i18n.t(localeKeys.command.dev.describe)).option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('-e --entry [entry...]', i18n.t(localeKeys.command.dev.entry)).option('--analyze', i18n.t(localeKeys.command.shared.analyze)).option('--api-only', i18n.t(localeKeys.command.dev.apiOnly)).option('--web-only', i18n.t(localeKeys.command.dev.webOnly)).action(async (options)=>{
|
|
5
9
|
const { dev } = await import("./dev.mjs");
|
|
@@ -7,7 +11,7 @@ const devCommand = async (program, api)=>{
|
|
|
7
11
|
});
|
|
8
12
|
};
|
|
9
13
|
const buildCommand = async (program, api)=>{
|
|
10
|
-
program.command('build').usage('[options]').description(i18n.t(localeKeys.command.build.describe)).option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('--analyze', i18n.t(localeKeys.command.shared.analyze)).option('-w --watch', i18n.t(localeKeys.command.build.watch)).action(async (options)=>{
|
|
14
|
+
program.command('build').usage('[options]').description(i18n.t(localeKeys.command.build.describe)).option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('--analyze', i18n.t(localeKeys.command.shared.analyze)).option('-w --watch', i18n.t(localeKeys.command.build.watch)).option(...deployTargetOption).action(async (options)=>{
|
|
11
15
|
const { build } = await import("./build.mjs");
|
|
12
16
|
await build(api, options);
|
|
13
17
|
});
|
|
@@ -19,7 +23,7 @@ const serverCommand = (program, api)=>{
|
|
|
19
23
|
});
|
|
20
24
|
};
|
|
21
25
|
const deployCommand = (program, api)=>{
|
|
22
|
-
program.command('deploy').usage('[options]').option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('-s --skip-build', i18n.t(localeKeys.command.shared.skipBuild)).description(i18n.t(localeKeys.command.deploy.describe)).action(async (options)=>{
|
|
26
|
+
program.command('deploy').usage('[options]').option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('-s --skip-build', i18n.t(localeKeys.command.shared.skipBuild)).option(...deployTargetOption).description(i18n.t(localeKeys.command.deploy.describe)).action(async (options)=>{
|
|
23
27
|
const { deploy } = await import("./deploy.mjs");
|
|
24
28
|
await deploy(api, options);
|
|
25
29
|
process.exit(0);
|
package/dist/esm-node/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import __rslib_shim_module__ from "node:module";
|
|
2
2
|
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
|
+
import { resolveDeployTarget } from "@modern-js/app-tools-extensions/deploy-output/target";
|
|
3
4
|
import { createPolicyDefaultsPlugin } from "@modern-js/app-tools-extensions/policy-defaults";
|
|
4
5
|
import { castArray } from "@modern-js/builder";
|
|
5
6
|
import { getLocaleLanguage } from "@modern-js/i18n-utils/language-detector";
|
|
@@ -76,6 +77,11 @@ const appTools = (options = {})=>({
|
|
|
76
77
|
deprecatedCommands(program);
|
|
77
78
|
});
|
|
78
79
|
api.onPrepare(async ()=>{
|
|
80
|
+
api.updateAppContext({
|
|
81
|
+
deployTarget: resolveDeployTarget({
|
|
82
|
+
configTarget: api.getNormalizedConfig().deploy?.target
|
|
83
|
+
})
|
|
84
|
+
});
|
|
79
85
|
const command = getCommand();
|
|
80
86
|
if ('deploy' === command) {
|
|
81
87
|
const isSkipBuild = [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { createCloudflarePreset } from "@modern-js/app-tools-extensions/cloudflare";
|
|
3
|
-
import {
|
|
3
|
+
import { getDeployingTarget } from "@modern-js/app-tools-extensions/deploy-output/target";
|
|
4
4
|
import { createGhPagesPreset } from "./platforms/gh-pages.mjs";
|
|
5
5
|
import { createNetlifyPreset } from "./platforms/netlify.mjs";
|
|
6
6
|
import { createNodePreset } from "./platforms/node.mjs";
|
|
@@ -13,24 +13,11 @@ const deployPresets = {
|
|
|
13
13
|
ghPages: createGhPagesPreset,
|
|
14
14
|
cloudflare: createCloudflarePreset
|
|
15
15
|
};
|
|
16
|
-
const getSupportedDeployTargets = ()=>Object.keys(deployPresets);
|
|
17
|
-
const isDeployTarget = (target)=>Object.prototype.hasOwnProperty.call(deployPresets, target);
|
|
18
|
-
const providerDeployTargets = {
|
|
19
|
-
vercel: 'vercel',
|
|
20
|
-
netlify: 'netlify',
|
|
21
|
-
cloudflare: 'cloudflare',
|
|
22
|
-
cloudflare_pages: 'cloudflare',
|
|
23
|
-
cloudflare_workers: 'cloudflare'
|
|
24
|
-
};
|
|
25
|
-
const normalizeDetectedProvider = (value)=>value ? providerDeployTargets[value] : void 0;
|
|
26
|
-
const resolveDeployTarget = (modernConfig, envDeployTarget = process.env.MODERNJS_DEPLOY, detectedProvider = provider)=>modernConfig.deploy?.target || envDeployTarget || normalizeDetectedProvider(detectedProvider) || 'node';
|
|
27
16
|
async function getDeployPreset(appContext, modernConfig, deployTarget, api) {
|
|
28
17
|
const { appDirectory, distDirectory, metaName } = appContext;
|
|
29
18
|
const { useSSR, useAPI, useWebServer } = getProjectUsage(appDirectory, distDirectory, metaName);
|
|
30
19
|
const needModernServer = useSSR || useAPI || useWebServer;
|
|
31
|
-
|
|
32
|
-
const createPreset = deployPresets[deployTarget];
|
|
33
|
-
return createPreset({
|
|
20
|
+
return deployPresets[deployTarget]({
|
|
34
21
|
appContext,
|
|
35
22
|
modernConfig,
|
|
36
23
|
needModernServer,
|
|
@@ -42,11 +29,9 @@ const deploy = ()=>({
|
|
|
42
29
|
setup: (api)=>{
|
|
43
30
|
api.deploy(async ()=>{
|
|
44
31
|
const appContext = api.getAppContext();
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
if ('modern-js' !== metaName && !modernConfig.deploy?.target && !process.env.MODERNJS_DEPLOY) return;
|
|
49
|
-
const deployPreset = await getDeployPreset(appContext, modernConfig, deployTarget, api);
|
|
32
|
+
const deployTarget = getDeployingTarget(appContext);
|
|
33
|
+
if (!deployTarget) return;
|
|
34
|
+
const deployPreset = await getDeployPreset(appContext, api.getNormalizedConfig(), deployTarget, api);
|
|
50
35
|
deployPreset?.prepare && await deployPreset?.prepare();
|
|
51
36
|
deployPreset?.writeOutput && await deployPreset?.writeOutput();
|
|
52
37
|
deployPreset?.genEntry && await deployPreset?.genEntry();
|
|
@@ -55,4 +40,3 @@ const deploy = ()=>({
|
|
|
55
40
|
}
|
|
56
41
|
});
|
|
57
42
|
export default deploy;
|
|
58
|
-
export { getSupportedDeployTargets, resolveDeployTarget };
|
|
@@ -20,7 +20,7 @@ const initialize = ()=>({
|
|
|
20
20
|
lazyCompilation: {
|
|
21
21
|
imports: true,
|
|
22
22
|
entries: false,
|
|
23
|
-
test: buildDefaultLazyCompilationTest(appContext.internalDirectory)
|
|
23
|
+
test: buildDefaultLazyCompilationTest(appContext.appDirectory, appContext.internalDirectory)
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
return defaultConfig;
|
|
@@ -27,17 +27,20 @@ export declare function aggregateEagerRouteComponentFiles(byEntry: EagerRouteCom
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function buildSSRLazyCompilationTest(eagerRouteFiles: Set<string>, userTest?: LazyCompilationTest): LazyCompilationTestFn;
|
|
29
29
|
/**
|
|
30
|
-
* Build the default dev `lazyCompilation.test`:
|
|
31
|
-
*
|
|
32
|
-
* `<internalDirectory>/<entry>/index.jsx
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
30
|
+
* Build the default dev `lazyCompilation.test`: a dynamic import is lazy only
|
|
31
|
+
* when it targets the app's own source. Everything else compiles eagerly:
|
|
32
|
+
* - the generated `<internalDirectory>/<entry>/index.jsx`, which
|
|
33
|
+
* `bootstrap.jsx` imports as the async entry boundary Module Federation
|
|
34
|
+
* needs to initialize shared scopes, not a code-split point;
|
|
35
|
+
* - framework and dependency modules (outside `appDirectory` or under
|
|
36
|
+
* `node_modules`), such as plugin-i18n's backend, utils and react-i18next.
|
|
37
|
+
* Each lazy module costs one on-demand compile and HMR cycle on the first page
|
|
38
|
+
* load. Back-to-back cycles for framework imports raced on loaded CI runners
|
|
39
|
+
* ("Cannot read properties of undefined (reading 'call')"), and the app never
|
|
40
|
+
* rendered.
|
|
38
41
|
* Typed `object` so it is assignable to Rspack's `(module: Module) => boolean`.
|
|
39
42
|
*/
|
|
40
|
-
export declare function buildDefaultLazyCompilationTest(internalDirectory: string): (m: object) => boolean;
|
|
43
|
+
export declare function buildDefaultLazyCompilationTest(appDirectory: string, internalDirectory: string): (m: object) => boolean;
|
|
41
44
|
export type SSRLazyPlan = {
|
|
42
45
|
apply: false;
|
|
43
46
|
unresolvedByEntry?: Map<string, string[]>;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import type { AppTools,
|
|
2
|
-
import type { DeployTarget } from '../../types/config/deploy.js';
|
|
3
|
-
export declare const getSupportedDeployTargets: () => DeployTarget[];
|
|
4
|
-
export declare const resolveDeployTarget: (modernConfig: AppToolsNormalizedConfig, envDeployTarget?: string | undefined, detectedProvider?: import("std-env").ProviderName) => string;
|
|
1
|
+
import type { AppTools, CliPlugin } from '../../types/index.js';
|
|
5
2
|
export default _default;
|
|
6
3
|
declare function _default(): CliPlugin<AppTools>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ResolvedDeployTarget } from '@modern-js/app-tools-extensions/deploy-output/target';
|
|
1
2
|
import type { AppContext, AsyncHook, InternalContext, PluginHook, PluginHookTap, TransformFunction } from '@modern-js/plugin';
|
|
2
3
|
import type { Hooks } from '@modern-js/plugin/cli';
|
|
3
4
|
import type { BffRuntimeFramework } from '@modern-js/plugin/server';
|
|
@@ -150,6 +151,7 @@ export interface AppToolsExtendContext {
|
|
|
150
151
|
serverRoutes: ServerRoute[];
|
|
151
152
|
/** Whether to use api only mode */
|
|
152
153
|
apiOnly: boolean;
|
|
154
|
+
deployTarget: ResolvedDeployTarget;
|
|
153
155
|
_internalContext: InternalContext<AppTools>;
|
|
154
156
|
/**
|
|
155
157
|
* Information for HTML templates by entry
|
|
@@ -227,6 +227,7 @@ Usage: modern deploy [options]
|
|
|
227
227
|
Options:
|
|
228
228
|
-c --config <config> Specify configuration file path, either relative or absolute
|
|
229
229
|
-s --skip-build Skip the build stage
|
|
230
|
+
--deploy-target <target> Deploy target (node, vercel, netlify, ghPages, cloudflare); overrides deploy.target and MODERNJS_DEPLOY
|
|
230
231
|
-h, --help Display command help
|
|
231
232
|
```
|
|
232
233
|
|
|
@@ -77,7 +77,7 @@ target.
|
|
|
77
77
|
| Effect compiler | `@effect/tsgo@0.45.0` |
|
|
78
78
|
| Oxc and Ultracite | `oxlint@1.85.0`, `oxfmt@0.70.0`, `ultracite@7.12.0` |
|
|
79
79
|
| TanStack Router | `@tanstack/react-router@1.170.39`, `@tanstack/router-core@1.171.32`, `@tanstack/history@1.162.4` |
|
|
80
|
-
| Module Federation | `bridge-react`, `manifest`, `modern-js-v3`, and `rspack`: `2.9.
|
|
80
|
+
| Module Federation | `bridge-react`, `manifest`, `modern-js-v3`, and `rspack`: `2.9.2`; `@module-federation/node@2.7.52` |
|
|
81
81
|
| Tailwind CSS | `tailwindcss@4.3.3` |
|
|
82
82
|
| Node and package tooling | Node `26.7.0`, `@types/node@^26.6.2`, pnpm `11.27.1` |
|
|
83
83
|
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.9.0-ultramodern.
|
|
20
|
+
"version": "3.9.0-ultramodern.20",
|
|
21
21
|
"types": "./dist/types/index.d.ts",
|
|
22
22
|
"main": "./dist/cjs/index.js",
|
|
23
23
|
"exports": {
|
|
@@ -127,18 +127,18 @@
|
|
|
127
127
|
"@babel/traverse": "^8.0.6",
|
|
128
128
|
"@babel/types": "^8.0.6",
|
|
129
129
|
"@loadable/component": "5.16.7",
|
|
130
|
-
"@modern-js/app-tools-extensions": "npm:@bleedingdev/modern-js-app-tools-extensions@3.9.0-ultramodern.
|
|
131
|
-
"@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.9.0-ultramodern.
|
|
132
|
-
"@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.9.0-ultramodern.
|
|
133
|
-
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.
|
|
134
|
-
"@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.0-ultramodern.
|
|
135
|
-
"@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.9.0-ultramodern.
|
|
136
|
-
"@modern-js/server": "npm:@bleedingdev/modern-js-server@3.9.0-ultramodern.
|
|
137
|
-
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.
|
|
138
|
-
"@modern-js/server-runtime-extensions": "npm:@bleedingdev/modern-js-server-runtime-extensions@3.9.0-ultramodern.
|
|
139
|
-
"@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.9.0-ultramodern.
|
|
140
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.
|
|
141
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.
|
|
130
|
+
"@modern-js/app-tools-extensions": "npm:@bleedingdev/modern-js-app-tools-extensions@3.9.0-ultramodern.20",
|
|
131
|
+
"@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.9.0-ultramodern.20",
|
|
132
|
+
"@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.9.0-ultramodern.20",
|
|
133
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.20",
|
|
134
|
+
"@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.0-ultramodern.20",
|
|
135
|
+
"@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.9.0-ultramodern.20",
|
|
136
|
+
"@modern-js/server": "npm:@bleedingdev/modern-js-server@3.9.0-ultramodern.20",
|
|
137
|
+
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.20",
|
|
138
|
+
"@modern-js/server-runtime-extensions": "npm:@bleedingdev/modern-js-server-runtime-extensions@3.9.0-ultramodern.20",
|
|
139
|
+
"@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.9.0-ultramodern.20",
|
|
140
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.20",
|
|
141
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.20",
|
|
142
142
|
"@rsbuild/core": "2.2.9",
|
|
143
143
|
"@swc/core": "1.16.2",
|
|
144
144
|
"@swc/helpers": "^0.5.23",
|