@modern-js/app-tools 2.57.1-beta.0 → 2.57.1-beta.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.
@@ -28,7 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var dependencies_exports = {};
30
30
  __export(dependencies_exports, {
31
- handleDependencies: () => handleDependencies
31
+ handleDependencies: () => handleDependencies,
32
+ nodeFileTrace: () => import_nft.nodeFileTrace
32
33
  });
33
34
  module.exports = __toCommonJS(dependencies_exports);
34
35
  var import_node_path = __toESM(require("node:path"));
@@ -36,10 +37,16 @@ var import_utils = require("@modern-js/utils");
36
37
  var import_pkg_types = require("pkg-types");
37
38
  var import_mlly = require("mlly");
38
39
  var import_utils2 = require("./utils");
39
- const handleDependencies = async ({ appDir, serverRootDir, includeEntries, traceFiles = import_utils2.traceFiles, entryFilter, modifyPackageJson, copyWholePackage }) => {
40
+ var import_nft = require("@vercel/nft");
41
+ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, traceFiles = import_utils2.traceFiles, entryFilter, modifyPackageJson, copyWholePackage, traceOptions }) => {
40
42
  const base = "/";
41
43
  const entryFiles = await (0, import_utils2.findEntryFiles)(serverRootDir, entryFilter);
42
- const fileTrace = await traceFiles(entryFiles.concat(includeEntries), serverRootDir, base);
44
+ const fileTrace = await traceFiles({
45
+ entryFiles: entryFiles.concat(includeEntries),
46
+ serverRootDir,
47
+ base,
48
+ traceOptions
49
+ });
43
50
  const currentProjectModules = import_node_path.default.join(appDir, "node_modules");
44
51
  const dependencySearchRoot = import_node_path.default.resolve(appDir, "../../../../../../");
45
52
  const tracedFiles = Object.fromEntries(await Promise.all([
@@ -224,5 +231,6 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
224
231
  };
225
232
  // Annotate the CommonJS export names for ESM import in node:
226
233
  0 && (module.exports = {
227
- handleDependencies
234
+ handleDependencies,
235
+ nodeFileTrace
228
236
  });
@@ -138,13 +138,11 @@ const findPackageParents = (pkg, version, tracedFiles) => {
138
138
  ];
139
139
  return parentPkgs.filter((parentPkg) => parentPkg);
140
140
  };
141
- const traceFiles = async (entryFiles, serverRootDir, base = "/") => {
141
+ const traceFiles = async ({ entryFiles, serverRootDir, base = "/", traceOptions }) => {
142
142
  return await (0, import_nft.nodeFileTrace)(entryFiles, {
143
143
  base,
144
144
  processCwd: serverRootDir,
145
- analysis: {
146
- evaluatePureExpressions: false
147
- }
145
+ ...traceOptions
148
146
  });
149
147
  };
150
148
  const resolveTracedPath = async (base, p) => import_utils.fs.realpath(import_path.default.resolve(base, p));
@@ -8,13 +8,14 @@ import { fs as fse, pkgUp, semver } from "@modern-js/utils";
8
8
  import { readPackageJSON } from "pkg-types";
9
9
  import { parseNodeModulePath } from "mlly";
10
10
  import { linkPackage, writePackage, isFile, findEntryFiles, traceFiles as defaultTraceFiles, findPackageParents, resolveTracedPath, readDirRecursive } from "./utils";
11
+ import { nodeFileTrace } from "@vercel/nft";
11
12
  var handleDependencies = function() {
12
13
  var _ref = _async_to_generator(function(param) {
13
- var appDir, serverRootDir, includeEntries, _param_traceFiles, traceFiles, entryFilter, modifyPackageJson, copyWholePackage, base, entryFiles, fileTrace, currentProjectModules, dependencySearchRoot, tracedFiles, _, tracedPackages, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, tracedFile, pkgName, tracedPackage, pkgJSON, tracedPackageVersion, shouldCopyWholePackage, _tracedPackageVersion_files, allFiles, err, multiVersionPkgs, singleVersionPackages, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, tracedPackage1, versions, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, version, projectPkgJson, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _loop, _iterator3, _step3, err, outputPkgPath, newPkgJson, finalPkgJson;
14
+ var appDir, serverRootDir, includeEntries, _param_traceFiles, traceFiles, entryFilter, modifyPackageJson, copyWholePackage, traceOptions, base, entryFiles, fileTrace, currentProjectModules, dependencySearchRoot, tracedFiles, _, tracedPackages, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, tracedFile, pkgName, tracedPackage, pkgJSON, tracedPackageVersion, shouldCopyWholePackage, _tracedPackageVersion_files, allFiles, err, multiVersionPkgs, singleVersionPackages, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, tracedPackage1, versions, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, version, projectPkgJson, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _loop, _iterator3, _step3, err, outputPkgPath, newPkgJson, finalPkgJson;
14
15
  return _ts_generator(this, function(_state) {
15
16
  switch (_state.label) {
16
17
  case 0:
17
- appDir = param.appDir, serverRootDir = param.serverRootDir, includeEntries = param.includeEntries, _param_traceFiles = param.traceFiles, traceFiles = _param_traceFiles === void 0 ? defaultTraceFiles : _param_traceFiles, entryFilter = param.entryFilter, modifyPackageJson = param.modifyPackageJson, copyWholePackage = param.copyWholePackage;
18
+ appDir = param.appDir, serverRootDir = param.serverRootDir, includeEntries = param.includeEntries, _param_traceFiles = param.traceFiles, traceFiles = _param_traceFiles === void 0 ? defaultTraceFiles : _param_traceFiles, entryFilter = param.entryFilter, modifyPackageJson = param.modifyPackageJson, copyWholePackage = param.copyWholePackage, traceOptions = param.traceOptions;
18
19
  base = "/";
19
20
  return [
20
21
  4,
@@ -24,7 +25,12 @@ var handleDependencies = function() {
24
25
  entryFiles = _state.sent();
25
26
  return [
26
27
  4,
27
- traceFiles(entryFiles.concat(includeEntries), serverRootDir, base)
28
+ traceFiles({
29
+ entryFiles: entryFiles.concat(includeEntries),
30
+ serverRootDir,
31
+ base,
32
+ traceOptions
33
+ })
28
34
  ];
29
35
  case 2:
30
36
  fileTrace = _state.sent();
@@ -603,5 +609,6 @@ var handleDependencies = function() {
603
609
  };
604
610
  }();
605
611
  export {
606
- handleDependencies
612
+ handleDependencies,
613
+ nodeFileTrace
607
614
  };
@@ -1,4 +1,5 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
3
  import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
3
4
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
4
5
  import path from "path";
@@ -335,22 +336,18 @@ var findPackageParents = function(pkg, version, tracedFiles) {
335
336
  });
336
337
  };
337
338
  var traceFiles = function() {
338
- var _ref = _async_to_generator(function(entryFiles, serverRootDir) {
339
- var base;
340
- var _arguments = arguments;
339
+ var _ref = _async_to_generator(function(param) {
340
+ var entryFiles, serverRootDir, _param_base, base, traceOptions;
341
341
  return _ts_generator(this, function(_state) {
342
342
  switch (_state.label) {
343
343
  case 0:
344
- base = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : "/";
344
+ entryFiles = param.entryFiles, serverRootDir = param.serverRootDir, _param_base = param.base, base = _param_base === void 0 ? "/" : _param_base, traceOptions = param.traceOptions;
345
345
  return [
346
346
  4,
347
- nodeFileTrace(entryFiles, {
347
+ nodeFileTrace(entryFiles, _object_spread({
348
348
  base,
349
- processCwd: serverRootDir,
350
- analysis: {
351
- evaluatePureExpressions: false
352
- }
353
- })
349
+ processCwd: serverRootDir
350
+ }, traceOptions))
354
351
  ];
355
352
  case 1:
356
353
  return [
@@ -360,7 +357,7 @@ var traceFiles = function() {
360
357
  }
361
358
  });
362
359
  });
363
- return function traceFiles2(entryFiles, serverRootDir) {
360
+ return function traceFiles2(_) {
364
361
  return _ref.apply(this, arguments);
365
362
  };
366
363
  }();
@@ -3,10 +3,16 @@ import { fs as fse, pkgUp, semver } from "@modern-js/utils";
3
3
  import { readPackageJSON } from "pkg-types";
4
4
  import { parseNodeModulePath } from "mlly";
5
5
  import { linkPackage, writePackage, isFile, findEntryFiles, traceFiles as defaultTraceFiles, findPackageParents, resolveTracedPath, readDirRecursive } from "./utils";
6
- const handleDependencies = async ({ appDir, serverRootDir, includeEntries, traceFiles = defaultTraceFiles, entryFilter, modifyPackageJson, copyWholePackage }) => {
6
+ import { nodeFileTrace } from "@vercel/nft";
7
+ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, traceFiles = defaultTraceFiles, entryFilter, modifyPackageJson, copyWholePackage, traceOptions }) => {
7
8
  const base = "/";
8
9
  const entryFiles = await findEntryFiles(serverRootDir, entryFilter);
9
- const fileTrace = await traceFiles(entryFiles.concat(includeEntries), serverRootDir, base);
10
+ const fileTrace = await traceFiles({
11
+ entryFiles: entryFiles.concat(includeEntries),
12
+ serverRootDir,
13
+ base,
14
+ traceOptions
15
+ });
10
16
  const currentProjectModules = path.join(appDir, "node_modules");
11
17
  const dependencySearchRoot = path.resolve(appDir, "../../../../../../");
12
18
  const tracedFiles = Object.fromEntries(await Promise.all([
@@ -190,5 +196,6 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, trace
190
196
  await fse.writeJSON(outputPkgPath, finalPkgJson);
191
197
  };
192
198
  export {
193
- handleDependencies
199
+ handleDependencies,
200
+ nodeFileTrace
194
201
  };
@@ -98,13 +98,11 @@ const findPackageParents = (pkg, version, tracedFiles) => {
98
98
  ];
99
99
  return parentPkgs.filter((parentPkg) => parentPkg);
100
100
  };
101
- const traceFiles = async (entryFiles, serverRootDir, base = "/") => {
101
+ const traceFiles = async ({ entryFiles, serverRootDir, base = "/", traceOptions }) => {
102
102
  return await nodeFileTrace(entryFiles, {
103
103
  base,
104
104
  processCwd: serverRootDir,
105
- analysis: {
106
- evaluatePureExpressions: false
107
- }
105
+ ...traceOptions
108
106
  });
109
107
  };
110
108
  const resolveTracedPath = async (base, p) => fse.realpath(path.resolve(base, p));
@@ -1,11 +1,20 @@
1
1
  import type { PackageJson } from 'pkg-types';
2
+ import type { NodeFileTraceOptions } from '@vercel/nft';
2
3
  import { traceFiles as defaultTraceFiles } from './utils';
3
- export declare const handleDependencies: ({ appDir, serverRootDir, includeEntries, traceFiles, entryFilter, modifyPackageJson, copyWholePackage, }: {
4
+ export type { NodeFileTraceOptions } from '@vercel/nft';
5
+ export { nodeFileTrace } from '@vercel/nft';
6
+ export declare const handleDependencies: ({ appDir, serverRootDir, includeEntries, traceFiles, entryFilter, modifyPackageJson, copyWholePackage, traceOptions, }: {
4
7
  appDir: string;
5
8
  serverRootDir: string;
6
9
  includeEntries: string[];
7
- traceFiles?: ((entryFiles: string[], serverRootDir: string, base?: string) => Promise<import("@vercel/nft").NodeFileTraceResult>) | undefined;
10
+ traceFiles?: (({ entryFiles, serverRootDir, base, traceOptions, }: {
11
+ entryFiles: string[];
12
+ serverRootDir: string;
13
+ base?: string | undefined;
14
+ traceOptions?: NodeFileTraceOptions | undefined;
15
+ }) => Promise<import("@vercel/nft").NodeFileTraceResult>) | undefined;
8
16
  entryFilter?: ((filePath: string) => boolean) | undefined;
9
17
  modifyPackageJson?: ((pkgJson: PackageJson) => PackageJson) | undefined;
10
18
  copyWholePackage?: ((pkgName: string) => boolean) | undefined;
19
+ traceOptions?: NodeFileTraceOptions | undefined;
11
20
  }) => Promise<void>;
@@ -1,4 +1,5 @@
1
1
  import type { PackageJson } from 'pkg-types';
2
+ import { NodeFileTraceOptions } from '@vercel/nft';
2
3
  export type TracedPackage = {
3
4
  name: string;
4
5
  versions: Record<string, {
@@ -32,6 +33,11 @@ export declare const readDirRecursive: (dir: string, options?: ReadDirOptions) =
32
33
  export declare const isFile: (file: string) => Promise<boolean>;
33
34
  export declare const findEntryFiles: (rootDir: string, entryFilter?: ((filePath: string) => boolean) | undefined) => Promise<string[]>;
34
35
  export declare const findPackageParents: (pkg: TracedPackage, version: string, tracedFiles: Record<string, TracedFile>) => string[];
35
- export declare const traceFiles: (entryFiles: string[], serverRootDir: string, base?: string) => Promise<import("@vercel/nft").NodeFileTraceResult>;
36
+ export declare const traceFiles: ({ entryFiles, serverRootDir, base, traceOptions, }: {
37
+ entryFiles: string[];
38
+ serverRootDir: string;
39
+ base?: string | undefined;
40
+ traceOptions?: NodeFileTraceOptions | undefined;
41
+ }) => Promise<import("@vercel/nft").NodeFileTraceResult>;
36
42
  export declare const resolveTracedPath: (base: string, p: string) => Promise<string>;
37
43
  export {};
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.57.1-beta.0",
18
+ "version": "2.57.1-beta.2",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -87,20 +87,20 @@
87
87
  "mlly": "^1.6.1",
88
88
  "pkg-types": "^1.1.0",
89
89
  "std-env": "^3.7.0",
90
- "@modern-js/node-bundle-require": "2.57.0",
91
90
  "@modern-js/core": "2.57.0",
92
- "@modern-js/plugin-i18n": "2.57.0",
91
+ "@modern-js/plugin": "2.57.0",
92
+ "@modern-js/node-bundle-require": "2.57.0",
93
93
  "@modern-js/prod-server": "2.57.0",
94
94
  "@modern-js/plugin-data-loader": "2.57.0",
95
- "@modern-js/server-core": "2.57.1-alpha.0",
96
- "@modern-js/plugin": "2.57.0",
97
- "@modern-js/types": "2.57.0",
95
+ "@modern-js/plugin-i18n": "2.57.0",
96
+ "@modern-js/server-core": "2.57.0",
98
97
  "@modern-js/plugin-lint": "2.57.0",
99
- "@modern-js/server-utils": "2.57.0",
98
+ "@modern-js/types": "2.57.0",
99
+ "@modern-js/server": "2.57.0",
100
100
  "@modern-js/utils": "2.57.0",
101
101
  "@modern-js/rsbuild-plugin-esbuild": "2.57.0",
102
- "@modern-js/uni-builder": "2.57.0",
103
- "@modern-js/server": "2.57.0"
102
+ "@modern-js/server-utils": "2.57.0",
103
+ "@modern-js/uni-builder": "2.57.0"
104
104
  },
105
105
  "devDependencies": {
106
106
  "@rsbuild/plugin-swc": "1.0.1-beta.3",