@bleedingdev/modern-js-app-tools 3.9.0-ultramodern.9 → 3.9.3-ultramodern.2

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 (145) hide show
  1. package/bin/modern-bundle-docs.js +2 -2
  2. package/bin/modern.js +2 -2
  3. package/dist/cjs/builder/generator/adapterCopy.js +26 -0
  4. package/dist/cjs/builder/generator/createCopyPattern.js +2 -1
  5. package/dist/cjs/builder/index.js +4 -0
  6. package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +2 -1
  7. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +11 -6
  8. package/dist/cjs/builder/shared/lazyCompilation.js +26 -0
  9. package/dist/cjs/commands/build.js +1 -2
  10. package/dist/cjs/commands/deploy.js +1 -3
  11. package/dist/cjs/commands/index.js +10 -2
  12. package/dist/cjs/compat/hooks.js +1 -1
  13. package/dist/cjs/esm/ts-paths-loader.js +5 -4
  14. package/dist/cjs/esm/ts-paths-loader.mjs +5 -4
  15. package/dist/cjs/index.js +73 -99
  16. package/dist/cjs/plugins/analyze/getFileSystemEntry.js +1 -1
  17. package/dist/cjs/plugins/analyze/getServerRoutes.js +1 -1
  18. package/dist/cjs/plugins/analyze/index.js +2 -2
  19. package/dist/cjs/plugins/analyze/utils.js +6 -6
  20. package/dist/cjs/plugins/deploy/index.js +7 -28
  21. package/dist/cjs/plugins/deploy/platforms/netlify.js +2 -1
  22. package/dist/cjs/plugins/deploy/platforms/node.js +12 -3
  23. package/dist/cjs/plugins/deploy/platforms/templates/node-entry.cjs +3 -2
  24. package/dist/cjs/plugins/deploy/platforms/templates/node-entry.mjs +3 -2
  25. package/dist/cjs/plugins/deploy/platforms/vercel.js +2 -1
  26. package/dist/cjs/plugins/deploy/utils/index.js +15 -12
  27. package/dist/cjs/plugins/initialize/index.js +6 -5
  28. package/dist/cjs/plugins/serverBuild.js +0 -2
  29. package/dist/cjs/run/index.js +5 -5
  30. package/dist/cjs/types/config/base.js +62 -0
  31. package/dist/cjs/types/plugin-base.js +18 -0
  32. package/dist/cjs/types/plugin.js +46 -2
  33. package/dist/cjs/utils/initAppContext.js +1 -1
  34. package/dist/cjs/utils/loadPlugins.js +13 -7
  35. package/dist/cjs/utils/register.js +1 -1
  36. package/dist/esm/builder/generator/adapterCopy.mjs +23 -1
  37. package/dist/esm/builder/generator/createCopyPattern.mjs +2 -1
  38. package/dist/esm/builder/index.mjs +1 -0
  39. package/dist/esm/builder/shared/builderPlugins/adapterHtml.mjs +2 -1
  40. package/dist/esm/builder/shared/builderPlugins/adapterSSR.mjs +9 -7
  41. package/dist/esm/builder/shared/lazyCompilation.mjs +14 -1
  42. package/dist/esm/commands/build.mjs +1 -2
  43. package/dist/esm/commands/deploy.mjs +1 -3
  44. package/dist/esm/commands/index.mjs +10 -2
  45. package/dist/esm/compat/hooks.mjs +1 -1
  46. package/dist/esm/esm/ts-paths-loader.mjs +5 -4
  47. package/dist/esm/index.mjs +9 -18
  48. package/dist/esm/plugins/analyze/getFileSystemEntry.mjs +1 -1
  49. package/dist/esm/plugins/analyze/getServerRoutes.mjs +1 -1
  50. package/dist/esm/plugins/analyze/index.mjs +2 -2
  51. package/dist/esm/plugins/analyze/utils.mjs +7 -7
  52. package/dist/esm/plugins/deploy/index.mjs +5 -21
  53. package/dist/esm/plugins/deploy/platforms/netlify.mjs +2 -1
  54. package/dist/esm/plugins/deploy/platforms/node.mjs +12 -3
  55. package/dist/esm/plugins/deploy/platforms/templates/node-entry.cjs +3 -2
  56. package/dist/esm/plugins/deploy/platforms/templates/node-entry.mjs +3 -2
  57. package/dist/esm/plugins/deploy/platforms/vercel.mjs +2 -1
  58. package/dist/esm/plugins/deploy/utils/index.mjs +17 -14
  59. package/dist/esm/plugins/initialize/index.mjs +6 -5
  60. package/dist/esm/plugins/serverBuild.mjs +0 -2
  61. package/dist/esm/run/index.mjs +5 -5
  62. package/dist/esm/types/config/base.mjs +1 -0
  63. package/dist/esm/types/plugin-base.mjs +0 -0
  64. package/dist/esm/types/plugin.mjs +1 -0
  65. package/dist/esm/utils/initAppContext.mjs +2 -2
  66. package/dist/esm/utils/loadPlugins.mjs +4 -8
  67. package/dist/esm/utils/register.mjs +1 -1
  68. package/dist/esm-node/builder/generator/adapterCopy.mjs +23 -1
  69. package/dist/esm-node/builder/generator/createCopyPattern.mjs +2 -1
  70. package/dist/esm-node/builder/index.mjs +1 -0
  71. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.mjs +2 -1
  72. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.mjs +9 -7
  73. package/dist/esm-node/builder/shared/lazyCompilation.mjs +14 -1
  74. package/dist/esm-node/commands/build.mjs +1 -2
  75. package/dist/esm-node/commands/deploy.mjs +1 -3
  76. package/dist/esm-node/commands/index.mjs +10 -2
  77. package/dist/esm-node/compat/hooks.mjs +1 -1
  78. package/dist/esm-node/esm/ts-paths-loader.mjs +5 -4
  79. package/dist/esm-node/index.mjs +10 -20
  80. package/dist/esm-node/plugins/analyze/getFileSystemEntry.mjs +1 -1
  81. package/dist/esm-node/plugins/analyze/getServerRoutes.mjs +1 -1
  82. package/dist/esm-node/plugins/analyze/index.mjs +2 -2
  83. package/dist/esm-node/plugins/analyze/utils.mjs +7 -7
  84. package/dist/esm-node/plugins/deploy/index.mjs +5 -21
  85. package/dist/esm-node/plugins/deploy/platforms/netlify.mjs +2 -1
  86. package/dist/esm-node/plugins/deploy/platforms/node.mjs +12 -3
  87. package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.cjs +3 -2
  88. package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.mjs +3 -2
  89. package/dist/esm-node/plugins/deploy/platforms/vercel.mjs +2 -1
  90. package/dist/esm-node/plugins/deploy/utils/index.mjs +17 -15
  91. package/dist/esm-node/plugins/initialize/index.mjs +6 -5
  92. package/dist/esm-node/plugins/serverBuild.mjs +0 -2
  93. package/dist/esm-node/run/index.mjs +5 -5
  94. package/dist/esm-node/types/config/base.mjs +2 -0
  95. package/dist/esm-node/types/plugin-base.mjs +1 -0
  96. package/dist/esm-node/types/plugin.mjs +1 -0
  97. package/dist/esm-node/utils/initAppContext.mjs +2 -2
  98. package/dist/esm-node/utils/loadPlugins.mjs +4 -8
  99. package/dist/esm-node/utils/register.mjs +1 -1
  100. package/dist/types/builder/generator/adapterCopy.d.ts +13 -1
  101. package/dist/types/builder/index.d.ts +1 -0
  102. package/dist/types/builder/shared/builderPlugins/adapterBasic.d.ts +4 -2
  103. package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +2 -1
  104. package/dist/types/builder/shared/builderPlugins/builderHooks.d.ts +10 -2
  105. package/dist/types/builder/shared/lazyCompilation.d.ts +15 -0
  106. package/dist/types/compat/hooks.d.ts +3 -2
  107. package/dist/types/index.d.ts +1 -3
  108. package/dist/types/plugins/analyze/getBundleEntry.d.ts +5 -4
  109. package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +5 -4
  110. package/dist/types/plugins/analyze/utils.d.ts +2 -2
  111. package/dist/types/plugins/deploy/index.d.ts +1 -4
  112. package/dist/types/plugins/deploy/utils/index.d.ts +1 -1
  113. package/dist/types/run/index.d.ts +1 -1
  114. package/dist/types/types/config/base.d.ts +58 -0
  115. package/dist/types/types/config/deploy.d.ts +2 -50
  116. package/dist/types/types/config/dev.d.ts +1 -1
  117. package/dist/types/types/config/index.d.ts +18 -42
  118. package/dist/types/types/config/output.d.ts +2 -2
  119. package/dist/types/types/config/testing.d.ts +1 -1
  120. package/dist/types/types/config/tools.d.ts +1 -1
  121. package/dist/types/types/plugin-base.d.ts +188 -0
  122. package/dist/types/types/plugin.d.ts +9 -183
  123. package/dist/types/utils/initAppContext.d.ts +1 -1
  124. package/docs/apis/app/commands.md +1 -0
  125. package/docs/configure/app/bff/effect.md +5 -12
  126. package/docs/configure/app/output/disable-svgr.md +4 -0
  127. package/docs/configure/app/output/svg-default-export.md +4 -0
  128. package/docs/configure/app/source/react-compiler.md +2 -0
  129. package/docs/configure/app/tools/less.md +94 -19
  130. package/docs/configure/app/tools/sass.md +87 -18
  131. package/docs/configure/app/tools/svgr.md +91 -0
  132. package/docs/configure/app/tools/ts-checker.md +7 -21
  133. package/docs/guides/basic-features/render/ssr-cache.md +14 -1
  134. package/docs/guides/basic-features/static-assets/svg-assets.md +29 -17
  135. package/docs/guides/basic-features/testing/rstest.md +0 -2
  136. package/docs/guides/get-started/quick-start.md +1 -1
  137. package/docs/guides/get-started/ultramodern.md +45 -14
  138. package/docs/llms.txt +4 -3
  139. package/docs/plugin/introduction.md +10 -10
  140. package/docs/plugin/server-plugins/api.md +1 -0
  141. package/package.json +59 -30
  142. package/dist/cjs/plugins/serverRuntime.js +0 -53
  143. package/dist/esm/plugins/serverRuntime.mjs +0 -15
  144. package/dist/esm-node/plugins/serverRuntime.mjs +0 -16
  145. package/dist/types/plugins/serverRuntime.d.ts +0 -3
