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

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 (147) hide show
  1. package/bin/modern-bundle-docs.js +2 -2
  2. package/bin/modern.js +2 -2
  3. package/dist/cjs/builder/generator/createCopyPattern.js +2 -1
  4. package/dist/cjs/builder/index.js +4 -0
  5. package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +2 -1
  6. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +11 -6
  7. package/dist/cjs/builder/shared/lazyCompilation.js +26 -0
  8. package/dist/cjs/commands/build.js +1 -2
  9. package/dist/cjs/commands/deploy.js +1 -3
  10. package/dist/cjs/commands/index.js +10 -2
  11. package/dist/cjs/compat/hooks.js +1 -1
  12. package/dist/cjs/esm/ts-paths-loader.js +5 -4
  13. package/dist/cjs/esm/ts-paths-loader.mjs +5 -4
  14. package/dist/cjs/index.js +73 -99
  15. package/dist/cjs/plugins/analyze/getFileSystemEntry.js +1 -1
  16. package/dist/cjs/plugins/analyze/getServerRoutes.js +2 -2
  17. package/dist/cjs/plugins/analyze/index.js +2 -2
  18. package/dist/cjs/plugins/analyze/utils.js +6 -6
  19. package/dist/cjs/plugins/deploy/index.js +7 -28
  20. package/dist/cjs/plugins/deploy/platforms/netlify.js +2 -1
  21. package/dist/cjs/plugins/deploy/platforms/node.js +12 -3
  22. package/dist/cjs/plugins/deploy/platforms/templates/node-entry.cjs +3 -2
  23. package/dist/cjs/plugins/deploy/platforms/templates/node-entry.mjs +3 -2
  24. package/dist/cjs/plugins/deploy/platforms/vercel.js +2 -1
  25. package/dist/cjs/plugins/deploy/utils/index.js +15 -12
  26. package/dist/cjs/plugins/initialize/index.js +6 -5
  27. package/dist/cjs/plugins/serverBuild.js +0 -2
  28. package/dist/cjs/run/index.js +5 -5
  29. package/dist/cjs/types/config/base.js +62 -0
  30. package/dist/cjs/types/plugin-base.js +18 -0
  31. package/dist/cjs/types/plugin.js +46 -2
  32. package/dist/cjs/utils/initAppContext.js +1 -1
  33. package/dist/cjs/utils/loadPlugins.js +13 -7
  34. package/dist/cjs/utils/register.js +1 -1
  35. package/dist/esm/builder/generator/createCopyPattern.mjs +2 -1
  36. package/dist/esm/builder/index.mjs +1 -0
  37. package/dist/esm/builder/shared/builderPlugins/adapterHtml.mjs +2 -1
  38. package/dist/esm/builder/shared/builderPlugins/adapterSSR.mjs +9 -7
  39. package/dist/esm/builder/shared/lazyCompilation.mjs +14 -1
  40. package/dist/esm/commands/build.mjs +1 -2
  41. package/dist/esm/commands/deploy.mjs +1 -3
  42. package/dist/esm/commands/index.mjs +10 -2
  43. package/dist/esm/compat/hooks.mjs +1 -1
  44. package/dist/esm/esm/ts-paths-loader.mjs +5 -4
  45. package/dist/esm/index.mjs +9 -18
  46. package/dist/esm/plugins/analyze/getFileSystemEntry.mjs +1 -1
  47. package/dist/esm/plugins/analyze/getServerRoutes.mjs +2 -2
  48. package/dist/esm/plugins/analyze/index.mjs +2 -2
  49. package/dist/esm/plugins/analyze/utils.mjs +7 -7
  50. package/dist/esm/plugins/deploy/index.mjs +5 -21
  51. package/dist/esm/plugins/deploy/platforms/netlify.mjs +2 -1
  52. package/dist/esm/plugins/deploy/platforms/node.mjs +12 -3
  53. package/dist/esm/plugins/deploy/platforms/templates/node-entry.cjs +3 -2
  54. package/dist/esm/plugins/deploy/platforms/templates/node-entry.mjs +3 -2
  55. package/dist/esm/plugins/deploy/platforms/vercel.mjs +2 -1
  56. package/dist/esm/plugins/deploy/utils/index.mjs +17 -14
  57. package/dist/esm/plugins/initialize/index.mjs +6 -5
  58. package/dist/esm/plugins/serverBuild.mjs +0 -2
  59. package/dist/esm/run/index.mjs +5 -5
  60. package/dist/esm/types/config/base.mjs +1 -0
  61. package/dist/esm/types/plugin-base.mjs +0 -0
  62. package/dist/esm/types/plugin.mjs +1 -0
  63. package/dist/esm/utils/initAppContext.mjs +2 -2
  64. package/dist/esm/utils/loadPlugins.mjs +4 -8
  65. package/dist/esm/utils/register.mjs +1 -1
  66. package/dist/esm-node/builder/generator/createCopyPattern.mjs +2 -1
  67. package/dist/esm-node/builder/index.mjs +1 -0
  68. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.mjs +2 -1
  69. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.mjs +9 -7
  70. package/dist/esm-node/builder/shared/lazyCompilation.mjs +14 -1
  71. package/dist/esm-node/commands/build.mjs +1 -2
  72. package/dist/esm-node/commands/deploy.mjs +1 -3
  73. package/dist/esm-node/commands/index.mjs +10 -2
  74. package/dist/esm-node/compat/hooks.mjs +1 -1
  75. package/dist/esm-node/esm/ts-paths-loader.mjs +5 -4
  76. package/dist/esm-node/index.mjs +10 -20
  77. package/dist/esm-node/plugins/analyze/getFileSystemEntry.mjs +1 -1
  78. package/dist/esm-node/plugins/analyze/getServerRoutes.mjs +2 -2
  79. package/dist/esm-node/plugins/analyze/index.mjs +2 -2
  80. package/dist/esm-node/plugins/analyze/utils.mjs +7 -7
  81. package/dist/esm-node/plugins/deploy/index.mjs +5 -21
  82. package/dist/esm-node/plugins/deploy/platforms/netlify.mjs +2 -1
  83. package/dist/esm-node/plugins/deploy/platforms/node.mjs +12 -3
  84. package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.cjs +3 -2
  85. package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.mjs +3 -2
  86. package/dist/esm-node/plugins/deploy/platforms/vercel.mjs +2 -1
  87. package/dist/esm-node/plugins/deploy/utils/index.mjs +17 -15
  88. package/dist/esm-node/plugins/initialize/index.mjs +6 -5
  89. package/dist/esm-node/plugins/serverBuild.mjs +0 -2
  90. package/dist/esm-node/run/index.mjs +5 -5
  91. package/dist/esm-node/types/config/base.mjs +2 -0
  92. package/dist/esm-node/types/plugin-base.mjs +1 -0
  93. package/dist/esm-node/types/plugin.mjs +1 -0
  94. package/dist/esm-node/utils/initAppContext.mjs +2 -2
  95. package/dist/esm-node/utils/loadPlugins.mjs +4 -8
  96. package/dist/esm-node/utils/register.mjs +1 -1
  97. package/dist/types/builder/index.d.ts +1 -0
  98. package/dist/types/builder/shared/builderPlugins/adapterBasic.d.ts +4 -2
  99. package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +2 -1
  100. package/dist/types/builder/shared/builderPlugins/builderHooks.d.ts +10 -2
  101. package/dist/types/builder/shared/lazyCompilation.d.ts +15 -0
  102. package/dist/types/compat/hooks.d.ts +3 -2
  103. package/dist/types/index.d.ts +1 -3
  104. package/dist/types/plugins/analyze/getBundleEntry.d.ts +5 -4
  105. package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +5 -4
  106. package/dist/types/plugins/analyze/utils.d.ts +2 -2
  107. package/dist/types/plugins/deploy/index.d.ts +1 -4
  108. package/dist/types/plugins/deploy/utils/index.d.ts +1 -1
  109. package/dist/types/run/index.d.ts +1 -1
  110. package/dist/types/types/config/base.d.ts +58 -0
  111. package/dist/types/types/config/deploy.d.ts +2 -50
  112. package/dist/types/types/config/dev.d.ts +1 -1
  113. package/dist/types/types/config/index.d.ts +18 -42
  114. package/dist/types/types/config/output.d.ts +2 -2
  115. package/dist/types/types/config/testing.d.ts +1 -1
  116. package/dist/types/types/config/tools.d.ts +1 -1
  117. package/dist/types/types/plugin-base.d.ts +188 -0
  118. package/dist/types/types/plugin.d.ts +9 -183
  119. package/dist/types/utils/initAppContext.d.ts +1 -1
  120. package/docs/apis/app/commands.md +1 -0
  121. package/docs/configure/app/bff/effect.md +5 -12
  122. package/docs/configure/app/output/disable-css-module-extension.md +3 -3
  123. package/docs/configure/app/output/disable-svgr.md +4 -0
  124. package/docs/configure/app/output/svg-default-export.md +4 -0
  125. package/docs/configure/app/server/routes.md +1 -1
  126. package/docs/configure/app/server/ssr.md +1 -1
  127. package/docs/configure/app/source/react-compiler.md +2 -0
  128. package/docs/configure/app/tools/less.md +94 -19
  129. package/docs/configure/app/tools/sass.md +87 -18
  130. package/docs/configure/app/tools/svgr.md +91 -0
  131. package/docs/configure/app/tools/swc.md +2 -2
  132. package/docs/configure/app/tools/ts-checker.md +7 -21
  133. package/docs/guides/advanced-features/server-monitor/logger.md +5 -5
  134. package/docs/guides/basic-features/env-vars.md +6 -6
  135. package/docs/guides/basic-features/render/ssr-cache.md +14 -1
  136. package/docs/guides/basic-features/static-assets/svg-assets.md +29 -17
  137. package/docs/guides/basic-features/testing/rstest.md +0 -2
  138. package/docs/guides/get-started/quick-start.md +1 -1
  139. package/docs/guides/get-started/ultramodern.md +45 -14
  140. package/docs/llms.txt +4 -3
  141. package/docs/plugin/introduction.md +10 -10
  142. package/docs/plugin/server-plugins/api.md +1 -0
  143. package/package.json +59 -30
  144. package/dist/cjs/plugins/serverRuntime.js +0 -53
  145. package/dist/esm/plugins/serverRuntime.mjs +0 -15
  146. package/dist/esm-node/plugins/serverRuntime.mjs +0 -16
  147. package/dist/types/plugins/serverRuntime.d.ts +0 -3
