@modern-js/app-tools 2.63.1 → 2.63.3

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 (138) hide show
  1. package/bin/modern.js +1 -1
  2. package/dist/cjs/commands/build.js +19 -13
  3. package/dist/cjs/commands/deploy.js +5 -5
  4. package/dist/cjs/commands/dev.js +11 -11
  5. package/dist/cjs/commands/index.js +6 -6
  6. package/dist/cjs/commands/inspect.js +1 -1
  7. package/dist/cjs/commands/serve.js +4 -4
  8. package/dist/cjs/{new/compat → compat}/hooks.js +21 -6
  9. package/dist/cjs/{new/compat → compat}/index.js +7 -2
  10. package/dist/cjs/{new/compat → compat}/utils.js +29 -8
  11. package/dist/cjs/config/default.js +6 -1
  12. package/dist/cjs/config/legacy/index.js +0 -1
  13. package/dist/cjs/index.js +154 -5
  14. package/dist/cjs/plugins/analyze/getServerRoutes.js +12 -2
  15. package/dist/cjs/plugins/analyze/index.js +25 -10
  16. package/dist/cjs/plugins/analyze/utils.js +6 -0
  17. package/dist/cjs/plugins/deploy/platforms/netlify.js +7 -4
  18. package/dist/cjs/plugins/deploy/platforms/node.js +6 -3
  19. package/dist/cjs/plugins/deploy/platforms/vercel.js +7 -4
  20. package/dist/cjs/plugins/serverBuild.js +30 -32
  21. package/dist/cjs/{new/run.js → run/index.js} +6 -6
  22. package/dist/cjs/{new → utils}/getConfigFile.js +1 -1
  23. package/dist/cjs/{new/context.js → utils/initAppContext.js} +3 -3
  24. package/dist/cjs/{new/utils/index.js → utils/isAutoLoadPlugins.js} +6 -6
  25. package/dist/cjs/utils/loadPlugins.js +35 -4
  26. package/dist/cjs/utils/printInstructions.js +2 -11
  27. package/dist/cjs/utils/restart.js +2 -2
  28. package/dist/esm/commands/build.js +18 -12
  29. package/dist/esm/commands/deploy.js +6 -6
  30. package/dist/esm/commands/dev.js +11 -11
  31. package/dist/esm/commands/index.js +8 -8
  32. package/dist/esm/commands/inspect.js +1 -1
  33. package/dist/esm/commands/serve.js +6 -6
  34. package/dist/esm/{new/compat → compat}/hooks.js +98 -49
  35. package/dist/esm/{new/compat → compat}/index.js +8 -3
  36. package/dist/esm/{new/compat → compat}/utils.js +29 -8
  37. package/dist/esm/config/default.js +12 -1
  38. package/dist/esm/config/legacy/index.js +0 -1
  39. package/dist/esm/index.js +245 -2
  40. package/dist/esm/plugins/analyze/getServerRoutes.js +11 -2
  41. package/dist/esm/plugins/analyze/index.js +76 -34
  42. package/dist/esm/plugins/analyze/utils.js +5 -0
  43. package/dist/esm/plugins/deploy/platforms/netlify.js +6 -3
  44. package/dist/esm/plugins/deploy/platforms/node.js +5 -2
  45. package/dist/esm/plugins/deploy/platforms/vercel.js +6 -3
  46. package/dist/esm/plugins/serverBuild.js +52 -56
  47. package/dist/esm/{new/run.js → run/index.js} +6 -6
  48. package/dist/esm/{new → utils}/getConfigFile.js +1 -1
  49. package/dist/esm/{new/utils/index.js → utils/isAutoLoadPlugins.js} +6 -6
  50. package/dist/esm/utils/loadPlugins.js +95 -7
  51. package/dist/esm/utils/printInstructions.js +1 -28
  52. package/dist/esm/utils/restart.js +3 -3
  53. package/dist/esm-node/commands/build.js +19 -13
  54. package/dist/esm-node/commands/deploy.js +5 -5
  55. package/dist/esm-node/commands/dev.js +12 -12
  56. package/dist/esm-node/commands/index.js +6 -6
  57. package/dist/esm-node/commands/inspect.js +1 -1
  58. package/dist/esm-node/commands/serve.js +5 -5
  59. package/dist/esm-node/{new/compat → compat}/hooks.js +21 -6
  60. package/dist/esm-node/{new/compat → compat}/index.js +8 -3
  61. package/dist/esm-node/{new/compat → compat}/utils.js +29 -8
  62. package/dist/esm-node/config/default.js +6 -1
  63. package/dist/esm-node/config/legacy/index.js +0 -1
  64. package/dist/esm-node/index.js +140 -2
  65. package/dist/esm-node/plugins/analyze/getServerRoutes.js +11 -2
  66. package/dist/esm-node/plugins/analyze/index.js +26 -11
  67. package/dist/esm-node/plugins/analyze/utils.js +5 -0
  68. package/dist/esm-node/plugins/deploy/platforms/netlify.js +6 -3
  69. package/dist/esm-node/plugins/deploy/platforms/node.js +5 -2
  70. package/dist/esm-node/plugins/deploy/platforms/vercel.js +6 -3
  71. package/dist/esm-node/plugins/serverBuild.js +30 -32
  72. package/dist/esm-node/{new/run.js → run/index.js} +6 -6
  73. package/dist/esm-node/{new → utils}/getConfigFile.js +1 -1
  74. package/dist/esm-node/{new/utils/index.js → utils/isAutoLoadPlugins.js} +2 -2
  75. package/dist/esm-node/utils/loadPlugins.js +34 -4
  76. package/dist/esm-node/utils/printInstructions.js +1 -9
  77. package/dist/esm-node/utils/restart.js +2 -2
  78. package/dist/types/commands/build.d.ts +2 -2
  79. package/dist/types/commands/deploy.d.ts +2 -2
  80. package/dist/types/commands/dev.d.ts +2 -2
  81. package/dist/types/commands/index.d.ts +6 -6
  82. package/dist/types/commands/inspect.d.ts +2 -2
  83. package/dist/types/commands/serve.d.ts +2 -2
  84. package/dist/types/{new/compat → compat}/hooks.d.ts +2 -2
  85. package/dist/types/compat/index.d.ts +2 -0
  86. package/dist/types/{new/compat → compat}/utils.d.ts +8 -1
  87. package/dist/types/index.d.ts +5 -3
  88. package/dist/types/plugins/analyze/getServerRoutes.d.ts +1 -0
  89. package/dist/types/plugins/analyze/utils.d.ts +1 -0
  90. package/dist/types/plugins/serverBuild.d.ts +2 -2
  91. package/dist/types/types/config/index.d.ts +0 -1
  92. package/dist/types/types/index.d.ts +2 -0
  93. package/dist/types/types/new.d.ts +11 -16
  94. package/dist/types/utils/generateWatchFiles.d.ts +2 -2
  95. package/dist/types/utils/isAutoLoadPlugins.d.ts +1 -0
  96. package/dist/types/utils/loadPlugins.d.ts +13 -3
  97. package/dist/types/utils/printInstructions.d.ts +1 -3
  98. package/dist/types/utils/restart.d.ts +2 -3
  99. package/package.json +24 -28
  100. package/dist/cjs/hooks.js +0 -60
  101. package/dist/cjs/new/index.js +0 -79
  102. package/dist/cjs/new/loadPlugins.js +0 -57
  103. package/dist/cjs/old.js +0 -179
  104. package/dist/cjs/plugins/deploy/dependencies/index.js +0 -237
  105. package/dist/cjs/plugins/deploy/dependencies/utils.js +0 -179
  106. package/dist/cjs/plugins/deploy/exports.js +0 -28
  107. package/dist/esm/hooks.js +0 -36
  108. package/dist/esm/new/index.js +0 -55
  109. package/dist/esm/new/loadPlugins.js +0 -94
  110. package/dist/esm/old.js +0 -258
  111. package/dist/esm/plugins/deploy/dependencies/index.js +0 -615
  112. package/dist/esm/plugins/deploy/dependencies/utils.js +0 -421
  113. package/dist/esm/plugins/deploy/exports.js +0 -4
  114. package/dist/esm-node/hooks.js +0 -36
  115. package/dist/esm-node/new/index.js +0 -52
  116. package/dist/esm-node/new/loadPlugins.js +0 -33
  117. package/dist/esm-node/old.js +0 -140
  118. package/dist/esm-node/plugins/deploy/dependencies/index.js +0 -202
  119. package/dist/esm-node/plugins/deploy/dependencies/utils.js +0 -137
  120. package/dist/esm-node/plugins/deploy/exports.js +0 -4
  121. package/dist/types/hooks.d.ts +0 -2
  122. package/dist/types/new/compat/index.d.ts +0 -2
  123. package/dist/types/new/index.d.ts +0 -6
  124. package/dist/types/new/loadPlugins.d.ts +0 -9
  125. package/dist/types/new/utils/index.d.ts +0 -1
  126. package/dist/types/old.d.ts +0 -13
  127. package/dist/types/plugins/deploy/dependencies/index.d.ts +0 -20
  128. package/dist/types/plugins/deploy/dependencies/utils.d.ts +0 -44
  129. package/dist/types/plugins/deploy/exports.d.ts +0 -1
  130. /package/dist/cjs/{new/constants.js → constants.js} +0 -0
  131. /package/dist/esm/{new/constants.js → constants.js} +0 -0
  132. /package/dist/esm/{new/context.js → utils/initAppContext.js} +0 -0
  133. /package/dist/esm-node/{new/constants.js → constants.js} +0 -0
  134. /package/dist/esm-node/{new/context.js → utils/initAppContext.js} +0 -0
  135. /package/dist/types/{new/constants.d.ts → constants.d.ts} +0 -0
  136. /package/dist/types/{new/run.d.ts → run/index.d.ts} +0 -0
  137. /package/dist/types/{new → utils}/getConfigFile.d.ts +0 -0
  138. /package/dist/types/{new/context.d.ts → utils/initAppContext.d.ts} +0 -0
