@modern-js/app-tools 2.62.1-alpha.1 → 2.62.2-alpha.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/dist/cjs/index.js +10 -4
- package/dist/cjs/new/compat/hooks.js +4 -4
- package/dist/cjs/new/compat/index.js +10 -7
- package/dist/cjs/new/context.js +2 -2
- package/dist/cjs/new/index.js +4 -1
- package/dist/cjs/new/loadPlugins.js +2 -2
- package/dist/cjs/new/run.js +5 -4
- package/dist/cjs/utils/restart.js +2 -2
- package/dist/esm/index.js +6 -2
- package/dist/esm/new/compat/hooks.js +24 -14
- package/dist/esm/new/compat/index.js +10 -7
- package/dist/esm/new/context.js +2 -2
- package/dist/esm/new/index.js +4 -1
- package/dist/esm/new/loadPlugins.js +3 -3
- package/dist/esm/new/run.js +6 -5
- package/dist/esm/utils/restart.js +1 -1
- package/dist/esm-node/index.js +6 -2
- package/dist/esm-node/new/compat/hooks.js +4 -4
- package/dist/esm-node/new/compat/index.js +10 -7
- package/dist/esm-node/new/context.js +2 -2
- package/dist/esm-node/new/index.js +4 -1
- package/dist/esm-node/new/loadPlugins.js +2 -2
- package/dist/esm-node/new/run.js +5 -4
- package/dist/esm-node/utils/restart.js +1 -1
- package/dist/types/index.d.ts +2 -9
- package/dist/types/new/compat/hooks.d.ts +1 -1
- package/dist/types/new/compat/index.d.ts +1 -1
- package/dist/types/new/context.d.ts +2 -1
- package/dist/types/new/index.d.ts +2 -8
- package/dist/types/new/loadPlugins.d.ts +2 -2
- package/dist/types/new/run.d.ts +1 -2
- package/dist/types/new/types/index.d.ts +6 -5
- package/dist/types/old.d.ts +1 -8
- package/dist/types/types/index.d.ts +7 -0
- package/dist/types/utils/restart.d.ts +1 -1
- package/package.json +16 -16
package/dist/cjs/index.js
CHANGED
@@ -19,23 +19,29 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
20
20
|
var src_exports = {};
|
21
21
|
__export(src_exports, {
|
22
|
+
appTools: () => import_new2.appTools,
|
22
23
|
default: () => src_default,
|
24
|
+
defineConfig: () => import_defineConfig.defineConfig,
|
25
|
+
defineLegacyConfig: () => import_defineConfig.defineLegacyConfig,
|
23
26
|
dev: () => import_dev.dev,
|
27
|
+
initAppContext: () => import_new2.initAppContext,
|
24
28
|
mergeConfig: () => import_core.mergeConfig
|
25
29
|
});
|
26
30
|
module.exports = __toCommonJS(src_exports);
|
27
31
|
var import_new = require("./new/index");
|
28
|
-
|
32
|
+
var import_new2 = require("./new/index");
|
29
33
|
var import_dev = require("./commands/dev");
|
30
34
|
var import_core = require("@modern-js/core");
|
31
|
-
|
35
|
+
var import_defineConfig = require("./defineConfig");
|
32
36
|
__reExport(src_exports, require("./types"), module.exports);
|
33
37
|
var src_default = import_new.appTools;
|
34
38
|
// Annotate the CommonJS export names for ESM import in node:
|
35
39
|
0 && (module.exports = {
|
40
|
+
appTools,
|
41
|
+
defineConfig,
|
42
|
+
defineLegacyConfig,
|
36
43
|
dev,
|
44
|
+
initAppContext,
|
37
45
|
mergeConfig,
|
38
|
-
...require("./new/index"),
|
39
|
-
...require("./defineConfig"),
|
40
46
|
...require("./types")
|
41
47
|
});
|
@@ -107,11 +107,11 @@ function getHookRunners(context) {
|
|
107
107
|
afterDev: async (params) => {
|
108
108
|
return hooks.onAfterDev.call(params);
|
109
109
|
},
|
110
|
-
beforeDeploy: async () => {
|
111
|
-
return hooks.onBeforeDeploy.call();
|
110
|
+
beforeDeploy: async (options) => {
|
111
|
+
return hooks.onBeforeDeploy.call(options);
|
112
112
|
},
|
113
|
-
afterDeploy: async () => {
|
114
|
-
return hooks.onAfterDeploy.call();
|
113
|
+
afterDeploy: async (options) => {
|
114
|
+
return hooks.onAfterDeploy.call(options);
|
115
115
|
},
|
116
116
|
beforeExit: async () => {
|
117
117
|
return hooks.onBeforeExit.call();
|
@@ -24,22 +24,25 @@ module.exports = __toCommonJS(compat_exports);
|
|
24
24
|
var import_hooks = require("./hooks");
|
25
25
|
const compatPlugin = () => ({
|
26
26
|
name: "@modern-js/app-tools-compat",
|
27
|
-
|
27
|
+
_registryApi: (getAppContext, updateAppContext) => {
|
28
|
+
const getInternalContext = () => {
|
29
|
+
return getAppContext()._internalContext;
|
30
|
+
};
|
28
31
|
return {
|
29
32
|
useAppContext: () => {
|
30
|
-
return
|
33
|
+
return getAppContext();
|
31
34
|
},
|
32
|
-
setAppContext: (
|
33
|
-
return updateAppContext(
|
35
|
+
setAppContext: (context) => {
|
36
|
+
return updateAppContext(context);
|
34
37
|
},
|
35
38
|
useConfigContext: () => {
|
36
|
-
return
|
39
|
+
return getInternalContext().config;
|
37
40
|
},
|
38
41
|
useResolvedConfigContext: () => {
|
39
|
-
return
|
42
|
+
return getInternalContext().normalizedConfig;
|
40
43
|
},
|
41
44
|
useHookRunners: () => {
|
42
|
-
return (0, import_hooks.getHookRunners)(
|
45
|
+
return (0, import_hooks.getHookRunners)(getInternalContext());
|
43
46
|
}
|
44
47
|
};
|
45
48
|
},
|
package/dist/cjs/new/context.js
CHANGED
@@ -33,7 +33,7 @@ __export(context_exports, {
|
|
33
33
|
module.exports = __toCommonJS(context_exports);
|
34
34
|
var import_path = __toESM(require("path"));
|
35
35
|
var import_utils = require("@modern-js/utils");
|
36
|
-
const initAppContext = ({ appDirectory, runtimeConfigFile, options, serverConfigFile }) => {
|
36
|
+
const initAppContext = ({ appDirectory, runtimeConfigFile, options, serverConfigFile, tempDir }) => {
|
37
37
|
const { metaName = "modern-js", apiDir = "api", distDir = "", sharedDir = "shared" } = options || {};
|
38
38
|
return {
|
39
39
|
metaName,
|
@@ -47,7 +47,7 @@ const initAppContext = ({ appDirectory, runtimeConfigFile, options, serverConfig
|
|
47
47
|
sharedDirectory: import_path.default.resolve(appDirectory, sharedDir),
|
48
48
|
distDirectory: distDir,
|
49
49
|
serverPlugins: [],
|
50
|
-
internalDirectory: import_path.default.resolve(appDirectory, `./node_modules/.${metaName}`),
|
50
|
+
internalDirectory: import_path.default.resolve(appDirectory, tempDir || `./node_modules/.${metaName}`),
|
51
51
|
htmlTemplates: {},
|
52
52
|
serverRoutes: [],
|
53
53
|
entrypoints: [],
|
package/dist/cjs/new/index.js
CHANGED
@@ -59,12 +59,15 @@ const appTools = (options = {
|
|
59
59
|
addRuntimeExports: (0, import_plugin_v2.createAsyncHook)()
|
60
60
|
},
|
61
61
|
setup: (api) => {
|
62
|
+
var _userConfig_output;
|
62
63
|
const context = api.getAppContext();
|
64
|
+
const userConfig = api.getConfig();
|
63
65
|
api.updateAppContext((0, import_context.initAppContext)({
|
64
66
|
appDirectory: context.appDirectory,
|
65
67
|
options: {},
|
66
68
|
serverConfigFile: import_constants.DEFAULT_SERVER_CONFIG_FILE,
|
67
|
-
runtimeConfigFile: import_constants.DEFAULT_RUNTIME_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
|
68
71
|
}));
|
69
72
|
}
|
70
73
|
});
|
@@ -39,9 +39,9 @@ const resolveCliPlugin = async (p, appDirectory) => {
|
|
39
39
|
}
|
40
40
|
return module2;
|
41
41
|
};
|
42
|
-
const loadInternalPlugins = async (appDirectory, internalPlugins, autoLoad, autoLoadPlugins
|
42
|
+
const loadInternalPlugins = async (appDirectory, internalPlugins, autoLoad, autoLoadPlugins) => {
|
43
43
|
const plugins = [
|
44
|
-
...
|
44
|
+
...autoLoadPlugins ? (0, import_utils.getInternalPlugins)(appDirectory, internalPlugins) : [],
|
45
45
|
...autoLoad ? (0, import_utils.getInternalPlugins)(appDirectory, autoLoad) : []
|
46
46
|
];
|
47
47
|
const loadedPlugins = await Promise.all(plugins.map((plugin) => {
|
package/dist/cjs/new/run.js
CHANGED
@@ -29,7 +29,7 @@ var import_constants = require("./constants");
|
|
29
29
|
var import_getConfigFile = require("./getConfigFile");
|
30
30
|
var import_loadPlugins = require("./loadPlugins");
|
31
31
|
var import_utils2 = require("./utils");
|
32
|
-
async function run({ cwd, initialLog, version, internalPlugins,
|
32
|
+
async function run({ cwd, initialLog, version, internalPlugins, packageJsonConfig, configFile }) {
|
33
33
|
const command = process.argv[2];
|
34
34
|
const cliParams = (0, import_utils.minimist)(process.argv.slice(2));
|
35
35
|
const SUPPORT_CONFIG_PARAM_COMMANDS = [
|
@@ -49,12 +49,13 @@ async function run({ cwd, initialLog, version, internalPlugins, forceAutoLoadPlu
|
|
49
49
|
customConfigFile = cliParams["config-file"];
|
50
50
|
}
|
51
51
|
const appDirectory = await (0, import_cli.initAppDir)(cwd);
|
52
|
-
const
|
53
|
-
const
|
52
|
+
const finalConfigFile = customConfigFile || (0, import_getConfigFile.getConfigFile)(configFile);
|
53
|
+
const autoLoadPlugins = await (0, import_utils2.getIsAutoLoadPlugins)(appDirectory, finalConfigFile);
|
54
|
+
const plugins = await (0, import_loadPlugins.loadInternalPlugins)(appDirectory, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.cli, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.autoLoad, autoLoadPlugins);
|
54
55
|
await (0, import_run.run)({
|
55
56
|
cwd,
|
56
57
|
initialLog: initialLog || `Modern.js Framework v${version}`,
|
57
|
-
configFile:
|
58
|
+
configFile: finalConfigFile,
|
58
59
|
packageJsonConfig: packageJsonConfig || import_constants.PACKAGE_JSON_CONFIG_NAME,
|
59
60
|
internalPlugins: plugins,
|
60
61
|
handleSetupResult: import_hooks.handleSetupResult
|
@@ -21,7 +21,7 @@ __export(restart_exports, {
|
|
21
21
|
restart: () => restart
|
22
22
|
});
|
23
23
|
module.exports = __toCommonJS(restart_exports);
|
24
|
-
var
|
24
|
+
var import_cli = require("@modern-js/plugin-v2/cli");
|
25
25
|
var import_utils = require("@modern-js/utils");
|
26
26
|
async function restart(hooksRunner, filename) {
|
27
27
|
(0, import_utils.clearConsole)();
|
@@ -30,7 +30,7 @@ async function restart(hooksRunner, filename) {
|
|
30
30
|
let hasGetError = false;
|
31
31
|
await hooksRunner.beforeRestart();
|
32
32
|
try {
|
33
|
-
await
|
33
|
+
await import_cli.cli.init(import_cli.cli.getPrevInitOptions());
|
34
34
|
} catch (err) {
|
35
35
|
console.error(err);
|
36
36
|
hasGetError = true;
|
package/dist/esm/index.js
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
import { appTools } from "./new/index";
|
2
|
-
|
2
|
+
import { appTools as appTools2, initAppContext } from "./new/index";
|
3
3
|
import { dev } from "./commands/dev";
|
4
4
|
import { mergeConfig } from "@modern-js/core";
|
5
|
-
|
5
|
+
import { defineConfig, defineLegacyConfig } from "./defineConfig";
|
6
6
|
export * from "./types";
|
7
7
|
var src_default = appTools;
|
8
8
|
export {
|
9
|
+
appTools2 as appTools,
|
9
10
|
src_default as default,
|
11
|
+
defineConfig,
|
12
|
+
defineLegacyConfig,
|
10
13
|
dev,
|
14
|
+
initAppContext,
|
11
15
|
mergeConfig
|
12
16
|
};
|
@@ -290,22 +290,32 @@ function getHookRunners(context) {
|
|
290
290
|
return _ref.apply(this, arguments);
|
291
291
|
};
|
292
292
|
}(),
|
293
|
-
beforeDeploy:
|
294
|
-
|
295
|
-
return
|
296
|
-
|
297
|
-
|
298
|
-
|
293
|
+
beforeDeploy: function() {
|
294
|
+
var _ref = _async_to_generator(function(options) {
|
295
|
+
return _ts_generator(this, function(_state) {
|
296
|
+
return [
|
297
|
+
2,
|
298
|
+
hooks.onBeforeDeploy.call(options)
|
299
|
+
];
|
300
|
+
});
|
299
301
|
});
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
302
|
+
return function(options) {
|
303
|
+
return _ref.apply(this, arguments);
|
304
|
+
};
|
305
|
+
}(),
|
306
|
+
afterDeploy: function() {
|
307
|
+
var _ref = _async_to_generator(function(options) {
|
308
|
+
return _ts_generator(this, function(_state) {
|
309
|
+
return [
|
310
|
+
2,
|
311
|
+
hooks.onAfterDeploy.call(options)
|
312
|
+
];
|
313
|
+
});
|
307
314
|
});
|
308
|
-
|
315
|
+
return function(options) {
|
316
|
+
return _ref.apply(this, arguments);
|
317
|
+
};
|
318
|
+
}(),
|
309
319
|
beforeExit: /* @__PURE__ */ _async_to_generator(function() {
|
310
320
|
return _ts_generator(this, function(_state) {
|
311
321
|
return [
|
@@ -2,22 +2,25 @@ import { getHookRunners } from "./hooks";
|
|
2
2
|
var compatPlugin = function() {
|
3
3
|
return {
|
4
4
|
name: "@modern-js/app-tools-compat",
|
5
|
-
|
5
|
+
_registryApi: function(getAppContext, updateAppContext) {
|
6
|
+
var getInternalContext = function() {
|
7
|
+
return getAppContext()._internalContext;
|
8
|
+
};
|
6
9
|
return {
|
7
10
|
useAppContext: function() {
|
8
|
-
return
|
11
|
+
return getAppContext();
|
9
12
|
},
|
10
|
-
setAppContext: function(
|
11
|
-
return updateAppContext(
|
13
|
+
setAppContext: function(context) {
|
14
|
+
return updateAppContext(context);
|
12
15
|
},
|
13
16
|
useConfigContext: function() {
|
14
|
-
return
|
17
|
+
return getInternalContext().config;
|
15
18
|
},
|
16
19
|
useResolvedConfigContext: function() {
|
17
|
-
return
|
20
|
+
return getInternalContext().normalizedConfig;
|
18
21
|
},
|
19
22
|
useHookRunners: function() {
|
20
|
-
return getHookRunners(
|
23
|
+
return getHookRunners(getInternalContext());
|
21
24
|
}
|
22
25
|
};
|
23
26
|
},
|
package/dist/esm/new/context.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import path from "path";
|
2
2
|
import { address } from "@modern-js/utils";
|
3
3
|
var initAppContext = function(param) {
|
4
|
-
var appDirectory = param.appDirectory, runtimeConfigFile = param.runtimeConfigFile, options = param.options, serverConfigFile = param.serverConfigFile;
|
4
|
+
var appDirectory = param.appDirectory, runtimeConfigFile = param.runtimeConfigFile, options = param.options, serverConfigFile = param.serverConfigFile, tempDir = param.tempDir;
|
5
5
|
var _ref = options || {}, _ref_metaName = _ref.metaName, metaName = _ref_metaName === void 0 ? "modern-js" : _ref_metaName, _ref_apiDir = _ref.apiDir, apiDir = _ref_apiDir === void 0 ? "api" : _ref_apiDir, _ref_distDir = _ref.distDir, distDir = _ref_distDir === void 0 ? "" : _ref_distDir, _ref_sharedDir = _ref.sharedDir, sharedDir = _ref_sharedDir === void 0 ? "shared" : _ref_sharedDir;
|
6
6
|
return {
|
7
7
|
metaName,
|
@@ -15,7 +15,7 @@ var initAppContext = function(param) {
|
|
15
15
|
sharedDirectory: path.resolve(appDirectory, sharedDir),
|
16
16
|
distDirectory: distDir,
|
17
17
|
serverPlugins: [],
|
18
|
-
internalDirectory: path.resolve(appDirectory, "./node_modules/.".concat(metaName)),
|
18
|
+
internalDirectory: path.resolve(appDirectory, tempDir || "./node_modules/.".concat(metaName)),
|
19
19
|
htmlTemplates: {},
|
20
20
|
serverRoutes: [],
|
21
21
|
entrypoints: [],
|
package/dist/esm/new/index.js
CHANGED
@@ -36,12 +36,15 @@ var appTools = function() {
|
|
36
36
|
addRuntimeExports: createAsyncHook()
|
37
37
|
},
|
38
38
|
setup: function(api) {
|
39
|
+
var _userConfig_output;
|
39
40
|
var context = api.getAppContext();
|
41
|
+
var userConfig = api.getConfig();
|
40
42
|
api.updateAppContext(initAppContext({
|
41
43
|
appDirectory: context.appDirectory,
|
42
44
|
options: {},
|
43
45
|
serverConfigFile: DEFAULT_SERVER_CONFIG_FILE,
|
44
|
-
runtimeConfigFile: DEFAULT_RUNTIME_CONFIG_FILE
|
46
|
+
runtimeConfigFile: DEFAULT_RUNTIME_CONFIG_FILE,
|
47
|
+
tempDir: (_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir
|
45
48
|
}));
|
46
49
|
}
|
47
50
|
};
|
@@ -62,12 +62,12 @@ var resolveCliPlugin = function() {
|
|
62
62
|
};
|
63
63
|
}();
|
64
64
|
var loadInternalPlugins = function() {
|
65
|
-
var _ref = _async_to_generator(function(appDirectory, internalPlugins, autoLoad, autoLoadPlugins
|
65
|
+
var _ref = _async_to_generator(function(appDirectory, internalPlugins, autoLoad, autoLoadPlugins) {
|
66
66
|
var plugins, loadedPlugins;
|
67
67
|
return _ts_generator(this, function(_state) {
|
68
68
|
switch (_state.label) {
|
69
69
|
case 0:
|
70
|
-
plugins = _to_consumable_array(
|
70
|
+
plugins = _to_consumable_array(autoLoadPlugins ? getInternalPlugins(appDirectory, internalPlugins) : []).concat(_to_consumable_array(autoLoad ? getInternalPlugins(appDirectory, autoLoad) : []));
|
71
71
|
return [
|
72
72
|
4,
|
73
73
|
Promise.all(plugins.map(function(plugin) {
|
@@ -85,7 +85,7 @@ var loadInternalPlugins = function() {
|
|
85
85
|
}
|
86
86
|
});
|
87
87
|
});
|
88
|
-
return function loadInternalPlugins2(appDirectory, internalPlugins, autoLoad, autoLoadPlugins
|
88
|
+
return function loadInternalPlugins2(appDirectory, internalPlugins, autoLoad, autoLoadPlugins) {
|
89
89
|
return _ref.apply(this, arguments);
|
90
90
|
};
|
91
91
|
}();
|
package/dist/esm/new/run.js
CHANGED
@@ -13,11 +13,11 @@ function run(_) {
|
|
13
13
|
}
|
14
14
|
function _run() {
|
15
15
|
_run = _async_to_generator(function(param) {
|
16
|
-
var cwd, initialLog, version, internalPlugins,
|
16
|
+
var cwd, initialLog, version, internalPlugins, packageJsonConfig, configFile, command, cliParams, SUPPORT_CONFIG_PARAM_COMMANDS, customConfigFile, appDirectory, finalConfigFile, autoLoadPlugins, plugins;
|
17
17
|
return _ts_generator(this, function(_state) {
|
18
18
|
switch (_state.label) {
|
19
19
|
case 0:
|
20
|
-
cwd = param.cwd, initialLog = param.initialLog, version = param.version, internalPlugins = param.internalPlugins,
|
20
|
+
cwd = param.cwd, initialLog = param.initialLog, version = param.version, internalPlugins = param.internalPlugins, packageJsonConfig = param.packageJsonConfig, configFile = param.configFile;
|
21
21
|
command = process.argv[2];
|
22
22
|
cliParams = minimist(process.argv.slice(2));
|
23
23
|
SUPPORT_CONFIG_PARAM_COMMANDS = [
|
@@ -41,15 +41,16 @@ function _run() {
|
|
41
41
|
];
|
42
42
|
case 1:
|
43
43
|
appDirectory = _state.sent();
|
44
|
+
finalConfigFile = customConfigFile || getConfigFile(configFile);
|
44
45
|
return [
|
45
46
|
4,
|
46
|
-
getIsAutoLoadPlugins(appDirectory,
|
47
|
+
getIsAutoLoadPlugins(appDirectory, finalConfigFile)
|
47
48
|
];
|
48
49
|
case 2:
|
49
50
|
autoLoadPlugins = _state.sent();
|
50
51
|
return [
|
51
52
|
4,
|
52
|
-
loadInternalPlugins(appDirectory, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.cli, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.autoLoad, autoLoadPlugins
|
53
|
+
loadInternalPlugins(appDirectory, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.cli, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.autoLoad, autoLoadPlugins)
|
53
54
|
];
|
54
55
|
case 3:
|
55
56
|
plugins = _state.sent();
|
@@ -58,7 +59,7 @@ function _run() {
|
|
58
59
|
CLIPluginRun({
|
59
60
|
cwd,
|
60
61
|
initialLog: initialLog || "Modern.js Framework v".concat(version),
|
61
|
-
configFile:
|
62
|
+
configFile: finalConfigFile,
|
62
63
|
packageJsonConfig: packageJsonConfig || PACKAGE_JSON_CONFIG_NAME,
|
63
64
|
internalPlugins: plugins,
|
64
65
|
handleSetupResult
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
3
|
-
import { cli } from "@modern-js/
|
3
|
+
import { cli } from "@modern-js/plugin-v2/cli";
|
4
4
|
import { chalk, clearConsole, getFullArgv, logger, program } from "@modern-js/utils";
|
5
5
|
function restart(hooksRunner, filename) {
|
6
6
|
return _restart.apply(this, arguments);
|
package/dist/esm-node/index.js
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
import { appTools } from "./new/index";
|
2
|
-
|
2
|
+
import { appTools as appTools2, initAppContext } from "./new/index";
|
3
3
|
import { dev } from "./commands/dev";
|
4
4
|
import { mergeConfig } from "@modern-js/core";
|
5
|
-
|
5
|
+
import { defineConfig, defineLegacyConfig } from "./defineConfig";
|
6
6
|
export * from "./types";
|
7
7
|
var src_default = appTools;
|
8
8
|
export {
|
9
|
+
appTools2 as appTools,
|
9
10
|
src_default as default,
|
11
|
+
defineConfig,
|
12
|
+
defineLegacyConfig,
|
10
13
|
dev,
|
14
|
+
initAppContext,
|
11
15
|
mergeConfig
|
12
16
|
};
|
@@ -83,11 +83,11 @@ function getHookRunners(context) {
|
|
83
83
|
afterDev: async (params) => {
|
84
84
|
return hooks.onAfterDev.call(params);
|
85
85
|
},
|
86
|
-
beforeDeploy: async () => {
|
87
|
-
return hooks.onBeforeDeploy.call();
|
86
|
+
beforeDeploy: async (options) => {
|
87
|
+
return hooks.onBeforeDeploy.call(options);
|
88
88
|
},
|
89
|
-
afterDeploy: async () => {
|
90
|
-
return hooks.onAfterDeploy.call();
|
89
|
+
afterDeploy: async (options) => {
|
90
|
+
return hooks.onAfterDeploy.call(options);
|
91
91
|
},
|
92
92
|
beforeExit: async () => {
|
93
93
|
return hooks.onBeforeExit.call();
|
@@ -1,22 +1,25 @@
|
|
1
1
|
import { getHookRunners } from "./hooks";
|
2
2
|
const compatPlugin = () => ({
|
3
3
|
name: "@modern-js/app-tools-compat",
|
4
|
-
|
4
|
+
_registryApi: (getAppContext, updateAppContext) => {
|
5
|
+
const getInternalContext = () => {
|
6
|
+
return getAppContext()._internalContext;
|
7
|
+
};
|
5
8
|
return {
|
6
9
|
useAppContext: () => {
|
7
|
-
return
|
10
|
+
return getAppContext();
|
8
11
|
},
|
9
|
-
setAppContext: (
|
10
|
-
return updateAppContext(
|
12
|
+
setAppContext: (context) => {
|
13
|
+
return updateAppContext(context);
|
11
14
|
},
|
12
15
|
useConfigContext: () => {
|
13
|
-
return
|
16
|
+
return getInternalContext().config;
|
14
17
|
},
|
15
18
|
useResolvedConfigContext: () => {
|
16
|
-
return
|
19
|
+
return getInternalContext().normalizedConfig;
|
17
20
|
},
|
18
21
|
useHookRunners: () => {
|
19
|
-
return getHookRunners(
|
22
|
+
return getHookRunners(getInternalContext());
|
20
23
|
}
|
21
24
|
};
|
22
25
|
},
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import path from "path";
|
2
2
|
import { address } from "@modern-js/utils";
|
3
|
-
const initAppContext = ({ appDirectory, runtimeConfigFile, options, serverConfigFile }) => {
|
3
|
+
const initAppContext = ({ appDirectory, runtimeConfigFile, options, serverConfigFile, tempDir }) => {
|
4
4
|
const { metaName = "modern-js", apiDir = "api", distDir = "", sharedDir = "shared" } = options || {};
|
5
5
|
return {
|
6
6
|
metaName,
|
@@ -14,7 +14,7 @@ const initAppContext = ({ appDirectory, runtimeConfigFile, options, serverConfig
|
|
14
14
|
sharedDirectory: path.resolve(appDirectory, sharedDir),
|
15
15
|
distDirectory: distDir,
|
16
16
|
serverPlugins: [],
|
17
|
-
internalDirectory: path.resolve(appDirectory, `./node_modules/.${metaName}`),
|
17
|
+
internalDirectory: path.resolve(appDirectory, tempDir || `./node_modules/.${metaName}`),
|
18
18
|
htmlTemplates: {},
|
19
19
|
serverRoutes: [],
|
20
20
|
entrypoints: [],
|
@@ -34,12 +34,15 @@ const appTools = (options = {
|
|
34
34
|
addRuntimeExports: createAsyncHook()
|
35
35
|
},
|
36
36
|
setup: (api) => {
|
37
|
+
var _userConfig_output;
|
37
38
|
const context = api.getAppContext();
|
39
|
+
const userConfig = api.getConfig();
|
38
40
|
api.updateAppContext(initAppContext({
|
39
41
|
appDirectory: context.appDirectory,
|
40
42
|
options: {},
|
41
43
|
serverConfigFile: DEFAULT_SERVER_CONFIG_FILE,
|
42
|
-
runtimeConfigFile: DEFAULT_RUNTIME_CONFIG_FILE
|
44
|
+
runtimeConfigFile: DEFAULT_RUNTIME_CONFIG_FILE,
|
45
|
+
tempDir: (_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir
|
43
46
|
}));
|
44
47
|
}
|
45
48
|
});
|
@@ -16,9 +16,9 @@ const resolveCliPlugin = async (p, appDirectory) => {
|
|
16
16
|
}
|
17
17
|
return module;
|
18
18
|
};
|
19
|
-
const loadInternalPlugins = async (appDirectory, internalPlugins, autoLoad, autoLoadPlugins
|
19
|
+
const loadInternalPlugins = async (appDirectory, internalPlugins, autoLoad, autoLoadPlugins) => {
|
20
20
|
const plugins = [
|
21
|
-
...
|
21
|
+
...autoLoadPlugins ? getInternalPlugins(appDirectory, internalPlugins) : [],
|
22
22
|
...autoLoad ? getInternalPlugins(appDirectory, autoLoad) : []
|
23
23
|
];
|
24
24
|
const loadedPlugins = await Promise.all(plugins.map((plugin) => {
|
package/dist/esm-node/new/run.js
CHANGED
@@ -6,7 +6,7 @@ import { PACKAGE_JSON_CONFIG_NAME } from "./constants";
|
|
6
6
|
import { getConfigFile } from "./getConfigFile";
|
7
7
|
import { loadInternalPlugins } from "./loadPlugins";
|
8
8
|
import { getIsAutoLoadPlugins } from "./utils";
|
9
|
-
async function run({ cwd, initialLog, version, internalPlugins,
|
9
|
+
async function run({ cwd, initialLog, version, internalPlugins, packageJsonConfig, configFile }) {
|
10
10
|
const command = process.argv[2];
|
11
11
|
const cliParams = minimist(process.argv.slice(2));
|
12
12
|
const SUPPORT_CONFIG_PARAM_COMMANDS = [
|
@@ -26,12 +26,13 @@ async function run({ cwd, initialLog, version, internalPlugins, forceAutoLoadPlu
|
|
26
26
|
customConfigFile = cliParams["config-file"];
|
27
27
|
}
|
28
28
|
const appDirectory = await initAppDir(cwd);
|
29
|
-
const
|
30
|
-
const
|
29
|
+
const finalConfigFile = customConfigFile || getConfigFile(configFile);
|
30
|
+
const autoLoadPlugins = await getIsAutoLoadPlugins(appDirectory, finalConfigFile);
|
31
|
+
const plugins = await loadInternalPlugins(appDirectory, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.cli, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.autoLoad, autoLoadPlugins);
|
31
32
|
await CLIPluginRun({
|
32
33
|
cwd,
|
33
34
|
initialLog: initialLog || `Modern.js Framework v${version}`,
|
34
|
-
configFile:
|
35
|
+
configFile: finalConfigFile,
|
35
36
|
packageJsonConfig: packageJsonConfig || PACKAGE_JSON_CONFIG_NAME,
|
36
37
|
internalPlugins: plugins,
|
37
38
|
handleSetupResult
|
package/dist/types/index.d.ts
CHANGED
@@ -1,16 +1,9 @@
|
|
1
1
|
import { appTools } from './new/index';
|
2
|
-
export
|
2
|
+
export { appTools, initAppContext, type AppToolsPlugin } from './new/index';
|
3
3
|
export { dev } from './commands/dev';
|
4
4
|
export type { DevOptions } from './utils/types';
|
5
5
|
export { mergeConfig } from '@modern-js/core';
|
6
|
-
export
|
6
|
+
export { defineConfig, defineLegacyConfig } from './defineConfig';
|
7
7
|
export * from './types';
|
8
8
|
export type { RuntimeUserConfig } from './types/config';
|
9
|
-
export type AppToolsOptions = {
|
10
|
-
/**
|
11
|
-
* Specify which bundler to use for the build.
|
12
|
-
* @default `webpack`
|
13
|
-
* */
|
14
|
-
bundler?: 'rspack' | 'webpack' | 'experimental-rspack';
|
15
|
-
};
|
16
9
|
export default appTools;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { InternalContext } from '@modern-js/plugin-v2';
|
1
|
+
import type { InternalContext } from '@modern-js/plugin-v2/types';
|
2
2
|
import type { AppToolsNormalizedConfig, AppToolsUserConfig } from '../../types';
|
3
3
|
import type { AppToolsExtendAPIName } from '../types';
|
4
4
|
/**
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { InternalContext, Plugin } from '@modern-js/plugin-v2';
|
1
|
+
import type { InternalContext, Plugin } from '@modern-js/plugin-v2/types';
|
2
2
|
import type { AppToolsNormalizedConfig, AppToolsUserConfig } from '../../types/config';
|
3
3
|
import type { AppTools, AppToolsExtendAPIName } from '../types';
|
4
4
|
export declare const compatPlugin: () => Plugin<AppTools<'shared'>, InternalContext<AppToolsUserConfig<'shared'>, AppToolsNormalizedConfig, AppToolsExtendAPIName<'shared'>>>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export declare const initAppContext: ({ appDirectory, runtimeConfigFile, options, serverConfigFile, }: {
|
1
|
+
export declare const initAppContext: ({ appDirectory, runtimeConfigFile, options, serverConfigFile, tempDir, }: {
|
2
2
|
appDirectory: string;
|
3
3
|
runtimeConfigFile: string | false;
|
4
4
|
options?: {
|
@@ -9,6 +9,7 @@ export declare const initAppContext: ({ appDirectory, runtimeConfigFile, options
|
|
9
9
|
sharedDir?: string | undefined;
|
10
10
|
} | undefined;
|
11
11
|
serverConfigFile: string;
|
12
|
+
tempDir?: string | undefined;
|
12
13
|
}) => {
|
13
14
|
metaName: string;
|
14
15
|
runtimeConfigFile: string | false;
|
@@ -1,15 +1,9 @@
|
|
1
|
-
import type { InternalContext, Plugin } from '@modern-js/plugin-v2';
|
1
|
+
import type { InternalContext, Plugin } from '@modern-js/plugin-v2/types';
|
2
|
+
import { type AppToolsOptions } from '../old';
|
2
3
|
import type { AppToolsNormalizedConfig, AppToolsUserConfig } from '../types';
|
3
4
|
import { initAppContext } from './context';
|
4
5
|
import type { AppTools, AppToolsExtendAPIName } from './types';
|
5
6
|
export * from '../defineConfig';
|
6
7
|
export { initAppContext };
|
7
|
-
export type AppToolsOptions = {
|
8
|
-
/**
|
9
|
-
* Specify which bundler to use for the build.
|
10
|
-
* @default `webpack`
|
11
|
-
* */
|
12
|
-
bundler?: 'rspack' | 'webpack' | 'experimental-rspack';
|
13
|
-
};
|
14
8
|
export type AppToolsPlugin = Plugin<AppTools<'shared'>, InternalContext<AppToolsUserConfig<'shared'>, AppToolsNormalizedConfig, AppToolsExtendAPIName<'shared'>>>;
|
15
9
|
export declare const appTools: (options?: AppToolsOptions) => AppToolsPlugin;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { Plugin } from '@modern-js/plugin-v2';
|
1
|
+
import type { Plugin } from '@modern-js/plugin-v2/types';
|
2
2
|
import type { InternalPlugins } from '@modern-js/types';
|
3
3
|
/**
|
4
4
|
* Load internal plugins which in @modern-js scope and user's custom plugins.
|
@@ -6,4 +6,4 @@ import type { InternalPlugins } from '@modern-js/types';
|
|
6
6
|
* @param internalPlugins - Internal plugins.
|
7
7
|
* @returns Plugin Objects has been required.
|
8
8
|
*/
|
9
|
-
export declare const loadInternalPlugins: (appDirectory: string, internalPlugins?: InternalPlugins, autoLoad?: InternalPlugins, autoLoadPlugins?: boolean
|
9
|
+
export declare const loadInternalPlugins: (appDirectory: string, internalPlugins?: InternalPlugins, autoLoad?: InternalPlugins, autoLoadPlugins?: boolean) => Promise<Plugin[]>;
|
package/dist/types/new/run.d.ts
CHANGED
@@ -7,8 +7,7 @@ export interface RunOptions {
|
|
7
7
|
cli?: InternalPlugins;
|
8
8
|
autoLoad?: InternalPlugins;
|
9
9
|
};
|
10
|
-
forceAutoLoadPlugins?: boolean;
|
11
10
|
initialLog?: string;
|
12
11
|
version: string;
|
13
12
|
}
|
14
|
-
export declare function run({ cwd, initialLog, version, internalPlugins,
|
13
|
+
export declare function run({ cwd, initialLog, version, internalPlugins, packageJsonConfig, configFile, }: RunOptions): Promise<void>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { DevToolData, RegisterBuildPlatformResult } from '@modern-js/core';
|
2
|
-
import type {
|
3
|
-
import type {
|
2
|
+
import type { AppContext } from '@modern-js/plugin-v2/types';
|
3
|
+
import type { CLIPluginAPI, PluginHookTap, TransformFunction } from '@modern-js/plugin-v2/types';
|
4
4
|
import type { Entrypoint, NestedRouteForCli, PageRoute, RouteLegacy, ServerPlugin, ServerRoute } from '@modern-js/types';
|
5
5
|
import type { AppToolsNormalizedConfig, AppToolsUserConfig } from '../../types/config';
|
6
6
|
import type { RuntimePlugin } from '../../types/hooks';
|
@@ -39,7 +39,7 @@ export type BeforePrintInstructionsFn = TransformFunction<{
|
|
39
39
|
export type RegisterDevFn = () => Promise<DevToolData> | DevToolData;
|
40
40
|
export type RegisterBuildPlatformFn = () => Promise<RegisterBuildPlatformResult> | RegisterBuildPlatformResult;
|
41
41
|
export type AddRuntimeExportsFn = () => Promise<void> | void;
|
42
|
-
|
42
|
+
interface AppToolsExtendAPI<B extends Bundler = 'webpack'> {
|
43
43
|
onBeforeConfig: PluginHookTap<BeforeConfigFn>;
|
44
44
|
onAfterPrepare: PluginHookTap<AfterPrepareFn>;
|
45
45
|
deploy: PluginHookTap<DeplpoyFn>;
|
@@ -84,6 +84,7 @@ export interface AppToolsExtendAPI<B extends Bundler> {
|
|
84
84
|
*/
|
85
85
|
useHookRunners: () => ReturnType<typeof getHookRunners>;
|
86
86
|
}
|
87
|
-
export interface AppTools<B extends Bundler> extends CLIPluginAPI<AppToolsUserConfig<B>, AppToolsNormalizedConfig<AppToolsUserConfig<B>>>, AppToolsExtendAPI<B> {
|
87
|
+
export interface AppTools<B extends Bundler = 'webpack'> extends CLIPluginAPI<AppToolsUserConfig<B>, AppToolsNormalizedConfig<AppToolsUserConfig<B>>>, AppToolsExtendAPI<B> {
|
88
88
|
}
|
89
|
-
export type AppToolsExtendAPIName<B extends Bundler> = keyof AppToolsExtendAPI<B> & string;
|
89
|
+
export type AppToolsExtendAPIName<B extends Bundler = 'webpack'> = keyof AppToolsExtendAPI<B> & string;
|
90
|
+
export {};
|
package/dist/types/old.d.ts
CHANGED
@@ -1,18 +1,11 @@
|
|
1
1
|
import type { CliPlugin } from '@modern-js/core';
|
2
|
-
import type { AppTools } from './types';
|
2
|
+
import type { AppTools, AppToolsOptions } from './types';
|
3
3
|
export { dev } from './commands/dev';
|
4
4
|
export type { DevOptions } from './utils/types';
|
5
5
|
export { mergeConfig } from '@modern-js/core';
|
6
6
|
export * from './defineConfig';
|
7
7
|
export * from './types';
|
8
8
|
export type { RuntimeUserConfig } from './types/config';
|
9
|
-
export type AppToolsOptions = {
|
10
|
-
/**
|
11
|
-
* Specify which bundler to use for the build.
|
12
|
-
* @default `webpack`
|
13
|
-
* */
|
14
|
-
bundler?: 'rspack' | 'webpack' | 'experimental-rspack';
|
15
|
-
};
|
16
9
|
/**
|
17
10
|
* The core package of the framework, providing CLI commands, build capabilities, configuration parsing and more.
|
18
11
|
*/
|
@@ -24,3 +24,10 @@ export type AppNormalizedConfig<B extends Bundler = 'webpack'> = NormalizedConfi
|
|
24
24
|
export type AppLegacyNormalizedConfig = NormalizedConfig<LegacyAppTools>;
|
25
25
|
export type AppUserConfig<B extends Bundler = 'webpack'> = UserConfig<AppTools<B>>;
|
26
26
|
export type AppLegacyUserConfig = UserConfig<LegacyAppTools>;
|
27
|
+
export type AppToolsOptions = {
|
28
|
+
/**
|
29
|
+
* Specify which bundler to use for the build.
|
30
|
+
* @default `webpack`
|
31
|
+
* */
|
32
|
+
bundler?: 'rspack' | 'webpack' | 'experimental-rspack';
|
33
|
+
};
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.62.
|
18
|
+
"version": "2.62.2-alpha.0",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -96,20 +96,20 @@
|
|
96
96
|
"mlly": "^1.6.1",
|
97
97
|
"pkg-types": "^1.1.0",
|
98
98
|
"std-env": "^3.7.0",
|
99
|
-
"@modern-js/plugin": "2.62.0",
|
100
99
|
"@modern-js/plugin-v2": "2.60.6",
|
101
|
-
"@modern-js/
|
102
|
-
"@modern-js/plugin
|
103
|
-
"@modern-js/
|
104
|
-
"@modern-js/
|
105
|
-
"@modern-js/server": "2.62.
|
106
|
-
"@modern-js/
|
107
|
-
"@modern-js/
|
108
|
-
"@modern-js/server
|
109
|
-
"@modern-js/
|
110
|
-
"@modern-js/utils": "2.62.
|
111
|
-
"@modern-js/
|
112
|
-
"@modern-js/
|
100
|
+
"@modern-js/core": "2.62.1",
|
101
|
+
"@modern-js/plugin": "2.62.1",
|
102
|
+
"@modern-js/plugin-i18n": "2.62.1",
|
103
|
+
"@modern-js/plugin-data-loader": "2.62.1",
|
104
|
+
"@modern-js/prod-server": "2.62.1",
|
105
|
+
"@modern-js/rsbuild-plugin-esbuild": "2.62.1",
|
106
|
+
"@modern-js/node-bundle-require": "2.62.1",
|
107
|
+
"@modern-js/server": "2.62.1",
|
108
|
+
"@modern-js/uni-builder": "2.62.1",
|
109
|
+
"@modern-js/server-utils": "2.62.1",
|
110
|
+
"@modern-js/server-core": "2.62.1",
|
111
|
+
"@modern-js/utils": "2.62.1",
|
112
|
+
"@modern-js/types": "2.62.1"
|
113
113
|
},
|
114
114
|
"devDependencies": {
|
115
115
|
"@rsbuild/plugin-webpack-swc": "~1.0.3",
|
@@ -121,8 +121,8 @@
|
|
121
121
|
"tsconfig-paths": "^4.2.0",
|
122
122
|
"typescript": "^5",
|
123
123
|
"webpack": "^5.96.1",
|
124
|
-
"@scripts/build": "2.62.
|
125
|
-
"@scripts/jest-config": "2.62.
|
124
|
+
"@scripts/build": "2.62.1",
|
125
|
+
"@scripts/jest-config": "2.62.1"
|
126
126
|
},
|
127
127
|
"peerDependencies": {
|
128
128
|
"ts-node": "^10.7.0",
|