@modern-js/app-tools 2.67.11 → 2.68.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.
Files changed (33) hide show
  1. package/dist/cjs/builder/generator/createBuilderProviderConfig.js +3 -0
  2. package/dist/cjs/builder/generator/index.js +1 -0
  3. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +3 -3
  4. package/dist/cjs/commands/build.js +10 -4
  5. package/dist/cjs/commands/dev.js +10 -4
  6. package/dist/cjs/commands/inspect.js +5 -1
  7. package/dist/cjs/config/default.js +4 -0
  8. package/dist/cjs/config/legacy/index.js +1 -0
  9. package/dist/cjs/run/index.js +2 -2
  10. package/dist/cjs/types/config/resolve.js +16 -0
  11. package/dist/esm/builder/generator/createBuilderProviderConfig.js +1 -0
  12. package/dist/esm/builder/generator/index.js +1 -0
  13. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +4 -4
  14. package/dist/esm/commands/build.js +4 -3
  15. package/dist/esm/commands/dev.js +3 -3
  16. package/dist/esm/commands/inspect.js +5 -2
  17. package/dist/esm/config/default.js +5 -1
  18. package/dist/esm/config/legacy/index.js +1 -0
  19. package/dist/esm/run/index.js +1 -1
  20. package/dist/esm/types/config/resolve.js +0 -0
  21. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +3 -0
  22. package/dist/esm-node/builder/generator/index.js +1 -0
  23. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +4 -4
  24. package/dist/esm-node/commands/build.js +10 -4
  25. package/dist/esm-node/commands/dev.js +10 -4
  26. package/dist/esm-node/commands/inspect.js +5 -1
  27. package/dist/esm-node/config/default.js +4 -0
  28. package/dist/esm-node/config/legacy/index.js +1 -0
  29. package/dist/esm-node/run/index.js +2 -2
  30. package/dist/esm-node/types/config/resolve.js +0 -0
  31. package/dist/types/types/config/index.d.ts +2 -0
  32. package/dist/types/types/config/resolve.d.ts +2 -0
  33. package/package.json +20 -20