@@ -2,6 +2,7 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
3
  import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
4
  import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
5
+ import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
5
6
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
6
7
  import * as path from "path";
7
8
  import { fs, createDebugger, getArgv, isApiOnly, isDevCommand, minimist } from "@modern-js/utils";
@@ -11,7 +12,7 @@ import { emitResolvedConfig } from "../../utils/config";
11
12
  import { getSelectedEntries } from "../../utils/getSelectedEntries";
12
13
  import { printInstructions } from "../../utils/printInstructions";
13
14
  import { generateRoutes } from "../../utils/routes";
14
- import { checkIsBuildCommands } from "./utils";
15
+ import { checkIsBuildCommands, checkIsServeCommand } from "./utils";
15
16
  var debug = createDebugger("plugin-analyze");
16
17
  function analyze_default(param) {
17
18
  var bundler = param.bundler;
@@ -24,7 +25,7 @@ function analyze_default(param) {
24
25
  var pagesDir = [];
25
26
  var nestedRouteEntries = [];
26
27
  api.onPrepare(/* @__PURE__ */ _async_to_generator(function() {
27
- var _resolvedConfig_source, appContext, resolvedConfig, hooks, apiOnly, routes, _ref, getBundleEntry, getServerRoutes, getHtmlTemplate, entrypoints, _, _1, _tmp, initialRoutes, routes1, _ref1, partialsByEntrypoint, htmlTemplates, checkedEntries, entry, normalizedConfig, createBuilderForModern, builder;
28
+ var _resolvedConfig_source, appContext, resolvedConfig, hooks, apiOnly, _ref, getProdServerRoutes, routes, _routes, _routes1, _ref1, modifiedRoutes, _ref2, getBundleEntry, getServerRoutes, getHtmlTemplate, entrypoints, _, _1, _tmp, routes1, _routes2, _routes3, initialRoutes, _ref3, modifiedRoutes1, _ref4, partialsByEntrypoint, htmlTemplates, checkedEntries, entry, normalizedConfig, createBuilderForModern, builder;
28
29
  return _ts_generator(this, function(_state) {
29
30
  switch (_state.label) {
30
31
  case 0:
@@ -49,19 +50,45 @@ function analyze_default(param) {
49
50
  ];
50
51
  case 2:
51
52
  _state.sent();
53
+ return [
54
+ 4,
55
+ Promise.all([
56
+ import("./getServerRoutes.js")
57
+ ])
58
+ ];
59
+ case 3:
60
+ _ref = _sliced_to_array.apply(void 0, [
61
+ _state.sent(),
62
+ 1
63
+ ]), getProdServerRoutes = _ref[0].getProdServerRoutes;
52
64
  if (!apiOnly)
65
+ return [
66
+ 3,
67
+ 7
68
+ ];
69
+ routes = [];
70
+ if (!checkIsServeCommand())
53
71
  return [
54
72
  3,
55
73
  4
56
74
  ];
75
+ (_routes = routes).push.apply(_routes, _to_consumable_array(getProdServerRoutes(appContext.distDirectory)));
76
+ return [
77
+ 3,
78
+ 6
79
+ ];
80
+ case 4:
57
81
  return [
58
82
  4,
59
83
  hooks.modifyServerRoutes.call({
60
84
  routes: []
61
85
  })
62
86
  ];
63
- case 3:
64
- routes = _state.sent().routes;
87
+ case 5:
88
+ _ref1 = _state.sent(), modifiedRoutes = _ref1.routes;
89
+ (_routes1 = routes).push.apply(_routes1, _to_consumable_array(modifiedRoutes));
90
+ _state.label = 6;
91
+ case 6:
65
92
  debug("server routes: %o", routes);
66
93
  api.updateAppContext({
67
94
  apiOnly,
@@ -70,7 +97,7 @@ function analyze_default(param) {
70
97
  return [
71
98
  2
72
99
  ];
73
- case 4:
100
+ case 7:
74
101
  return [
75
102
  4,
76
103
  Promise.all([
@@ -79,27 +106,39 @@ function analyze_default(param) {
79
106
  import("./getHtmlTemplate.js")
80
107
  ])
81
108
  ];
82
- case 5:
83
- _ref = _sliced_to_array.apply(void 0, [
109
+ case 8:
110
+ _ref2 = _sliced_to_array.apply(void 0, [
84
111
  _state.sent(),
85
112
  3
86
- ]), getBundleEntry = _ref[0].getBundleEntry, getServerRoutes = _ref[1].getServerRoutes, getHtmlTemplate = _ref[2].getHtmlTemplate;
113
+ ]), getBundleEntry = _ref2[0].getBundleEntry, getServerRoutes = _ref2[1].getServerRoutes, getHtmlTemplate = _ref2[2].getHtmlTemplate;
87
114
  _1 = (_ = hooks.modifyEntrypoints).call;
88
115
  _tmp = {};
89
116
  return [
90
117
  4,
91
118
  getBundleEntry(hooks, appContext, resolvedConfig)
92
119
  ];
93
- case 6:
120
+ case 9:
94
121
  return [
95
122
  4,
96
123
  _1.apply(_, [
97
124
  (_tmp.entrypoints = _state.sent(), _tmp)
98
125
  ])
99
126
  ];
100
- case 7:
127
+ case 10:
101
128
  entrypoints = _state.sent().entrypoints;
102
129
  debug("entrypoints: %o", entrypoints);
130
+ routes1 = [];
131
+ if (!checkIsServeCommand())
132
+ return [
133
+ 3,
134
+ 11
135
+ ];
136
+ (_routes2 = routes1).push.apply(_routes2, _to_consumable_array(getProdServerRoutes(appContext.distDirectory)));
137
+ return [
138
+ 3,
139
+ 13
140
+ ];
141
+ case 11:
103
142
  initialRoutes = getServerRoutes(entrypoints, {
104
143
  appContext,
105
144
  config: resolvedConfig
@@ -110,8 +149,11 @@ function analyze_default(param) {
110
149
  routes: initialRoutes
111
150
  })
112
151
  ];
113
- case 8:
114
- routes1 = _state.sent().routes;
152
+ case 12:
153
+ _ref3 = _state.sent(), modifiedRoutes1 = _ref3.routes;
154
+ (_routes3 = routes1).push.apply(_routes3, _to_consumable_array(modifiedRoutes1));
155
+ _state.label = 13;
156
+ case 13:
115
157
  debug("server routes: %o", routes1);
116
158
  appContext = _object_spread_props(_object_spread({}, api.getAppContext()), {
117
159
  entrypoints,
@@ -133,8 +175,8 @@ function analyze_default(param) {
133
175
  config: resolvedConfig
134
176
  })
135
177
  ];
136
- case 9:
137
- _ref1 = _state.sent(), partialsByEntrypoint = _ref1.partialsByEntrypoint, htmlTemplates = _ref1.htmlTemplates;
178
+ case 14:
179
+ _ref4 = _state.sent(), partialsByEntrypoint = _ref4.partialsByEntrypoint, htmlTemplates = _ref4.htmlTemplates;
138
180
  debug("html templates: %o", htmlTemplates);
139
181
  api.updateAppContext({
140
182
  partialsByEntrypoint
@@ -145,17 +187,17 @@ function analyze_default(param) {
145
187
  if (!isDevCommand())
146
188
  return [
147
189
  3,
148
- 11
190
+ 16
149
191
  ];
150
192
  entry = minimist(getArgv()).entry;
151
193
  return [
152
194
  4,
153
195
  getSelectedEntries(typeof entry === "string" ? entry.split(",") : entry, entrypoints)
154
196
  ];
155
- case 10:
197
+ case 15:
156
198
  checkedEntries = _state.sent();
157
- _state.label = 11;
158
- case 11:
199
+ _state.label = 16;
200
+ case 16:
159
201
  appContext = _object_spread_props(_object_spread({}, api.getAppContext()), {
160
202
  entrypoints,
161
203
  checkedEntries,
@@ -167,7 +209,7 @@ function analyze_default(param) {
167
209
  if (!checkIsBuildCommands())
168
210
  return [
169
211
  3,
170
- 15
212
+ 20
171
213
  ];
172
214
  return [
173
215
  4,
@@ -175,14 +217,14 @@ function analyze_default(param) {
175
217
  entrypoints
176
218
  })
177
219
  ];
178
- case 12:
220
+ case 17:
179
221
  _state.sent();
180
222
  normalizedConfig = api.getNormalizedConfig();
181
223
  return [
182
224
  4,
183
225
  createBuilderGenerator(bundler)
184
226
  ];
185
- case 13:
227
+ case 18:
186
228
  createBuilderForModern = _state.sent();
187
229
  return [
188
230
  4,
@@ -191,10 +233,10 @@ function analyze_default(param) {
191
233
  appContext
192
234
  })
193
235
  ];
194
- case 14:
236
+ case 19:
195
237
  builder = _state.sent();
196
238
  builder.onBeforeBuild(function() {
197
- var _ref2 = _async_to_generator(function(param2) {
239
+ var _ref5 = _async_to_generator(function(param2) {
198
240
  var bundlerConfigs, isFirstCompile, environments, isWatch;
199
241
  return _ts_generator(this, function(_state2) {
200
242
  switch (_state2.label) {
@@ -229,11 +271,11 @@ function analyze_default(param) {
229
271
  });
230
272
  });
231
273
  return function(_2) {
232
- return _ref2.apply(this, arguments);
274
+ return _ref5.apply(this, arguments);
233
275
  };
234
276
  }());
235
277
  builder.onAfterBuild(function() {
236
- var _ref2 = _async_to_generator(function(param2) {
278
+ var _ref5 = _async_to_generator(function(param2) {
237
279
  var stats, environments, isFirstCompile, isWatch;
238
280
  return _ts_generator(this, function(_state2) {
239
281
  switch (_state2.label) {
@@ -263,11 +305,11 @@ function analyze_default(param) {
263
305
  });
264
306
  });
265
307
  return function(_2) {
266
- return _ref2.apply(this, arguments);
308
+ return _ref5.apply(this, arguments);
267
309
  };
268
310
  }());
269
311
  builder.onDevCompileDone(function() {
270
- var _ref2 = _async_to_generator(function(param2) {
312
+ var _ref5 = _async_to_generator(function(param2) {
271
313
  var isFirstCompile;
272
314
  return _ts_generator(this, function(_state2) {
273
315
  isFirstCompile = param2.isFirstCompile;
@@ -283,11 +325,11 @@ function analyze_default(param) {
283
325
  });
284
326
  });
285
327
  return function(_2) {
286
- return _ref2.apply(this, arguments);
328
+ return _ref5.apply(this, arguments);
287
329
  };
288
330
  }());
289
331
  builder.onBeforeCreateCompiler(function() {
290
- var _ref2 = _async_to_generator(function(param2) {
332
+ var _ref5 = _async_to_generator(function(param2) {
291
333
  var bundlerConfigs, environments;
292
334
  return _ts_generator(this, function(_state2) {
293
335
  switch (_state2.label) {
@@ -309,11 +351,11 @@ function analyze_default(param) {
309
351
  });
310
352
  });
311
353
  return function(_2) {
312
- return _ref2.apply(this, arguments);
354
+ return _ref5.apply(this, arguments);
313
355
  };
314
356
  }());
315
357
  builder.onAfterCreateCompiler(function() {
316
- var _ref2 = _async_to_generator(function(param2) {
358
+ var _ref5 = _async_to_generator(function(param2) {
317
359
  var compiler, environments;
318
360
  return _ts_generator(this, function(_state2) {
319
361
  switch (_state2.label) {
@@ -335,15 +377,15 @@ function analyze_default(param) {
335
377
  });
336
378
  });
337
379
  return function(_2) {
338
- return _ref2.apply(this, arguments);
380
+ return _ref5.apply(this, arguments);
339
381
  };
340
382
  }());
341
383
  builder.addPlugins(resolvedConfig.builderPlugins);
342
384
  api.updateAppContext({
343
385
  builder
344
386
  });
345
- _state.label = 15;
346
- case 15:
387
+ _state.label = 20;
388
+ case 20:
347
389
  return [
348
390
  2
349
391
  ];
@@ -83,6 +83,10 @@ var checkIsBuildCommands = function() {
83
83
  var command = getCommand();
84
84
  return buildCommands.includes(command);
85
85
  };
86
+ var checkIsServeCommand = function() {
87
+ var command = getCommand();
88
+ return command === "serve";
89
+ };
86
90
  var isSubDirOrEqual = function(parent, child) {
87
91
  if (parent === child) {
88
92
  return true;
@@ -93,6 +97,7 @@ var isSubDirOrEqual = function(parent, child) {
93
97
  };
94
98
  export {
95
99
  checkIsBuildCommands,
100
+ checkIsServeCommand,
96
101
  getServerCombinedModueFile,
97
102
  isSubDirOrEqual,
98
103
  parseModule,
@@ -2,8 +2,8 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import path from "node:path";
4
4
  import { DEFAULT_SERVER_CONFIG, ROUTE_SPEC_FILE, fs as fse } from "@modern-js/utils";
5
+ import { nodeDepEmit as handleDependencies } from "ndepe";
5
6
  import { isMainEntry } from "../../../utils/routes";
6
- import { handleDependencies } from "../dependencies";
7
7
  import { genPluginImportsCode, getPluginsCode, serverAppContenxtTemplate } from "../utils";
8
8
  function cleanDistDirectory(dir) {
9
9
  return _cleanDistDirectory.apply(this, arguments);
@@ -306,10 +306,13 @@ var createNetlifyPreset = function(appContext, modernConfig, needModernServer) {
306
306
  4,
307
307
  handleDependencies({
308
308
  appDir: appDirectory,
309
- serverRootDir: funcsDirectory,
309
+ sourceDir: funcsDirectory,
310
310
  includeEntries: [
311
311
  require.resolve("@modern-js/prod-server")
312
- ]
312
+ ],
313
+ copyWholePackage: function copyWholePackage(pkgName) {
314
+ return pkgName === "@modern-js/utils";
315
+ }
313
316
  })
314
317
  ];
315
318
  case 3:
@@ -2,7 +2,7 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import path from "node:path";
4
4
  import { DEFAULT_SERVER_CONFIG, ROUTE_SPEC_FILE, chalk, fs as fse } from "@modern-js/utils";
5
- import { handleDependencies } from "../dependencies";
5
+ import { nodeDepEmit as handleDependencies } from "ndepe";
6
6
  import { genPluginImportsCode, getPluginsCode, serverAppContenxtTemplate } from "../utils";
7
7
  var createNodePreset = function(appContext, config) {
8
8
  var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverPlugins = appContext.serverPlugins, moduleType = appContext.moduleType;
@@ -139,10 +139,13 @@ var createNodePreset = function(appContext, config) {
139
139
  4,
140
140
  handleDependencies({
141
141
  appDir: appDirectory,
142
- serverRootDir: outputDirectory,
142
+ sourceDir: outputDirectory,
143
143
  includeEntries: [
144
144
  require.resolve("@modern-js/prod-server")
145
145
  ],
146
+ copyWholePackage: function copyWholePackage(pkgName) {
147
+ return pkgName === "@modern-js/utils";
148
+ },
146
149
  entryFilter: filter
147
150
  })
148
151
  ];
@@ -2,8 +2,8 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import path from "node:path";
4
4
  import { DEFAULT_SERVER_CONFIG, ROUTE_SPEC_FILE, fs as fse } from "@modern-js/utils";
5
+ import { nodeDepEmit as handleDependencies } from "ndepe";
5
6
  import { isMainEntry } from "../../../utils/routes";
6
- import { handleDependencies } from "../dependencies";
7
7
  import { genPluginImportsCode, getPluginsCode, serverAppContenxtTemplate } from "../utils";
8
8
  var createVercelPreset = function(appContext, modernConfig, needModernServer) {
9
9
  var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, entrypoints = appContext.entrypoints, serverPlugins = appContext.serverPlugins, moduleType = appContext.moduleType;
@@ -240,10 +240,13 @@ var createVercelPreset = function(appContext, modernConfig, needModernServer) {
240
240
  4,
241
241
  handleDependencies({
242
242
  appDir: appDirectory,
243
- serverRootDir: funcsDirectory,
243
+ sourceDir: funcsDirectory,
244
244
  includeEntries: [
245
245
  require.resolve("@modern-js/prod-server")
246
- ]
246
+ ],
247
+ copyWholePackage: function copyWholePackage(pkgName) {
248
+ return pkgName === "@modern-js/utils";
249
+ }
247
250
  })
248
251
  ];
249
252
  case 1:
@@ -21,63 +21,59 @@ function serverBuild_default() {
21
21
  return {
22
22
  name: "@modern-js/server-build",
23
23
  setup: function setup(api) {
24
- return {
25
- afterBuild: function afterBuild() {
26
- return _async_to_generator(function() {
27
- var _api_useAppContext, appDirectory, distDirectory, metaName, modernConfig, distDir, serverDir, sharedDir, tsconfigPath, sourceDirs, server, alias, babel;
28
- return _ts_generator(this, function(_state) {
29
- switch (_state.label) {
30
- case 0:
31
- _api_useAppContext = api.useAppContext(), appDirectory = _api_useAppContext.appDirectory, distDirectory = _api_useAppContext.distDirectory, metaName = _api_useAppContext.metaName;
32
- if (!checkHasCache(appDirectory) && !checkHasConfig(appDirectory, metaName)) {
33
- return [
34
- 2
35
- ];
36
- }
37
- modernConfig = api.useResolvedConfigContext();
38
- distDir = path.resolve(distDirectory);
39
- serverDir = path.resolve(appDirectory, SERVER_DIR);
40
- sharedDir = path.resolve(appDirectory, SHARED_DIR);
41
- tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
42
- sourceDirs = [];
43
- if (fs.existsSync(serverDir)) {
44
- sourceDirs.push(serverDir);
45
- if (fs.existsSync(sharedDir)) {
46
- sourceDirs.push(sharedDir);
47
- }
48
- }
49
- server = modernConfig.server;
50
- alias = modernConfig.source.alias;
51
- babel = modernConfig.tools.babel;
52
- if (!(sourceDirs.length > 0))
53
- return [
54
- 3,
55
- 2
56
- ];
57
- return [
58
- 4,
59
- compile(appDirectory, {
60
- server,
61
- alias,
62
- babelConfig: babel
63
- }, {
64
- sourceDirs,
65
- distDir,
66
- tsconfigPath
67
- })
68
- ];
69
- case 1:
70
- _state.sent();
71
- _state.label = 2;
72
- case 2:
73
- return [
74
- 2
75
- ];
24
+ api.onAfterBuild(/* @__PURE__ */ _async_to_generator(function() {
25
+ var _api_getAppContext, appDirectory, distDirectory, metaName, modernConfig, distDir, serverDir, sharedDir, tsconfigPath, sourceDirs, server, alias, babel;
26
+ return _ts_generator(this, function(_state) {
27
+ switch (_state.label) {
28
+ case 0:
29
+ _api_getAppContext = api.getAppContext(), appDirectory = _api_getAppContext.appDirectory, distDirectory = _api_getAppContext.distDirectory, metaName = _api_getAppContext.metaName;
30
+ if (!checkHasCache(appDirectory) && !checkHasConfig(appDirectory, metaName)) {
31
+ return [
32
+ 2
33
+ ];
76
34
  }
77
- });
78
- })();
79
- }
80
- };
35
+ modernConfig = api.getNormalizedConfig();
36
+ distDir = path.resolve(distDirectory);
37
+ serverDir = path.resolve(appDirectory, SERVER_DIR);
38
+ sharedDir = path.resolve(appDirectory, SHARED_DIR);
39
+ tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
40
+ sourceDirs = [];
41
+ if (fs.existsSync(serverDir)) {
42
+ sourceDirs.push(serverDir);
43
+ if (fs.existsSync(sharedDir)) {
44
+ sourceDirs.push(sharedDir);
45
+ }
46
+ }
47
+ server = modernConfig.server;
48
+ alias = modernConfig.source.alias;
49
+ babel = modernConfig.tools.babel;
50
+ if (!(sourceDirs.length > 0))
51
+ return [
52
+ 3,
53
+ 2
54
+ ];
55
+ return [
56
+ 4,
57
+ compile(appDirectory, {
58
+ server,
59
+ alias,
60
+ babelConfig: babel
61
+ }, {
62
+ sourceDirs,
63
+ distDir,
64
+ tsconfigPath
65
+ })
66
+ ];
67
+ case 1:
68
+ _state.sent();
69
+ _state.label = 2;
70
+ case 2:
71
+ return [
72
+ 2
73
+ ];
74
+ }
75
+ });
76
+ }));
81
77
  }
82
78
  };
83
79
  }
@@ -3,11 +3,11 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import { initAppDir } from "@modern-js/plugin-v2/cli";
4
4
  import { run as CLIPluginRun } from "@modern-js/plugin-v2/run";
5
5
  import { minimist } from "@modern-js/utils";
6
- import { handleSetupResult } from "./compat/hooks";
7
- import { PACKAGE_JSON_CONFIG_NAME } from "./constants";
8
- import { getConfigFile } from "./getConfigFile";
9
- import { loadInternalPlugins } from "./loadPlugins";
10
- import { getIsAutoLoadPlugins } from "./utils";
6
+ import { handleSetupResult } from "../compat/hooks";
7
+ import { PACKAGE_JSON_CONFIG_NAME } from "../constants";
8
+ import { getConfigFile } from "../utils/getConfigFile";
9
+ import { isAutoLoadPlugins } from "../utils/isAutoLoadPlugins";
10
+ import { loadInternalPlugins } from "../utils/loadPlugins";
11
11
  function run(_) {
12
12
  return _run.apply(this, arguments);
13
13
  }
@@ -44,7 +44,7 @@ function _run() {
44
44
  finalConfigFile = customConfigFile || getConfigFile(configFile);
45
45
  return [
46
46
  4,
47
- getIsAutoLoadPlugins(appDirectory, finalConfigFile)
47
+ isAutoLoadPlugins(appDirectory, finalConfigFile)
48
48
  ];
49
49
  case 2:
50
50
  autoLoadPlugins = _state.sent();
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
2
  import { CONFIG_FILE_EXTENSIONS, findExists } from "@modern-js/utils";
3
- import { DEFAULT_CONFIG_FILE } from "./constants";
3
+ import { DEFAULT_CONFIG_FILE } from "../constants";
4
4
  var getConfigFile = function(configFile) {
5
5
  return findExists(CONFIG_FILE_EXTENSIONS.map(function(extension) {
6
6
  return path.resolve(process.cwd(), "".concat(configFile || DEFAULT_CONFIG_FILE).concat(extension));
@@ -1,11 +1,11 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import { createLoadedConfig } from "@modern-js/plugin-v2/cli";
4
- function getIsAutoLoadPlugins(appDirectory) {
5
- return _getIsAutoLoadPlugins.apply(this, arguments);
4
+ function isAutoLoadPlugins(appDirectory) {
5
+ return _isAutoLoadPlugins.apply(this, arguments);
6
6
  }
7
- function _getIsAutoLoadPlugins() {
8
- _getIsAutoLoadPlugins = _async_to_generator(function(appDirectory) {
7
+ function _isAutoLoadPlugins() {
8
+ _isAutoLoadPlugins = _async_to_generator(function(appDirectory) {
9
9
  var configFile, packageJsonConfig, _loaded_config, loaded, autoLoadPlugins;
10
10
  var _arguments = arguments;
11
11
  return _ts_generator(this, function(_state) {
@@ -26,8 +26,8 @@ function _getIsAutoLoadPlugins() {
26
26
  }
27
27
  });
28
28
  });
29
- return _getIsAutoLoadPlugins.apply(this, arguments);
29
+ return _isAutoLoadPlugins.apply(this, arguments);
30
30
  }
31
31
  export {
32
- getIsAutoLoadPlugins
32
+ isAutoLoadPlugins
33
33
  };