@modern-js/app-tools 2.65.5 → 2.67.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.
Files changed (55) hide show
  1. package/dist/cjs/builder/generator/index.js +1 -1
  2. package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +8 -1
  3. package/dist/cjs/constants.js +5 -2
  4. package/dist/cjs/index.js +1 -1
  5. package/dist/cjs/run/index.js +31 -4
  6. package/dist/cjs/utils/{isAutoLoadPlugins.js → getUserConfig.js} +9 -10
  7. package/dist/cjs/utils/initAppContext.js +2 -3
  8. package/dist/esm/builder/generator/index.js +1 -1
  9. package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +8 -1
  10. package/dist/esm/constants.js +3 -1
  11. package/dist/esm/index.js +1 -1
  12. package/dist/esm/run/index.js +17 -8
  13. package/dist/esm/utils/getUserConfig.js +32 -0
  14. package/dist/esm/utils/initAppContext.js +2 -3
  15. package/dist/esm-node/builder/generator/index.js +1 -1
  16. package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +8 -1
  17. package/dist/esm-node/constants.js +3 -1
  18. package/dist/esm-node/index.js +1 -1
  19. package/dist/esm-node/run/index.js +23 -6
  20. package/dist/esm-node/utils/getUserConfig.js +10 -0
  21. package/dist/esm-node/utils/initAppContext.js +2 -3
  22. package/dist/types/builder/generator/createCopyPattern.d.ts +0 -1
  23. package/dist/types/builder/shared/builderPlugins/adapterBasic.d.ts +3 -1
  24. package/dist/types/commands/build.d.ts +1 -1
  25. package/dist/types/commands/deploy.d.ts +1 -1
  26. package/dist/types/commands/dev.d.ts +1 -1
  27. package/dist/types/commands/index.d.ts +5 -5
  28. package/dist/types/commands/inspect.d.ts +1 -1
  29. package/dist/types/commands/serve.d.ts +1 -1
  30. package/dist/types/compat/index.d.ts +1 -1
  31. package/dist/types/constants.d.ts +1 -0
  32. package/dist/types/defineConfig.d.ts +1 -1
  33. package/dist/types/exports/server.d.ts +1 -1
  34. package/dist/types/index.d.ts +1 -1
  35. package/dist/types/plugins/analyze/getBundleEntry.d.ts +1 -1
  36. package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +1 -1
  37. package/dist/types/plugins/analyze/getHtmlTemplate.d.ts +3 -3
  38. package/dist/types/plugins/analyze/getServerRoutes.d.ts +2 -2
  39. package/dist/types/plugins/analyze/index.d.ts +2 -2
  40. package/dist/types/plugins/analyze/utils.d.ts +1 -1
  41. package/dist/types/plugins/deploy/index.d.ts +1 -1
  42. package/dist/types/plugins/deploy/utils.d.ts +1 -1
  43. package/dist/types/plugins/initialize/index.d.ts +2 -2
  44. package/dist/types/plugins/serverBuild.d.ts +1 -1
  45. package/dist/types/run/index.d.ts +2 -1
  46. package/dist/types/utils/config.d.ts +2 -2
  47. package/dist/types/utils/createServer.d.ts +0 -1
  48. package/dist/types/utils/getUserConfig.d.ts +6 -0
  49. package/dist/types/utils/initAppContext.d.ts +8 -9
  50. package/dist/types/utils/printInstructions.d.ts +1 -1
  51. package/dist/types/utils/routes.d.ts +1 -1
  52. package/package.json +20 -20
  53. package/dist/esm/utils/isAutoLoadPlugins.js +0 -32
  54. package/dist/esm-node/utils/isAutoLoadPlugins.js +0 -11
  55. package/dist/types/utils/isAutoLoadPlugins.d.ts +0 -1