@@ -3,10 +3,10 @@ const nodeVersion = /^(\d+)\.(\d+)\.(\d+)$/.exec(process.versions.node);
3
3
  if (
4
4
  !nodeVersion ||
5
5
  +nodeVersion[1] < 26 ||
6
- (+nodeVersion[1] === 26 && +nodeVersion[2] < 7)
6
+ (+nodeVersion[1] === 26 && +nodeVersion[2] < 10)
7
7
  ) {
8
8
  console.error(
9
- `UltraModern.js requires Node.js >=26.7.0; detected v${process.versions.node}. Legacy Node runtimes and transpiler fallbacks are unsupported.`,
9
+ `UltraModern.js requires Node.js >=26.12.0; detected v${process.versions.node}. Legacy Node runtimes and transpiler fallbacks are unsupported.`,
10
10
  );
11
11
  process.exit(1);
12
12
  }
package/bin/modern.js CHANGED
@@ -3,10 +3,10 @@ const nodeVersion = /^(\d+)\.(\d+)\.(\d+)$/.exec(process.versions.node);
3
3
  if (
4
4
  !nodeVersion ||
5
5
  +nodeVersion[1] < 26 ||
6
- (+nodeVersion[1] === 26 && +nodeVersion[2] < 7)
6
+ (+nodeVersion[1] === 26 && +nodeVersion[2] < 10)
7
7
  ) {
8
8
  console.error(
9
- `UltraModern.js requires Node.js >=26.7.0; detected v${process.versions.node}. Legacy Node runtimes and transpiler fallbacks are unsupported.`,
9
+ `UltraModern.js requires Node.js >=26.12.0; detected v${process.versions.node}. Legacy Node runtimes and transpiler fallbacks are unsupported.`,
10
10
  );
11
11
  process.exit(1);
12
12
  }