@@ -31,6 +31,7 @@ __webpack_require__.d(__webpack_exports__, {
31
31
  default: ()=>initialize
32
32
  });
33
33
  const utils_namespaceObject = require("@modern-js/utils");
34
+ const lazyCompilation_js_namespaceObject = require("../../builder/shared/lazyCompilation.js");
34
35
  const index_js_namespaceObject = require("../../config/index.js");
35
36
  const initialize = ()=>({
36
37
  name: '@modern-js/plugin-initialize',
@@ -49,7 +50,8 @@ const initialize = ()=>({
49
50
  ...defaultConfig.dev,
50
51
  lazyCompilation: {
51
52
  imports: true,
52
- entries: false
53
+ entries: false,
54
+ test: (0, lazyCompilation_js_namespaceObject.buildDefaultLazyCompilationTest)(appContext.appDirectory, appContext.internalDirectory)
53
55
  }
54
56
  };
55
57
  return defaultConfig;
@@ -57,7 +59,7 @@ const initialize = ()=>({
57
59
  api.modifyResolvedConfig(async (resolved)=>{
58
60
  let appContext = api.getAppContext();
59
61
  const userConfig = api.getConfig();
60
- const port = await getServerPort(resolved, appContext.command);
62
+ const port = await getServerPort(resolved);
61
63
  appContext = {
62
64
  ...appContext,
63
65
  port,
@@ -92,10 +94,9 @@ function stabilizeConfig(resolve, config, keys) {
92
94
  resolve[key] = config[key] || {};
93
95
  });
94
96
  }
95
- async function getServerPort(config, contextCommand) {
97
+ async function getServerPort(config) {
96
98
  const prodPort = Number(process.env.PORT) || config.server.port || 8080;
97
- const isProgrammaticDev = 'dev' === contextCommand || 'start' === contextCommand;
98
- if ((0, utils_namespaceObject.isDev)() && ((0, utils_namespaceObject.isDevCommand)() || isProgrammaticDev)) return (0, utils_namespaceObject.getPort)(Number(process.env.PORT) || prodPort);
99
+ if ((0, utils_namespaceObject.isDev)() && (0, utils_namespaceObject.isDevCommand)()) return (0, utils_namespaceObject.getPort)(Number(process.env.PORT) || prodPort);
99
100
  return prodPort;
100
101
  }
101
102
  exports["default"] = __webpack_exports__["default"];
@@ -72,10 +72,8 @@ const serverBuild = ()=>({
72
72
  sourceDirs.push(serverDir);
73
73
  if (external_fs_default().existsSync(sharedDir)) sourceDirs.push(sharedDir);
74
74
  }
75
- const { server } = modernConfig;
76
75
  const { alias } = modernConfig.source;
77
76
  if (sourceDirs.length > 0) await (0, server_utils_namespaceObject.compile)(appDirectory, {
78
- server,
79
77
  alias
80
78
  }, {
81
79
  sourceDirs,
@@ -40,21 +40,21 @@ const loadPlugins_js_namespaceObject = require("../utils/loadPlugins.js");
40
40
  async function createRunOptions({ cwd, initialLog, metaName = 'modern-js', version, internalPlugins, configFile }) {
41
41
  const nodeVersion = process.versions.node;
42
42
  const versionArr = nodeVersion.split('.').map(Number);
43
- if (versionArr[0] < 26 || 26 === versionArr[0] && versionArr[1] < 7) throw new Error(`
43
+ if (versionArr[0] < 26 || 26 === versionArr[0] && versionArr[1] < 10) throw new Error(`
44
44
  ${utils_namespaceObject.chalk.bgRed.white.bold(' UNSUPPORTED NODE.JS RUNTIME ')}
45
45
 
46
- ${utils_namespaceObject.chalk.red.bold(`UltraModern.js requires Node.js >=26.7.0; detected v${nodeVersion}.`)}
46
+ ${utils_namespaceObject.chalk.red.bold(`UltraModern.js requires Node.js >=26.10.0; detected v${nodeVersion}.`)}
47
47
  ${utils_namespaceObject.chalk.red('- Legacy Node runtimes and TypeScript transpiler fallbacks are unsupported.')}
48
48
 
49
49
  ${utils_namespaceObject.chalk.yellow('▸ Detected Runtime:')} ${utils_namespaceObject.chalk.yellow.bold(`Node.js v${nodeVersion}`)}
50
- ${utils_namespaceObject.chalk.green('▸ Required Minimum:')} ${utils_namespaceObject.chalk.green.bold('Node.js v26.7.0 or higher')}
51
- ${utils_namespaceObject.chalk.green('▸ Pinned Runtime:')} ${utils_namespaceObject.chalk.green.bold('Node.js v26.7.0')}
50
+ ${utils_namespaceObject.chalk.green('▸ Required Minimum:')} ${utils_namespaceObject.chalk.green.bold('Node.js v26.10.0 or higher')}
51
+ ${utils_namespaceObject.chalk.green('▸ Pinned Runtime:')} ${utils_namespaceObject.chalk.green.bold('Node.js v26.10.0')}
52
52
 
53
53
  ${utils_namespaceObject.chalk.cyan('Immediate Action Required:')}
54
54
  ${utils_namespaceObject.chalk.gray('├──')} ${utils_namespaceObject.chalk.yellow('Recommended Upgrade')}
55
55
  ${utils_namespaceObject.chalk.bold('mise install && mise exec -- node --version')}
56
56
  ${utils_namespaceObject.chalk.gray('├──')} ${utils_namespaceObject.chalk.yellow('Manual Installation')}
57
- ${utils_namespaceObject.chalk.underline('https://nodejs.org/download/release/v26.7.0/')}
57
+ ${utils_namespaceObject.chalk.underline('https://nodejs.org/download/release/v26.10.0/')}
58
58
  ${utils_namespaceObject.chalk.gray('└──')} ${utils_namespaceObject.chalk.yellow('Environment Verification')}
59
59
  ${utils_namespaceObject.chalk.bold('node -v && npm -v')}
60
60
 
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __webpack_modules__ = {
3
+ "./output" (module) {
4
+ module.exports = require("./output.js");
5
+ }
6
+ };
7
+ var __webpack_module_cache__ = {};
8
+ function __webpack_require__(moduleId) {
9
+ var cachedModule = __webpack_module_cache__[moduleId];
10
+ if (void 0 !== cachedModule) return cachedModule.exports;
11
+ var module = __webpack_module_cache__[moduleId] = {
12
+ exports: {}
13
+ };
14
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
15
+ return module.exports;
16
+ }
17
+ (()=>{
18
+ __webpack_require__.n = (module)=>{
19
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
20
+ __webpack_require__.d(getter, {
21
+ a: getter
22
+ });
23
+ return getter;
24
+ };
25
+ })();
26
+ (()=>{
27
+ __webpack_require__.d = (exports1, getters, values)=>{
28
+ var define = (defs, kind)=>{
29
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
30
+ enumerable: true,
31
+ [kind]: defs[key]
32
+ });
33
+ };
34
+ define(getters, "get");
35
+ define(values, "value");
36
+ };
37
+ })();
38
+ (()=>{
39
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
40
+ })();
41
+ (()=>{
42
+ __webpack_require__.r = (exports1)=>{
43
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
44
+ value: 'Module'
45
+ });
46
+ Object.defineProperty(exports1, '__esModule', {
47
+ value: true
48
+ });
49
+ };
50
+ })();
51
+ var __webpack_exports__ = {};
52
+ (()=>{
53
+ __webpack_require__.r(__webpack_exports__);
54
+ var _output__rspack_import_0 = __webpack_require__("./output");
55
+ var __rspack_reexport = {};
56
+ for(const __rspack_import_key in _output__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_output__rspack_import_0[__rspack_import_key];
57
+ __webpack_require__.d(__webpack_exports__, __rspack_reexport);
58
+ })();
59
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
60
+ Object.defineProperty(exports, '__esModule', {
61
+ value: true
62
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.r = (exports1)=>{
5
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
+ value: 'Module'
7
+ });
8
+ Object.defineProperty(exports1, '__esModule', {
9
+ value: true
10
+ });
11
+ };
12
+ })();
13
+ var __webpack_exports__ = {};
14
+ __webpack_require__.r(__webpack_exports__);
15
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
16
+ Object.defineProperty(exports, '__esModule', {
17
+ value: true
18
+ });
@@ -1,5 +1,43 @@
1
1
  "use strict";
2
- var __webpack_require__ = {};
2
+ var __webpack_modules__ = {
3
+ "./plugin-base" (module) {
4
+ module.exports = require("./plugin-base.js");
5
+ }
6
+ };
7
+ var __webpack_module_cache__ = {};
8
+ function __webpack_require__(moduleId) {
9
+ var cachedModule = __webpack_module_cache__[moduleId];
10
+ if (void 0 !== cachedModule) return cachedModule.exports;
11
+ var module = __webpack_module_cache__[moduleId] = {
12
+ exports: {}
13
+ };
14
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
15
+ return module.exports;
16
+ }
17
+ (()=>{
18
+ __webpack_require__.n = (module)=>{
19
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
20
+ __webpack_require__.d(getter, {
21
+ a: getter
22
+ });
23
+ return getter;
24
+ };
25
+ })();
26
+ (()=>{
27
+ __webpack_require__.d = (exports1, getters, values)=>{
28
+ var define = (defs, kind)=>{
29
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
30
+ enumerable: true,
31
+ [kind]: defs[key]
32
+ });
33
+ };
34
+ define(getters, "get");
35
+ define(values, "value");
36
+ };
37
+ })();
38
+ (()=>{
39
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
40
+ })();
3
41
  (()=>{
4
42
  __webpack_require__.r = (exports1)=>{
5
43
  if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
@@ -11,7 +49,13 @@ var __webpack_require__ = {};
11
49
  };
12
50
  })();
13
51
  var __webpack_exports__ = {};
14
- __webpack_require__.r(__webpack_exports__);
52
+ (()=>{
53
+ __webpack_require__.r(__webpack_exports__);
54
+ var _plugin_base__rspack_import_0 = __webpack_require__("./plugin-base");
55
+ var __rspack_reexport = {};
56
+ for(const __rspack_import_key in _plugin_base__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_plugin_base__rspack_import_0[__rspack_import_key];
57
+ __webpack_require__.d(__webpack_exports__, __rspack_reexport);
58
+ })();
15
59
  for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
16
60
  Object.defineProperty(exports, '__esModule', {
17
61
  value: true
@@ -59,7 +59,7 @@ const initAppContext = ({ metaName, appDirectory, runtimeConfigFile, options, te
59
59
  const moduleType = utils_namespaceObject.fs.existsSync(pkgPath) ? utils_namespaceObject.fs.readJSONSync(pkgPath).type || 'commonjs' : 'commonjs';
60
60
  return {
61
61
  runtimeConfigFile,
62
- ip: utils_namespaceObject.address.ip(),
62
+ ip: (0, utils_namespaceObject.ip)(),
63
63
  port: 0,
64
64
  moduleType,
65
65
  apiDirectory: external_path_default().resolve(appDirectory, apiDir),
@@ -1,5 +1,14 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
3
12
  (()=>{
4
13
  __webpack_require__.d = (exports1, getters, values)=>{
5
14
  var define = (defs, kind)=>{
@@ -32,6 +41,8 @@ __webpack_require__.d(__webpack_exports__, {
32
41
  loadInternalPlugins: ()=>loadInternalPlugins,
33
42
  loadServerPlugins: ()=>loadServerPlugins
34
43
  });
44
+ const external_node_path_namespaceObject = require("node:path");
45
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
35
46
  const node_namespaceObject = require("@modern-js/server-core/node");
36
47
  const utils_namespaceObject = require("@modern-js/utils");
37
48
  const debug = (0, utils_namespaceObject.createDebugger)('load-plugins');
@@ -40,7 +51,7 @@ async function getServerPlugins(api, metaName = 'modern-js') {
40
51
  const { plugins } = await hooks._internalServerPlugins.call({
41
52
  plugins: []
42
53
  });
43
- const filtedPlugins = plugins.filter((plugin)=>plugin.name.includes(metaName));
54
+ const filtedPlugins = plugins.filter((plugin)=>external_node_path_default().isAbsolute(plugin.name) || plugin.name.includes(metaName));
44
55
  api.updateAppContext({
45
56
  serverPlugins: filtedPlugins
46
57
  });
@@ -55,12 +66,7 @@ const resolveCliPlugin = async (p, appDirectory)=>{
55
66
  const pkg = 'string' == typeof p ? p : p[0];
56
67
  const pluginOptions = 'string' == typeof p ? void 0 : p[1];
57
68
  const path = (0, utils_namespaceObject.tryResolve)(pkg, appDirectory);
58
- let module;
59
- try {
60
- module = await (0, utils_namespaceObject.compatibleRequire)(path);
61
- } catch (e) {
62
- ({ default: module } = await (0, utils_namespaceObject.dynamicImport)(path));
63
- }
69
+ const module = await (0, utils_namespaceObject.compatibleRequire)(path);
64
70
  if ('function' == typeof module) {
65
71
  const result = module(pluginOptions);
66
72
  return result;
@@ -100,7 +100,7 @@ const resolveTsRuntimeRegisterMode = ()=>{
100
100
  return 'unsupported';
101
101
  };
102
102
  const setupTsRuntime = async (appDir, distDir, alias, options = {})=>{
103
- if ('unsupported' === resolveTsRuntimeRegisterMode()) throw new Error(`UltraModern.js requires Node.js >=26.7.0 with native TypeScript support; detected v${process.versions.node}. Legacy TypeScript runtime transpilers are unsupported.`);
103
+ if ('unsupported' === resolveTsRuntimeRegisterMode()) throw new Error(`UltraModern.js requires Node.js >=26.10.0 with native TypeScript support; detected v${process.versions.node}. Legacy TypeScript runtime transpilers are unsupported.`);
104
104
  const tsconfigPath = (0, utils_namespaceObject.resolveServerTsconfig)(appDir, options.tsconfigPath);
105
105
  const isTsProject = await utils_namespaceObject.fs.pathExists(tsconfigPath);
106
106
  if (!isTsProject) return;
@@ -1,6 +1,21 @@
1
+ import node_fs from "node:fs";
1
2
  import path from "path";
2
3
  import { createCopyInfo } from "../shared/index.mjs";
3
4
  import { createPublicPattern } from "./createCopyPattern.mjs";
5
+ class MissingCopyContextPlugin {
6
+ apply(compiler) {
7
+ compiler.hooks.afterCompile.tap('MissingCopyContextPlugin', (compilation)=>{
8
+ for (const context of this.contexts)if (!node_fs.existsSync(context)) {
9
+ compilation.contextDependencies.delete(context);
10
+ compilation.missingDependencies.add(context);
11
+ for(let parent = path.dirname(context); parent !== path.dirname(parent) && !node_fs.existsSync(parent); parent = path.dirname(parent))compilation.missingDependencies.add(parent);
12
+ }
13
+ });
14
+ }
15
+ constructor(contexts){
16
+ this.contexts = contexts;
17
+ }
18
+ }
4
19
  const builderPluginAdapterCopy = (options)=>({
5
20
  name: 'builder-plugin-adapter-copy',
6
21
  setup (api) {
@@ -28,8 +43,15 @@ const builderPluginAdapterCopy = (options)=>({
28
43
  ]
29
44
  }
30
45
  ]);
46
+ const patterns = chain.plugin(CHAIN_ID.PLUGIN.COPY).get('args')?.[0]?.patterns ?? [];
47
+ const optionalContexts = patterns.flatMap((pattern)=>pattern && 'object' == typeof pattern && 'noErrorOnMissing' in pattern && pattern.noErrorOnMissing && 'context' in pattern && 'string' == typeof pattern.context ? [
48
+ path.resolve(appContext.appDirectory, pattern.context)
49
+ ] : []);
50
+ if (optionalContexts.length) chain.plugin('modern-missing-copy-context').use(MissingCopyContextPlugin, [
51
+ optionalContexts
52
+ ]);
31
53
  }
32
54
  });
33
55
  }
34
56
  });
35
- export { builderPluginAdapterCopy };
57
+ export { MissingCopyContextPlugin, builderPluginAdapterCopy };
@@ -14,7 +14,8 @@ function createPublicPattern(appContext, config, chain) {
14
14
  noErrorOnMissing: true,
15
15
  transform: (content, absoluteFrom)=>{
16
16
  if (!/\.html?$/.test(absoluteFrom)) return content;
17
- return content.toString('utf8').replace(/<%=\s*assetPrefix\s*%>/g, removeTailSlash(chain.output.get('publicPath')));
17
+ const publicPath = chain.output.get('publicPath');
18
+ return content.toString('utf8').replace(/<%=\s*assetPrefix\s*%>/g, removeTailSlash('string' == typeof publicPath ? publicPath : ''));
18
19
  }
19
20
  };
20
21
  }
@@ -3,5 +3,6 @@ async function createBuilderGenerator() {
3
3
  return createRspackBuilderForModern;
4
4
  }
5
5
  export { parseRspackConfig } from "@modern-js/builder";
6
+ export { getBundleEntry } from "../plugins/analyze/getBundleEntry.mjs";
6
7
  export { builderPluginAdapterBasic, builderPluginAdapterHooks } from "./shared/builderPlugins/index.mjs";
7
8
  export { createBuilderGenerator };
@@ -26,7 +26,8 @@ const builderPluginAdapterHtml = (options)=>({
26
26
  async function injectAssetPrefix({ chain }) {
27
27
  const entries = chain.entryPoints.entries() || {};
28
28
  const entryNames = Object.keys(entries);
29
- const assetPrefix = removeTailSlash(chain.output.get('publicPath') || '');
29
+ const publicPath = chain.output.get('publicPath');
30
+ const assetPrefix = removeTailSlash('string' == typeof publicPath ? publicPath : '');
30
31
  const code = `window.__assetPrefix__ = '${assetPrefix}';`;
31
32
  entryNames.forEach((entryName)=>{
32
33
  entries[entryName].prepend(createVirtualModule(code));
@@ -37,8 +37,8 @@ const builderPluginAdapterSSR = (options)=>({
37
37
  appNormalizedConfig: normalizedConfig
38
38
  });
39
39
  if (isUseSSRBundle(normalizedConfig) || isUseRsc(normalizedConfig)) {
40
- await applySSRLoaderEntry(chain, options, isServer);
41
- applySSRDataLoader(chain, options);
40
+ await applySSRLoaderEntry(chain, options, isServer, isServiceWorker);
41
+ applySSRDataLoader(chain, options, isServer || isServiceWorker);
42
42
  }
43
43
  if (!isHtmlDisabled(builderConfig, target)) applyAsyncChunkHtmlPlugin({
44
44
  chain,
@@ -123,7 +123,7 @@ function applyFilterEntriesBySSRConfig({ isProd, chain, appNormalizedConfig }) {
123
123
  if (!serverConfig?.rsc && !ssgEntries.includes(name) && !name.includes('server-loaders') && (ssr && ssrByEntries?.[name] === false || !ssr && !ssrByEntries?.[name])) chain.entryPoints.delete(name);
124
124
  });
125
125
  }
126
- async function applySSRLoaderEntry(chain, optinos, isServer) {
126
+ async function applySSRLoaderEntry(chain, optinos, isServer, isServiceWorker) {
127
127
  const { appContext } = optinos;
128
128
  const { internalDirectory } = appContext;
129
129
  const { entrypoints } = appContext;
@@ -134,15 +134,17 @@ async function applySSRLoaderEntry(chain, optinos, isServer) {
134
134
  await fs.access(serverLoadersFile, fs.constants.F_OK);
135
135
  chain.entry(`${entryName}-server-loaders`).add(serverLoadersFile);
136
136
  } catch (err) {}
137
- else if (isUseRsc(optinos.normalizedConfig)) chain.entry(`${entryName}-server-loaders`).add("data:text/javascript,export%20{};");
137
+ else if (!isServiceWorker && isUseRsc(optinos.normalizedConfig)) chain.entry(`${entryName}-server-loaders`).add("data:text/javascript,export%20{};");
138
138
  }));
139
139
  }
140
- function applySSRDataLoader(chain, options) {
140
+ function applySSRDataLoader(chain, options, server) {
141
141
  const { normalizedConfig, appContext } = options;
142
142
  const { appDirectory } = appContext;
143
143
  const { entriesDir = './src' } = normalizedConfig.source;
144
144
  const absolutePath = __rspack_external_path.resolve(appDirectory, entriesDir).split(__rspack_external_path.sep).join('(\\\\|/)');
145
145
  const reg = new RegExp(`${absolutePath}.*\\.(loader|data|data.client)\\.[t|j]sx?$`);
146
- chain.module.rule('ssr-data-loader').test(reg).use('data-loader').loader(require.resolve('@modern-js/plugin-data-loader/loader')).end();
146
+ chain.module.rule('ssr-data-loader').test(reg).enforce('pre').use('data-loader').loader(require.resolve('@modern-js/plugin-data-loader/loader')).options({
147
+ server
148
+ }).end();
147
149
  }
148
- export { builderPluginAdapterSSR, getSSRLazyCompilation };
150
+ export { applySSRLoaderEntry, builderPluginAdapterSSR, getSSRLazyCompilation };
@@ -1,3 +1,4 @@
1
+ import node_path from "node:path";
1
2
  import { collectRouteComponentFiles, normalizeModulePath } from "@modern-js/utils";
2
3
  function aggregateEagerRouteComponentFiles(byEntry) {
3
4
  const files = new Set();
@@ -20,6 +21,18 @@ function buildSSRLazyCompilationTest(eagerRouteFiles, userTest) {
20
21
  return userTestFn(m);
21
22
  };
22
23
  }
24
+ function buildDefaultLazyCompilationTest(appDirectory, internalDirectory) {
25
+ let dirs;
26
+ return (m)=>{
27
+ if (!('resource' in m) || 'string' != typeof m.resource) return true;
28
+ dirs ??= {
29
+ app: normalizeModulePath(appDirectory),
30
+ internal: normalizeModulePath(internalDirectory)
31
+ };
32
+ const file = m.resource.split('?')[0].split(node_path.sep).join('/');
33
+ return file.startsWith(`${dirs.app}/`) && !file.startsWith(`${dirs.internal}/`) && !file.slice(dirs.app.length).includes('/node_modules/');
34
+ };
35
+ }
23
36
  function planSSRLazyCompilation(current, info) {
24
37
  if (!current) return {
25
38
  apply: false
@@ -41,4 +54,4 @@ function planSSRLazyCompilation(current, info) {
41
54
  }
42
55
  };
43
56
  }
44
- export { aggregateEagerRouteComponentFiles, buildSSRLazyCompilationTest, collectRouteComponentFiles, normalizeModulePath, planSSRLazyCompilation };
57
+ export { aggregateEagerRouteComponentFiles, buildDefaultLazyCompilationTest, buildSSRLazyCompilationTest, collectRouteComponentFiles, normalizeModulePath, planSSRLazyCompilation };
@@ -56,9 +56,8 @@ const build = async (api, options)=>{
56
56
  logger.info('Starting production build...');
57
57
  if (!appContext.builder) throw new Error('Expect the Builder to have been initialized, But the appContext.builder received `undefined`');
58
58
  await appContext.builder.onAfterBuild(async ()=>copyEnvFiles(appContext.appDirectory, appContext.distDirectory));
59
- const buildResult = await appContext.builder.build({
59
+ await appContext.builder.build({
60
60
  watch: options?.watch
61
61
  });
62
- if (!options?.watch) await buildResult?.close();
63
62
  };
64
63
  export { build };
@@ -1,10 +1,8 @@
1
1
  import { getServerPlugins } from "../utils/loadPlugins.mjs";
2
- import { build } from "./build.mjs";
3
2
  const deploy = async (api, options = {})=>{
4
3
  const hooks = api.getHooks();
5
4
  const { metaName } = api.getAppContext();
6
- if (options.skipBuild) await getServerPlugins(api, metaName);
7
- else await build(api);
5
+ await getServerPlugins(api, metaName);
8
6
  await hooks.onBeforeDeploy.call(options);
9
7
  await hooks.deploy.call();
10
8
  await hooks.onAfterDeploy.call(options);
@@ -1,4 +1,8 @@
1
1
  import { i18n, localeKeys } from "../locale/index.mjs";
2
+ const deployTargetOption = [
3
+ '--deploy-target <target>',
4
+ 'deploy target; overrides deploy.target and MODERNJS_DEPLOY'
5
+ ];
2
6
  const devCommand = async (program, api)=>{
3
7
  program.command('dev').alias('start').usage('[options]').description(i18n.t(localeKeys.command.dev.describe)).option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('-e --entry [entry...]', i18n.t(localeKeys.command.dev.entry)).option('--analyze', i18n.t(localeKeys.command.shared.analyze)).option('--api-only', i18n.t(localeKeys.command.dev.apiOnly)).option('--web-only', i18n.t(localeKeys.command.dev.webOnly)).action(async (options)=>{
4
8
  const { dev } = await import("./dev.mjs");
@@ -6,7 +10,7 @@ const devCommand = async (program, api)=>{
6
10
  });
7
11
  };
8
12
  const buildCommand = async (program, api)=>{
9
- program.command('build').usage('[options]').description(i18n.t(localeKeys.command.build.describe)).option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('--analyze', i18n.t(localeKeys.command.shared.analyze)).option('-w --watch', i18n.t(localeKeys.command.build.watch)).action(async (options)=>{
13
+ program.command('build').usage('[options]').description(i18n.t(localeKeys.command.build.describe)).option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('--analyze', i18n.t(localeKeys.command.shared.analyze)).option('-w --watch', i18n.t(localeKeys.command.build.watch)).option(...deployTargetOption).action(async (options)=>{
10
14
  const { build } = await import("./build.mjs");
11
15
  await build(api, options);
12
16
  });
@@ -18,7 +22,11 @@ const serverCommand = (program, api)=>{
18
22
  });
19
23
  };
20
24
  const deployCommand = (program, api)=>{
21
- program.command('deploy').usage('[options]').option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('-s --skip-build', i18n.t(localeKeys.command.shared.skipBuild)).description(i18n.t(localeKeys.command.deploy.describe)).action(async (options)=>{
25
+ program.command('deploy').usage('[options]').option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('-s --skip-build', i18n.t(localeKeys.command.shared.skipBuild)).option(...deployTargetOption).description(i18n.t(localeKeys.command.deploy.describe)).action(async (options)=>{
26
+ if (!options.skipBuild) {
27
+ const { build } = await import("./build.mjs");
28
+ await build(api);
29
+ }
22
30
  const { deploy } = await import("./deploy.mjs");
23
31
  await deploy(api, options);
24
32
  process.exit(0);
@@ -59,7 +59,7 @@ function handleSetupResult(setupResult, api) {
59
59
  if (newAPI && api[newAPI]) api[newAPI](async (...params)=>{
60
60
  const { isMultiple, params: transformParams } = transformHookParams(key, params);
61
61
  if (isMultiple) return transformHookResult(key, await fn(...transformParams));
62
- return transformHookResult(key, await fn(transformParams));
62
+ else return transformHookResult(key, await fn(transformParams));
63
63
  });
64
64
  }
65
65
  });
@@ -14,8 +14,9 @@ const getParentPath = (parentURL)=>{
14
14
  } catch {}
15
15
  return process.cwd();
16
16
  };
17
+ const resolveSourcePath = (resolvedPath, context, defaultResolve)=>defaultResolve(context.conditions?.find((condition)=>'require' === condition || 'import' === condition) === 'require' ? resolvedPath : pathToFileURL(resolvedPath).href, context, defaultResolve);
17
18
  async function initialize({ appDir: currentAppDir, baseUrl, paths }) {
18
- appDir = node_path.resolve(currentAppDir);
19
+ appDir = node_fs.existsSync(currentAppDir) ? node_fs.realpathSync(currentAppDir) : node_path.resolve(currentAppDir);
19
20
  matchPath = createMatchPath(baseUrl || './', paths || {});
20
21
  }
21
22
  function resolve(specifier, context, defaultResolve) {
@@ -25,12 +26,12 @@ function resolve(specifier, context, defaultResolve) {
25
26
  if ((specifier.startsWith('./') || specifier.startsWith('../')) && !node_path.extname(specifier) && isAppFile) {
26
27
  const matchedPath = node_path.resolve(parentPath, specifier);
27
28
  const resolvedPath = findSourceEntry(matchedPath) || matchedPath;
28
- if (resolvedPath && node_fs.existsSync(resolvedPath)) return defaultResolve(pathToFileURL(resolvedPath).href, context, defaultResolve);
29
+ if (resolvedPath && node_fs.existsSync(resolvedPath)) return resolveSourcePath(resolvedPath, context, defaultResolve);
29
30
  }
30
- if (!matchPath) return defaultResolve(specifier, context, defaultResolve);
31
+ if (!matchPath || !isAppFile) return defaultResolve(specifier, context, defaultResolve);
31
32
  const match = findMatchedSourcePath(matchPath, specifier);
32
33
  if (!match) return defaultResolve(specifier, context, defaultResolve);
33
34
  const resolvedPath = findSourceEntry(match) || match;
34
- return defaultResolve(pathToFileURL(resolvedPath).href, context, defaultResolve);
35
+ return resolveSourcePath(resolvedPath, context, defaultResolve);
35
36
  }
36
37
  export { initialize, resolve };
@@ -1,8 +1,9 @@
1
+ import { resolveDeployTarget } from "@modern-js/app-tools-extensions/deploy-output/target";
1
2
  import { createPolicyDefaultsPlugin } from "@modern-js/app-tools-extensions/policy-defaults";
2
3
  import { castArray } from "@modern-js/builder";
3
4
  import { getLocaleLanguage } from "@modern-js/i18n-utils/language-detector";
4
5
  import { createAsyncHook } from "@modern-js/plugin";
5
- import { cleanRequireCache, deprecatedCommands, emptyDir, getArgv, getCommand } from "@modern-js/utils";
6
+ import { deprecatedCommands, emptyDir, getArgv, getCommand } from "@modern-js/utils";
6
7
  import path from "path";
7
8
  import { buildCommand, deployCommand, devCommand, infoCommand, inspectCommand, serverCommand } from "./commands/index.mjs";
8
9
  import { compatPlugin } from "./compat/index.mjs";
@@ -12,7 +13,6 @@ import analyze from "./plugins/analyze/index.mjs";
12
13
  import deploy from "./plugins/deploy/index.mjs";
13
14
  import initialize from "./plugins/initialize/index.mjs";
14
15
  import serverBuild from "./plugins/serverBuild.mjs";
15
- import serverRuntime from "./plugins/serverRuntime.mjs";
16
16
  import { generateWatchFiles } from "./utils/generateWatchFiles.mjs";
17
17
  import { initAppContext } from "./utils/initAppContext.mjs";
18
18
  import { restart } from "./utils/restart.mjs";
@@ -21,7 +21,6 @@ export * from "./types/index.mjs";
21
21
  const appTools = (options = {})=>({
22
22
  name: '@modern-js/app-tools',
23
23
  usePlugins: [
24
- serverRuntime(),
25
24
  compatPlugin(),
26
25
  initialize(),
27
26
  analyze(),
@@ -74,6 +73,11 @@ const appTools = (options = {})=>({
74
73
  deprecatedCommands(program);
75
74
  });
76
75
  api.onPrepare(async ()=>{
76
+ api.updateAppContext({
77
+ deployTarget: resolveDeployTarget({
78
+ configTarget: api.getNormalizedConfig().deploy?.target
79
+ })
80
+ });
77
81
  const command = getCommand();
78
82
  if ('deploy' === command) {
79
83
  const isSkipBuild = [
@@ -82,18 +86,12 @@ const appTools = (options = {})=>({
82
86
  ].some((tag)=>getArgv().includes(tag));
83
87
  if (isSkipBuild) return;
84
88
  }
85
- const { command: contextCommand } = api.getAppContext();
86
- const shouldClean = [
89
+ if ([
87
90
  'dev',
88
91
  'start',
89
92
  'build',
90
93
  'deploy'
91
- ].includes(command) || [
92
- 'dev',
93
- 'start',
94
- 'build'
95
- ].includes(contextCommand);
96
- if (shouldClean) {
94
+ ].includes(command)) {
97
95
  const resolvedConfig = api.getNormalizedConfig();
98
96
  if (resolvedConfig.output.cleanDistPath) {
99
97
  const appContext = api.getAppContext();
@@ -124,17 +122,10 @@ const appTools = (options = {})=>({
124
122
  await restart(api.getHooks(), filename);
125
123
  }
126
124
  });
127
- api.onBeforeRestart(()=>{
128
- cleanRequireCache([
129
- require.resolve('./plugins/analyze')
130
- ]);
131
- });
132
125
  }
133
126
  });
134
127
  const src = appTools;
135
128
  export { defineConfig } from "./defineConfig.mjs";
136
- export { build } from "./commands/build.mjs";
137
- export { deploy } from "./commands/deploy.mjs";
138
129
  export { dev } from "./commands/dev.mjs";
139
130
  export { serve } from "./commands/serve.mjs";
140
131
  export { resolveModernRsbuildConfig } from "./rsbuild.mjs";
@@ -61,6 +61,6 @@ const getFileSystemEntry = async (hooks, appContext, config)=>{
61
61
  }));
62
62
  return scanDir(hooks, dirs);
63
63
  } else throw Error("source.entriesDir accept a directory.");
64
- throw Error(`src dir ${entriesDir} not found.`);
64
+ else throw Error(`src dir ${entriesDir} not found.`);
65
65
  };
66
66
  export { getFileSystemEntry, hasEntry, hasServerEntry };
@@ -26,7 +26,7 @@ const applyRouteOptions = (original, routeOptions)=>{
26
26
  ...original,
27
27
  urlPath: url
28
28
  };
29
- {
29
+ else {
30
30
  const { path: urlPath, ...other } = url;
31
31
  return {
32
32
  ...original,
@@ -23,7 +23,7 @@ const analyze = ()=>({
23
23
  const resolvedConfig = api.getNormalizedConfig();
24
24
  const hooks = api.getHooks();
25
25
  try {
26
- if (checkIsBuildCommands(appContext.command)) fs.emptydirSync(appContext.internalDirectory);
26
+ if (checkIsBuildCommands()) fs.emptydirSync(appContext.internalDirectory);
27
27
  } catch {}
28
28
  const apiOnly = await isApiOnly(appContext.appDirectory, resolvedConfig.source?.entriesDir, appContext.apiDirectory);
29
29
  const [{ getProdEntrypoints, getProdServerRoutes }] = await Promise.all([
@@ -125,7 +125,7 @@ const analyze = ()=>({
125
125
  htmlTemplates
126
126
  };
127
127
  api.updateAppContext(appContext);
128
- if (checkIsBuildCommands(appContext.command)) {
128
+ if (checkIsBuildCommands()) {
129
129
  await hooks.generateEntryCode.call({
130
130
  entrypoints
131
131
  });