@@ -48,6 +48,9 @@ function createBuilderProviderConfig(resolveConfig, appContext) {
48
48
  const config = {
49
49
  ...resolveConfig,
50
50
  plugins: [],
51
+ resolve: {
52
+ ...resolveConfig.resolve
53
+ },
51
54
  dev: {
52
55
  ...resolveConfig.dev,
53
56
  port: appContext.port
@@ -45,6 +45,7 @@ async function generateBuilder(options, bundlerType) {
45
45
  cwd: appContext.appDirectory,
46
46
  rscClientRuntimePath: `@${appContext.metaName}/runtime/rsc/client`,
47
47
  rscServerRuntimePath: `@${appContext.metaName}/runtime/rsc/server`,
48
+ internalDirectory: appContext.internalDirectory,
48
49
  frameworkConfigPath: appContext.configFile || void 0,
49
50
  bundlerType,
50
51
  config: builderConfig
@@ -49,7 +49,7 @@ const builderPluginAdapterSSR = (options) => ({
49
49
  server: {
50
50
  // the http-compression can't handler stream http.
51
51
  // so we disable compress when user use stream ssr temporarily.
52
- compress: isStreamingSSR(normalizedConfig) ? false : void 0
52
+ compress: isStreamingSSR(normalizedConfig) || (0, import_utils.isUseRsc)(normalizedConfig) ? false : void 0
53
53
  }
54
54
  });
55
55
  });
@@ -65,7 +65,7 @@ const builderPluginAdapterSSR = (options) => ({
65
65
  appNormalizedConfig: normalizedConfig2
66
66
  });
67
67
  }
68
- if ((0, import_utils.isUseSSRBundle)(normalizedConfig2)) {
68
+ if ((0, import_utils.isUseSSRBundle)(normalizedConfig2) || (0, import_utils.isUseRsc)(normalizedConfig2)) {
69
69
  await applySSRLoaderEntry(chain, options, isServer);
70
70
  applySSRDataLoader(chain, options);
71
71
  }
@@ -95,7 +95,7 @@ const isStreamingSSR = (userConfig) => {
95
95
  return false;
96
96
  };
97
97
  function applyAsyncChunkHtmlPlugin({ chain, modernConfig, HtmlBundlerPlugin }) {
98
- if (isStreamingSSR(modernConfig)) {
98
+ if (isStreamingSSR(modernConfig) || (0, import_utils.isUseRsc)(modernConfig)) {
99
99
  chain.plugin("html-async-chunk").use(import_bundlerPlugins.HtmlAsyncChunkPlugin, [
100
100
  HtmlBundlerPlugin
101
101
  ]);
@@ -37,7 +37,7 @@ var import_loadPlugins = require("../utils/loadPlugins");
37
37
  var import_register = require("../utils/register");
38
38
  var import_routes = require("../utils/routes");
39
39
  const build = async (api, options) => {
40
- var _resolvedConfig_source;
40
+ var _resolvedConfig_resolve, _resolvedConfig_source;
41
41
  if (options === null || options === void 0 ? void 0 : options.analyze) {
42
42
  process.env.BUNDLE_ANALYZE = "true";
43
43
  }
@@ -46,15 +46,21 @@ const build = async (api, options) => {
46
46
  const hooks = api.getHooks();
47
47
  await (0, import_loadPlugins.loadServerPlugins)(api, appContext.appDirectory, appContext.metaName);
48
48
  if (appContext.moduleType && appContext.moduleType === "module") {
49
- var _resolvedConfig_source1;
49
+ var _resolvedConfig_resolve1, _resolvedConfig_source1;
50
50
  const { registerEsm } = await import("../esm/register-esm.mjs");
51
51
  await registerEsm({
52
52
  appDir: appContext.appDirectory,
53
53
  distDir: appContext.distDirectory,
54
- alias: (_resolvedConfig_source1 = resolvedConfig.source) === null || _resolvedConfig_source1 === void 0 ? void 0 : _resolvedConfig_source1.alias
54
+ alias: {
55
+ ...(_resolvedConfig_resolve1 = resolvedConfig.resolve) === null || _resolvedConfig_resolve1 === void 0 ? void 0 : _resolvedConfig_resolve1.alias,
56
+ ...(_resolvedConfig_source1 = resolvedConfig.source) === null || _resolvedConfig_source1 === void 0 ? void 0 : _resolvedConfig_source1.alias
57
+ }
55
58
  });
56
59
  }
57
- await (0, import_register.registerCompiler)(appContext.appDirectory, appContext.distDirectory, resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.alias);
60
+ await (0, import_register.registerCompiler)(appContext.appDirectory, appContext.distDirectory, {
61
+ ...resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig_resolve = resolvedConfig.resolve) === null || _resolvedConfig_resolve === void 0 ? void 0 : _resolvedConfig_resolve.alias,
62
+ ...resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.alias
63
+ });
58
64
  const { apiOnly } = appContext;
59
65
  if (apiOnly) {
60
66
  const { appDirectory: appDirectory2, distDirectory: distDirectory2, serverConfigFile: serverConfigFile2 } = appContext;
@@ -42,7 +42,7 @@ var import_printInstructions = require("../utils/printInstructions");
42
42
  var import_register = require("../utils/register");
43
43
  var import_routes = require("../utils/routes");
44
44
  const dev = async (api, options, devServerOptions) => {
45
- var _normalizedConfig_source, _normalizedConfig_tools, _normalizedConfig_dev;
45
+ var _normalizedConfig_source, _normalizedConfig_resolve, _normalizedConfig_tools, _normalizedConfig_dev;
46
46
  if (options.analyze) {
47
47
  process.env.BUNDLE_ANALYZE = "true";
48
48
  }
@@ -50,15 +50,21 @@ const dev = async (api, options, devServerOptions) => {
50
50
  const appContext = api.getAppContext();
51
51
  const hooks = api.getHooks();
52
52
  if (appContext.moduleType && appContext.moduleType === "module") {
53
- var _normalizedConfig_source1;
53
+ var _normalizedConfig_resolve1, _normalizedConfig_source1;
54
54
  const { registerEsm } = await import("../esm/register-esm.mjs");
55
55
  await registerEsm({
56
56
  appDir: appContext.appDirectory,
57
57
  distDir: appContext.distDirectory,
58
- alias: (_normalizedConfig_source1 = normalizedConfig.source) === null || _normalizedConfig_source1 === void 0 ? void 0 : _normalizedConfig_source1.alias
58
+ alias: {
59
+ ...(_normalizedConfig_resolve1 = normalizedConfig.resolve) === null || _normalizedConfig_resolve1 === void 0 ? void 0 : _normalizedConfig_resolve1.alias,
60
+ ...(_normalizedConfig_source1 = normalizedConfig.source) === null || _normalizedConfig_source1 === void 0 ? void 0 : _normalizedConfig_source1.alias
61
+ }
59
62
  });
60
63
  }
61
- 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);
64
+ await (0, import_register.registerCompiler)(appContext.appDirectory, appContext.distDirectory, {
65
+ ...normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig_source = normalizedConfig.source) === null || _normalizedConfig_source === void 0 ? void 0 : _normalizedConfig_source.alias,
66
+ ...normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig_resolve = normalizedConfig.resolve) === null || _normalizedConfig_resolve === void 0 ? void 0 : _normalizedConfig_resolve.alias
67
+ });
62
68
  const { appDirectory, distDirectory, port, apiOnly, serverConfigFile, metaName, serverRoutes } = appContext;
63
69
  await (0, import_config.buildServerConfig)({
64
70
  appDirectory,
@@ -26,11 +26,15 @@ const inspect = async (api, options) => {
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
  }
29
+ const metaName = appContext.metaName === "modern-js" ? "modern.js" : appContext.metaName;
29
30
  return appContext.builder.inspectConfig({
30
31
  mode: options.env,
31
32
  verbose: options.verbose,
32
33
  outputPath: options.output,
33
- writeToDisk: true
34
+ writeToDisk: true,
35
+ extraConfigs: {
36
+ [metaName]: api.getNormalizedConfig()
37
+ }
34
38
  });
35
39
  };
36
40
  // Annotate the CommonJS export names for ESM import in node:
@@ -58,6 +58,9 @@ function createDefaultConfig(appContext) {
58
58
  entriesDir: "./src",
59
59
  configDir: "./config",
60
60
  globalVars: (0, import_env.getAutoInjectEnv)(appContext),
61
+ alias: {}
62
+ };
63
+ const resolve = {
61
64
  alias: {
62
65
  [appContext.internalDirAlias]: appContext.internalDirectory,
63
66
  [appContext.internalSrcAlias]: appContext.srcDirectory,
@@ -94,6 +97,7 @@ function createDefaultConfig(appContext) {
94
97
  };
95
98
  return {
96
99
  source,
100
+ resolve,
97
101
  output,
98
102
  server,
99
103
  dev,
@@ -33,6 +33,7 @@ function transformNormalizedConfig(config) {
33
33
  const tools = (0, import_createToolsConfig.createToolsConfig)(config);
34
34
  const { bff, dev, deploy, runtime, runtimeByEntries, server, cliOptions, plugins, testing, autoLoadPlugins } = config;
35
35
  return {
36
+ resolve: {},
36
37
  source,
37
38
  html,
38
39
  output,
@@ -49,7 +49,7 @@ async function run({ cwd, initialLog, metaName = "modern-js", version, internalP
49
49
  ${import_utils.chalk.bgRed.white.bold(" ⚠️ CRITICAL NODE.JS VERSION ALERT ⚠️ ")}
50
50
 
51
51
  ${import_utils.chalk.red.bold("Node.js 16 End-of-Life Notice:")}
52
- ${import_utils.chalk.red.bold.underline("June 30, 2025")} ${import_utils.chalk.red("- Security updates and support will cease")}
52
+ ${import_utils.chalk.red("- Security updates and support have ended for Node.js 16")}
53
53
 
54
54
  ${import_utils.chalk.yellow("▸ Detected Runtime:")} ${import_utils.chalk.yellow.bold(`Node.js v${nodeVersion}`)}
55
55
  ${import_utils.chalk.green("▸ Required Minimum:")} ${import_utils.chalk.green.bold("Node.js LTS (v18.x or higher)")}
@@ -63,7 +63,7 @@ async function run({ cwd, initialLog, metaName = "modern-js", version, internalP
63
63
  ${import_utils.chalk.gray("└──")} ${import_utils.chalk.yellow("Environment Verification")}
64
64
  ${import_utils.chalk.bold("node -v && npm -v")}
65
65
 
66
- ${import_utils.chalk.hex("#AAAAAA").italic("[Security Advisory] Production environments must update before 2025-06-30")}
66
+ ${import_utils.chalk.hex("#AAAAAA").italic("[Security Advisory] Node.js 16 is no longer supported. Upgrade immediately for security and compatibility.")}
67
67
  `);
68
68
  }
69
69
  const command = process.argv[2];
@@ -0,0 +1,16 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var resolve_exports = {};
16
+ module.exports = __toCommonJS(resolve_exports);
@@ -20,6 +20,7 @@ function createBuilderProviderConfig(resolveConfig, appContext) {
20
20
  }
21
21
  var config = _object_spread_props(_object_spread({}, resolveConfig), {
22
22
  plugins: [],
23
+ resolve: _object_spread({}, resolveConfig.resolve),
23
24
  dev: _object_spread_props(_object_spread({}, resolveConfig.dev), {
24
25
  port: appContext.port
25
26
  }),
@@ -24,6 +24,7 @@ function _generateBuilder() {
24
24
  cwd: appContext.appDirectory,
25
25
  rscClientRuntimePath: "@".concat(appContext.metaName, "/runtime/rsc/client"),
26
26
  rscServerRuntimePath: "@".concat(appContext.metaName, "/runtime/rsc/server"),
27
+ internalDirectory: appContext.internalDirectory,
27
28
  frameworkConfigPath: appContext.configFile || void 0,
28
29
  bundlerType,
29
30
  config: builderConfig
@@ -3,7 +3,7 @@ import { _ as _type_of } from "@swc/helpers/_/_type_of";
3
3
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
4
4
  import * as path from "path";
5
5
  import { SERVICE_WORKER_ENVIRONMENT_NAME, isHtmlDisabled } from "@modern-js/uni-builder";
6
- import { fs, isUseSSRBundle } from "@modern-js/utils";
6
+ import { fs, isUseRsc, isUseSSRBundle } from "@modern-js/utils";
7
7
  import { mergeRsbuildConfig } from "@rsbuild/core";
8
8
  import { getServerCombinedModueFile } from "../../../plugins/analyze/utils";
9
9
  import { HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins";
@@ -20,7 +20,7 @@ var builderPluginAdapterSSR = function(options) {
20
20
  server: {
21
21
  // the http-compression can't handler stream http.
22
22
  // so we disable compress when user use stream ssr temporarily.
23
- compress: isStreamingSSR(normalizedConfig) ? false : void 0
23
+ compress: isStreamingSSR(normalizedConfig) || isUseRsc(normalizedConfig) ? false : void 0
24
24
  }
25
25
  });
26
26
  });
@@ -42,7 +42,7 @@ var builderPluginAdapterSSR = function(options) {
42
42
  appNormalizedConfig: normalizedConfig2
43
43
  });
44
44
  }
45
- if (!isUseSSRBundle(normalizedConfig2))
45
+ if (!(isUseSSRBundle(normalizedConfig2) || isUseRsc(normalizedConfig2)))
46
46
  return [
47
47
  3,
48
48
  2
@@ -112,7 +112,7 @@ var isStreamingSSR = function(userConfig) {
112
112
  };
113
113
  function applyAsyncChunkHtmlPlugin(param) {
114
114
  var chain = param.chain, modernConfig = param.modernConfig, HtmlBundlerPlugin = param.HtmlBundlerPlugin;
115
- if (isStreamingSSR(modernConfig)) {
115
+ if (isStreamingSSR(modernConfig) || isUseRsc(modernConfig)) {
116
116
  chain.plugin("html-async-chunk").use(HtmlAsyncChunkPlugin, [
117
117
  HtmlBundlerPlugin
118
118
  ]);
@@ -1,4 +1,5 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
3
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
4
  import { logger } from "@modern-js/utils";
4
5
  import { buildServerConfig } from "../utils/config";
@@ -7,7 +8,7 @@ import { registerCompiler } from "../utils/register";
7
8
  import { generateRoutes } from "../utils/routes";
8
9
  var build = function() {
9
10
  var _ref = _async_to_generator(function(api, options) {
10
- var _resolvedConfig_source, resolvedConfig, appContext, hooks, _resolvedConfig_source1, registerEsm, apiOnly, appDirectory, distDirectory, serverConfigFile, distDirectory1, appDirectory1, serverConfigFile1;
11
+ var _resolvedConfig_resolve, _resolvedConfig_source, resolvedConfig, appContext, hooks, _resolvedConfig_resolve1, _resolvedConfig_source1, registerEsm, apiOnly, appDirectory, distDirectory, serverConfigFile, distDirectory1, appDirectory1, serverConfigFile1;
11
12
  return _ts_generator(this, function(_state) {
12
13
  switch (_state.label) {
13
14
  case 0:
@@ -39,7 +40,7 @@ var build = function() {
39
40
  registerEsm({
40
41
  appDir: appContext.appDirectory,
41
42
  distDir: appContext.distDirectory,
42
- alias: (_resolvedConfig_source1 = resolvedConfig.source) === null || _resolvedConfig_source1 === void 0 ? void 0 : _resolvedConfig_source1.alias
43
+ alias: _object_spread({}, (_resolvedConfig_resolve1 = resolvedConfig.resolve) === null || _resolvedConfig_resolve1 === void 0 ? void 0 : _resolvedConfig_resolve1.alias, (_resolvedConfig_source1 = resolvedConfig.source) === null || _resolvedConfig_source1 === void 0 ? void 0 : _resolvedConfig_source1.alias)
43
44
  })
44
45
  ];
45
46
  case 3:
@@ -48,7 +49,7 @@ var build = function() {
48
49
  case 4:
49
50
  return [
50
51
  4,
51
- registerCompiler(appContext.appDirectory, appContext.distDirectory, resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.alias)
52
+ registerCompiler(appContext.appDirectory, appContext.distDirectory, _object_spread({}, resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig_resolve = resolvedConfig.resolve) === null || _resolvedConfig_resolve === void 0 ? void 0 : _resolvedConfig_resolve.alias, resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.alias))
52
53
  ];
53
54
  case 5:
54
55
  _state.sent();
@@ -14,7 +14,7 @@ import { registerCompiler } from "../utils/register";
14
14
  import { generateRoutes } from "../utils/routes";
15
15
  var dev = function() {
16
16
  var _ref = _async_to_generator(function(api, options, devServerOptions) {
17
- var _normalizedConfig_source, _normalizedConfig_tools, _normalizedConfig_dev, normalizedConfig, appContext, hooks, _normalizedConfig_source1, registerEsm, appDirectory, distDirectory, port, apiOnly, serverConfigFile, metaName, serverRoutes, meta, serverConfigPath, pluginInstances, toolsDevServerConfig, _normalizedConfig_dev_host, _normalizedConfig_dev_https, _normalizedConfig_dev_hmr, _normalizedConfig_dev_setupMiddlewares, serverOptions, host, server, _ref2, server1, afterListen;
17
+ var _normalizedConfig_source, _normalizedConfig_resolve, _normalizedConfig_tools, _normalizedConfig_dev, normalizedConfig, appContext, hooks, _normalizedConfig_resolve1, _normalizedConfig_source1, registerEsm, appDirectory, distDirectory, port, apiOnly, serverConfigFile, metaName, serverRoutes, meta, serverConfigPath, pluginInstances, toolsDevServerConfig, _normalizedConfig_dev_host, _normalizedConfig_dev_https, _normalizedConfig_dev_hmr, _normalizedConfig_dev_setupMiddlewares, serverOptions, host, server, _ref2, server1, afterListen;
18
18
  return _ts_generator(this, function(_state) {
19
19
  switch (_state.label) {
20
20
  case 0:
@@ -40,7 +40,7 @@ var dev = function() {
40
40
  registerEsm({
41
41
  appDir: appContext.appDirectory,
42
42
  distDir: appContext.distDirectory,
43
- alias: (_normalizedConfig_source1 = normalizedConfig.source) === null || _normalizedConfig_source1 === void 0 ? void 0 : _normalizedConfig_source1.alias
43
+ alias: _object_spread({}, (_normalizedConfig_resolve1 = normalizedConfig.resolve) === null || _normalizedConfig_resolve1 === void 0 ? void 0 : _normalizedConfig_resolve1.alias, (_normalizedConfig_source1 = normalizedConfig.source) === null || _normalizedConfig_source1 === void 0 ? void 0 : _normalizedConfig_source1.alias)
44
44
  })
45
45
  ];
46
46
  case 2:
@@ -49,7 +49,7 @@ var dev = function() {
49
49
  case 3:
50
50
  return [
51
51
  4,
52
- 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)
52
+ registerCompiler(appContext.appDirectory, appContext.distDirectory, _object_spread({}, normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig_source = normalizedConfig.source) === null || _normalizedConfig_source === void 0 ? void 0 : _normalizedConfig_source.alias, normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig_resolve = normalizedConfig.resolve) === null || _normalizedConfig_resolve === void 0 ? void 0 : _normalizedConfig_resolve.alias))
53
53
  ];
54
54
  case 4:
55
55
  _state.sent();
@@ -1,20 +1,23 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _define_property } from "@swc/helpers/_/_define_property";
2
3
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
4
  var inspect = function() {
4
5
  var _ref = _async_to_generator(function(api, options) {
5
- var appContext;
6
+ var appContext, metaName;
6
7
  return _ts_generator(this, function(_state) {
7
8
  appContext = api.getAppContext();
8
9
  if (!appContext.builder) {
9
10
  throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
10
11
  }
12
+ metaName = appContext.metaName === "modern-js" ? "modern.js" : appContext.metaName;
11
13
  return [
12
14
  2,
13
15
  appContext.builder.inspectConfig({
14
16
  mode: options.env,
15
17
  verbose: options.verbose,
16
18
  outputPath: options.output,
17
- writeToDisk: true
19
+ writeToDisk: true,
20
+ extraConfigs: _define_property({}, metaName, api.getNormalizedConfig())
18
21
  })
19
22
  ];
20
23
  });
@@ -32,7 +32,6 @@ function createDefaultConfig(appContext) {
32
32
  enableInlineRouteManifests: true,
33
33
  disableInlineRouteManifests: false
34
34
  };
35
- var _obj;
36
35
  var source = {
37
36
  entries: void 0,
38
37
  mainEntryName: MAIN_ENTRY_NAME,
@@ -42,6 +41,10 @@ function createDefaultConfig(appContext) {
42
41
  entriesDir: "./src",
43
42
  configDir: "./config",
44
43
  globalVars: getAutoInjectEnv(appContext),
44
+ alias: {}
45
+ };
46
+ var _obj;
47
+ var resolve = {
45
48
  alias: (_obj = {}, _define_property(_obj, appContext.internalDirAlias, appContext.internalDirectory), _define_property(_obj, appContext.internalSrcAlias, appContext.srcDirectory), _define_property(_obj, "@", appContext.srcDirectory), _define_property(_obj, "@shared", appContext.sharedDirectory), _obj)
46
49
  };
47
50
  var html = {
@@ -73,6 +76,7 @@ function createDefaultConfig(appContext) {
73
76
  };
74
77
  return {
75
78
  source,
79
+ resolve,
76
80
  output,
77
81
  server,
78
82
  dev,
@@ -9,6 +9,7 @@ function transformNormalizedConfig(config) {
9
9
  var tools = createToolsConfig(config);
10
10
  var bff = config.bff, dev = config.dev, deploy = config.deploy, runtime = config.runtime, runtimeByEntries = config.runtimeByEntries, server = config.server, cliOptions = config.cliOptions, plugins = config.plugins, testing = config.testing, autoLoadPlugins = config.autoLoadPlugins;
11
11
  return {
12
+ resolve: {},
12
13
  source,
13
14
  html,
14
15
  output,
@@ -23,7 +23,7 @@ function _run() {
23
23
  nodeVersion = process.versions.node;
24
24
  versionArr = nodeVersion.split(".").map(Number);
25
25
  if (versionArr[0] <= 16) {
26
- console.warn("\n ".concat(chalk.bgRed.white.bold(" ⚠️ CRITICAL NODE.JS VERSION ALERT ⚠️ "), "\n\n ").concat(chalk.red.bold("Node.js 16 End-of-Life Notice:"), "\n ").concat(chalk.red.bold.underline("June 30, 2025"), " ").concat(chalk.red("- Security updates and support will cease"), "\n\n ").concat(chalk.yellow("▸ Detected Runtime:"), " ").concat(chalk.yellow.bold("Node.js v".concat(nodeVersion)), "\n ").concat(chalk.green("▸ Required Minimum:"), " ").concat(chalk.green.bold("Node.js LTS (v18.x or higher)"), "\n ").concat(chalk.green("▸ Recommended:"), " ").concat(chalk.green.bold("Node.js LTS (v22.x or higher)"), "\n\n ").concat(chalk.cyan("Immediate Action Required:"), "\n ").concat(chalk.gray("├──"), " ").concat(chalk.yellow("Recommended Upgrade"), "\n ").concat(chalk.bold("nvm install 22 --lts && nvm use 22"), "\n ").concat(chalk.gray("├──"), " ").concat(chalk.yellow("Manual Installation"), "\n ").concat(chalk.underline("https://nodejs.org/download/release/lts-hydrogen/"), "\n ").concat(chalk.gray("└──"), " ").concat(chalk.yellow("Environment Verification"), "\n ").concat(chalk.bold("node -v && npm -v"), "\n\n ").concat(chalk.hex("#AAAAAA").italic("[Security Advisory] Production environments must update before 2025-06-30"), "\n "));
26
+ console.warn("\n ".concat(chalk.bgRed.white.bold(" ⚠️ CRITICAL NODE.JS VERSION ALERT ⚠️ "), "\n\n ").concat(chalk.red.bold("Node.js 16 End-of-Life Notice:"), "\n ").concat(chalk.red("- Security updates and support have ended for Node.js 16"), "\n\n ").concat(chalk.yellow("▸ Detected Runtime:"), " ").concat(chalk.yellow.bold("Node.js v".concat(nodeVersion)), "\n ").concat(chalk.green("▸ Required Minimum:"), " ").concat(chalk.green.bold("Node.js LTS (v18.x or higher)"), "\n ").concat(chalk.green("▸ Recommended:"), " ").concat(chalk.green.bold("Node.js LTS (v22.x or higher)"), "\n\n ").concat(chalk.cyan("Immediate Action Required:"), "\n ").concat(chalk.gray("├──"), " ").concat(chalk.yellow("Recommended Upgrade"), "\n ").concat(chalk.bold("nvm install 22 --lts && nvm use 22"), "\n ").concat(chalk.gray("├──"), " ").concat(chalk.yellow("Manual Installation"), "\n ").concat(chalk.underline("https://nodejs.org/download/release/lts-hydrogen/"), "\n ").concat(chalk.gray("└──"), " ").concat(chalk.yellow("Environment Verification"), "\n ").concat(chalk.bold("node -v && npm -v"), "\n\n ").concat(chalk.hex("#AAAAAA").italic("[Security Advisory] Node.js 16 is no longer supported. Upgrade immediately for security and compatibility."), "\n "));
27
27
  }
28
28
  command = process.argv[2];
29
29
  cliParams = minimist(process.argv.slice(2));
File without changes
@@ -25,6 +25,9 @@ function createBuilderProviderConfig(resolveConfig, appContext) {
25
25
  const config = {
26
26
  ...resolveConfig,
27
27
  plugins: [],
28
+ resolve: {
29
+ ...resolveConfig.resolve
30
+ },
28
31
  dev: {
29
32
  ...resolveConfig.dev,
30
33
  port: appContext.port
@@ -12,6 +12,7 @@ async function generateBuilder(options, bundlerType) {
12
12
  cwd: appContext.appDirectory,
13
13
  rscClientRuntimePath: `@${appContext.metaName}/runtime/rsc/client`,
14
14
  rscServerRuntimePath: `@${appContext.metaName}/runtime/rsc/server`,
15
+ internalDirectory: appContext.internalDirectory,
15
16
  frameworkConfigPath: appContext.configFile || void 0,
16
17
  bundlerType,
17
18
  config: builderConfig
@@ -1,6 +1,6 @@
1
1
  import * as path from "path";
2
2
  import { SERVICE_WORKER_ENVIRONMENT_NAME, isHtmlDisabled } from "@modern-js/uni-builder";
3
- import { fs, isUseSSRBundle } from "@modern-js/utils";
3
+ import { fs, isUseRsc, isUseSSRBundle } from "@modern-js/utils";
4
4
  import { mergeRsbuildConfig } from "@rsbuild/core";
5
5
  import { getServerCombinedModueFile } from "../../../plugins/analyze/utils";
6
6
  import { HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins";
@@ -16,7 +16,7 @@ const builderPluginAdapterSSR = (options) => ({
16
16
  server: {
17
17
  // the http-compression can't handler stream http.
18
18
  // so we disable compress when user use stream ssr temporarily.
19
- compress: isStreamingSSR(normalizedConfig) ? false : void 0
19
+ compress: isStreamingSSR(normalizedConfig) || isUseRsc(normalizedConfig) ? false : void 0
20
20
  }
21
21
  });
22
22
  });
@@ -32,7 +32,7 @@ const builderPluginAdapterSSR = (options) => ({
32
32
  appNormalizedConfig: normalizedConfig2
33
33
  });
34
34
  }
35
- if (isUseSSRBundle(normalizedConfig2)) {
35
+ if (isUseSSRBundle(normalizedConfig2) || isUseRsc(normalizedConfig2)) {
36
36
  await applySSRLoaderEntry(chain, options, isServer);
37
37
  applySSRDataLoader(chain, options);
38
38
  }
@@ -62,7 +62,7 @@ const isStreamingSSR = (userConfig) => {
62
62
  return false;
63
63
  };
64
64
  function applyAsyncChunkHtmlPlugin({ chain, modernConfig, HtmlBundlerPlugin }) {
65
- if (isStreamingSSR(modernConfig)) {
65
+ if (isStreamingSSR(modernConfig) || isUseRsc(modernConfig)) {
66
66
  chain.plugin("html-async-chunk").use(HtmlAsyncChunkPlugin, [
67
67
  HtmlBundlerPlugin
68
68
  ]);
@@ -4,7 +4,7 @@ import { loadServerPlugins } from "../utils/loadPlugins";
4
4
  import { registerCompiler } from "../utils/register";
5
5
  import { generateRoutes } from "../utils/routes";
6
6
  const build = async (api, options) => {
7
- var _resolvedConfig_source;
7
+ var _resolvedConfig_resolve, _resolvedConfig_source;
8
8
  if (options === null || options === void 0 ? void 0 : options.analyze) {
9
9
  process.env.BUNDLE_ANALYZE = "true";
10
10
  }
@@ -13,15 +13,21 @@ const build = async (api, options) => {
13
13
  const hooks = api.getHooks();
14
14
  await loadServerPlugins(api, appContext.appDirectory, appContext.metaName);
15
15
  if (appContext.moduleType && appContext.moduleType === "module") {
16
- var _resolvedConfig_source1;
16
+ var _resolvedConfig_resolve1, _resolvedConfig_source1;
17
17
  const { registerEsm } = await import("../esm/register-esm.mjs");
18
18
  await registerEsm({
19
19
  appDir: appContext.appDirectory,
20
20
  distDir: appContext.distDirectory,
21
- alias: (_resolvedConfig_source1 = resolvedConfig.source) === null || _resolvedConfig_source1 === void 0 ? void 0 : _resolvedConfig_source1.alias
21
+ alias: {
22
+ ...(_resolvedConfig_resolve1 = resolvedConfig.resolve) === null || _resolvedConfig_resolve1 === void 0 ? void 0 : _resolvedConfig_resolve1.alias,
23
+ ...(_resolvedConfig_source1 = resolvedConfig.source) === null || _resolvedConfig_source1 === void 0 ? void 0 : _resolvedConfig_source1.alias
24
+ }
22
25
  });
23
26
  }
24
- await registerCompiler(appContext.appDirectory, appContext.distDirectory, resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.alias);
27
+ await registerCompiler(appContext.appDirectory, appContext.distDirectory, {
28
+ ...resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig_resolve = resolvedConfig.resolve) === null || _resolvedConfig_resolve === void 0 ? void 0 : _resolvedConfig_resolve.alias,
29
+ ...resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.alias
30
+ });
25
31
  const { apiOnly } = appContext;
26
32
  if (apiOnly) {
27
33
  const { appDirectory: appDirectory2, distDirectory: distDirectory2, serverConfigFile: serverConfigFile2 } = appContext;
@@ -9,7 +9,7 @@ import { printInstructions } from "../utils/printInstructions";
9
9
  import { registerCompiler } from "../utils/register";
10
10
  import { generateRoutes } from "../utils/routes";
11
11
  const dev = async (api, options, devServerOptions) => {
12
- var _normalizedConfig_source, _normalizedConfig_tools, _normalizedConfig_dev;
12
+ var _normalizedConfig_source, _normalizedConfig_resolve, _normalizedConfig_tools, _normalizedConfig_dev;
13
13
  if (options.analyze) {
14
14
  process.env.BUNDLE_ANALYZE = "true";
15
15
  }
@@ -17,15 +17,21 @@ const dev = async (api, options, devServerOptions) => {
17
17
  const appContext = api.getAppContext();
18
18
  const hooks = api.getHooks();
19
19
  if (appContext.moduleType && appContext.moduleType === "module") {
20
- var _normalizedConfig_source1;
20
+ var _normalizedConfig_resolve1, _normalizedConfig_source1;
21
21
  const { registerEsm } = await import("../esm/register-esm.mjs");
22
22
  await registerEsm({
23
23
  appDir: appContext.appDirectory,
24
24
  distDir: appContext.distDirectory,
25
- alias: (_normalizedConfig_source1 = normalizedConfig.source) === null || _normalizedConfig_source1 === void 0 ? void 0 : _normalizedConfig_source1.alias
25
+ alias: {
26
+ ...(_normalizedConfig_resolve1 = normalizedConfig.resolve) === null || _normalizedConfig_resolve1 === void 0 ? void 0 : _normalizedConfig_resolve1.alias,
27
+ ...(_normalizedConfig_source1 = normalizedConfig.source) === null || _normalizedConfig_source1 === void 0 ? void 0 : _normalizedConfig_source1.alias
28
+ }
26
29
  });
27
30
  }
28
- await 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);
31
+ await registerCompiler(appContext.appDirectory, appContext.distDirectory, {
32
+ ...normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig_source = normalizedConfig.source) === null || _normalizedConfig_source === void 0 ? void 0 : _normalizedConfig_source.alias,
33
+ ...normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig_resolve = normalizedConfig.resolve) === null || _normalizedConfig_resolve === void 0 ? void 0 : _normalizedConfig_resolve.alias
34
+ });
29
35
  const { appDirectory, distDirectory, port, apiOnly, serverConfigFile, metaName, serverRoutes } = appContext;
30
36
  await buildServerConfig({
31
37
  appDirectory,
@@ -3,11 +3,15 @@ const inspect = async (api, options) => {
3
3
  if (!appContext.builder) {
4
4
  throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
5
5
  }
6
+ const metaName = appContext.metaName === "modern-js" ? "modern.js" : appContext.metaName;
6
7
  return appContext.builder.inspectConfig({
7
8
  mode: options.env,
8
9
  verbose: options.verbose,
9
10
  outputPath: options.output,
10
- writeToDisk: true
11
+ writeToDisk: true,
12
+ extraConfigs: {
13
+ [metaName]: api.getNormalizedConfig()
14
+ }
11
15
  });
12
16
  };
13
17
  export {
@@ -34,6 +34,9 @@ function createDefaultConfig(appContext) {
34
34
  entriesDir: "./src",
35
35
  configDir: "./config",
36
36
  globalVars: getAutoInjectEnv(appContext),
37
+ alias: {}
38
+ };
39
+ const resolve = {
37
40
  alias: {
38
41
  [appContext.internalDirAlias]: appContext.internalDirectory,
39
42
  [appContext.internalSrcAlias]: appContext.srcDirectory,
@@ -70,6 +73,7 @@ function createDefaultConfig(appContext) {
70
73
  };
71
74
  return {
72
75
  source,
76
+ resolve,
73
77
  output,
74
78
  server,
75
79
  dev,
@@ -9,6 +9,7 @@ function transformNormalizedConfig(config) {
9
9
  const tools = createToolsConfig(config);
10
10
  const { bff, dev, deploy, runtime, runtimeByEntries, server, cliOptions, plugins, testing, autoLoadPlugins } = config;
11
11
  return {
12
+ resolve: {},
12
13
  source,
13
14
  html,
14
15
  output,
@@ -16,7 +16,7 @@ async function run({ cwd, initialLog, metaName = "modern-js", version, internalP
16
16
  ${chalk.bgRed.white.bold(" ⚠️ CRITICAL NODE.JS VERSION ALERT ⚠️ ")}
17
17
 
18
18
  ${chalk.red.bold("Node.js 16 End-of-Life Notice:")}
19
- ${chalk.red.bold.underline("June 30, 2025")} ${chalk.red("- Security updates and support will cease")}
19
+ ${chalk.red("- Security updates and support have ended for Node.js 16")}
20
20
 
21
21
  ${chalk.yellow("▸ Detected Runtime:")} ${chalk.yellow.bold(`Node.js v${nodeVersion}`)}
22
22
  ${chalk.green("▸ Required Minimum:")} ${chalk.green.bold("Node.js LTS (v18.x or higher)")}
@@ -30,7 +30,7 @@ async function run({ cwd, initialLog, metaName = "modern-js", version, internalP
30
30
  ${chalk.gray("└──")} ${chalk.yellow("Environment Verification")}
31
31
  ${chalk.bold("node -v && npm -v")}
32
32
 
33
- ${chalk.hex("#AAAAAA").italic("[Security Advisory] Production environments must update before 2025-06-30")}
33
+ ${chalk.hex("#AAAAAA").italic("[Security Advisory] Node.js 16 is no longer supported. Upgrade immediately for security and compatibility.")}
34
34
  `);
35
35
  }
36
36
  const command = process.argv[2];
File without changes
@@ -8,6 +8,7 @@ import type { ExperimentsUserConfig } from './experiments';
8
8
  import type { HtmlUserConfig } from './html';
9
9
  import type { OutputUserConfig } from './output';
10
10
  import type { PerformanceUserConfig } from './performance';
11
+ import type { ResolveUserConfig } from './resolve';
11
12
  import type { SecurityUserConfig } from './security';
12
13
  import type { SourceUserConfig } from './source';
13
14
  import type { TestingUserConfig } from './testing';
@@ -20,6 +21,7 @@ export interface RuntimeByEntriesUserConfig {
20
21
  [name: string]: RuntimeUserConfig;
21
22
  }
22
23
  export interface AppToolsUserConfig<B extends Bundler> {
24
+ resolve?: ResolveUserConfig;
23
25
  server?: ServerUserConfig;
24
26
  source?: SourceUserConfig;
25
27
  output?: OutputUserConfig;
@@ -0,0 +1,2 @@
1
+ import type { UniBuilderConfig } from '@modern-js/uni-builder';
2
+ export type ResolveUserConfig = UniBuilderConfig['resolve'];
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.67.11",
18
+ "version": "2.68.1",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -85,31 +85,31 @@
85
85
  "@babel/parser": "^7.22.15",
86
86
  "@babel/traverse": "^7.23.2",
87
87
  "@babel/types": "^7.26.0",
88
- "@rsbuild/core": "1.3.22",
88
+ "@rsbuild/core": "1.4.4",
89
89
  "@rsbuild/plugin-node-polyfill": "1.3.0",
90
90
  "@swc/helpers": "^0.5.17",
91
91
  "es-module-lexer": "^1.1.0",
92
- "esbuild": "0.17.19",
92
+ "esbuild": "0.25.5",
93
93
  "esbuild-register": "^3.6.0",
94
94
  "flatted": "^3.3.3",
95
- "mlly": "^1.6.1",
96
- "ndepe": "^0.1.11",
97
- "pkg-types": "^1.1.0",
95
+ "mlly": "^1.7.4",
96
+ "ndepe": "^0.1.12",
97
+ "pkg-types": "^1.3.1",
98
98
  "std-env": "^3.7.0",
99
- "@modern-js/core": "2.67.11",
100
- "@modern-js/node-bundle-require": "2.67.11",
101
- "@modern-js/plugin": "2.67.11",
102
- "@modern-js/plugin-data-loader": "2.67.11",
103
- "@modern-js/plugin-i18n": "2.67.11",
104
- "@modern-js/plugin-v2": "2.67.11",
105
- "@modern-js/prod-server": "2.67.11",
106
- "@modern-js/rsbuild-plugin-esbuild": "2.67.11",
107
- "@modern-js/server": "2.67.11",
108
- "@modern-js/server-core": "2.67.11",
109
- "@modern-js/server-utils": "2.67.11",
110
- "@modern-js/types": "2.67.11",
111
- "@modern-js/uni-builder": "2.67.11",
112
- "@modern-js/utils": "2.67.11"
99
+ "@modern-js/core": "2.68.1",
100
+ "@modern-js/node-bundle-require": "2.68.1",
101
+ "@modern-js/plugin": "2.68.1",
102
+ "@modern-js/plugin-data-loader": "2.68.1",
103
+ "@modern-js/plugin-i18n": "2.68.1",
104
+ "@modern-js/plugin-v2": "2.68.1",
105
+ "@modern-js/prod-server": "2.68.1",
106
+ "@modern-js/rsbuild-plugin-esbuild": "2.68.1",
107
+ "@modern-js/server-core": "2.68.1",
108
+ "@modern-js/server": "2.68.1",
109
+ "@modern-js/server-utils": "2.68.1",
110
+ "@modern-js/uni-builder": "2.68.1",
111
+ "@modern-js/types": "2.68.1",
112
+ "@modern-js/utils": "2.68.1"
113
113
  },
114
114
  "devDependencies": {
115
115
  "@rsbuild/plugin-webpack-swc": "1.1.1",