@modern-js/app-tools 2.63.2 → 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 (32) hide show
  1. package/dist/cjs/compat/hooks.js +16 -1
  2. package/dist/cjs/compat/index.js +3 -1
  3. package/dist/cjs/compat/utils.js +29 -8
  4. package/dist/cjs/plugins/deploy/platforms/netlify.js +7 -4
  5. package/dist/cjs/plugins/deploy/platforms/node.js +6 -3
  6. package/dist/cjs/plugins/deploy/platforms/vercel.js +7 -4
  7. package/dist/esm/compat/hooks.js +83 -24
  8. package/dist/esm/compat/index.js +4 -2
  9. package/dist/esm/compat/utils.js +29 -8
  10. package/dist/esm/plugins/deploy/platforms/netlify.js +6 -3
  11. package/dist/esm/plugins/deploy/platforms/node.js +5 -2
  12. package/dist/esm/plugins/deploy/platforms/vercel.js +6 -3
  13. package/dist/esm-node/compat/hooks.js +16 -1
  14. package/dist/esm-node/compat/index.js +4 -2
  15. package/dist/esm-node/compat/utils.js +29 -8
  16. package/dist/esm-node/plugins/deploy/platforms/netlify.js +6 -3
  17. package/dist/esm-node/plugins/deploy/platforms/node.js +5 -2
  18. package/dist/esm-node/plugins/deploy/platforms/vercel.js +6 -3
  19. package/dist/types/compat/utils.d.ts +8 -1
  20. package/package.json +19 -23
  21. package/dist/cjs/plugins/deploy/dependencies/index.js +0 -237
  22. package/dist/cjs/plugins/deploy/dependencies/utils.js +0 -179
  23. package/dist/cjs/plugins/deploy/exports.js +0 -28
  24. package/dist/esm/plugins/deploy/dependencies/index.js +0 -615
  25. package/dist/esm/plugins/deploy/dependencies/utils.js +0 -421
  26. package/dist/esm/plugins/deploy/exports.js +0 -4
  27. package/dist/esm-node/plugins/deploy/dependencies/index.js +0 -202
  28. package/dist/esm-node/plugins/deploy/dependencies/utils.js +0 -137
  29. package/dist/esm-node/plugins/deploy/exports.js +0 -4
  30. package/dist/types/plugins/deploy/dependencies/index.d.ts +0 -20
  31. package/dist/types/plugins/deploy/dependencies/utils.d.ts +0 -44
  32. package/dist/types/plugins/deploy/exports.d.ts +0 -1
@@ -71,6 +71,14 @@ function getHookRunners(context) {
71
71
  const result = await (hooks === null || hooks === void 0 ? void 0 : hooks.appendEntryCode.call(params));
72
72
  return result;
73
73
  },
74
+ // test plugin hooks
75
+ jestConfig: async (utils) => {
76
+ const result = await (hooks === null || hooks === void 0 ? void 0 : hooks.jestConfig.call(utils, (utils2) => utils2));
77
+ return result;
78
+ },
79
+ afterTest: async () => {
80
+ return hooks.afterTest.call();
81
+ },
74
82
  /**
75
83
  * common hooks
76
84
  */
@@ -160,7 +168,14 @@ function handleSetupResult(setupResult, api) {
160
168
  if (typeof fn === "function") {
161
169
  const newAPI = (0, import_utils.transformHookRunner)(key);
162
170
  if (api[newAPI]) {
163
- api[newAPI](async (params) => (0, import_utils.transformHookResult)(key, await fn((0, import_utils.transformHookParams)(key, params))));
171
+ api[newAPI](async (...params) => {
172
+ const { isMultiple, params: transformParams } = (0, import_utils.transformHookParams)(key, params);
173
+ if (isMultiple) {
174
+ return (0, import_utils.transformHookResult)(key, await fn(...transformParams));
175
+ } else {
176
+ return (0, import_utils.transformHookResult)(key, await fn(transformParams));
177
+ }
178
+ });
164
179
  }
165
180
  }
166
181
  });
@@ -49,7 +49,9 @@ const compatPlugin = () => ({
49
49
  };
50
50
  },
