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.
package/README.md CHANGED
@@ -124,13 +124,17 @@ generate part of the packed filename. A personal preference is to set it to
124
124
  > NOTE: This step is not required if you use the
125
125
  > [internal packages strategy](#the-internal-packages-strategy) but you could
126
126
  > set it to `["src"]` instead of `["dist"]`.
127
+ >
128
+ > When using `includeDevDependencies`, packages that are only dev dependencies
129
+ > (like ESLint configs or other build tools) don't require a `files` field since
130
+ > they are not packed for deployment.
127
131
 
128
132
  The isolate process uses (p)npm `pack` to extract files from package
129
133
  directories, just like publishing a package would.
130
134
 
131
- For this to work it is required that you define the `files` property in each
132
- package manifest, as it declares what files should be included in the published
133
- output.
135
+ For production dependencies, it is required that you define the `files` property
136
+ in each package manifest, as it declares what files should be included in the
137
+ published output.
134
138
 
135
139
  Typically, the value contains an array with only the name of the build output
136
140
  directory. For example:
@@ -219,6 +223,11 @@ By default devDependencies are ignored and stripped from the isolated output
219
223
  `package.json` files. If you enable this the devDependencies will be included
220
224
  and isolated just like the production dependencies.
221
225
 
226
+ Note: Dev-only internal packages (like ESLint configs) that are included through
227
+ this option don't require a `files` field in their package.json, only a
228
+ `version` field. Production dependencies always require both `version` and
229
+ `files` fields.
230
+
222
231
  ### pickFromScripts
223
232
 
224
233
  Type: `string[]`, default: `undefined`
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  // src/isolate.ts
2
2
  import fs15 from "fs-extra";
3
- import assert6 from "node:assert";
4
- import path20 from "node:path";
3
+ import assert6 from "assert";
4
+ import path20 from "path";
5
5
  import { unique as unique2 } from "remeda";
6
6
 
7
7
  // src/lib/config.ts
8
8
  import fs8 from "fs-extra";
9
- import path6 from "node:path";
9
+ import path6 from "path";
10
10
  import { isEmpty } from "remeda";
11
11
 
12
12
  // src/lib/logger.ts
@@ -77,14 +77,14 @@ function toErrorWithMessage(maybeError) {
77
77
  }
78
78
 
79
79
  // src/lib/utils/inspect-value.ts
80
- import { inspect } from "node:util";
80
+ import { inspect } from "util";
81
81
  function inspectValue(value) {
82
82
  return inspect(value, false, 16, true);
83
83
  }
84
84
 
85
85
  // src/lib/utils/is-rush-workspace.ts
86
- import fs from "node:fs";
87
- import path from "node:path";
86
+ import fs from "fs";
87
+ import path from "path";
88
88
  function isRushWorkspace(workspaceRootDir) {
89
89
  return fs.existsSync(path.join(workspaceRootDir, "rush.json"));
90
90
  }
@@ -120,7 +120,7 @@ async function readTypedJson(filePath) {
120
120
  }
121
121
 
122
122
  // src/lib/utils/log-paths.ts
123
- import { join } from "node:path";
123
+ import { join } from "path";
124
124
  function getRootRelativeLogPath(path21, rootPath) {
125
125
  const strippedPath = path21.replace(rootPath, "");
126
126
  return join("(root)", strippedPath);
@@ -131,18 +131,18 @@ function getIsolateRelativeLogPath(path21, isolatePath) {
131
131
  }
132
132
 
133
133
  // src/lib/utils/pack.ts
134
- import assert2 from "node:assert";
135
- import { exec } from "node:child_process";
136
- import fs5 from "node:fs";
137
- import path5 from "node:path";
134
+ import assert2 from "assert";
135
+ import { exec } from "child_process";
136
+ import fs5 from "fs";
137
+ import path5 from "path";
138
138
 
139
139
  // src/lib/package-manager/index.ts
140
- import path4 from "node:path";
140
+ import path4 from "path";
141
141
 
142
142
  // src/lib/package-manager/helpers/infer-from-files.ts
143
143
  import fs3 from "fs-extra";
144
- import { execSync } from "node:child_process";
145
- import path2 from "node:path";
144
+ import { execSync } from "child_process";
145
+ import path2 from "path";
146
146
 
147
147
  // src/lib/utils/get-major-version.ts
148
148
  function getMajorVersion(version) {
@@ -197,8 +197,8 @@ function getVersion(packageManagerName) {
197
197
 
198
198
  // src/lib/package-manager/helpers/infer-from-manifest.ts
199
199
  import fs4 from "fs-extra";
200
- import assert from "node:assert";
201
- import path3 from "node:path";
200
+ import assert from "assert";
201
+ import path3 from "path";
202
202
  function inferFromManifest(workspaceRoot) {
203
203
  const log = useLogger();
204
204
  const { packageManager: packageManagerString } = readTypedJsonSync(
@@ -382,7 +382,7 @@ function resolveConfig(initialConfig) {
382
382
  // src/lib/lockfile/helpers/generate-npm-lockfile.ts
383
383
  import Arborist from "@npmcli/arborist";
384
384
  import fs9 from "fs-extra";
385
- import path7 from "node:path";
385
+ import path7 from "path";
386
386
 
387
387
  // src/lib/lockfile/helpers/load-npm-config.ts
388
388
  import Config from "@npmcli/config";
@@ -427,8 +427,8 @@ async function generateNpmLockfile({
427
427
  }
428
428
 
429
429
  // src/lib/lockfile/helpers/generate-pnpm-lockfile.ts
430
- import assert3 from "node:assert";
431
- import path9 from "node:path";
430
+ import assert3 from "assert";
431
+ import path9 from "path";
432
432
  import {
433
433
  getLockfileImporterId as getLockfileImporterId_v8,
434
434
  readWantedLockfile as readWantedLockfile_v8,
@@ -444,7 +444,7 @@ import { pruneLockfile as pruneLockfile_v9 } from "pnpm_prune_lockfile_v9";
444
444
  import { pick } from "remeda";
445
445
 
446
446
  // src/lib/lockfile/helpers/pnpm-map-importer.ts
447
- import path8 from "node:path";
447
+ import path8 from "path";
448
448
  import { mapValues } from "remeda";
449
449
  function pnpmMapImporter(importerPath, { dependencies, devDependencies, ...rest }, {
450
450
  includeDevDependencies,
@@ -553,7 +553,8 @@ async function generatePnpmLockfile({
553
553
  return [
554
554
  importerId,
555
555
  pnpmMapImporter(importerId, importer, {
556
- includeDevDependencies,
556
+ includeDevDependencies: false,
557
+ // Only include dev deps for target package
557
558
  includePatchedDependencies,
558
559
  directoryByPackageName
559
560
  })
@@ -582,8 +583,8 @@ async function generatePnpmLockfile({
582
583
 
583
584
  // src/lib/lockfile/helpers/generate-yarn-lockfile.ts
584
585
  import fs10 from "fs-extra";
585
- import { execSync as execSync2 } from "node:child_process";
586
- import path10 from "node:path";
586
+ import { execSync as execSync2 } from "child_process";
587
+ import path10 from "path";
587
588
  async function generateYarnLockfile({
588
589
  workspaceRootDir,
589
590
  isolateDir
@@ -694,12 +695,12 @@ async function processLockfile({
694
695
  import { omit as omit2, pick as pick2 } from "remeda";
695
696
 
696
697
  // src/lib/manifest/helpers/adapt-internal-package-manifests.ts
697
- import path13 from "node:path";
698
+ import path13 from "path";
698
699
  import { omit } from "remeda";
699
700
 
700
701
  // src/lib/manifest/io.ts
701
702
  import fs11 from "fs-extra";
702
- import path11 from "node:path";
703
+ import path11 from "path";
703
704
  async function readManifest(packageDir) {
704
705
  return readTypedJson(path11.join(packageDir, "package.json"));
705
706
  }
@@ -711,7 +712,7 @@ async function writeManifest(outputDir, manifest) {
711
712
  }
712
713
 
713
714
  // src/lib/manifest/helpers/patch-internal-entries.ts
714
- import path12 from "node:path";
715
+ import path12 from "path";
715
716
  function patchInternalEntries(dependencies, packagesRegistry, parentRootRelativeDir) {
716
717
  const log = useLogger();
717
718
  const allWorkspacePackageNames = Object.keys(packagesRegistry);
@@ -862,17 +863,17 @@ async function adaptTargetPackageManifest({
862
863
  }
863
864
 
864
865
  // src/lib/manifest/validate-manifest.ts
865
- function validateManifestMandatoryFields(manifest, packagePath) {
866
+ function validateManifestMandatoryFields(manifest, packagePath, requireFilesField = true) {
866
867
  const log = useLogger();
867
868
  const missingFields = [];
868
869
  if (!manifest.version) {
869
870
  missingFields.push("version");
870
871
  }
871
- if (!manifest.files || !Array.isArray(manifest.files) || manifest.files.length === 0) {
872
+ if (requireFilesField && (!manifest.files || !Array.isArray(manifest.files) || manifest.files.length === 0)) {
872
873
  missingFields.push("files");
873
874
  }
874
875
  if (missingFields.length > 0) {
875
- 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.`;
876
+ const errorMessage = `Package at ${packagePath} is missing mandatory fields: ${missingFields.join(", ")}. See the documentation for more details.`;
876
877
  log.error(errorMessage);
877
878
  throw new Error(errorMessage);
878
879
  }
@@ -881,7 +882,7 @@ function validateManifestMandatoryFields(manifest, packagePath) {
881
882
 
882
883
  // src/lib/output/get-build-output-dir.ts
883
884
  import { getTsconfig } from "get-tsconfig";
884
- import path15 from "node:path";
885
+ import path15 from "path";
885
886
  import outdent from "outdent";
886
887
  async function getBuildOutputDir({
887
888
  targetPackageDir,
@@ -914,7 +915,7 @@ async function getBuildOutputDir({
914
915
  }
915
916
 
916
917
  // src/lib/output/pack-dependencies.ts
917
- import assert4 from "node:assert";
918
+ import assert4 from "assert";
918
919
  async function packDependencies({
919
920
  /** All packages found in the monorepo by workspaces declaration */
920
921
  packagesRegistry,
@@ -945,7 +946,7 @@ async function packDependencies({
945
946
 
946
947
  // src/lib/output/process-build-output-files.ts
947
948
  import fs12 from "fs-extra";
948
- import path16 from "node:path";
949
+ import path16 from "path";
949
950
  var TIMEOUT_MS = 5e3;
950
951
  async function processBuildOutputFiles({
951
952
  targetPackageDir,
@@ -970,7 +971,7 @@ async function processBuildOutputFiles({
970
971
 
971
972
  // src/lib/output/unpack-dependencies.ts
972
973
  import fs13 from "fs-extra";
973
- import path17, { join as join2 } from "node:path";
974
+ import path17, { join as join2 } from "path";
974
975
  async function unpackDependencies(packedFilesByName, packagesRegistry, tmpDir, isolateDir) {
975
976
  const log = useLogger();
976
977
  await Promise.all(
@@ -997,11 +998,11 @@ async function unpackDependencies(packedFilesByName, packagesRegistry, tmpDir, i
997
998
  // src/lib/registry/create-packages-registry.ts
998
999
  import fs14 from "fs-extra";
999
1000
  import { globSync } from "glob";
1000
- import path19 from "node:path";
1001
+ import path19 from "path";
1001
1002
 
1002
1003
  // src/lib/registry/helpers/find-packages-globs.ts
1003
- import assert5 from "node:assert";
1004
- import path18 from "node:path";
1004
+ import assert5 from "assert";
1005
+ import path18 from "path";
1005
1006
  function findPackagesGlobs(workspaceRootDir) {
1006
1007
  const log = useLogger();
1007
1008
  const packageManager2 = usePackageManager();
@@ -1194,11 +1195,20 @@ function createIsolator(config) {
1194
1195
  includeDevDependencies: config2.includeDevDependencies
1195
1196
  }
1196
1197
  );
1198
+ const productionInternalPackageNames = listInternalPackages(
1199
+ targetPackageManifest,
1200
+ packagesRegistry,
1201
+ {
1202
+ includeDevDependencies: false
1203
+ }
1204
+ );
1197
1205
  for (const packageName of internalPackageNames) {
1198
1206
  const packageDef = packagesRegistry[packageName];
1207
+ const isProductionDependency = productionInternalPackageNames.includes(packageName);
1199
1208
  validateManifestMandatoryFields(
1200
1209
  packageDef.manifest,
1201
- getRootRelativeLogPath(packageDef.absoluteDir, workspaceRootDir)
1210
+ getRootRelativeLogPath(packageDef.absoluteDir, workspaceRootDir),
1211
+ isProductionDependency
1202
1212
  );
1203
1213
  }
1204
1214
  const packedFilesByName = await packDependencies({