@modern-js/app-tools 2.63.1-alpha.0 → 2.63.1
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 +1 -1
- package/dist/cjs/commands/build.js +13 -19
- package/dist/cjs/commands/deploy.js +5 -5
- package/dist/cjs/commands/dev.js +11 -11
- package/dist/cjs/commands/index.js +6 -6
- package/dist/cjs/commands/inspect.js +1 -1
- package/dist/cjs/commands/serve.js +4 -4
- package/dist/cjs/hooks.js +60 -0
- package/dist/cjs/index.js +5 -154
- package/dist/cjs/{compat → new/compat}/hooks.js +5 -5
- package/dist/cjs/{compat → new/compat}/index.js +1 -4
- package/dist/cjs/{utils/initAppContext.js → new/context.js} +3 -3
- package/dist/cjs/{utils → new}/getConfigFile.js +1 -1
- package/dist/cjs/new/index.js +79 -0
- package/dist/cjs/new/loadPlugins.js +57 -0
- package/dist/cjs/{run/index.js → new/run.js} +6 -6
- package/dist/cjs/{utils/isAutoLoadPlugins.js → new/utils/index.js} +6 -6
- package/dist/cjs/old.js +179 -0
- package/dist/cjs/plugins/serverBuild.js +32 -30
- package/dist/cjs/utils/loadPlugins.js +4 -35
- package/dist/cjs/utils/printInstructions.js +11 -2
- package/dist/cjs/utils/restart.js +2 -2
- package/dist/esm/commands/build.js +12 -18
- package/dist/esm/commands/deploy.js +6 -6
- package/dist/esm/commands/dev.js +11 -11
- package/dist/esm/commands/index.js +8 -8
- package/dist/esm/commands/inspect.js +1 -1
- package/dist/esm/commands/serve.js +6 -6
- package/dist/esm/hooks.js +36 -0
- package/dist/esm/index.js +2 -245
- package/dist/esm/{compat → new/compat}/hooks.js +25 -15
- package/dist/esm/{compat → new/compat}/index.js +1 -4
- package/dist/esm/{utils → new}/getConfigFile.js +1 -1
- package/dist/esm/new/index.js +55 -0
- package/dist/esm/new/loadPlugins.js +94 -0
- package/dist/esm/{run/index.js → new/run.js} +6 -6
- package/dist/esm/{utils/isAutoLoadPlugins.js → new/utils/index.js} +6 -6
- package/dist/esm/old.js +258 -0
- package/dist/esm/plugins/serverBuild.js +56 -52
- package/dist/esm/utils/loadPlugins.js +7 -95
- package/dist/esm/utils/printInstructions.js +28 -1
- package/dist/esm/utils/restart.js +3 -3
- package/dist/esm-node/commands/build.js +13 -19
- package/dist/esm-node/commands/deploy.js +5 -5
- package/dist/esm-node/commands/dev.js +12 -12
- package/dist/esm-node/commands/index.js +6 -6
- package/dist/esm-node/commands/inspect.js +1 -1
- package/dist/esm-node/commands/serve.js +5 -5
- package/dist/esm-node/hooks.js +36 -0
- package/dist/esm-node/index.js +2 -140
- package/dist/esm-node/{compat → new/compat}/hooks.js +5 -5
- package/dist/esm-node/{compat → new/compat}/index.js +1 -4
- package/dist/esm-node/{utils → new}/getConfigFile.js +1 -1
- package/dist/esm-node/new/index.js +52 -0
- package/dist/esm-node/new/loadPlugins.js +33 -0
- package/dist/esm-node/{run/index.js → new/run.js} +6 -6
- package/dist/esm-node/{utils/isAutoLoadPlugins.js → new/utils/index.js} +2 -2
- package/dist/esm-node/old.js +140 -0
- package/dist/esm-node/plugins/serverBuild.js +32 -30
- package/dist/esm-node/utils/loadPlugins.js +4 -34
- package/dist/esm-node/utils/printInstructions.js +9 -1
- package/dist/esm-node/utils/restart.js +2 -2
- package/dist/types/commands/build.d.ts +2 -2
- package/dist/types/commands/deploy.d.ts +2 -2
- package/dist/types/commands/dev.d.ts +2 -2
- package/dist/types/commands/index.d.ts +6 -6
- package/dist/types/commands/inspect.d.ts +2 -2
- package/dist/types/commands/serve.d.ts +2 -2
- package/dist/types/hooks.d.ts +2 -0
- package/dist/types/index.d.ts +3 -5
- package/dist/types/{compat → new/compat}/hooks.d.ts +2 -2
- package/dist/types/new/compat/index.d.ts +2 -0
- package/dist/types/new/index.d.ts +6 -0
- package/dist/types/new/loadPlugins.d.ts +9 -0
- package/dist/types/new/utils/index.d.ts +1 -0
- package/dist/types/old.d.ts +13 -0
- package/dist/types/plugins/serverBuild.d.ts +2 -2
- package/dist/types/types/index.d.ts +0 -2
- package/dist/types/types/new.d.ts +16 -11
- package/dist/types/utils/generateWatchFiles.d.ts +2 -2
- package/dist/types/utils/loadPlugins.d.ts +3 -13
- package/dist/types/utils/printInstructions.d.ts +3 -1
- package/dist/types/utils/restart.d.ts +3 -2
- package/package.json +23 -22
- package/dist/types/compat/index.d.ts +0 -2
- package/dist/types/utils/isAutoLoadPlugins.d.ts +0 -1
- /package/dist/cjs/{compat → new/compat}/utils.js +0 -0
- /package/dist/cjs/{constants.js → new/constants.js} +0 -0
- /package/dist/esm/{compat → new/compat}/utils.js +0 -0
- /package/dist/esm/{constants.js → new/constants.js} +0 -0
- /package/dist/esm/{utils/initAppContext.js → new/context.js} +0 -0
- /package/dist/esm-node/{compat → new/compat}/utils.js +0 -0
- /package/dist/esm-node/{constants.js → new/constants.js} +0 -0
- /package/dist/esm-node/{utils/initAppContext.js → new/context.js} +0 -0
- /package/dist/types/{compat → new/compat}/utils.d.ts +0 -0
- /package/dist/types/{constants.d.ts → new/constants.d.ts} +0 -0
- /package/dist/types/{utils/initAppContext.d.ts → new/context.d.ts} +0 -0
- /package/dist/types/{utils → new}/getConfigFile.d.ts +0 -0
- /package/dist/types/{run/index.d.ts → new/run.d.ts} +0 -0
package/bin/modern.js
CHANGED
|
@@ -10,7 +10,7 @@ if (!process.env.MODERN_JS_VERSION) {
|
|
|
10
10
|
process.env.MODERN_JS_VERSION = version;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
require('../dist/cjs/run
|
|
13
|
+
require('../dist/cjs/new/run.js').run({
|
|
14
14
|
internalPlugins: {
|
|
15
15
|
cli: INTERNAL_APP_TOOLS_PLUGINS,
|
|
16
16
|
autoLoad: INTERNAL_APP_TOOLS_RUNTIME_PLUGINS,
|
|
@@ -31,6 +31,7 @@ __export(build_exports, {
|
|
|
31
31
|
build: () => build
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(build_exports);
|
|
34
|
+
var import_core = require("@modern-js/core");
|
|
34
35
|
var import_utils = require("@modern-js/utils");
|
|
35
36
|
var import_config = require("../utils/config");
|
|
36
37
|
var import_loadPlugins = require("../utils/loadPlugins");
|
|
@@ -41,9 +42,9 @@ const build = async (api, options) => {
|
|
|
41
42
|
if (options === null || options === void 0 ? void 0 : options.analyze) {
|
|
42
43
|
process.env.BUNDLE_ANALYZE = "true";
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
-
const appContext = api.
|
|
46
|
-
const
|
|
45
|
+
let resolvedConfig = api.useResolvedConfigContext();
|
|
46
|
+
const appContext = api.useAppContext();
|
|
47
|
+
const hookRunners = api.useHookRunners();
|
|
47
48
|
await (0, import_loadPlugins.loadServerPlugins)(api, appContext.appDirectory, appContext.metaName);
|
|
48
49
|
if (appContext.moduleType && appContext.moduleType === "module") {
|
|
49
50
|
var _resolvedConfig_source1;
|
|
@@ -58,12 +59,9 @@ const build = async (api, options) => {
|
|
|
58
59
|
const { apiOnly } = appContext;
|
|
59
60
|
if (apiOnly) {
|
|
60
61
|
const { appDirectory: appDirectory2, distDirectory: distDirectory2, serverConfigFile: serverConfigFile2 } = appContext;
|
|
61
|
-
await
|
|
62
|
-
environments: {},
|
|
62
|
+
await hookRunners.beforeBuild({
|
|
63
63
|
// "null" bundlerConfigs
|
|
64
|
-
bundlerConfigs: void 0
|
|
65
|
-
isFirstCompile: false,
|
|
66
|
-
isWatch: false
|
|
64
|
+
bundlerConfigs: void 0
|
|
67
65
|
});
|
|
68
66
|
await (0, import_config.buildServerConfig)({
|
|
69
67
|
appDirectory: appDirectory2,
|
|
@@ -71,21 +69,17 @@ const build = async (api, options) => {
|
|
|
71
69
|
configFile: serverConfigFile2
|
|
72
70
|
});
|
|
73
71
|
await (0, import_routes.generateRoutes)(appContext);
|
|
74
|
-
await
|
|
75
|
-
environments: {},
|
|
72
|
+
await hookRunners.afterBuild({
|
|
76
73
|
// "null" stats
|
|
77
|
-
stats: void 0
|
|
78
|
-
isFirstCompile: false,
|
|
79
|
-
isWatch: false
|
|
74
|
+
stats: void 0
|
|
80
75
|
});
|
|
81
76
|
return;
|
|
82
77
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
});
|
|
78
|
+
resolvedConfig = {
|
|
79
|
+
...resolvedConfig,
|
|
80
|
+
cliOptions: options
|
|
81
|
+
};
|
|
82
|
+
import_core.ResolvedConfigContext.set(resolvedConfig);
|
|
89
83
|
const { distDirectory, appDirectory, serverConfigFile } = appContext;
|
|
90
84
|
await (0, import_config.buildServerConfig)({
|
|
91
85
|
appDirectory,
|
|
@@ -23,12 +23,12 @@ __export(deploy_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(deploy_exports);
|
|
24
24
|
var import_loadPlugins = require("../utils/loadPlugins");
|
|
25
25
|
const deploy = async (api, options) => {
|
|
26
|
-
const
|
|
27
|
-
const { metaName } = api.
|
|
26
|
+
const hookRunners = api.useHookRunners();
|
|
27
|
+
const { metaName } = api.useAppContext();
|
|
28
28
|
await (0, import_loadPlugins.getServerPlugins)(api, metaName);
|
|
29
|
-
await
|
|
30
|
-
await
|
|
31
|
-
await
|
|
29
|
+
await hookRunners.beforeDeploy(options);
|
|
30
|
+
await hookRunners.deploy(options);
|
|
31
|
+
await hookRunners.afterDeploy(options);
|
|
32
32
|
};
|
|
33
33
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
34
|
0 && (module.exports = {
|
package/dist/cjs/commands/dev.js
CHANGED
|
@@ -32,6 +32,7 @@ __export(dev_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(dev_exports);
|
|
34
34
|
var import_node_path = __toESM(require("node:path"));
|
|
35
|
+
var import_core = require("@modern-js/core");
|
|
35
36
|
var import_prod_server = require("@modern-js/prod-server");
|
|
36
37
|
var import_server = require("@modern-js/server");
|
|
37
38
|
var import_utils = require("@modern-js/utils");
|
|
@@ -46,9 +47,9 @@ const dev = async (api, options, devServerOptions) => {
|
|
|
46
47
|
if (options.analyze) {
|
|
47
48
|
process.env.BUNDLE_ANALYZE = "true";
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
const appContext = api.
|
|
51
|
-
const
|
|
50
|
+
let normalizedConfig = api.useResolvedConfigContext();
|
|
51
|
+
const appContext = api.useAppContext();
|
|
52
|
+
const hookRunners = api.useHookRunners();
|
|
52
53
|
if (appContext.moduleType && appContext.moduleType === "module") {
|
|
53
54
|
var _normalizedConfig_source1;
|
|
54
55
|
const { registerEsm } = await import("../esm/register-esm.mjs");
|
|
@@ -59,12 +60,11 @@ const dev = async (api, options, devServerOptions) => {
|
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
62
|
await (0, import_register.registerCompiler)(appContext.appDirectory, appContext.distDirectory, normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig_source = normalizedConfig.source) === null || _normalizedConfig_source === void 0 ? void 0 : _normalizedConfig_source.alias);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
63
|
+
normalizedConfig = {
|
|
64
|
+
...normalizedConfig,
|
|
65
|
+
cliOptions: options
|
|
66
|
+
};
|
|
67
|
+
import_core.ResolvedConfigContext.set(normalizedConfig);
|
|
68
68
|
const { appDirectory, distDirectory, port, apiOnly, serverConfigFile, metaName, serverRoutes } = appContext;
|
|
69
69
|
await (0, import_config.buildServerConfig)({
|
|
70
70
|
appDirectory,
|
|
@@ -74,7 +74,7 @@ const dev = async (api, options, devServerOptions) => {
|
|
|
74
74
|
});
|
|
75
75
|
const meta = (0, import_utils.getMeta)(metaName);
|
|
76
76
|
const serverConfigPath = import_node_path.default.resolve(appDirectory, import_utils.SERVER_DIR, `${meta}.server`);
|
|
77
|
-
await
|
|
77
|
+
await hookRunners.beforeDev();
|
|
78
78
|
if (!appContext.builder && !apiOnly) {
|
|
79
79
|
throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
|
|
80
80
|
}
|
|
@@ -113,7 +113,7 @@ const dev = async (api, options, devServerOptions) => {
|
|
|
113
113
|
port,
|
|
114
114
|
host
|
|
115
115
|
}, () => {
|
|
116
|
-
(0, import_printInstructions.
|
|
116
|
+
(0, import_printInstructions.printInstructionsCompat)(hookRunners, appContext, normalizedConfig);
|
|
117
117
|
});
|
|
118
118
|
} else {
|
|
119
119
|
const { server, afterListen } = await (0, import_server.createDevServer)({
|
|
@@ -41,8 +41,8 @@ var import_uni_builder = require("@modern-js/uni-builder");
|
|
|
41
41
|
var import_utils = require("@modern-js/utils");
|
|
42
42
|
var import_locale = require("../locale");
|
|
43
43
|
const devCommand = async (program, api) => {
|
|
44
|
-
const
|
|
45
|
-
const devToolMetas = await
|
|
44
|
+
const runner = api.useHookRunners();
|
|
45
|
+
const devToolMetas = await runner.registerDev();
|
|
46
46
|
const devProgram = program.command("dev").alias("start").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.dev.describe)).option("-c --config <config>", import_locale.i18n.t(import_locale.localeKeys.command.shared.config)).option("-e --entry [entry...]", import_locale.i18n.t(import_locale.localeKeys.command.dev.entry)).option("--analyze", import_locale.i18n.t(import_locale.localeKeys.command.shared.analyze)).option("--api-only", import_locale.i18n.t(import_locale.localeKeys.command.dev.apiOnly)).option("--web-only", import_locale.i18n.t(import_locale.localeKeys.command.dev.webOnly)).action(async (options) => {
|
|
47
47
|
const { dev } = await import("./dev.js");
|
|
48
48
|
await dev(api, options);
|
|
@@ -53,7 +53,7 @@ const devCommand = async (program, api) => {
|
|
|
53
53
|
}
|
|
54
54
|
for (const subCmd of meta.subCommands) {
|
|
55
55
|
devProgram.command(subCmd).action(async (options = {}) => {
|
|
56
|
-
const { appDirectory } = api.
|
|
56
|
+
const { appDirectory } = api.useAppContext();
|
|
57
57
|
const { isTypescript } = await import("@modern-js/utils");
|
|
58
58
|
await meta.action(options, {
|
|
59
59
|
isTsProject: isTypescript(appDirectory)
|
|
@@ -63,8 +63,8 @@ const devCommand = async (program, api) => {
|
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
const buildCommand = async (program, api) => {
|
|
66
|
-
const
|
|
67
|
-
const platformBuilders = await
|
|
66
|
+
const runner = api.useHookRunners();
|
|
67
|
+
const platformBuilders = await runner.registerBuildPlatform();
|
|
68
68
|
const buildProgram = program.command("build").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.build.describe)).option("-c --config <config>", import_locale.i18n.t(import_locale.localeKeys.command.shared.config)).option("--analyze", import_locale.i18n.t(import_locale.localeKeys.command.shared.analyze)).action(async (options) => {
|
|
69
69
|
const { build } = await import("./build.js");
|
|
70
70
|
await build(api, options);
|
|
@@ -73,7 +73,7 @@ const buildCommand = async (program, api) => {
|
|
|
73
73
|
const platforms = (0, import_uni_builder.castArray)(platformBuilder.platform);
|
|
74
74
|
for (const platform of platforms) {
|
|
75
75
|
buildProgram.command(platform).action(async () => {
|
|
76
|
-
const { appDirectory } = api.
|
|
76
|
+
const { appDirectory } = api.useAppContext();
|
|
77
77
|
const { isTypescript } = await import("@modern-js/utils");
|
|
78
78
|
await platformBuilder.build(platform, {
|
|
79
79
|
isTsProject: isTypescript(appDirectory)
|
|
@@ -22,7 +22,7 @@ __export(inspect_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(inspect_exports);
|
|
24
24
|
const inspect = async (api, options) => {
|
|
25
|
-
const appContext = api.
|
|
25
|
+
const appContext = api.useAppContext();
|
|
26
26
|
if (!appContext.builder) {
|
|
27
27
|
throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
|
|
28
28
|
}
|
|
@@ -38,9 +38,9 @@ var import_loadPlugins = require("../utils/loadPlugins");
|
|
|
38
38
|
var import_printInstructions = require("../utils/printInstructions");
|
|
39
39
|
const start = async (api) => {
|
|
40
40
|
var _userConfig_source, _userConfig_output_distPath;
|
|
41
|
-
const appContext = api.
|
|
42
|
-
const userConfig = api.
|
|
43
|
-
const
|
|
41
|
+
const appContext = api.useAppContext();
|
|
42
|
+
const userConfig = api.useResolvedConfigContext();
|
|
43
|
+
const hookRunners = api.useHookRunners();
|
|
44
44
|
const { distDirectory, appDirectory, internalDirectory, port, metaName, serverRoutes, serverConfigFile } = appContext;
|
|
45
45
|
import_utils.logger.info(`Starting production server...`);
|
|
46
46
|
const apiOnly = await (0, import_utils.isApiOnly)(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_source = userConfig.source) === null || _userConfig_source === void 0 ? void 0 : _userConfig_source.entriesDir, appContext.apiDirectory);
|
|
@@ -77,7 +77,7 @@ const start = async (api) => {
|
|
|
77
77
|
runMode
|
|
78
78
|
});
|
|
79
79
|
app.listen(port, async () => {
|
|
80
|
-
await (0, import_printInstructions.
|
|
80
|
+
await (0, import_printInstructions.printInstructionsCompat)(hookRunners, appContext, userConfig);
|
|
81
81
|
});
|
|
82
82
|
};
|
|
83
83
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var hooks_exports = {};
|
|
20
|
+
__export(hooks_exports, {
|
|
21
|
+
hooks: () => hooks
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
24
|
+
var import_plugin = require("@modern-js/plugin");
|
|
25
|
+
const hooks = {
|
|
26
|
+
_internalRuntimePlugins: (0, import_plugin.createAsyncWaterfall)(),
|
|
27
|
+
modifyFileSystemRoutes: (0, import_plugin.createAsyncWaterfall)(),
|
|
28
|
+
modifyServerRoutes: (0, import_plugin.createAsyncWaterfall)(),
|
|
29
|
+
/** add entry point info to entrypoints array */
|
|
30
|
+
modifyEntrypoints: (0, import_plugin.createAsyncWaterfall)(),
|
|
31
|
+
/** add entry type */
|
|
32
|
+
checkEntryPoint: (0, import_plugin.createAsyncWaterfall)(),
|
|
33
|
+
generateEntryCode: (0, import_plugin.createAsyncWorkflow)(),
|
|
34
|
+
htmlPartials: (0, import_plugin.createAsyncWaterfall)(),
|
|
35
|
+
beforeGenerateRoutes: (0, import_plugin.createAsyncWaterfall)(),
|
|
36
|
+
_internalServerPlugins: (0, import_plugin.createAsyncWaterfall)(),
|
|
37
|
+
beforeDev: (0, import_plugin.createAsyncWorkflow)(),
|
|
38
|
+
afterDev: (0, import_plugin.createAsyncWorkflow)(),
|
|
39
|
+
beforeCreateCompiler: (0, import_plugin.createAsyncWorkflow)(),
|
|
40
|
+
afterCreateCompiler: (0, import_plugin.createAsyncWorkflow)(),
|
|
41
|
+
beforePrintInstructions: (0, import_plugin.createAsyncWaterfall)(),
|
|
42
|
+
beforeBuild: (0, import_plugin.createAsyncWorkflow)(),
|
|
43
|
+
afterBuild: (0, import_plugin.createAsyncWorkflow)(),
|
|
44
|
+
beforeDeploy: (0, import_plugin.createAsyncWorkflow)(),
|
|
45
|
+
deploy: (0, import_plugin.createAsyncWorkflow)(),
|
|
46
|
+
afterDeploy: (0, import_plugin.createAsyncWorkflow)(),
|
|
47
|
+
beforeRestart: (0, import_plugin.createAsyncWorkflow)(),
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated
|
|
50
|
+
*/
|
|
51
|
+
registerDev: (0, import_plugin.createParallelWorkflow)(),
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated
|
|
54
|
+
*/
|
|
55
|
+
registerBuildPlatform: (0, import_plugin.createParallelWorkflow)()
|
|
56
|
+
};
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
hooks
|
|
60
|
+
});
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -18,171 +16,25 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
18
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
20
|
var src_exports = {};
|
|
31
21
|
__export(src_exports, {
|
|
32
|
-
appTools: () => appTools,
|
|
22
|
+
appTools: () => import_new.appTools,
|
|
33
23
|
default: () => src_default,
|
|
34
24
|
defineConfig: () => import_defineConfig.defineConfig,
|
|
35
25
|
defineLegacyConfig: () => import_defineConfig.defineLegacyConfig,
|
|
36
26
|
dev: () => import_dev.dev,
|
|
37
|
-
initAppContext: () =>
|
|
27
|
+
initAppContext: () => import_new2.initAppContext,
|
|
38
28
|
mergeConfig: () => import_core.mergeConfig
|
|
39
29
|
});
|
|
40
30
|
module.exports = __toCommonJS(src_exports);
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var import_uni_builder = require("@modern-js/uni-builder");
|
|
44
|
-
var import_utils = require("@modern-js/utils");
|
|
45
|
-
var import_commands = require("./commands");
|
|
46
|
-
var import_compat = require("./compat");
|
|
47
|
-
var import_constants = require("./constants");
|
|
48
|
-
var import_locale = require("./locale");
|
|
49
|
-
var import_analyze = __toESM(require("./plugins/analyze"));
|
|
50
|
-
var import_deploy = __toESM(require("./plugins/deploy"));
|
|
51
|
-
var import_initialize = __toESM(require("./plugins/initialize"));
|
|
52
|
-
var import_serverBuild = __toESM(require("./plugins/serverBuild"));
|
|
53
|
-
var import_generateWatchFiles = require("./utils/generateWatchFiles");
|
|
54
|
-
var import_initAppContext = require("./utils/initAppContext");
|
|
55
|
-
var import_restart = require("./utils/restart");
|
|
56
|
-
__reExport(src_exports, require("./defineConfig"), module.exports);
|
|
31
|
+
var import_new = require("./new/index");
|
|
32
|
+
var import_new2 = require("./new/index");
|
|
57
33
|
var import_defineConfig = require("./defineConfig");
|
|
58
34
|
var import_core = require("@modern-js/core");
|
|
59
35
|
var import_dev = require("./commands/dev");
|
|
60
36
|
__reExport(src_exports, require("./types"), module.exports);
|
|
61
|
-
|
|
62
|
-
// default webpack to be compatible with original projects
|
|
63
|
-
bundler: "webpack"
|
|
64
|
-
}) => ({
|
|
65
|
-
name: "@modern-js/app-tools",
|
|
66
|
-
usePlugins: [
|
|
67
|
-
(0, import_compat.compatPlugin)(),
|
|
68
|
-
(0, import_initialize.default)({
|
|
69
|
-
bundler: (options === null || options === void 0 ? void 0 : options.bundler) && [
|
|
70
|
-
"rspack",
|
|
71
|
-
"experimental-rspack"
|
|
72
|
-
].includes(options.bundler) ? "rspack" : "webpack"
|
|
73
|
-
}),
|
|
74
|
-
(0, import_analyze.default)({
|
|
75
|
-
bundler: (options === null || options === void 0 ? void 0 : options.bundler) && [
|
|
76
|
-
"rspack",
|
|
77
|
-
"experimental-rspack"
|
|
78
|
-
].includes(options.bundler) ? "rspack" : "webpack"
|
|
79
|
-
}),
|
|
80
|
-
(0, import_serverBuild.default)(),
|
|
81
|
-
(0, import_deploy.default)()
|
|
82
|
-
],
|
|
83
|
-
post: [
|
|
84
|
-
"@modern-js/plugin-initialize",
|
|
85
|
-
"@modern-js/plugin-analyze",
|
|
86
|
-
"@modern-js/plugin-ssr",
|
|
87
|
-
"@modern-js/plugin-document",
|
|
88
|
-
"@modern-js/plugin-state",
|
|
89
|
-
"@modern-js/plugin-router",
|
|
90
|
-
"@modern-js/plugin-router-v5",
|
|
91
|
-
"@modern-js/plugin-polyfill"
|
|
92
|
-
],
|
|
93
|
-
registryHooks: {
|
|
94
|
-
onBeforeConfig: (0, import_plugin_v2.createAsyncHook)(),
|
|
95
|
-
onAfterPrepare: (0, import_plugin_v2.createAsyncHook)(),
|
|
96
|
-
deploy: (0, import_plugin_v2.createAsyncHook)(),
|
|
97
|
-
_internalRuntimePlugins: (0, import_plugin_v2.createAsyncHook)(),
|
|
98
|
-
_internalServerPlugins: (0, import_plugin_v2.createAsyncHook)(),
|
|
99
|
-
checkEntryPoint: (0, import_plugin_v2.createAsyncHook)(),
|
|
100
|
-
modifyEntrypoints: (0, import_plugin_v2.createAsyncHook)(),
|
|
101
|
-
modifyFileSystemRoutes: (0, import_plugin_v2.createAsyncHook)(),
|
|
102
|
-
modifyServerRoutes: (0, import_plugin_v2.createAsyncHook)(),
|
|
103
|
-
generateEntryCode: (0, import_plugin_v2.createAsyncHook)(),
|
|
104
|
-
onBeforeGenerateRoutes: (0, import_plugin_v2.createAsyncHook)(),
|
|
105
|
-
onBeforePrintInstructions: (0, import_plugin_v2.createAsyncHook)(),
|
|
106
|
-
registerDev: (0, import_plugin_v2.createCollectAsyncHook)(),
|
|
107
|
-
registerBuildPlatform: (0, import_plugin_v2.createCollectAsyncHook)(),
|
|
108
|
-
addRuntimeExports: (0, import_plugin_v2.createAsyncHook)()
|
|
109
|
-
},
|
|
110
|
-
setup: (api) => {
|
|
111
|
-
var _userConfig_output;
|
|
112
|
-
const context = api.getAppContext();
|
|
113
|
-
const userConfig = api.getConfig();
|
|
114
|
-
const locale = (0, import_language_detector.getLocaleLanguage)();
|
|
115
|
-
import_locale.i18n.changeLanguage({
|
|
116
|
-
locale
|
|
117
|
-
});
|
|
118
|
-
api.updateAppContext((0, import_initAppContext.initAppContext)({
|
|
119
|
-
appDirectory: context.appDirectory,
|
|
120
|
-
options: {},
|
|
121
|
-
serverConfigFile: import_constants.DEFAULT_SERVER_CONFIG_FILE,
|
|
122
|
-
runtimeConfigFile: import_constants.DEFAULT_RUNTIME_CONFIG_FILE,
|
|
123
|
-
tempDir: (_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir
|
|
124
|
-
}));
|
|
125
|
-
api.addCommand(async ({ program }) => {
|
|
126
|
-
await (0, import_commands.devCommand)(program, api);
|
|
127
|
-
await (0, import_commands.buildCommand)(program, api);
|
|
128
|
-
(0, import_commands.serverCommand)(program, api);
|
|
129
|
-
(0, import_commands.deployCommand)(program, api);
|
|
130
|
-
(0, import_commands.newCommand)(program, locale);
|
|
131
|
-
(0, import_commands.inspectCommand)(program, api);
|
|
132
|
-
(0, import_commands.upgradeCommand)(program);
|
|
133
|
-
(0, import_utils.deprecatedCommands)(program);
|
|
134
|
-
});
|
|
135
|
-
api.onPrepare(async () => {
|
|
136
|
-
const command = (0, import_utils.getCommand)();
|
|
137
|
-
if (command === "deploy") {
|
|
138
|
-
const isSkipBuild = [
|
|
139
|
-
"-s",
|
|
140
|
-
"--skip-build"
|
|
141
|
-
].some((tag) => {
|
|
142
|
-
return (0, import_utils.getArgv)().includes(tag);
|
|
143
|
-
});
|
|
144
|
-
if (isSkipBuild) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
if (command === "dev" || command === "start" || command === "build" || command === "deploy") {
|
|
149
|
-
const resolvedConfig = api.getNormalizedConfig();
|
|
150
|
-
if (resolvedConfig.output.cleanDistPath) {
|
|
151
|
-
const appContext = api.getAppContext();
|
|
152
|
-
await (0, import_utils.emptyDir)(appContext.distDirectory);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
api.addWatchFiles(async () => {
|
|
157
|
-
const appContext = api.getAppContext();
|
|
158
|
-
const config = api.getNormalizedConfig();
|
|
159
|
-
const files = await (0, import_generateWatchFiles.generateWatchFiles)(appContext, config.source.configDir);
|
|
160
|
-
const watchFiles = (0, import_uni_builder.castArray)(config.dev.watchFiles);
|
|
161
|
-
watchFiles.forEach(({ type, paths }) => {
|
|
162
|
-
if (type === "reload-server") {
|
|
163
|
-
files.push(...Array.isArray(paths) ? paths : [
|
|
164
|
-
paths
|
|
165
|
-
]);
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
return files;
|
|
169
|
-
});
|
|
170
|
-
api.onFileChanged(async (e) => {
|
|
171
|
-
const { filename, eventType, isPrivate } = e;
|
|
172
|
-
if (!isPrivate && (eventType === "change" || eventType === "unlink")) {
|
|
173
|
-
const { closeServer } = await import("./utils/createServer.js");
|
|
174
|
-
await closeServer();
|
|
175
|
-
await (0, import_restart.restart)(api.getHooks(), filename);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
api.onBeforeRestart(() => {
|
|
179
|
-
(0, import_utils.cleanRequireCache)([
|
|
180
|
-
require.resolve("./plugins/analyze")
|
|
181
|
-
]);
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
var src_default = appTools;
|
|
37
|
+
var src_default = import_new.appTools;
|
|
186
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
187
39
|
0 && (module.exports = {
|
|
188
40
|
appTools,
|
|
@@ -191,6 +43,5 @@ var src_default = appTools;
|
|
|
191
43
|
dev,
|
|
192
44
|
initAppContext,
|
|
193
45
|
mergeConfig,
|
|
194
|
-
...require("./defineConfig"),
|
|
195
46
|
...require("./types")
|
|
196
47
|
});
|
|
@@ -22,7 +22,7 @@ __export(hooks_exports, {
|
|
|
22
22
|
handleSetupResult: () => handleSetupResult
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(hooks_exports);
|
|
25
|
-
var import_getHtmlTemplate = require("
|
|
25
|
+
var import_getHtmlTemplate = require("../../plugins/analyze/getHtmlTemplate");
|
|
26
26
|
var import_utils = require("./utils");
|
|
27
27
|
function getHookRunners(context) {
|
|
28
28
|
const { hooks } = context;
|
|
@@ -134,14 +134,14 @@ function getHookRunners(context) {
|
|
|
134
134
|
/**
|
|
135
135
|
* @deprecated
|
|
136
136
|
*/
|
|
137
|
-
registerDev: async () => {
|
|
138
|
-
return hooks.registerDev.call();
|
|
137
|
+
registerDev: async (params) => {
|
|
138
|
+
return hooks.registerDev.call(params);
|
|
139
139
|
},
|
|
140
140
|
/**
|
|
141
141
|
* @deprecated
|
|
142
142
|
*/
|
|
143
|
-
registerBuildPlatform: async () => {
|
|
144
|
-
return hooks.registerBuildPlatform.call();
|
|
143
|
+
registerBuildPlatform: async (params) => {
|
|
144
|
+
return hooks.registerBuildPlatform.call(params);
|
|
145
145
|
},
|
|
146
146
|
/**
|
|
147
147
|
* @deprecated
|
|
@@ -51,10 +51,7 @@ const compatPlugin = () => ({
|
|
|
51
51
|
registryHooks: {
|
|
52
52
|
appendEntryCode: (0, import_plugin_v2.createCollectAsyncHook)()
|
|
53
53
|
},
|
|
54
|
-
setup: (
|
|
55
|
-
api.updateAppContext({
|
|
56
|
-
toolsType: "app-tools"
|
|
57
|
-
});
|
|
54
|
+
setup: (_api) => {
|
|
58
55
|
}
|
|
59
56
|
});
|
|
60
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -26,11 +26,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var context_exports = {};
|
|
30
|
+
__export(context_exports, {
|
|
31
31
|
initAppContext: () => initAppContext
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
33
|
+
module.exports = __toCommonJS(context_exports);
|
|
34
34
|
var import_path = __toESM(require("path"));
|
|
35
35
|
var import_utils = require("@modern-js/utils");
|
|
36
36
|
const initAppContext = ({ appDirectory, runtimeConfigFile, options, serverConfigFile, tempDir }) => {
|
|
@@ -33,7 +33,7 @@ __export(getConfigFile_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(getConfigFile_exports);
|
|
34
34
|
var import_path = __toESM(require("path"));
|
|
35
35
|
var import_utils = require("@modern-js/utils");
|
|
36
|
-
var import_constants = require("
|
|
36
|
+
var import_constants = require("./constants");
|
|
37
37
|
const getConfigFile = (configFile) => (0, import_utils.findExists)(import_utils.CONFIG_FILE_EXTENSIONS.map((extension) => import_path.default.resolve(process.cwd(), `${configFile || import_constants.DEFAULT_CONFIG_FILE}${extension}`)));
|
|
38
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
39
39
|
0 && (module.exports = {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var new_exports = {};
|
|
21
|
+
__export(new_exports, {
|
|
22
|
+
appTools: () => appTools,
|
|
23
|
+
initAppContext: () => import_context.initAppContext
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(new_exports);
|
|
26
|
+
var import_plugin_v2 = require("@modern-js/plugin-v2");
|
|
27
|
+
var import_old = require("../old");
|
|
28
|
+
var import_compat = require("./compat");
|
|
29
|
+
var import_constants = require("./constants");
|
|
30
|
+
var import_context = require("./context");
|
|
31
|
+
__reExport(new_exports, require("../defineConfig"), module.exports);
|
|
32
|
+
const appTools = (options = {
|
|
33
|
+
// default webpack to be compatible with original projects
|
|
34
|
+
bundler: "webpack"
|
|
35
|
+
}) => ({
|
|
36
|
+
name: "@modern-js/app-tools",
|
|
37
|
+
usePlugins: [
|
|
38
|
+
(0, import_compat.compatPlugin)(),
|
|
39
|
+
(0, import_old.appTools)(options)
|
|
40
|
+
],
|
|
41
|
+
post: [
|
|
42
|
+
"@modern-js/app-tools-old"
|
|
43
|
+
],
|
|
44
|
+
registryHooks: {
|
|
45
|
+
onBeforeConfig: (0, import_plugin_v2.createAsyncHook)(),
|
|
46
|
+
onAfterPrepare: (0, import_plugin_v2.createAsyncHook)(),
|
|
47
|
+
deploy: (0, import_plugin_v2.createAsyncHook)(),
|
|
48
|
+
_internalRuntimePlugins: (0, import_plugin_v2.createAsyncHook)(),
|
|
49
|
+
_internalServerPlugins: (0, import_plugin_v2.createAsyncHook)(),
|
|
50
|
+
checkEntryPoint: (0, import_plugin_v2.createAsyncHook)(),
|
|
51
|
+
modifyEntrypoints: (0, import_plugin_v2.createAsyncHook)(),
|
|
52
|
+
modifyFileSystemRoutes: (0, import_plugin_v2.createAsyncHook)(),
|
|
53
|
+
modifyServerRoutes: (0, import_plugin_v2.createAsyncHook)(),
|
|
54
|
+
generateEntryCode: (0, import_plugin_v2.createAsyncHook)(),
|
|
55
|
+
onBeforeGenerateRoutes: (0, import_plugin_v2.createAsyncHook)(),
|
|
56
|
+
onBeforePrintInstructions: (0, import_plugin_v2.createAsyncHook)(),
|
|
57
|
+
registerDev: (0, import_plugin_v2.createAsyncHook)(),
|
|
58
|
+
registerBuildPlatform: (0, import_plugin_v2.createAsyncHook)(),
|
|
59
|
+
addRuntimeExports: (0, import_plugin_v2.createAsyncHook)()
|
|
60
|
+
},
|
|
61
|
+
setup: (api) => {
|
|
62
|
+
var _userConfig_output;
|
|
63
|
+
const context = api.getAppContext();
|
|
64
|
+
const userConfig = api.getConfig();
|
|
65
|
+
api.updateAppContext((0, import_context.initAppContext)({
|
|
66
|
+
appDirectory: context.appDirectory,
|
|
67
|
+
options: {},
|
|
68
|
+
serverConfigFile: import_constants.DEFAULT_SERVER_CONFIG_FILE,
|
|
69
|
+
runtimeConfigFile: import_constants.DEFAULT_RUNTIME_CONFIG_FILE,
|
|
70
|
+
tempDir: (_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
appTools,
|
|
77
|
+
initAppContext,
|
|
78
|
+
...require("../defineConfig")
|
|
79
|
+
});
|