51
51
  registryHooks: {
52
- appendEntryCode: (0, import_plugin_v2.createCollectAsyncHook)()
52
+ appendEntryCode: (0, import_plugin_v2.createCollectAsyncHook)(),
53
+ jestConfig: (0, import_plugin_v2.createAsyncHook)(),
54
+ afterTest: (0, import_plugin_v2.createAsyncHook)()
53
55
  },
54
56
  setup: (api) => {
55
57
  api.updateAppContext({
@@ -23,6 +23,7 @@ __export(utils_exports, {
23
23
  transformHookRunner: () => transformHookRunner
24
24
  });
25
25
  module.exports = __toCommonJS(utils_exports);
26
+ var import_getHtmlTemplate = require("../plugins/analyze/getHtmlTemplate");
26
27
  function transformHookRunner(hookRunnerName) {
27
28
  switch (hookRunnerName) {
28
29
  case "beforeConfig":
@@ -73,25 +74,45 @@ function transformHookParams(hookRunnerName, params) {
73
74
  switch (hookRunnerName) {
74
75
  case "resolvedConfig":
75
76
  return {
76
- resolved: params
77
+ isMultiple: false,
78
+ params: {
79
+ resolved: params[0]
80
+ }
77
81
  };
78
82
  case "htmlPartials":
79
83
  return {
80
- partials: {
81
- top: params.partials.top.current,
82
- head: params.partials.head.current,
83
- body: params.partials.body.current
84
- },
85
- entrypoint: params.entrypoint
84
+ isMultiple: false,
85
+ params: {
86
+ partials: {
87
+ top: params[0].partials.top.current,
88
+ head: params[0].partials.head.current,
89
+ body: params[0].partials.body.current
90
+ },
91
+ entrypoint: params[0].entrypoint
92
+ }
86
93
  };
94
+ case "jestConfig": {
95
+ return {
96
+ isMultiple: true,
97
+ params
98
+ };
99
+ }
87
100
  default:
88
- return params;
101
+ return {
102
+ isMultiple: false,
103
+ params: params[0]
104
+ };
89
105
  }
90
106
  }
91
107
  function transformHookResult(hookRunnerName, result) {
92
108
  switch (hookRunnerName) {
93
109
  case "resolvedConfig":
94
110
  return result.resolved;
111
+ case "htmlPartials":
112
+ return {
113
+ partials: (0, import_getHtmlTemplate.getModifyHtmlPartials)(result.partials),
114
+ entrypoint: result.entrypoint
115
+ };
95
116
  default:
96
117
  return result;
97
118
  }
@@ -33,8 +33,8 @@ __export(netlify_exports, {
33
33
  module.exports = __toCommonJS(netlify_exports);
34
34
  var import_node_path = __toESM(require("node:path"));
35
35
  var import_utils = require("@modern-js/utils");
36
+ var import_ndepe = require("ndepe");
36
37
  var import_routes = require("../../../utils/routes");
37
- var import_dependencies = require("../dependencies");
38
38
  var import_utils2 = require("../utils");
39
39
  async function cleanDistDirectory(dir) {
40
40
  try {
@@ -136,12 +136,15 @@ const createNetlifyPreset = (appContext, modernConfig, needModernServer) => {
136
136
  if (!needModernServer) {
137
137
  return;
138
138
  }
139
- await (0, import_dependencies.handleDependencies)({
139
+ await (0, import_ndepe.nodeDepEmit)({
140
140
  appDir: appDirectory,
141
- serverRootDir: funcsDirectory,
141
+ sourceDir: funcsDirectory,
142
142
  includeEntries: [
143
143
  require.resolve("@modern-js/prod-server")
144
- ]
144
+ ],
145
+ copyWholePackage(pkgName) {
146
+ return pkgName === "@modern-js/utils";
147
+ }
145
148
  });
146
149
  }
147
150
  };
@@ -33,7 +33,7 @@ __export(node_exports, {
33
33
  module.exports = __toCommonJS(node_exports);
34
34
  var import_node_path = __toESM(require("node:path"));
35
35
  var import_utils = require("@modern-js/utils");
36
- var import_dependencies = require("../dependencies");
36
+ var import_ndepe = require("ndepe");
37
37
  var import_utils2 = require("../utils");
38
38
  const createNodePreset = (appContext, config) => {
39
39
  const { appDirectory, distDirectory, serverPlugins, moduleType } = appContext;
@@ -90,12 +90,15 @@ const createNodePreset = (appContext, config) => {
90
90
  const filter = (filePath) => {
91
91
  return !filePath.startsWith(staticDirectory);
92
92
  };
93
- await (0, import_dependencies.handleDependencies)({
93
+ await (0, import_ndepe.nodeDepEmit)({
94
94
  appDir: appDirectory,
95
- serverRootDir: outputDirectory,
95
+ sourceDir: outputDirectory,
96
96
  includeEntries: [
97
97
  require.resolve("@modern-js/prod-server")
98
98
  ],
99
+ copyWholePackage(pkgName) {
100
+ return pkgName === "@modern-js/utils";
101
+ },
99
102
  entryFilter: filter
100
103
  });
101
104
  }
@@ -33,8 +33,8 @@ __export(vercel_exports, {
33
33
  module.exports = __toCommonJS(vercel_exports);
34
34
  var import_node_path = __toESM(require("node:path"));
35
35
  var import_utils = require("@modern-js/utils");
36
+ var import_ndepe = require("ndepe");
36
37
  var import_routes = require("../../../utils/routes");
37
- var import_dependencies = require("../dependencies");
38
38
  var import_utils2 = require("../utils");
39
39
  const createVercelPreset = (appContext, modernConfig, needModernServer) => {
40
40
  const { appDirectory, distDirectory, entrypoints, serverPlugins, moduleType } = appContext;
@@ -148,12 +148,15 @@ const createVercelPreset = (appContext, modernConfig, needModernServer) => {
148
148
  if (!needModernServer) {
149
149
  return;
150
150
  }
151
- await (0, import_dependencies.handleDependencies)({
151
+ await (0, import_ndepe.nodeDepEmit)({
152
152
  appDir: appDirectory,
153
- serverRootDir: funcsDirectory,
153
+ sourceDir: funcsDirectory,
154
154
  includeEntries: [
155
155
  require.resolve("@modern-js/prod-server")
156
- ]
156
+ ],
157
+ copyWholePackage(pkgName) {
158
+ return pkgName === "@modern-js/utils";
159
+ }
157
160
  });
158
161
  }
159
162
  };
@@ -1,4 +1,5 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
2
3
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
4
  import { getModifyHtmlPartials } from "../plugins/analyze/getHtmlTemplate";
4
5
  import { transformHookParams, transformHookResult, transformHookRunner } from "./utils";
@@ -173,6 +174,40 @@ function getHookRunners(context) {
173
174
  return _ref.apply(this, arguments);
174
175
  };
175
176
  }(),
177
+ // test plugin hooks
178
+ jestConfig: function() {
179
+ var _ref = _async_to_generator(function(utils) {
180
+ var result;
181
+ return _ts_generator(this, function(_state) {
182
+ switch (_state.label) {
183
+ case 0:
184
+ return [
185
+ 4,
186
+ hooks === null || hooks === void 0 ? void 0 : hooks.jestConfig.call(utils, function(utils2) {
187
+ return utils2;
188
+ })
189
+ ];
190
+ case 1:
191
+ result = _state.sent();
192
+ return [
193
+ 2,
194
+ result
195
+ ];
196
+ }
197
+ });
198
+ });
199
+ return function(utils) {
200
+ return _ref.apply(this, arguments);
201
+ };
202
+ }(),
203
+ afterTest: /* @__PURE__ */ _async_to_generator(function() {
204
+ return _ts_generator(this, function(_state) {
205
+ return [
206
+ 2,
207
+ hooks.afterTest.call()
208
+ ];
209
+ });
210
+ }),
176
211
  /**
177
212
  * common hooks
178
213
  */
@@ -415,33 +450,57 @@ function handleSetupResult(setupResult, api) {
415
450
  if (typeof fn === "function") {
416
451
  var newAPI = transformHookRunner(key);
417
452
  if (api[newAPI]) {
418
- api[newAPI](function() {
419
- var _ref = _async_to_generator(function(params) {
420
- var _tmp;
421
- return _ts_generator(this, function(_state) {
422
- switch (_state.label) {
423
- case 0:
424
- _tmp = [
425
- key
426
- ];
427
- return [
428
- 4,
429
- fn(transformHookParams(key, params))
430
- ];
431
- case 1:
453
+ api[newAPI](/* @__PURE__ */ _async_to_generator(function() {
454
+ var _len, params, _key, _transformHookParams, isMultiple, transformParams, _tmp, _tmp1;
455
+ var _arguments = arguments;
456
+ return _ts_generator(this, function(_state) {
457
+ switch (_state.label) {
458
+ case 0:
459
+ for (_len = _arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
460
+ params[_key] = _arguments[_key];
461
+ }
462
+ _transformHookParams = transformHookParams(key, params), isMultiple = _transformHookParams.isMultiple, transformParams = _transformHookParams.params;
463
+ if (!isMultiple)
432
464
  return [
433
- 2,
434
- transformHookResult.apply(void 0, _tmp.concat([
435
- _state.sent()
436
- ]))
465
+ 3,
466
+ 2
437
467
  ];
438
- }
439
- });
468
+ _tmp = [
469
+ key
470
+ ];
471
+ return [
472
+ 4,
473
+ fn.apply(void 0, _to_consumable_array(transformParams))
474
+ ];
475
+ case 1:
476
+ return [
477
+ 2,
478
+ transformHookResult.apply(void 0, _tmp.concat([
479
+ _state.sent()
480
+ ]))
481
+ ];
482
+ case 2:
483
+ _tmp1 = [
484
+ key
485
+ ];
486
+ return [
487
+ 4,
488
+ fn(transformParams)
489
+ ];
490
+ case 3:
491
+ return [
492
+ 2,
493
+ transformHookResult.apply(void 0, _tmp1.concat([
494
+ _state.sent()
495
+ ]))
496
+ ];
497
+ case 4:
498
+ return [
499
+ 2
500
+ ];
501
+ }
440
502
  });
441
- return function(params) {
442
- return _ref.apply(this, arguments);
443
- };
444
- }());
503
+ }));
445
504
  }
446
505
  }
447
506
  });
@@ -1,5 +1,5 @@
1
1
  import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
2
- import { createCollectAsyncHook } from "@modern-js/plugin-v2";
2
+ import { createAsyncHook, createCollectAsyncHook } from "@modern-js/plugin-v2";
3
3
  import { getHookRunners } from "./hooks";
4
4
  var compatPlugin = function() {
5
5
  return {
@@ -30,7 +30,9 @@ var compatPlugin = function() {
30
30
  };
31
31
  },
32
32
  registryHooks: {
33
- appendEntryCode: createCollectAsyncHook()
33
+ appendEntryCode: createCollectAsyncHook(),
34
+ jestConfig: createAsyncHook(),
35
+ afterTest: createAsyncHook()
34
36
  },
35
37
  setup: function(api) {
36
38
  api.updateAppContext({
@@ -1,3 +1,4 @@
1
+ import { getModifyHtmlPartials } from "../plugins/analyze/getHtmlTemplate";
1
2
  function transformHookRunner(hookRunnerName) {
2
3
  switch (hookRunnerName) {
3
4
  case "beforeConfig":
@@ -48,25 +49,45 @@ function transformHookParams(hookRunnerName, params) {
48
49
  switch (hookRunnerName) {
49
50
  case "resolvedConfig":
50
51
  return {
51
- resolved: params
52
+ isMultiple: false,
53
+ params: {
54
+ resolved: params[0]
55
+ }
52
56
  };
53
57
  case "htmlPartials":
54
58
  return {
55
- partials: {
56
- top: params.partials.top.current,
57
- head: params.partials.head.current,
58
- body: params.partials.body.current
59
- },
60
- entrypoint: params.entrypoint
59
+ isMultiple: false,
60
+ params: {
61
+ partials: {
62
+ top: params[0].partials.top.current,
63
+ head: params[0].partials.head.current,
64
+ body: params[0].partials.body.current
65
+ },
66
+ entrypoint: params[0].entrypoint
67
+ }
61
68
  };
69
+ case "jestConfig": {
70
+ return {
71
+ isMultiple: true,
72
+ params
73
+ };
74
+ }
62
75
  default:
63
- return params;
76
+ return {
77
+ isMultiple: false,
78
+ params: params[0]
79
+ };
64
80
  }
65
81
  }
66
82
  function transformHookResult(hookRunnerName, result) {
67
83
  switch (hookRunnerName) {
68
84
  case "resolvedConfig":
69
85
  return result.resolved;
86
+ case "htmlPartials":
87
+ return {
88
+ partials: getModifyHtmlPartials(result.partials),
89
+ entrypoint: result.entrypoint
90
+ };
70
91
  default:
71
92
  return result;
72
93
  }
@@ -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:
@@ -47,6 +47,14 @@ function getHookRunners(context) {
47
47
  const result = await (hooks === null || hooks === void 0 ? void 0 : hooks.appendEntryCode.call(params));
48
48
  return result;
49
49
  },
50
+ // test plugin hooks
51
+ jestConfig: async (utils) => {
52
+ const result = await (hooks === null || hooks === void 0 ? void 0 : hooks.jestConfig.call(utils, (utils2) => utils2));
53
+ return result;
54
+ },
55
+ afterTest: async () => {
56
+ return hooks.afterTest.call();
57
+ },
50
58
  /**
51
59
  * common hooks
52
60
  */
@@ -136,7 +144,14 @@ function handleSetupResult(setupResult, api) {
136
144
  if (typeof fn === "function") {
137
145
  const newAPI = transformHookRunner(key);
138
146
  if (api[newAPI]) {
139
- api[newAPI](async (params) => transformHookResult(key, await fn(transformHookParams(key, params))));
147
+ api[newAPI](async (...params) => {
148
+ const { isMultiple, params: transformParams } = transformHookParams(key, params);
149
+ if (isMultiple) {
150
+ return transformHookResult(key, await fn(...transformParams));
151
+ } else {
152
+ return transformHookResult(key, await fn(transformParams));
153
+ }
154
+ });
140
155
  }
141
156
  }
142
157
  });
@@ -1,4 +1,4 @@
1
- import { createCollectAsyncHook } from "@modern-js/plugin-v2";
1
+ import { createAsyncHook, createCollectAsyncHook } from "@modern-js/plugin-v2";
2
2
  import { getHookRunners } from "./hooks";
3
3
  const compatPlugin = () => ({
4
4
  name: "@modern-js/app-tools-compat",
@@ -26,7 +26,9 @@ const compatPlugin = () => ({
26
26
  };
27
27
  },
28
28
  registryHooks: {
29
- appendEntryCode: createCollectAsyncHook()
29
+ appendEntryCode: createCollectAsyncHook(),
30
+ jestConfig: createAsyncHook(),
31
+ afterTest: createAsyncHook()
30
32
  },
31
33
  setup: (api) => {
32
34
  api.updateAppContext({
@@ -1,3 +1,4 @@
1
+ import { getModifyHtmlPartials } from "../plugins/analyze/getHtmlTemplate";
1
2
  function transformHookRunner(hookRunnerName) {
2
3
  switch (hookRunnerName) {
3
4
  case "beforeConfig":
@@ -48,25 +49,45 @@ function transformHookParams(hookRunnerName, params) {
48
49
  switch (hookRunnerName) {
49
50
  case "resolvedConfig":
50
51
  return {
51
- resolved: params
52
+ isMultiple: false,
53
+ params: {
54
+ resolved: params[0]
55
+ }
52
56
  };
53
57
  case "htmlPartials":
54
58
  return {
55
- partials: {
56
- top: params.partials.top.current,
57
- head: params.partials.head.current,
58
- body: params.partials.body.current
59
- },
60
- entrypoint: params.entrypoint
59
+ isMultiple: false,
60
+ params: {
61
+ partials: {
62
+ top: params[0].partials.top.current,
63
+ head: params[0].partials.head.current,
64
+ body: params[0].partials.body.current
65
+ },
66
+ entrypoint: params[0].entrypoint
67
+ }
61
68
  };
69
+ case "jestConfig": {
70
+ return {
71
+ isMultiple: true,
72
+ params
73
+ };
74
+ }
62
75
  default:
63
- return params;
76
+ return {
77
+ isMultiple: false,
78
+ params: params[0]
79
+ };
64
80
  }
65
81
  }
66
82
  function transformHookResult(hookRunnerName, result) {
67
83
  switch (hookRunnerName) {
68
84
  case "resolvedConfig":
69
85
  return result.resolved;
86
+ case "htmlPartials":
87
+ return {
88
+ partials: getModifyHtmlPartials(result.partials),
89
+ entrypoint: result.entrypoint
90
+ };
70
91
  default:
71
92
  return result;
72
93
  }
@@ -1,7 +1,7 @@
1
1
  import path from "node:path";
2
2
  import { DEFAULT_SERVER_CONFIG, ROUTE_SPEC_FILE, fs as fse } from "@modern-js/utils";
3
+ import { nodeDepEmit as handleDependencies } from "ndepe";
3
4
  import { isMainEntry } from "../../../utils/routes";
4
- import { handleDependencies } from "../dependencies";
5
5
  import { genPluginImportsCode, getPluginsCode, serverAppContenxtTemplate } from "../utils";
6
6
  async function cleanDistDirectory(dir) {
7
7
  try {
@@ -105,10 +105,13 @@ const createNetlifyPreset = (appContext, modernConfig, needModernServer) => {
105
105
  }
106
106
  await handleDependencies({
107
107
  appDir: appDirectory,
108
- serverRootDir: funcsDirectory,
108
+ sourceDir: funcsDirectory,
109
109
  includeEntries: [
110
110
  require.resolve("@modern-js/prod-server")
111
- ]
111
+ ],
112
+ copyWholePackage(pkgName) {
113
+ return pkgName === "@modern-js/utils";
114
+ }
112
115
  });
113
116
  }
114
117
  };
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
  import { DEFAULT_SERVER_CONFIG, ROUTE_SPEC_FILE, chalk, fs as fse } from "@modern-js/utils";
3
- import { handleDependencies } from "../dependencies";
3
+ import { nodeDepEmit as handleDependencies } from "ndepe";
4
4
  import { genPluginImportsCode, getPluginsCode, serverAppContenxtTemplate } from "../utils";
5
5
  const createNodePreset = (appContext, config) => {
6
6
  const { appDirectory, distDirectory, serverPlugins, moduleType } = appContext;
@@ -59,10 +59,13 @@ const createNodePreset = (appContext, config) => {
59
59
  };
60
60
  await handleDependencies({
61
61
  appDir: appDirectory,
62
- serverRootDir: outputDirectory,
62
+ sourceDir: outputDirectory,
63
63
  includeEntries: [
64
64
  require.resolve("@modern-js/prod-server")
65
65
  ],
66
+ copyWholePackage(pkgName) {
67
+ return pkgName === "@modern-js/utils";
68
+ },
66
69
  entryFilter: filter
67
70
  });
68
71
  }
@@ -1,7 +1,7 @@
1
1
  import path from "node:path";
2
2
  import { DEFAULT_SERVER_CONFIG, ROUTE_SPEC_FILE, fs as fse } from "@modern-js/utils";
3
+ import { nodeDepEmit as handleDependencies } from "ndepe";
3
4
  import { isMainEntry } from "../../../utils/routes";
4
- import { handleDependencies } from "../dependencies";
5
5
  import { genPluginImportsCode, getPluginsCode, serverAppContenxtTemplate } from "../utils";
6
6
  const createVercelPreset = (appContext, modernConfig, needModernServer) => {
7
7
  const { appDirectory, distDirectory, entrypoints, serverPlugins, moduleType } = appContext;
@@ -117,10 +117,13 @@ const createVercelPreset = (appContext, modernConfig, needModernServer) => {
117
117
  }
118
118
  await handleDependencies({
119
119
  appDir: appDirectory,
120
- serverRootDir: funcsDirectory,
120
+ sourceDir: funcsDirectory,
121
121
  includeEntries: [
122
122
  require.resolve("@modern-js/prod-server")
123
- ]
123
+ ],
124
+ copyWholePackage(pkgName) {
125
+ return pkgName === "@modern-js/utils";
126
+ }
124
127
  });
125
128
  }
126
129
  };