@@ -55,7 +55,7 @@ async function generateBuilder(options, bundlerType) {
55
55
  async function applyBuilderPlugins(builder, options) {
56
56
  const { builderPluginAdapterBasic, builderPluginAdapterHtml, builderPluginAdapterSSR, builderPluginAdapterHooks } = await import("../shared/builderPlugins/index.js");
57
57
  builder.addPlugins([
58
- builderPluginAdapterBasic(),
58
+ builderPluginAdapterBasic(options),
59
59
  builderPluginAdapterSSR(options),
60
60
  builderPluginAdapterHtml(options),
61
61
  builderPluginAdapterHooks(options)
@@ -33,7 +33,7 @@ __export(adapterBasic_exports, {
33
33
  module.exports = __toCommonJS(adapterBasic_exports);
34
34
  var import_path = __toESM(require("path"));
35
35
  var import_uni_builder = require("@modern-js/uni-builder");
36
- const builderPluginAdapterBasic = () => ({
36
+ const builderPluginAdapterBasic = (options) => ({
37
37
  name: "builder-plugin-adapter-modern-basic",
38
38
  setup(api) {
39
39
  api.modifyBundlerChain((chain, { target, CHAIN_ID, environment }) => {
@@ -46,7 +46,14 @@ const builderPluginAdapterBasic = () => ({
46
46
  chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
47
47
  chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
48
48
  }
49
+ const { appContext } = options;
50
+ const { metaName } = appContext;
49
51
  chain.resolve.modules.add("node_modules").add(import_path.default.join(api.context.rootPath, "node_modules"));
52
+ chain.watchOptions({
53
+ ignored: [
54
+ `[\\\\/](?:node_modules(?![\\\\/]\\.${metaName})|.git)[\\\\/]`
55
+ ]
56
+ });
50
57
  });
51
58
  }
52
59
  });
@@ -21,10 +21,12 @@ __export(constants_exports, {
21
21
  DEFAULT_CONFIG_FILE: () => DEFAULT_CONFIG_FILE,
22
22
  DEFAULT_RUNTIME_CONFIG_FILE: () => DEFAULT_RUNTIME_CONFIG_FILE,
23
23
  DEFAULT_SERVER_CONFIG_FILE: () => DEFAULT_SERVER_CONFIG_FILE,
24
- PACKAGE_JSON_CONFIG_NAME: () => PACKAGE_JSON_CONFIG_NAME
24
+ PACKAGE_JSON_CONFIG_NAME: () => PACKAGE_JSON_CONFIG_NAME,
25
+ STATE_PLUGIN_NAME: () => STATE_PLUGIN_NAME
25
26
  });
26
27
  module.exports = __toCommonJS(constants_exports);
27
28
  const PACKAGE_JSON_CONFIG_NAME = "modernConfig";
29
+ const STATE_PLUGIN_NAME = "@modern-js/plugin-state";
28
30
  const DEFAULT_CONFIG_FILE = "modern.config";
29
31
  const DEFAULT_SERVER_CONFIG_FILE = "modern.server-runtime.config";
30
32
  const DEFAULT_RUNTIME_CONFIG_FILE = "modern.runtime";
@@ -33,5 +35,6 @@ const DEFAULT_RUNTIME_CONFIG_FILE = "modern.runtime";
33
35
  DEFAULT_CONFIG_FILE,
34
36
  DEFAULT_RUNTIME_CONFIG_FILE,
35
37
  DEFAULT_SERVER_CONFIG_FILE,
36
- PACKAGE_JSON_CONFIG_NAME
38
+ PACKAGE_JSON_CONFIG_NAME,
39
+ STATE_PLUGIN_NAME
37
40
  });
package/dist/cjs/index.js CHANGED
@@ -117,8 +117,8 @@ const appTools = (options = {
117
117
  locale
118
118
  });
119
119
  api.updateAppContext((0, import_initAppContext.initAppContext)({
120
+ metaName: context.metaName,
120
121
  appDirectory: context.appDirectory,
121
- options: {},
122
122
  serverConfigFile: import_constants.DEFAULT_SERVER_CONFIG_FILE,
123
123
  runtimeConfigFile: import_constants.DEFAULT_RUNTIME_CONFIG_FILE,
124
124
  tempDir: (_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,21 +17,31 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var run_exports = {};
20
30
  __export(run_exports, {
21
31
  run: () => run
22
32
  });
23
33
  module.exports = __toCommonJS(run_exports);
34
+ var import_path = __toESM(require("path"));
24
35
  var import_cli = require("@modern-js/plugin-v2/cli");
25
36
  var import_run = require("@modern-js/plugin-v2/run");
26
37
  var import_utils = require("@modern-js/utils");
27
38
  var import_hooks = require("../compat/hooks");
28
39
  var import_constants = require("../constants");
29
40
  var import_getConfigFile = require("../utils/getConfigFile");
30
- var import_isAutoLoadPlugins = require("../utils/isAutoLoadPlugins");
41
+ var import_getUserConfig = require("../utils/getUserConfig");
31
42
  var import_loadPlugins = require("../utils/loadPlugins");
32
- async function run({ cwd, initialLog, metaName = "MODERN", version, internalPlugins, packageJsonConfig = import_constants.PACKAGE_JSON_CONFIG_NAME, configFile }) {
43
+ async function run({ cwd, initialLog, metaName = "modern-js", version, internalPlugins, packageJsonConfig = import_constants.PACKAGE_JSON_CONFIG_NAME, statePluginName = import_constants.STATE_PLUGIN_NAME, configFile }) {
44
+ var _userConfig_runtime, _userConfig_runtime1;
33
45
  const command = process.argv[2];
34
46
  const cliParams = (0, import_utils.minimist)(process.argv.slice(2));
35
47
  const SUPPORT_CONFIG_PARAM_COMMANDS = [
@@ -64,8 +76,23 @@ async function run({ cwd, initialLog, metaName = "MODERN", version, internalPlug
64
76
  }
65
77
  const appDirectory = await (0, import_cli.initAppDir)(cwd);
66
78
  const finalConfigFile = customConfigFile || (0, import_getConfigFile.getConfigFile)(configFile);
67
- const autoLoadPlugins = await (0, import_isAutoLoadPlugins.isAutoLoadPlugins)(appDirectory, finalConfigFile, packageJsonConfig, metaName);
68
- 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);
79
+ const userConfig = await (0, import_getUserConfig.getUserConfig)(appDirectory, finalConfigFile, packageJsonConfig, metaName);
80
+ 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, userConfig.autoLoadPlugins);
81
+ if (!userConfig.autoLoadPlugins && userConfig.runtime && typeof userConfig.runtime !== "boolean" && (((_userConfig_runtime = userConfig.runtime) === null || _userConfig_runtime === void 0 ? void 0 : _userConfig_runtime.state) === true || typeof ((_userConfig_runtime1 = userConfig.runtime) === null || _userConfig_runtime1 === void 0 ? void 0 : _userConfig_runtime1.state) === "object")) {
82
+ if (!userConfig.plugins.find((plugin) => plugin.name === statePluginName)) {
83
+ console.warn(`${import_utils.chalk.red("\n[Warning]")} We will no longer support built-in \`runtime.state\`. If you want to use Reduck, you must run ${import_utils.chalk.yellow.bold(`\`pnpm add ${statePluginName}@${version}\``)} to install the state plugin dependency and manually register the plugin. After install state plugin, please add the following code to ${import_utils.chalk.yellow.bold(`\`${import_path.default.basename(finalConfigFile)}\``)}:
84
+
85
+ ${import_utils.chalk.yellow.bold(`import { statePlugin } from '${statePluginName}';
86
+
87
+ export default defineConfig({
88
+ plugins: [
89
+ ...,
90
+ statePlugin(),
91
+ ],
92
+ });
93
+ `)}`);
94
+ }
95
+ }
69
96
  await (0, import_run.run)({
70
97
  cwd,
71
98
  initialLog: initialLog || `Modern.js Framework v${version}`,
@@ -16,20 +16,19 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var isAutoLoadPlugins_exports = {};
20
- __export(isAutoLoadPlugins_exports, {
21
- isAutoLoadPlugins: () => isAutoLoadPlugins
19
+ var getUserConfig_exports = {};
20
+ __export(getUserConfig_exports, {
21
+ getUserConfig: () => getUserConfig
22
22
  });
23
- module.exports = __toCommonJS(isAutoLoadPlugins_exports);
23
+ module.exports = __toCommonJS(getUserConfig_exports);
24
24
  var import_cli = require("@modern-js/plugin-v2/cli");
25
- async function isAutoLoadPlugins(appDirectory, configFile, packageJsonConfig, metaName) {
26
- var _loaded_config;
27
- (0, import_cli.loadEnv)(appDirectory, process.env[`${metaName.toUpperCase()}_ENV`]);
25
+ async function getUserConfig(appDirectory, configFile, packageJsonConfig, metaName) {
26
+ const envName = metaName === "modern-js" ? "MODERN" : metaName;
27
+ (0, import_cli.loadEnv)(appDirectory, process.env[`${envName.toUpperCase()}_ENV`]);
28
28
  const loaded = await (0, import_cli.createLoadedConfig)(appDirectory, configFile, packageJsonConfig);
29
- const autoLoadPlugins = (_loaded_config = loaded.config) === null || _loaded_config === void 0 ? void 0 : _loaded_config.autoLoadPlugins;
30
- return autoLoadPlugins || false;
29
+ return loaded.config || {};
31
30
  }
32
31
  // Annotate the CommonJS export names for ESM import in node:
33
32
  0 && (module.exports = {
34
- isAutoLoadPlugins
33
+ getUserConfig
35
34
  });
@@ -33,11 +33,10 @@ __export(initAppContext_exports, {
33
33
  module.exports = __toCommonJS(initAppContext_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, tempDir }) => {
37
- const { metaName = "modern-js", apiDir = "api", distDir = "", sharedDir = "shared" } = options || {};
36
+ const initAppContext = ({ metaName, appDirectory, runtimeConfigFile, options, serverConfigFile, tempDir }) => {
37
+ const { apiDir = "api", sharedDir = "shared" } = options || {};
38
38
  const pkgPath = import_path.default.resolve(appDirectory, "./package.json");
39
39
  return {
40
- metaName,
41
40
  runtimeConfigFile,
42
41
  serverConfigFile,
43
42
  ip: import_utils.address.ip(),
@@ -62,7 +62,7 @@ function _applyBuilderPlugins() {
62
62
  case 1:
63
63
  _ref = _state.sent(), builderPluginAdapterBasic = _ref.builderPluginAdapterBasic, builderPluginAdapterHtml = _ref.builderPluginAdapterHtml, builderPluginAdapterSSR = _ref.builderPluginAdapterSSR, builderPluginAdapterHooks = _ref.builderPluginAdapterHooks;
64
64
  builder.addPlugins([
65
- builderPluginAdapterBasic(),
65
+ builderPluginAdapterBasic(options),
66
66
  builderPluginAdapterSSR(options),
67
67
  builderPluginAdapterHtml(options),
68
68
  builderPluginAdapterHooks(options)
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
2
  import { SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/uni-builder";
3
- var builderPluginAdapterBasic = function() {
3
+ var builderPluginAdapterBasic = function(options) {
4
4
  return {
5
5
  name: "builder-plugin-adapter-modern-basic",
6
6
  setup: function setup(api) {
@@ -15,7 +15,14 @@ var builderPluginAdapterBasic = function() {
15
15
  chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
16
16
  chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
17
17
  }
18
+ var appContext = options.appContext;
19
+ var metaName = appContext.metaName;
18
20
  chain.resolve.modules.add("node_modules").add(path.join(api.context.rootPath, "node_modules"));
21
+ chain.watchOptions({
22
+ ignored: [
23
+ "[\\\\/](?:node_modules(?![\\\\/]\\.".concat(metaName, ")|.git)[\\\\/]")
24
+ ]
25
+ });
19
26
  });
20
27
  }
21
28
  };
@@ -1,4 +1,5 @@
1
1
  var PACKAGE_JSON_CONFIG_NAME = "modernConfig";
2
+ var STATE_PLUGIN_NAME = "@modern-js/plugin-state";
2
3
  var DEFAULT_CONFIG_FILE = "modern.config";
3
4
  var DEFAULT_SERVER_CONFIG_FILE = "modern.server-runtime.config";
4
5
  var DEFAULT_RUNTIME_CONFIG_FILE = "modern.runtime";
@@ -6,5 +7,6 @@ export {
6
7
  DEFAULT_CONFIG_FILE,
7
8
  DEFAULT_RUNTIME_CONFIG_FILE,
8
9
  DEFAULT_SERVER_CONFIG_FILE,
9
- PACKAGE_JSON_CONFIG_NAME
10
+ PACKAGE_JSON_CONFIG_NAME,
11
+ STATE_PLUGIN_NAME
10
12
  };
package/dist/esm/index.js CHANGED
@@ -74,8 +74,8 @@ var appTools = function() {
74
74
  locale
75
75
  });
76
76
  api.updateAppContext(initAppContext({
77
+ metaName: context.metaName,
77
78
  appDirectory: context.appDirectory,
78
- options: {},
79
79
  serverConfigFile: DEFAULT_SERVER_CONFIG_FILE,
80
80
  runtimeConfigFile: DEFAULT_RUNTIME_CONFIG_FILE,
81
81
  tempDir: (_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir
@@ -1,23 +1,25 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _type_of } from "@swc/helpers/_/_type_of";
2
3
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
4
+ import path from "path";
3
5
  import { initAppDir } from "@modern-js/plugin-v2/cli";
4
6
  import { run as CLIPluginRun } from "@modern-js/plugin-v2/run";
5
- import { minimist } from "@modern-js/utils";
7
+ import { chalk, minimist } from "@modern-js/utils";
6
8
  import { handleSetupResult } from "../compat/hooks";
7
- import { PACKAGE_JSON_CONFIG_NAME } from "../constants";
9
+ import { PACKAGE_JSON_CONFIG_NAME, STATE_PLUGIN_NAME } from "../constants";
8
10
  import { getConfigFile } from "../utils/getConfigFile";
9
- import { isAutoLoadPlugins } from "../utils/isAutoLoadPlugins";
11
+ import { getUserConfig } from "../utils/getUserConfig";
10
12
  import { loadInternalPlugins } from "../utils/loadPlugins";
11
13
  function run(_) {
12
14
  return _run.apply(this, arguments);
13
15
  }
14
16
  function _run() {
15
17
  _run = _async_to_generator(function(param) {
16
- var cwd, initialLog, _param_metaName, metaName, version, internalPlugins, _param_packageJsonConfig, packageJsonConfig, configFile, command, cliParams, SUPPORT_CONFIG_PARAM_COMMANDS, customConfigFile, appDirectory, finalConfigFile, autoLoadPlugins, plugins;
18
+ var cwd, initialLog, _param_metaName, metaName, version, internalPlugins, _param_packageJsonConfig, packageJsonConfig, _param_statePluginName, statePluginName, configFile, _userConfig_runtime, _userConfig_runtime1, command, cliParams, SUPPORT_CONFIG_PARAM_COMMANDS, customConfigFile, appDirectory, finalConfigFile, userConfig, plugins;
17
19
  return _ts_generator(this, function(_state) {
18
20
  switch (_state.label) {
19
21
  case 0:
20
- cwd = param.cwd, initialLog = param.initialLog, _param_metaName = param.metaName, metaName = _param_metaName === void 0 ? "MODERN" : _param_metaName, version = param.version, internalPlugins = param.internalPlugins, _param_packageJsonConfig = param.packageJsonConfig, packageJsonConfig = _param_packageJsonConfig === void 0 ? PACKAGE_JSON_CONFIG_NAME : _param_packageJsonConfig, configFile = param.configFile;
22
+ cwd = param.cwd, initialLog = param.initialLog, _param_metaName = param.metaName, metaName = _param_metaName === void 0 ? "modern-js" : _param_metaName, version = param.version, internalPlugins = param.internalPlugins, _param_packageJsonConfig = param.packageJsonConfig, packageJsonConfig = _param_packageJsonConfig === void 0 ? PACKAGE_JSON_CONFIG_NAME : _param_packageJsonConfig, _param_statePluginName = param.statePluginName, statePluginName = _param_statePluginName === void 0 ? STATE_PLUGIN_NAME : _param_statePluginName, configFile = param.configFile;
21
23
  command = process.argv[2];
22
24
  cliParams = minimist(process.argv.slice(2));
23
25
  SUPPORT_CONFIG_PARAM_COMMANDS = [
@@ -58,16 +60,23 @@ function _run() {
58
60
  finalConfigFile = customConfigFile || getConfigFile(configFile);
59
61
  return [
60
62
  4,
61
- isAutoLoadPlugins(appDirectory, finalConfigFile, packageJsonConfig, metaName)
63
+ getUserConfig(appDirectory, finalConfigFile, packageJsonConfig, metaName)
62
64
  ];
63
65
  case 2:
64
- autoLoadPlugins = _state.sent();
66
+ userConfig = _state.sent();
65
67
  return [
66
68
  4,
67
- loadInternalPlugins(appDirectory, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.cli, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.autoLoad, autoLoadPlugins)
69
+ loadInternalPlugins(appDirectory, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.cli, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.autoLoad, userConfig.autoLoadPlugins)
68
70
  ];
69
71
  case 3:
70
72
  plugins = _state.sent();
73
+ if (!userConfig.autoLoadPlugins && userConfig.runtime && typeof userConfig.runtime !== "boolean" && (((_userConfig_runtime = userConfig.runtime) === null || _userConfig_runtime === void 0 ? void 0 : _userConfig_runtime.state) === true || _type_of((_userConfig_runtime1 = userConfig.runtime) === null || _userConfig_runtime1 === void 0 ? void 0 : _userConfig_runtime1.state) === "object")) {
74
+ if (!userConfig.plugins.find(function(plugin) {
75
+ return plugin.name === statePluginName;
76
+ })) {
77
+ console.warn("".concat(chalk.red("\n[Warning]"), " We will no longer support built-in `runtime.state`. If you want to use Reduck, you must run ").concat(chalk.yellow.bold("`pnpm add ".concat(statePluginName, "@").concat(version, "`")), " to install the state plugin dependency and manually register the plugin. After install state plugin, please add the following code to ").concat(chalk.yellow.bold("`".concat(path.basename(finalConfigFile), "`")), ":\n\n").concat(chalk.yellow.bold("import { statePlugin } from '".concat(statePluginName, "';\n\nexport default defineConfig({\n plugins: [\n ...,\n statePlugin(),\n ],\n});\n "))));
78
+ }
79
+ }
71
80
  return [
72
81
  4,
73
82
  CLIPluginRun({
@@ -0,0 +1,32 @@
1
+ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
+ import { createLoadedConfig, loadEnv } from "@modern-js/plugin-v2/cli";
4
+ function getUserConfig(appDirectory, configFile, packageJsonConfig, metaName) {
5
+ return _getUserConfig.apply(this, arguments);
6
+ }
7
+ function _getUserConfig() {
8
+ _getUserConfig = _async_to_generator(function(appDirectory, configFile, packageJsonConfig, metaName) {
9
+ var envName, loaded;
10
+ return _ts_generator(this, function(_state) {
11
+ switch (_state.label) {
12
+ case 0:
13
+ envName = metaName === "modern-js" ? "MODERN" : metaName;
14
+ loadEnv(appDirectory, process.env["".concat(envName.toUpperCase(), "_ENV")]);
15
+ return [
16
+ 4,
17
+ createLoadedConfig(appDirectory, configFile, packageJsonConfig)
18
+ ];
19
+ case 1:
20
+ loaded = _state.sent();
21
+ return [
22
+ 2,
23
+ loaded.config || {}
24
+ ];
25
+ }
26
+ });
27
+ });
28
+ return _getUserConfig.apply(this, arguments);
29
+ }
30
+ export {
31
+ getUserConfig
32
+ };
@@ -1,11 +1,10 @@
1
1
  import path from "path";
2
2
  import { fs, 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, tempDir = param.tempDir;
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;
4
+ var metaName = param.metaName, appDirectory = param.appDirectory, runtimeConfigFile = param.runtimeConfigFile, options = param.options, serverConfigFile = param.serverConfigFile, tempDir = param.tempDir;
5
+ var _ref = options || {}, _ref_apiDir = _ref.apiDir, apiDir = _ref_apiDir === void 0 ? "api" : _ref_apiDir, _ref_sharedDir = _ref.sharedDir, sharedDir = _ref_sharedDir === void 0 ? "shared" : _ref_sharedDir;
6
6
  var pkgPath = path.resolve(appDirectory, "./package.json");
7
7
  return {
8
- metaName,
9
8
  runtimeConfigFile,
10
9
  serverConfigFile,
11
10
  ip: address.ip(),
@@ -22,7 +22,7 @@ async function generateBuilder(options, bundlerType) {
22
22
  async function applyBuilderPlugins(builder, options) {
23
23
  const { builderPluginAdapterBasic, builderPluginAdapterHtml, builderPluginAdapterSSR, builderPluginAdapterHooks } = await import("../shared/builderPlugins/index.js");
24
24
  builder.addPlugins([
25
- builderPluginAdapterBasic(),
25
+ builderPluginAdapterBasic(options),
26
26
  builderPluginAdapterSSR(options),
27
27
  builderPluginAdapterHtml(options),
28
28
  builderPluginAdapterHooks(options)
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
2
  import { SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/uni-builder";
3
- const builderPluginAdapterBasic = () => ({
3
+ const builderPluginAdapterBasic = (options) => ({
4
4
  name: "builder-plugin-adapter-modern-basic",
5
5
  setup(api) {
6
6
  api.modifyBundlerChain((chain, { target, CHAIN_ID, environment }) => {
@@ -13,7 +13,14 @@ const builderPluginAdapterBasic = () => ({
13
13
  chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
14
14
  chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
15
15
  }
16
+ const { appContext } = options;
17
+ const { metaName } = appContext;
16
18
  chain.resolve.modules.add("node_modules").add(path.join(api.context.rootPath, "node_modules"));
19
+ chain.watchOptions({
20
+ ignored: [
21
+ `[\\\\/](?:node_modules(?![\\\\/]\\.${metaName})|.git)[\\\\/]`
22
+ ]
23
+ });
17
24
  });
18
25
  }
19
26
  });
@@ -1,4 +1,5 @@
1
1
  const PACKAGE_JSON_CONFIG_NAME = "modernConfig";
2
+ const STATE_PLUGIN_NAME = "@modern-js/plugin-state";
2
3
  const DEFAULT_CONFIG_FILE = "modern.config";
3
4
  const DEFAULT_SERVER_CONFIG_FILE = "modern.server-runtime.config";
4
5
  const DEFAULT_RUNTIME_CONFIG_FILE = "modern.runtime";
@@ -6,5 +7,6 @@ export {
6
7
  DEFAULT_CONFIG_FILE,
7
8
  DEFAULT_RUNTIME_CONFIG_FILE,
8
9
  DEFAULT_SERVER_CONFIG_FILE,
9
- PACKAGE_JSON_CONFIG_NAME
10
+ PACKAGE_JSON_CONFIG_NAME,
11
+ STATE_PLUGIN_NAME
10
12
  };
@@ -69,8 +69,8 @@ const appTools = (options = {
69
69
  locale
70
70
  });
71
71
  api.updateAppContext(initAppContext({
72
+ metaName: context.metaName,
72
73
  appDirectory: context.appDirectory,
73
- options: {},
74
74
  serverConfigFile: DEFAULT_SERVER_CONFIG_FILE,
75
75
  runtimeConfigFile: DEFAULT_RUNTIME_CONFIG_FILE,
76
76
  tempDir: (_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir
@@ -1,12 +1,14 @@
1
+ import path from "path";
1
2
  import { initAppDir } from "@modern-js/plugin-v2/cli";
2
3
  import { run as CLIPluginRun } from "@modern-js/plugin-v2/run";
3
- import { minimist } from "@modern-js/utils";
4
+ import { chalk, minimist } from "@modern-js/utils";
4
5
  import { handleSetupResult } from "../compat/hooks";
5
- import { PACKAGE_JSON_CONFIG_NAME } from "../constants";
6
+ import { PACKAGE_JSON_CONFIG_NAME, STATE_PLUGIN_NAME } from "../constants";
6
7
  import { getConfigFile } from "../utils/getConfigFile";
7
- import { isAutoLoadPlugins } from "../utils/isAutoLoadPlugins";
8
+ import { getUserConfig } from "../utils/getUserConfig";
8
9
  import { loadInternalPlugins } from "../utils/loadPlugins";
9
- async function run({ cwd, initialLog, metaName = "MODERN", version, internalPlugins, packageJsonConfig = PACKAGE_JSON_CONFIG_NAME, configFile }) {
10
+ async function run({ cwd, initialLog, metaName = "modern-js", version, internalPlugins, packageJsonConfig = PACKAGE_JSON_CONFIG_NAME, statePluginName = STATE_PLUGIN_NAME, configFile }) {
11
+ var _userConfig_runtime, _userConfig_runtime1;
10
12
  const command = process.argv[2];
11
13
  const cliParams = minimist(process.argv.slice(2));
12
14
  const SUPPORT_CONFIG_PARAM_COMMANDS = [
@@ -41,8 +43,23 @@ async function run({ cwd, initialLog, metaName = "MODERN", version, internalPlug
41
43
  }
42
44
  const appDirectory = await initAppDir(cwd);
43
45
  const finalConfigFile = customConfigFile || getConfigFile(configFile);
44
- const autoLoadPlugins = await isAutoLoadPlugins(appDirectory, finalConfigFile, packageJsonConfig, metaName);
45
- const plugins = await loadInternalPlugins(appDirectory, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.cli, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.autoLoad, autoLoadPlugins);
46
+ const userConfig = await getUserConfig(appDirectory, finalConfigFile, packageJsonConfig, metaName);
47
+ const plugins = await loadInternalPlugins(appDirectory, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.cli, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.autoLoad, userConfig.autoLoadPlugins);
48
+ if (!userConfig.autoLoadPlugins && userConfig.runtime && typeof userConfig.runtime !== "boolean" && (((_userConfig_runtime = userConfig.runtime) === null || _userConfig_runtime === void 0 ? void 0 : _userConfig_runtime.state) === true || typeof ((_userConfig_runtime1 = userConfig.runtime) === null || _userConfig_runtime1 === void 0 ? void 0 : _userConfig_runtime1.state) === "object")) {
49
+ if (!userConfig.plugins.find((plugin) => plugin.name === statePluginName)) {
50
+ console.warn(`${chalk.red("\n[Warning]")} We will no longer support built-in \`runtime.state\`. If you want to use Reduck, you must run ${chalk.yellow.bold(`\`pnpm add ${statePluginName}@${version}\``)} to install the state plugin dependency and manually register the plugin. After install state plugin, please add the following code to ${chalk.yellow.bold(`\`${path.basename(finalConfigFile)}\``)}:
51
+
52
+ ${chalk.yellow.bold(`import { statePlugin } from '${statePluginName}';
53
+
54
+ export default defineConfig({
55
+ plugins: [
56
+ ...,
57
+ statePlugin(),
58
+ ],
59
+ });
60
+ `)}`);
61
+ }
62
+ }
46
63
  await CLIPluginRun({
47
64
  cwd,
48
65
  initialLog: initialLog || `Modern.js Framework v${version}`,
@@ -0,0 +1,10 @@
1
+ import { createLoadedConfig, loadEnv } from "@modern-js/plugin-v2/cli";
2
+ async function getUserConfig(appDirectory, configFile, packageJsonConfig, metaName) {
3
+ const envName = metaName === "modern-js" ? "MODERN" : metaName;
4
+ loadEnv(appDirectory, process.env[`${envName.toUpperCase()}_ENV`]);
5
+ const loaded = await createLoadedConfig(appDirectory, configFile, packageJsonConfig);
6
+ return loaded.config || {};
7
+ }
8
+ export {
9
+ getUserConfig
10
+ };
@@ -1,10 +1,9 @@
1
1
  import path from "path";
2
2
  import { fs, address } from "@modern-js/utils";
3
- const initAppContext = ({ appDirectory, runtimeConfigFile, options, serverConfigFile, tempDir }) => {
4
- const { metaName = "modern-js", apiDir = "api", distDir = "", sharedDir = "shared" } = options || {};
3
+ const initAppContext = ({ metaName, appDirectory, runtimeConfigFile, options, serverConfigFile, tempDir }) => {
4
+ const { apiDir = "api", sharedDir = "shared" } = options || {};
5
5
  const pkgPath = path.resolve(appDirectory, "./package.json");
6
6
  return {
7
- metaName,
8
7
  runtimeConfigFile,
9
8
  serverConfigFile,
10
9
  ip: address.ip(),
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { Rspack, RspackChain } from '@rsbuild/core';
3
2
  import type { AppNormalizedConfig, Bundler } from '../../types';
4
3
  import type { AppToolsContext } from '../../types/new';
@@ -1,2 +1,4 @@
1
1
  import type { RsbuildPlugin } from '@rsbuild/core';
2
- export declare const builderPluginAdapterBasic: () => RsbuildPlugin;
2
+ import type { Bundler } from '../../../types';
3
+ import type { BuilderOptions } from '../types';
4
+ export declare const builderPluginAdapterBasic: <B extends Bundler>(options: BuilderOptions<B>) => RsbuildPlugin;
@@ -1,4 +1,4 @@
1
1
  import type { CLIPluginAPI } from '@modern-js/plugin-v2';
2
2
  import type { AppTools } from '../types';
3
3
  import type { BuildOptions } from '../utils/types';
4
- export declare const build: (api: CLIPluginAPI<AppTools<'shared'>>, options?: BuildOptions) => Promise<void>;
4
+ export declare const build: (api: CLIPluginAPI<AppTools<"shared">>, options?: BuildOptions) => Promise<void>;
@@ -1,3 +1,3 @@
1
1
  import type { CLIPluginAPI } from '@modern-js/plugin-v2';
2
2
  import type { AppTools } from '../types';
3
- export declare const deploy: (api: CLIPluginAPI<AppTools<'shared'>>, options: any) => Promise<void>;
3
+ export declare const deploy: (api: CLIPluginAPI<AppTools<"shared">>, options: any) => Promise<void>;
@@ -5,5 +5,5 @@ import type { DevOptions } from '../utils/types';
5
5
  interface ExtraServerOptions {
6
6
  applyPlugins?: ApplyPlugins;
7
7
  }
8
- export declare const dev: (api: CLIPluginAPI<AppTools<'shared'>>, options: DevOptions, devServerOptions?: ExtraServerOptions) => Promise<void>;
8
+ export declare const dev: (api: CLIPluginAPI<AppTools<"shared">>, options: DevOptions, devServerOptions?: ExtraServerOptions) => Promise<void>;
9
9
  export {};
@@ -1,10 +1,10 @@
1
1
  import type { CLIPluginAPI } from '@modern-js/plugin-v2';
2
2
  import { type Command } from '@modern-js/utils';
3
3
  import type { AppTools } from '../types';
4
- export declare const devCommand: (program: Command, api: CLIPluginAPI<AppTools<'shared'>>) => Promise<void>;
5
- export declare const buildCommand: (program: Command, api: CLIPluginAPI<AppTools<'shared'>>) => Promise<void>;
6
- export declare const serverCommand: (program: Command, api: CLIPluginAPI<AppTools<'shared'>>) => void;
7
- export declare const deployCommand: (program: Command, api: CLIPluginAPI<AppTools<'shared'>>) => void;
4
+ export declare const devCommand: (program: Command, api: CLIPluginAPI<AppTools<"shared">>) => Promise<void>;
5
+ export declare const buildCommand: (program: Command, api: CLIPluginAPI<AppTools<"shared">>) => Promise<void>;
6
+ export declare const serverCommand: (program: Command, api: CLIPluginAPI<AppTools<"shared">>) => void;
7
+ export declare const deployCommand: (program: Command, api: CLIPluginAPI<AppTools<"shared">>) => void;
8
8
  export declare const newCommand: (program: Command, locale: string) => void;
9
- export declare const inspectCommand: (program: Command, api: CLIPluginAPI<AppTools<'shared'>>) => void;
9
+ export declare const inspectCommand: (program: Command, api: CLIPluginAPI<AppTools<"shared">>) => void;
10
10
  export declare const upgradeCommand: (program: Command) => void;
@@ -1,4 +1,4 @@
1
1
  import type { CLIPluginAPI } from '@modern-js/plugin-v2';
2
2
  import type { AppTools } from '../types';
3
3
  import type { InspectOptions } from '../utils/types';
4
- export declare const inspect: (api: CLIPluginAPI<AppTools<'shared'>>, options: InspectOptions) => Promise<import("@rsbuild/core").InspectConfigResult<"rspack">>;
4
+ export declare const inspect: (api: CLIPluginAPI<AppTools<"shared">>, options: InspectOptions) => Promise<import("@rsbuild/core").InspectConfigResult<"rspack">>;
@@ -4,5 +4,5 @@ import type { AppTools } from '../types';
4
4
  type ExtraServerOptions = {
5
5
  launcher?: typeof createProdServer;
6
6
  };
7
- export declare const serve: (api: CLIPluginAPI<AppTools<'shared'>>, serverOptions?: ExtraServerOptions) => Promise<void>;
7
+ export declare const serve: (api: CLIPluginAPI<AppTools<"shared">>, serverOptions?: ExtraServerOptions) => Promise<void>;
8
8
  export {};
@@ -1,2 +1,2 @@
1
1
  import type { AppTools, CliPluginFuture } from '../types';
2
- export declare const compatPlugin: () => CliPluginFuture<AppTools<'shared'>>;
2
+ export declare const compatPlugin: () => CliPluginFuture<AppTools<"shared">>;
@@ -1,4 +1,5 @@
1
1
  export declare const PACKAGE_JSON_CONFIG_NAME = "modernConfig";
2
+ export declare const STATE_PLUGIN_NAME = "@modern-js/plugin-state";
2
3
  export declare const DEFAULT_CONFIG_FILE = "modern.config";
3
4
  export declare const DEFAULT_SERVER_CONFIG_FILE = "modern.server-runtime.config";
4
5
  export declare const DEFAULT_RUNTIME_CONFIG_FILE = "modern.runtime";
@@ -4,7 +4,7 @@ import type { AppLegacyUserConfig, AppUserConfig } from './types';
4
4
  * This function helps you to autocomplete configuration types.
5
5
  * It accepts a direct config object, or a function that returns a config.
6
6
  */
7
- export declare const defineConfig: <B extends "webpack" | "rspack" = "webpack">(config: UserConfigExport<AppUserConfig<B>>) => UserConfigExport<AppUserConfig<B>>;
7
+ export declare const defineConfig: <B extends "rspack" | "webpack" = "webpack">(config: UserConfigExport<AppUserConfig<B>>) => UserConfigExport<AppUserConfig<B>>;
8
8
  /**
9
9
  * @deprecated Please use `defineConfig` instead.
10
10
  * `defineLegacyConfig` will be removed in the future major version.
@@ -1,5 +1,5 @@
1
1
  import type { UnstableMiddleware, UnstableMiddlewareContext, UnstableNext } from '@modern-js/types';
2
- export type { ServerPlugin } from '@modern-js/server-core';
2
+ export type { ServerPlugin, ServerPluginLegacy } from '@modern-js/server-core';
3
3
  export type RenderMiddleware = UnstableMiddleware;
4
4
  export type RenderMiddlewareContext = UnstableMiddlewareContext;
5
5
  export type RenderNext = UnstableNext;
@@ -1,7 +1,7 @@
1
1
  import type { AppTools, AppToolsOptions, CliPluginFuture } from './types';
2
2
  import { initAppContext } from './utils/initAppContext';
3
3
  export * from './defineConfig';
4
- export declare const appTools: (options?: AppToolsOptions) => CliPluginFuture<AppTools<'shared'>>;
4
+ export declare const appTools: (options?: AppToolsOptions) => CliPluginFuture<AppTools<"shared">>;
5
5
  export { defineConfig, defineLegacyConfig } from './defineConfig';
6
6
  export { mergeConfig } from '@modern-js/core';
7
7
  export type { RuntimeUserConfig } from './types/config';
@@ -1,4 +1,4 @@
1
1
  import type { Entrypoint } from '@modern-js/types';
2
2
  import type { AppNormalizedConfig } from '../../types';
3
3
  import type { AppToolsContext, AppToolsHooks } from '../../types/new';
4
- export declare const getBundleEntry: (hooks: AppToolsHooks<'shared'>, appContext: AppToolsContext<'shared'>, config: AppNormalizedConfig<'shared'>) => Promise<Entrypoint[]>;
4
+ export declare const getBundleEntry: (hooks: AppToolsHooks<"shared">, appContext: AppToolsContext<"shared">, config: AppNormalizedConfig<"shared">) => Promise<Entrypoint[]>;
@@ -2,4 +2,4 @@ import type { Entrypoint } from '@modern-js/types';
2
2
  import type { AppNormalizedConfig } from '../../types';
3
3
  import type { AppToolsContext, AppToolsHooks } from '../../types/new';
4
4
  export type { Entrypoint };
5
- export declare const getFileSystemEntry: (hooks: AppToolsHooks<'shared'>, appContext: AppToolsContext<'shared'>, config: AppNormalizedConfig<'shared'>) => Promise<Entrypoint[]>;
5
+ export declare const getFileSystemEntry: (hooks: AppToolsHooks<"shared">, appContext: AppToolsContext<"shared">, config: AppNormalizedConfig<"shared">) => Promise<Entrypoint[]>;
@@ -18,9 +18,9 @@ export declare const getModifyHtmlPartials: (partials: Record<keyof HtmlPartials
18
18
  current: string[];
19
19
  };
20
20
  };
21
- export declare const getHtmlTemplate: (entrypoints: Entrypoint[], hooks: AppToolsHooks<'shared'>, { appContext, config, }: {
22
- appContext: AppToolsContext<'shared'>;
23
- config: AppNormalizedConfig<'shared'>;
21
+ export declare const getHtmlTemplate: (entrypoints: Entrypoint[], hooks: AppToolsHooks<"shared">, { appContext, config, }: {
22
+ appContext: AppToolsContext<"shared">;
23
+ config: AppNormalizedConfig<"shared">;
24
24
  }) => Promise<{
25
25
  partialsByEntrypoint: Record<string, HtmlPartials>;
26
26
  htmlTemplates: HtmlTemplates;
@@ -2,7 +2,7 @@ import type { Entrypoint, ServerRoute } from '@modern-js/types';
2
2
  import type { AppNormalizedConfig } from '../../types';
3
3
  import type { AppToolsContext } from '../../types/new';
4
4
  export declare const getServerRoutes: (entrypoints: Entrypoint[], { appContext, config, }: {
5
- appContext: AppToolsContext<'shared'>;
6
- config: AppNormalizedConfig<'shared'>;
5
+ appContext: AppToolsContext<"shared">;
6
+ config: AppNormalizedConfig<"shared">;
7
7
  }) => ServerRoute[];
8
8
  export declare const getProdServerRoutes: (distDirectory: string) => any;
@@ -1,5 +1,5 @@
1
1
  import type { AppTools, CliPluginFuture } from '../../types';
2
2
  declare const _default: ({ bundler, }: {
3
- bundler: 'webpack' | 'rspack';
4
- }) => CliPluginFuture<AppTools<'shared'>>;
3
+ bundler: "webpack" | "rspack";
4
+ }) => CliPluginFuture<AppTools<"shared">>;
5
5
  export default _default;
@@ -3,7 +3,7 @@ export declare const replaceWithAlias: (base: string, filePath: string, alias: s
3
3
  export declare const parseModule: ({ source, filename, }: {
4
4
  source: string;
5
5
  filename: string;
6
- }) => Promise<readonly [imports: readonly import("es-module-lexer").ImportSpecifier[], exports: readonly import("es-module-lexer").ExportSpecifier[], facade: boolean]>;
6
+ }) => Promise<readonly [imports: readonly import("es-module-lexer").ImportSpecifier[], exports: readonly import("es-module-lexer").ExportSpecifier[], facade: boolean, hasModuleSyntax: boolean]>;
7
7
  export declare const getServerCombinedModueFile: (internalDirectory: string, entryName: string) => string;
8
8
  export declare const checkIsBuildCommands: () => boolean;
9
9
  export declare const checkIsServeCommand: () => boolean;
@@ -1,3 +1,3 @@
1
1
  import type { AppTools, CliPluginFuture } from '../../types';
2
- declare const _default: () => CliPluginFuture<AppTools<'shared'>>;
2
+ declare const _default: () => CliPluginFuture<AppTools<"shared">>;
3
3
  export default _default;
@@ -5,7 +5,7 @@ export type ServerAppContext = {
5
5
  lambdaDirectory: string;
6
6
  metaName: string;
7
7
  };
8
- export declare const serverAppContenxtTemplate: (appContext: AppToolsContext<'shared'>) => {
8
+ export declare const serverAppContenxtTemplate: (appContext: AppToolsContext<"shared">) => {
9
9
  sharedDirectory: string;
10
10
  apiDirectory: string;
11
11
  lambdaDirectory: string;
@@ -1,5 +1,5 @@
1
1
  import type { AppTools, CliPluginFuture } from '../../types';
2
2
  declare const _default: ({ bundler, }: {
3
- bundler: 'rspack' | 'webpack';
4
- }) => CliPluginFuture<AppTools<'shared'>>;
3
+ bundler: "rspack" | "webpack";
4
+ }) => CliPluginFuture<AppTools<"shared">>;
5
5
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import type { AppTools, CliPluginFuture } from '../types';
2
- declare const _default: () => CliPluginFuture<AppTools<'shared'>>;
2
+ declare const _default: () => CliPluginFuture<AppTools<"shared">>;
3
3
  export default _default;
@@ -4,6 +4,7 @@ export interface RunOptions {
4
4
  configFile?: string;
5
5
  metaName?: string;
6
6
  packageJsonConfig?: string;
7
+ statePluginName?: string;
7
8
  internalPlugins?: {
8
9
  cli?: InternalPlugins;
9
10
  autoLoad?: InternalPlugins;
@@ -11,4 +12,4 @@ export interface RunOptions {
11
12
  initialLog?: string;
12
13
  version: string;
13
14
  }
14
- export declare function run({ cwd, initialLog, metaName, version, internalPlugins, packageJsonConfig, configFile, }: RunOptions): Promise<void>;
15
+ export declare function run({ cwd, initialLog, metaName, version, internalPlugins, packageJsonConfig, statePluginName, configFile, }: RunOptions): Promise<void>;
@@ -7,6 +7,6 @@ export declare const buildServerConfig: ({ appDirectory, distDirectory, configFi
7
7
  distDirectory: string;
8
8
  configFile: string;
9
9
  options?: Parameters<typeof bundle>[1];
10
- watch?: boolean | undefined;
10
+ watch?: boolean;
11
11
  }) => Promise<void>;
12
- export declare const emitResolvedConfig: (appDirectory: string, resolvedConfig: AppNormalizedConfig<'shared'>) => Promise<void>;
12
+ export declare const emitResolvedConfig: (appDirectory: string, resolvedConfig: AppNormalizedConfig<"shared">) => Promise<void>;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { Server } from 'node:http';
3
2
  import { type ModernDevServerOptions } from '@modern-js/server';
4
3
  export declare const getServer: () => Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | null;
@@ -0,0 +1,6 @@
1
+ import type { AppTools, CliPlugin, CliPluginFuture } from '../types';
2
+ export declare function getUserConfig(appDirectory: string, configFile: string, packageJsonConfig: string, metaName: string): Promise<{
3
+ autoLoadPlugins: boolean;
4
+ runtime: boolean | Record<string, any>;
5
+ plugins: (CliPlugin<AppTools<"shared">> | CliPluginFuture<AppTools<"shared">>)[];
6
+ }>;
@@ -1,17 +1,16 @@
1
- export declare const initAppContext: ({ appDirectory, runtimeConfigFile, options, serverConfigFile, tempDir, }: {
1
+ export declare const initAppContext: ({ metaName, appDirectory, runtimeConfigFile, options, serverConfigFile, tempDir, }: {
2
+ metaName: string;
2
3
  appDirectory: string;
3
4
  runtimeConfigFile: string;
4
5
  options?: {
5
- metaName?: string | undefined;
6
- srcDir?: string | undefined;
7
- apiDir?: string | undefined;
8
- distDir?: string | undefined;
9
- sharedDir?: string | undefined;
10
- } | undefined;
6
+ srcDir?: string;
7
+ apiDir?: string;
8
+ distDir?: string;
9
+ sharedDir?: string;
10
+ };
11
11
  serverConfigFile: string;
12
- tempDir?: string | undefined;
12
+ tempDir?: string;
13
13
  }) => {
14
- metaName: string;
15
14
  runtimeConfigFile: string;
16
15
  serverConfigFile: string;
17
16
  ip: any;
@@ -1,3 +1,3 @@
1
1
  import type { AppNormalizedConfig } from '../types';
2
2
  import type { AppToolsContext, AppToolsHooks } from '../types/new';
3
- export declare const printInstructions: (hooks: AppToolsHooks<'shared'>, appContext: AppToolsContext<'shared'>, config: AppNormalizedConfig<'shared'>) => Promise<void>;
3
+ export declare const printInstructions: (hooks: AppToolsHooks<"shared">, appContext: AppToolsContext<"shared">, config: AppNormalizedConfig<"shared">) => Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import type { IAppContext } from '@modern-js/core';
2
2
  import type { AppToolsContext } from '../types/new';
3
- export declare const generateRoutes: (appContext: AppToolsContext<'shared'> | IAppContext) => Promise<void>;
3
+ export declare const generateRoutes: (appContext: AppToolsContext<"shared"> | IAppContext) => Promise<void>;
4
4
  export declare const getPathWithoutExt: (filename: string) => string;
5
5
  export declare const isMainEntry: (entryName: string, mainEntryName?: string) => boolean;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.65.5",
18
+ "version": "2.67.0",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -80,7 +80,7 @@
80
80
  "@babel/parser": "^7.22.15",
81
81
  "@babel/traverse": "^7.23.2",
82
82
  "@babel/types": "^7.26.0",
83
- "@rsbuild/core": "1.2.19",
83
+ "@rsbuild/core": "1.3.2",
84
84
  "@rsbuild/plugin-node-polyfill": "1.3.0",
85
85
  "@swc/helpers": "0.5.13",
86
86
  "es-module-lexer": "^1.1.0",
@@ -88,26 +88,26 @@
88
88
  "esbuild-register": "^3.5.0",
89
89
  "flatted": "^3.2.9",
90
90
  "mlly": "^1.6.1",
91
- "ndepe": "0.1.6",
91
+ "ndepe": "0.1.8",
92
92
  "pkg-types": "^1.1.0",
93
93
  "std-env": "^3.7.0",
94
- "@modern-js/core": "2.65.5",
95
- "@modern-js/node-bundle-require": "2.65.5",
96
- "@modern-js/plugin-data-loader": "2.65.5",
97
- "@modern-js/plugin-i18n": "2.65.5",
98
- "@modern-js/plugin-v2": "2.65.5",
99
- "@modern-js/rsbuild-plugin-esbuild": "2.65.5",
100
- "@modern-js/prod-server": "2.65.5",
101
- "@modern-js/server-core": "2.65.5",
102
- "@modern-js/server": "2.65.5",
103
- "@modern-js/server-utils": "2.65.5",
104
- "@modern-js/types": "2.65.5",
105
- "@modern-js/plugin": "2.65.5",
106
- "@modern-js/uni-builder": "2.65.5",
107
- "@modern-js/utils": "2.65.5"
94
+ "@modern-js/core": "2.67.0",
95
+ "@modern-js/node-bundle-require": "2.67.0",
96
+ "@modern-js/plugin": "2.67.0",
97
+ "@modern-js/plugin-i18n": "2.67.0",
98
+ "@modern-js/plugin-v2": "2.67.0",
99
+ "@modern-js/plugin-data-loader": "2.67.0",
100
+ "@modern-js/rsbuild-plugin-esbuild": "2.67.0",
101
+ "@modern-js/prod-server": "2.67.0",
102
+ "@modern-js/server": "2.67.0",
103
+ "@modern-js/server-core": "2.67.0",
104
+ "@modern-js/server-utils": "2.67.0",
105
+ "@modern-js/types": "2.67.0",
106
+ "@modern-js/uni-builder": "2.67.0",
107
+ "@modern-js/utils": "2.67.0"
108
108
  },
109
109
  "devDependencies": {
110
- "@rsbuild/plugin-webpack-swc": "1.0.12",
110
+ "@rsbuild/plugin-webpack-swc": "1.1.0",
111
111
  "@types/babel__traverse": "7.20.6",
112
112
  "@types/jest": "^29",
113
113
  "@types/node": "^16",
@@ -116,8 +116,8 @@
116
116
  "tsconfig-paths": "^4.2.0",
117
117
  "typescript": "^5",
118
118
  "webpack": "^5.98.0",
119
- "@scripts/build": "2.65.5",
120
- "@scripts/jest-config": "2.65.5"
119
+ "@scripts/jest-config": "2.66.0",
120
+ "@scripts/build": "2.66.0"
121
121
  },
122
122
  "peerDependencies": {
123
123
  "ts-node": "^10.7.0",
@@ -1,32 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
- import { createLoadedConfig, loadEnv } from "@modern-js/plugin-v2/cli";
4
- function isAutoLoadPlugins(appDirectory, configFile, packageJsonConfig, metaName) {
5
- return _isAutoLoadPlugins.apply(this, arguments);
6
- }
7
- function _isAutoLoadPlugins() {
8
- _isAutoLoadPlugins = _async_to_generator(function(appDirectory, configFile, packageJsonConfig, metaName) {
9
- var _loaded_config, loaded, autoLoadPlugins;
10
- return _ts_generator(this, function(_state) {
11
- switch (_state.label) {
12
- case 0:
13
- loadEnv(appDirectory, process.env["".concat(metaName.toUpperCase(), "_ENV")]);
14
- return [
15
- 4,
16
- createLoadedConfig(appDirectory, configFile, packageJsonConfig)
17
- ];
18
- case 1:
19
- loaded = _state.sent();
20
- autoLoadPlugins = (_loaded_config = loaded.config) === null || _loaded_config === void 0 ? void 0 : _loaded_config.autoLoadPlugins;
21
- return [
22
- 2,
23
- autoLoadPlugins || false
24
- ];
25
- }
26
- });
27
- });
28
- return _isAutoLoadPlugins.apply(this, arguments);
29
- }
30
- export {
31
- isAutoLoadPlugins
32
- };
@@ -1,11 +0,0 @@
1
- import { createLoadedConfig, loadEnv } from "@modern-js/plugin-v2/cli";
2
- async function isAutoLoadPlugins(appDirectory, configFile, packageJsonConfig, metaName) {
3
- var _loaded_config;
4
- loadEnv(appDirectory, process.env[`${metaName.toUpperCase()}_ENV`]);
5
- const loaded = await createLoadedConfig(appDirectory, configFile, packageJsonConfig);
6
- const autoLoadPlugins = (_loaded_config = loaded.config) === null || _loaded_config === void 0 ? void 0 : _loaded_config.autoLoadPlugins;
7
- return autoLoadPlugins || false;
8
- }
9
- export {
10
- isAutoLoadPlugins
11
- };
@@ -1 +0,0 @@
1
- export declare function isAutoLoadPlugins(appDirectory: string, configFile: string, packageJsonConfig: string, metaName: string): Promise<boolean>;