@@ -47,7 +47,8 @@ function createPublicPattern(appContext, config, chain) {
47
47
  noErrorOnMissing: true,
48
48
  transform: (content, absoluteFrom)=>{
49
49
  if (!/\.html?$/.test(absoluteFrom)) return content;
50
- return content.toString('utf8').replace(/<%=\s*assetPrefix\s*%>/g, (0, utils_namespaceObject.removeTailSlash)(chain.output.get('publicPath')));
50
+ const publicPath = chain.output.get('publicPath');
51
+ return content.toString('utf8').replace(/<%=\s*assetPrefix\s*%>/g, (0, utils_namespaceObject.removeTailSlash)('string' == typeof publicPath ? publicPath : ''));
51
52
  }
52
53
  };
53
54
  }
@@ -31,9 +31,11 @@ __webpack_require__.d(__webpack_exports__, {
31
31
  builderPluginAdapterBasic: ()=>index_js_namespaceObject.builderPluginAdapterBasic,
32
32
  builderPluginAdapterHooks: ()=>index_js_namespaceObject.builderPluginAdapterHooks,
33
33
  createBuilderGenerator: ()=>createBuilderGenerator,
34
+ getBundleEntry: ()=>getBundleEntry_js_namespaceObject.getBundleEntry,
34
35
  parseRspackConfig: ()=>builder_namespaceObject.parseRspackConfig
35
36
  });
