isolate-package 1.24.0 → 1.25.0

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.
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/isolate-bin.ts
4
- import console2 from "node:console";
4
+ import console2 from "console";
5
5
  import sourceMaps from "source-map-support";
6
6
 
7
7
  // src/isolate.ts
8
8
  import fs15 from "fs-extra";
9
- import assert6 from "node:assert";
10
- import path20 from "node:path";
9
+ import assert6 from "assert";
10
+ import path20 from "path";
11
11
  import { unique as unique2 } from "remeda";
12
12
 
13
13
  // src/lib/config.ts
14
14
  import fs8 from "fs-extra";
15
- import path6 from "node:path";
15
+ import path6 from "path";
16
16
  import { isEmpty } from "remeda";
17
17
 
18
18
  // src/lib/logger.ts
@@ -83,14 +83,14 @@ function toErrorWithMessage(maybeError) {
83
83
  }
84
84
 
85
85
  // src/lib/utils/inspect-value.ts
86
- import { inspect } from "node:util";
86
+ import { inspect } from "util";
87
87
  function inspectValue(value) {
88
88
  return inspect(value, false, 16, true);
89
89
  }
90
90
 
91
91
  // src/lib/utils/is-rush-workspace.ts
92
- import fs from "node:fs";
93
- import path from "node:path";
92
+ import fs from "fs";
93
+ import path from "path";
94
94
  function isRushWorkspace(workspaceRootDir) {
95
95
  return fs.existsSync(path.join(workspaceRootDir, "rush.json"));
96
96
  }
@@ -126,7 +126,7 @@ async function readTypedJson(filePath) {
126
126
  }
127
127
 
128
128
  // src/lib/utils/log-paths.ts