36
37
  const builder_namespaceObject = require("@modern-js/builder");
38
+ const getBundleEntry_js_namespaceObject = require("../plugins/analyze/getBundleEntry.js");
37
39
  const index_js_namespaceObject = require("./shared/builderPlugins/index.js");
38
40
  async function createBuilderGenerator() {
39
41
  const { createRspackBuilderForModern } = await import("./builder-rspack/index.js");
@@ -42,11 +44,13 @@ async function createBuilderGenerator() {
42
44
  exports.builderPluginAdapterBasic = __webpack_exports__.builderPluginAdapterBasic;
43
45
  exports.builderPluginAdapterHooks = __webpack_exports__.builderPluginAdapterHooks;
44
46
  exports.createBuilderGenerator = __webpack_exports__.createBuilderGenerator;
47
+ exports.getBundleEntry = __webpack_exports__.getBundleEntry;
45
48
  exports.parseRspackConfig = __webpack_exports__.parseRspackConfig;
46
49
  for(var __rspack_i in __webpack_exports__)if (-1 === [
47
50
  "builderPluginAdapterBasic",
48
51
  "builderPluginAdapterHooks",
49
52
  "createBuilderGenerator",
53
+ "getBundleEntry",
50
54
  "parseRspackConfig"
51
55
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
52
56
  Object.defineProperty(exports, '__esModule', {
@@ -58,7 +58,8 @@ const builderPluginAdapterHtml = (options)=>({
58
58
  async function injectAssetPrefix({ chain }) {
59
59
  const entries = chain.entryPoints.entries() || {};
60
60
  const entryNames = Object.keys(entries);
61
- const assetPrefix = (0, utils_namespaceObject.removeTailSlash)(chain.output.get('publicPath') || '');
61
+ const publicPath = chain.output.get('publicPath');
62
+ const assetPrefix = (0, utils_namespaceObject.removeTailSlash)('string' == typeof publicPath ? publicPath : '');
62
63
  const code = `window.__assetPrefix__ = '${assetPrefix}';`;
63
64
  entryNames.forEach((entryName)=>{
64
65
  entries[entryName].prepend(createVirtualModule(code));
@@ -28,6 +28,7 @@ var __webpack_require__ = {};
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
30
  __webpack_require__.d(__webpack_exports__, {
31
+ applySSRLoaderEntry: ()=>applySSRLoaderEntry,
31
32
  builderPluginAdapterSSR: ()=>builderPluginAdapterSSR,
32
33
  getSSRLazyCompilation: ()=>getSSRLazyCompilation
33
34
  });
@@ -70,8 +71,8 @@ const builderPluginAdapterSSR = (options)=>({
70
71
  appNormalizedConfig: normalizedConfig
71
72
  });
72
73
  if ((0, utils_namespaceObject.isUseSSRBundle)(normalizedConfig) || (0, utils_namespaceObject.isUseRsc)(normalizedConfig)) {
73
- await applySSRLoaderEntry(chain, options, isServer);
74
- applySSRDataLoader(chain, options);
74
+ await applySSRLoaderEntry(chain, options, isServer, isServiceWorker);
75
+ applySSRDataLoader(chain, options, isServer || isServiceWorker);
75
76
  }
76
77
  if (!(0, builder_namespaceObject.isHtmlDisabled)(builderConfig, target)) applyAsyncChunkHtmlPlugin({
77
78
  chain,
@@ -156,7 +157,7 @@ function applyFilterEntriesBySSRConfig({ isProd, chain, appNormalizedConfig }) {
156
157
  if (!serverConfig?.rsc && !ssgEntries.includes(name) && !name.includes('server-loaders') && (ssr && ssrByEntries?.[name] === false || !ssr && !ssrByEntries?.[name])) chain.entryPoints.delete(name);
157
158
  });
158
159
  }
159
- async function applySSRLoaderEntry(chain, optinos, isServer) {
160
+ async function applySSRLoaderEntry(chain, optinos, isServer, isServiceWorker) {
160
161
  const { appContext } = optinos;
161
162
  const { internalDirectory } = appContext;
162
163
  const { entrypoints } = appContext;
@@ -167,20 +168,24 @@ async function applySSRLoaderEntry(chain, optinos, isServer) {
167
168
  await utils_namespaceObject.fs.access(serverLoadersFile, utils_namespaceObject.fs.constants.F_OK);
168
169
  chain.entry(`${entryName}-server-loaders`).add(serverLoadersFile);
169
170
  } catch (err) {}
170
- else if ((0, utils_namespaceObject.isUseRsc)(optinos.normalizedConfig)) chain.entry(`${entryName}-server-loaders`).add("data:text/javascript,export%20{};");
171
+ else if (!isServiceWorker && (0, utils_namespaceObject.isUseRsc)(optinos.normalizedConfig)) chain.entry(`${entryName}-server-loaders`).add("data:text/javascript,export%20{};");
171
172
  }));
172
173
  }
173
- function applySSRDataLoader(chain, options) {
174
+ function applySSRDataLoader(chain, options, server) {
174
175
  const { normalizedConfig, appContext } = options;
175
176
  const { appDirectory } = appContext;
176
177
  const { entriesDir = './src' } = normalizedConfig.source;
177
178
  const absolutePath = external_path_namespaceObject.resolve(appDirectory, entriesDir).split(external_path_namespaceObject.sep).join('(\\\\|/)');
178
179
  const reg = new RegExp(`${absolutePath}.*\\.(loader|data|data.client)\\.[t|j]sx?$`);
179
- chain.module.rule('ssr-data-loader').test(reg).use('data-loader').loader(require.resolve('@modern-js/plugin-data-loader/loader')).end();
180
+ chain.module.rule('ssr-data-loader').test(reg).enforce('pre').use('data-loader').loader(require.resolve('@modern-js/plugin-data-loader/loader')).options({
181
+ server
182
+ }).end();
180
183
  }
184
+ exports.applySSRLoaderEntry = __webpack_exports__.applySSRLoaderEntry;
181
185
  exports.builderPluginAdapterSSR = __webpack_exports__.builderPluginAdapterSSR;
182
186
  exports.getSSRLazyCompilation = __webpack_exports__.getSSRLazyCompilation;
183
187
  for(var __rspack_i in __webpack_exports__)if (-1 === [
188
+ "applySSRLoaderEntry",
184
189
  "builderPluginAdapterSSR",
185
190
  "getSSRLazyCompilation"
186
191
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
@@ -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)=>{
@@ -29,11 +38,14 @@ var __webpack_exports__ = {};
29
38
  __webpack_require__.r(__webpack_exports__);
30
39
  __webpack_require__.d(__webpack_exports__, {
31
40
  aggregateEagerRouteComponentFiles: ()=>aggregateEagerRouteComponentFiles,
41
+ buildDefaultLazyCompilationTest: ()=>buildDefaultLazyCompilationTest,
32
42
  buildSSRLazyCompilationTest: ()=>buildSSRLazyCompilationTest,
33
43
  collectRouteComponentFiles: ()=>utils_namespaceObject.collectRouteComponentFiles,
34
44
  normalizeModulePath: ()=>utils_namespaceObject.normalizeModulePath,
35
45
  planSSRLazyCompilation: ()=>planSSRLazyCompilation
36
46
  });
47
+ const external_node_path_namespaceObject = require("node:path");
48
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
37
49
  const utils_namespaceObject = require("@modern-js/utils");
38
50
  function aggregateEagerRouteComponentFiles(byEntry) {
39
51
  const files = new Set();
@@ -56,6 +68,18 @@ function buildSSRLazyCompilationTest(eagerRouteFiles, userTest) {
56
68
  return userTestFn(m);
57
69
  };
58
70
  }
71
+ function buildDefaultLazyCompilationTest(appDirectory, internalDirectory) {
72
+ let dirs;
73
+ return (m)=>{
74
+ if (!('resource' in m) || 'string' != typeof m.resource) return true;
75
+ dirs ??= {
76
+ app: (0, utils_namespaceObject.normalizeModulePath)(appDirectory),
77
+ internal: (0, utils_namespaceObject.normalizeModulePath)(internalDirectory)
78
+ };
79
+ const file = m.resource.split('?')[0].split(external_node_path_default().sep).join('/');
80
+ return file.startsWith(`${dirs.app}/`) && !file.startsWith(`${dirs.internal}/`) && !file.slice(dirs.app.length).includes('/node_modules/');
81
+ };
82
+ }
59
83
  function planSSRLazyCompilation(current, info) {
60
84
  if (!current) return {
61
85
  apply: false
@@ -78,12 +102,14 @@ function planSSRLazyCompilation(current, info) {
78
102
  };
79
103
  }
80
104
  exports.aggregateEagerRouteComponentFiles = __webpack_exports__.aggregateEagerRouteComponentFiles;
105
+ exports.buildDefaultLazyCompilationTest = __webpack_exports__.buildDefaultLazyCompilationTest;
81
106
  exports.buildSSRLazyCompilationTest = __webpack_exports__.buildSSRLazyCompilationTest;
82
107
  exports.collectRouteComponentFiles = __webpack_exports__.collectRouteComponentFiles;
83
108
  exports.normalizeModulePath = __webpack_exports__.normalizeModulePath;
84
109
  exports.planSSRLazyCompilation = __webpack_exports__.planSSRLazyCompilation;
85
110
  for(var __rspack_i in __webpack_exports__)if (-1 === [
86
111
  "aggregateEagerRouteComponentFiles",
112
+ "buildDefaultLazyCompilationTest",
87
113
  "buildSSRLazyCompilationTest",
88
114
  "collectRouteComponentFiles",
89
115
  "normalizeModulePath",
@@ -98,10 +98,9 @@ const build = async (api, options)=>{
98
98
  utils_namespaceObject.logger.info('Starting production build...');
99
99
  if (!appContext.builder) throw new Error('Expect the Builder to have been initialized, But the appContext.builder received `undefined`');
100
100
  await appContext.builder.onAfterBuild(async ()=>copyEnvFiles(appContext.appDirectory, appContext.distDirectory));
101
- const buildResult = await appContext.builder.build({
101
+ await appContext.builder.build({
102
102
  watch: options?.watch
103
103
  });
104
- if (!options?.watch) await buildResult?.close();
105
104
  };
106
105
  exports.build = __webpack_exports__.build;
107
106
  for(var __rspack_i in __webpack_exports__)if (-1 === [
@@ -31,12 +31,10 @@ __webpack_require__.d(__webpack_exports__, {
31
31
  deploy: ()=>deploy
32
32
  });
33
33
  const loadPlugins_js_namespaceObject = require("../utils/loadPlugins.js");
34
- const external_build_js_namespaceObject = require("./build.js");
35
34
  const deploy = async (api, options = {})=>{
36
35
  const hooks = api.getHooks();
37
36
  const { metaName } = api.getAppContext();
38
- if (options.skipBuild) await (0, loadPlugins_js_namespaceObject.getServerPlugins)(api, metaName);
39
- else await (0, external_build_js_namespaceObject.build)(api);
37
+ await (0, loadPlugins_js_namespaceObject.getServerPlugins)(api, metaName);
40
38
  await hooks.onBeforeDeploy.call(options);
41
39
  await hooks.deploy.call();
42
40
  await hooks.onAfterDeploy.call(options);
@@ -36,6 +36,10 @@ __webpack_require__.d(__webpack_exports__, {
36
36
  serverCommand: ()=>serverCommand
37
37
  });
38
38
  const index_js_namespaceObject = require("../locale/index.js");
39
+ const deployTargetOption = [
40
+ '--deploy-target <target>',
41
+ 'deploy target; overrides deploy.target and MODERNJS_DEPLOY'
42
+ ];
39
43
  const devCommand = async (program, api)=>{
40
44
  program.command('dev').alias('start').usage('[options]').description(index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.dev.describe)).option('-c --config <config>', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.config)).option('-e --entry [entry...]', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.dev.entry)).option('--analyze', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.analyze)).option('--api-only', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.dev.apiOnly)).option('--web-only', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.dev.webOnly)).action(async (options)=>{
41
45
  const { dev } = await import("./dev.js");
@@ -43,7 +47,7 @@ const devCommand = async (program, api)=>{
43
47
  });
44
48
  };
45
49
  const buildCommand = async (program, api)=>{
46
- program.command('build').usage('[options]').description(index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.build.describe)).option('-c --config <config>', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.config)).option('--analyze', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.analyze)).option('-w --watch', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.build.watch)).action(async (options)=>{
50
+ program.command('build').usage('[options]').description(index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.build.describe)).option('-c --config <config>', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.config)).option('--analyze', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.analyze)).option('-w --watch', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.build.watch)).option(...deployTargetOption).action(async (options)=>{
47
51
  const { build } = await import("./build.js");
48
52
  await build(api, options);
49
53
  });
@@ -55,7 +59,11 @@ const serverCommand = (program, api)=>{
55
59
  });
56
60
  };
57
61
  const deployCommand = (program, api)=>{
58
- program.command('deploy').usage('[options]').option('-c --config <config>', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.config)).option('-s --skip-build', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.skipBuild)).description(index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.deploy.describe)).action(async (options)=>{
62
+ program.command('deploy').usage('[options]').option('-c --config <config>', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.config)).option('-s --skip-build', index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.shared.skipBuild)).option(...deployTargetOption).description(index_js_namespaceObject.i18n.t(index_js_namespaceObject.localeKeys.command.deploy.describe)).action(async (options)=>{
63
+ if (!options.skipBuild) {
64
+ const { build } = await import("./build.js");
65
+ await build(api);
66
+ }
59
67
  const { deploy } = await import("./deploy.js");
60
68
  await deploy(api, options);
61
69
  process.exit(0);
@@ -92,7 +92,7 @@ function handleSetupResult(setupResult, api) {
92
92
  if (newAPI && api[newAPI]) api[newAPI](async (...params)=>{
93
93
  const { isMultiple, params: transformParams } = (0, external_utils_js_namespaceObject.transformHookParams)(key, params);
94
94
  if (isMultiple) return (0, external_utils_js_namespaceObject.transformHookResult)(key, await fn(...transformParams));
95
- return (0, external_utils_js_namespaceObject.transformHookResult)(key, await fn(transformParams));
95
+ else return (0, external_utils_js_namespaceObject.transformHookResult)(key, await fn(transformParams));
96
96
  });
97
97
  }
98
98
  });
@@ -47,8 +47,9 @@ const getParentPath = (parentURL)=>{
47
47
  } catch {}
48
48
  return process.cwd();
49
49
  };
50
+ const resolveSourcePath = (resolvedPath, context, defaultResolve)=>defaultResolve(context.conditions?.find((condition)=>'require' === condition || 'import' === condition) === 'require' ? resolvedPath : (0, external_url_namespaceObject.pathToFileURL)(resolvedPath).href, context, defaultResolve);
50
51
  async function initialize({ appDir: currentAppDir, baseUrl, paths }) {
51
- appDir = external_node_path_namespaceObject.resolve(currentAppDir);
52
+ appDir = external_node_fs_namespaceObject.existsSync(currentAppDir) ? external_node_fs_namespaceObject.realpathSync(currentAppDir) : external_node_path_namespaceObject.resolve(currentAppDir);
52
53
  matchPath = (0, tsconfig_paths_namespaceObject.createMatchPath)(baseUrl || './', paths || {});
53
54
  }
54
55
  function resolve(specifier, context, defaultResolve) {
@@ -58,13 +59,13 @@ function resolve(specifier, context, defaultResolve) {
58
59
  if ((specifier.startsWith('./') || specifier.startsWith('../')) && !external_node_path_namespaceObject.extname(specifier) && isAppFile) {
59
60
  const matchedPath = external_node_path_namespaceObject.resolve(parentPath, specifier);
60
61
  const resolvedPath = (0, utils_namespaceObject.findSourceEntry)(matchedPath) || matchedPath;
61
- if (resolvedPath && external_node_fs_namespaceObject.existsSync(resolvedPath)) return defaultResolve((0, external_url_namespaceObject.pathToFileURL)(resolvedPath).href, context, defaultResolve);
62
+ if (resolvedPath && external_node_fs_namespaceObject.existsSync(resolvedPath)) return resolveSourcePath(resolvedPath, context, defaultResolve);
62
63
  }
63
- if (!matchPath) return defaultResolve(specifier, context, defaultResolve);
64
+ if (!matchPath || !isAppFile) return defaultResolve(specifier, context, defaultResolve);
64
65
  const match = (0, utils_namespaceObject.findMatchedSourcePath)(matchPath, specifier);
65
66
  if (!match) return defaultResolve(specifier, context, defaultResolve);
66
67
  const resolvedPath = (0, utils_namespaceObject.findSourceEntry)(match) || match;
67
- return defaultResolve((0, external_url_namespaceObject.pathToFileURL)(resolvedPath).href, context, defaultResolve);
68
+ return resolveSourcePath(resolvedPath, context, defaultResolve);
68
69
  }
69
70
  exports.initialize = __webpack_exports__.initialize;
70
71
  exports.resolve = __webpack_exports__.resolve;
@@ -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
  export async function initialize({ appDir: currentAppDir, baseUrl, paths }) {
18
- appDir = path.resolve(currentAppDir);
19
+ appDir = fs.existsSync(currentAppDir) ? fs.realpathSync(currentAppDir) : path.resolve(currentAppDir);
19
20
  matchPath = oCreateMatchPath(baseUrl || './', paths || {});
20
21
  }
21
22
  export function resolve(specifier, context, defaultResolve) {
@@ -25,11 +26,11 @@ export function resolve(specifier, context, defaultResolve) {
25
26
  if ((specifier.startsWith('./') || specifier.startsWith('../')) && !path.extname(specifier) && isAppFile) {
26
27
  const matchedPath = path.resolve(parentPath, specifier);
27
28
  const resolvedPath = findSourceEntry(matchedPath) || matchedPath;
28
- if (resolvedPath && fs.existsSync(resolvedPath)) return defaultResolve(pathToFileURL(resolvedPath).href, context, defaultResolve);
29
+ if (resolvedPath && 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
  }