129
- import { join } from "node:path";
129
+ import { join } from "path";
130
130
  function getRootRelativeLogPath(path21, rootPath) {
131
131
  const strippedPath = path21.replace(rootPath, "");
132
132
  return join("(root)", strippedPath);
@@ -137,18 +137,18 @@ function getIsolateRelativeLogPath(path21, isolatePath) {
137
137
  }
138
138
 
139
139
  // src/lib/utils/pack.ts
140
- import assert2 from "node:assert";
141
- import { exec } from "node:child_process";
142
- import fs5 from "node:fs";
143
- import path5 from "node:path";
140
+ import assert2 from "assert";
141
+ import { exec } from "child_process";
142
+ import fs5 from "fs";
143
+ import path5 from "path";
144
144
 
145
145
  // src/lib/package-manager/index.ts
146
- import path4 from "node:path";
146
+ import path4 from "path";
147
147
 
148
148
  // src/lib/package-manager/helpers/infer-from-files.ts
149
149
  import fs3 from "fs-extra";
150
- import { execSync } from "node:child_process";
151
- import path2 from "node:path";
150
+ import { execSync } from "child_process";
151
+ import path2 from "path";
152
152
 
153
153
  // src/lib/utils/get-major-version.ts
154
154
  function getMajorVersion(version) {
@@ -203,8 +203,8 @@ function getVersion(packageManagerName) {
203
203
 
204
204
  // src/lib/package-manager/helpers/infer-from-manifest.ts
205
205
  import fs4 from "fs-extra";
206
- import assert from "node:assert";
207
- import path3 from "node:path";
206
+ import assert from "assert";
207
+ import path3 from "path";
208
208
  function inferFromManifest(workspaceRoot) {
209
209
  const log = useLogger();
210
210
  const { packageManager: packageManagerString } = readTypedJsonSync(
@@ -388,7 +388,7 @@ function resolveConfig(initialConfig) {
388
388
  // src/lib/lockfile/helpers/generate-npm-lockfile.ts
389
389
  import Arborist from "@npmcli/arborist";
390
390
  import fs9 from "fs-extra";
391
- import path7 from "node:path";
391
+ import path7 from "path";
392
392
 
393
393
  // src/lib/lockfile/helpers/load-npm-config.ts
394
394
  import Config from "@npmcli/config";
@@ -433,8 +433,8 @@ async function generateNpmLockfile({
433
433
  }
434
434
 
435
435
  // src/lib/lockfile/helpers/generate-pnpm-lockfile.ts
436
- import assert3 from "node:assert";
437
- import path9 from "node:path";
436
+ import assert3 from "assert";
437
+ import path9 from "path";
438
438
  import {
439
439
  getLockfileImporterId as getLockfileImporterId_v8,
440
440
  readWantedLockfile as readWantedLockfile_v8,
@@ -450,7 +450,7 @@ import { pruneLockfile as pruneLockfile_v9 } from "pnpm_prune_lockfile_v9";
450
450
  import { pick } from "remeda";
451
451
 
452
452
  // src/lib/lockfile/helpers/pnpm-map-importer.ts
453
- import path8 from "node:path";
453
+ import path8 from "path";
454
454
  import { mapValues } from "remeda";
455
455
  function pnpmMapImporter(importerPath, { dependencies, devDependencies, ...rest }, {
456
456
  includeDevDependencies,
@@ -559,7 +559,8 @@ async function generatePnpmLockfile({
559
559
  return [
560
560
  importerId,
561
561
  pnpmMapImporter(importerId, importer, {
562
- includeDevDependencies,
562
+ includeDevDependencies: false,
563
+ // Only include dev deps for target package
563
564
  includePatchedDependencies,
564
565
  directoryByPackageName
565
566
  })
@@ -588,8 +589,8 @@ async function generatePnpmLockfile({
588
589
 
589
590
  // src/lib/lockfile/helpers/generate-yarn-lockfile.ts
590
591
  import fs10 from "fs-extra";
591
- import { execSync as execSync2 } from "node:child_process";
592
- import path10 from "node:path";
592
+ import { execSync as execSync2 } from "child_process";
593
+ import path10 from "path";
593
594
  async function generateYarnLockfile({
594
595
  workspaceRootDir,
595
596
  isolateDir
@@ -700,12 +701,12 @@ async function processLockfile({
700
701
  import { omit as omit2, pick as pick2 } from "remeda";
701
702
 
702
703
  // src/lib/manifest/helpers/adapt-internal-package-manifests.ts
703
- import path13 from "node:path";
704
+ import path13 from "path";
704
705
  import { omit } from "remeda";
705
706
 
706
707
  // src/lib/manifest/io.ts
707
708
  import fs11 from "fs-extra";
708
- import path11 from "node:path";
709
+ import path11 from "path";
709
710
  async function readManifest(packageDir) {
710
711
  return readTypedJson(path11.join(packageDir, "package.json"));
711
712
  }
@@ -717,7 +718,7 @@ async function writeManifest(outputDir, manifest) {
717
718
  }
718
719
 
719
720
  // src/lib/manifest/helpers/patch-internal-entries.ts
720
- import path12 from "node:path";
721
+ import path12 from "path";
721
722
  function patchInternalEntries(dependencies, packagesRegistry, parentRootRelativeDir) {
722
723
  const log = useLogger();
723
724
  const allWorkspacePackageNames = Object.keys(packagesRegistry);
@@ -868,17 +869,17 @@ async function adaptTargetPackageManifest({
868
869
  }
869
870
 
870
871
  // src/lib/manifest/validate-manifest.ts
871
- function validateManifestMandatoryFields(manifest, packagePath) {
872
+ function validateManifestMandatoryFields(manifest, packagePath, requireFilesField = true) {
872
873
  const log = useLogger();
873
874
  const missingFields = [];
874
875
  if (!manifest.version) {
875
876
  missingFields.push("version");
876
877
  }
877
- if (!manifest.files || !Array.isArray(manifest.files) || manifest.files.length === 0) {
878
+ if (requireFilesField && (!manifest.files || !Array.isArray(manifest.files) || manifest.files.length === 0)) {
878
879
  missingFields.push("files");
879
880
  }
880
881
  if (missingFields.length > 0) {
881
- const errorMessage = `Package at ${packagePath} is missing mandatory fields: ${missingFields.join(", ")}. The "version" field is required for pack to execute, and the "files" field is required to declare what files should be included in the output. See the documentation for more details.`;
882
+ const errorMessage = `Package at ${packagePath} is missing mandatory fields: ${missingFields.join(", ")}. See the documentation for more details.`;
882
883
  log.error(errorMessage);
883
884
  throw new Error(errorMessage);
884
885
  }
@@ -887,7 +888,7 @@ function validateManifestMandatoryFields(manifest, packagePath) {
887
888
 
888
889
  // src/lib/output/get-build-output-dir.ts
889
890
  import { getTsconfig } from "get-tsconfig";
890
- import path15 from "node:path";
891
+ import path15 from "path";
891
892
  import outdent from "outdent";
892
893
  async function getBuildOutputDir({
893
894
  targetPackageDir,
@@ -920,7 +921,7 @@ async function getBuildOutputDir({
920
921
  }
921
922
 
922
923
  // src/lib/output/pack-dependencies.ts
923
- import assert4 from "node:assert";
924
+ import assert4 from "assert";
924
925
  async function packDependencies({
925
926
  /** All packages found in the monorepo by workspaces declaration */
926
927
  packagesRegistry,
@@ -951,7 +952,7 @@ async function packDependencies({
951
952
 
952
953
  // src/lib/output/process-build-output-files.ts
953
954
  import fs12 from "fs-extra";
954
- import path16 from "node:path";
955
+ import path16 from "path";
955
956
  var TIMEOUT_MS = 5e3;
956
957
  async function processBuildOutputFiles({
957
958
  targetPackageDir,
@@ -976,7 +977,7 @@ async function processBuildOutputFiles({
976
977
 
977
978
  // src/lib/output/unpack-dependencies.ts
978
979
  import fs13 from "fs-extra";
979
- import path17, { join as join2 } from "node:path";
980
+ import path17, { join as join2 } from "path";
980
981
  async function unpackDependencies(packedFilesByName, packagesRegistry, tmpDir, isolateDir) {
981
982
  const log = useLogger();
982
983
  await Promise.all(
@@ -1003,11 +1004,11 @@ async function unpackDependencies(packedFilesByName, packagesRegistry, tmpDir, i
1003
1004
  // src/lib/registry/create-packages-registry.ts
1004
1005
  import fs14 from "fs-extra";
1005
1006
  import { globSync } from "glob";
1006
- import path19 from "node:path";
1007
+ import path19 from "path";
1007
1008
 
1008
1009
  // src/lib/registry/helpers/find-packages-globs.ts
1009
- import assert5 from "node:assert";
1010
- import path18 from "node:path";
1010
+ import assert5 from "assert";
1011
+ import path18 from "path";
1011
1012
  function findPackagesGlobs(workspaceRootDir) {
1012
1013
  const log = useLogger();
1013
1014
  const packageManager2 = usePackageManager();
@@ -1200,11 +1201,20 @@ function createIsolator(config) {
1200
1201
  includeDevDependencies: config2.includeDevDependencies
1201
1202
  }
1202
1203
  );
1204
+ const productionInternalPackageNames = listInternalPackages(
1205
+ targetPackageManifest,
1206
+ packagesRegistry,
1207
+ {
1208
+ includeDevDependencies: false
1209
+ }
1210
+ );
1203
1211
  for (const packageName of internalPackageNames) {
1204
1212
  const packageDef = packagesRegistry[packageName];
1213
+ const isProductionDependency = productionInternalPackageNames.includes(packageName);
1205
1214
  validateManifestMandatoryFields(
1206
1215
  packageDef.manifest,
1207
- getRootRelativeLogPath(packageDef.absoluteDir, workspaceRootDir)
1216
+ getRootRelativeLogPath(packageDef.absoluteDir, workspaceRootDir),
1217
+ isProductionDependency
1208
1218
  );
1209
1219
  }
1210
1220
  const packedFilesByName = await packDependencies({