Skip to content

Commit 61122c2

Browse files
authored
Remove forceNpm option for sake of simplicity (#70)
1 parent bc093f0 commit 61122c2

File tree

5 files changed

+8
-58
lines changed

5 files changed

+8
-58
lines changed

README.md

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -210,30 +210,6 @@ Because the configuration loader depends on this setting, its output is not
210210
affected by this setting. If you want to debug the configuration set
211211
`DEBUG_ISOLATE_CONFIG=true` before you run `isolate`
212212

213-
### forceNpm
214-
215-
Type: `boolean`, default: `false`
216-
217-
By default the isolate process will generate output based on the package manager
218-
that you are using for your monorepo. But your deployment target might not be
219-
compatible with that package manager, or it might not be the best choice given
220-
the available tooling.
221-
222-
Also, it should not really matter what package manager is used in de deployment
223-
as long as the versions match your original lockfile.
224-
225-
By setting this option to `true` you are forcing the isolate output to use NPM.
226-
A package-lock file will be generated based on the contents of node_modules and
227-
therefore should match the versions in your original lockfile.
228-
229-
This way you can enjoy using PNPM or Yarn for your monorepo, while your
230-
deployment uses NPM with modules locked to the same versions.
231-
232-
> !! Warning: Generating an NPM lockfile currently requires moving the
233-
> node_modules from the root of the monorepo temporarily into the isolate
234-
> directory. This will not be compatible with setups that run multiple isolation
235-
> processes in parallel.
236-
237213
### buildDirName
238214

239215
Type: `string | undefined`, default: `undefined`
@@ -341,13 +317,8 @@ When you use the `targetPackagePath` option, this setting will be ignored.
341317
## Lockfiles
342318

343319
The isolate process tries to generate an isolated / pruned lockfile for the
344-
package manager that you use in your monorepo. If the package manager is not
345-
supported (modern Yarn versions), it can still generate a matching NPM lockfile
346-
based on the installed versions in node_modules.
347-
348-
In case your package manager is not supported by your deployment target you can
349-
also choose NPM to be used by setting the `makeNpmLockfile` to `true` in your
350-
configuration.
320+
package manager that you use in your monorepo. The strategy is different for
321+
each package manager, with NPM currently being the least attractive.
351322

352323
### NPM
353324

@@ -366,13 +337,8 @@ after Arborist has finished doing its thing.
366337
367338
### PNPM
368339

369-
The PNPM lockfile format is very readable (YAML) but getting it adapted to the
370-
isolate output was a bit of a trip.
371-
372-
It turns out, at least up to v10, that the isolated output has to be formatted
373-
as a workspace itself, otherwise dependencies of internally linked packages are
374-
not installed by PNPM. Therefore, the output looks a bit different from other
375-
package managers:
340+
For PNPM, the isolated output will be formatted as a workspace itself, otherwise
341+
dependencies of internally linked packages are not installed by PNPM.
376342

377343
- Links are preserved
378344
- Versions specifiers like "workspace:\*" are preserved

src/isolate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export async function isolate(
191191
await writeManifest(isolateDir, manifest);
192192
}
193193

194-
if (packageManager.name === "pnpm" && !config.forceNpm) {
194+
if (packageManager.name === "pnpm") {
195195
/**
196196
* PNPM doesn't install dependencies of packages that are linked via link:
197197
* or file: specifiers. It requires the directory to be configured as a

src/lib/lockfile/process-lockfile.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useConfig } from "../config";
21
import { useLogger } from "../logger";
32
import { usePackageManager } from "../package-manager";
43
import type { PackageManifest, PackagesRegistry } from "../types";
@@ -33,19 +32,6 @@ export async function processLockfile({
3332
}) {
3433
const log = useLogger();
3534

36-
const { forceNpm } = useConfig();
37-
38-
if (forceNpm) {
39-
log.info("Forcing to use NPM for isolate output");
40-
41-
await generateNpmLockfile({
42-
workspaceRootDir,
43-
isolateDir,
44-
});
45-
46-
return true;
47-
}
48-
4935
const { name, version } = usePackageManager();
5036
let usedFallbackToNpm = false;
5137

src/lib/manifest/adapt-target-package-manifest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export async function adaptTargetPackageManifest({
2121
workspaceRootDir: string;
2222
}) {
2323
const packageManager = usePackageManager();
24-
const { includeDevDependencies, forceNpm, pickFromScripts, omitFromScripts } =
24+
const { includeDevDependencies, pickFromScripts, omitFromScripts } =
2525
useConfig();
2626

2727
/** Dev dependencies are omitted by default */
@@ -30,7 +30,7 @@ export async function adaptTargetPackageManifest({
3030
: omit(manifest, ["devDependencies"]);
3131

3232
const adaptedManifest =
33-
packageManager.name === "pnpm" && !forceNpm
33+
packageManager.name === "pnpm"
3434
? /**
3535
* For PNPM the output itself is a workspace so we can preserve the specifiers
3636
* with "workspace:*" in the output manifest, but we do want to adopt the

src/lib/manifest/helpers/adapt-internal-package-manifests.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import path from "node:path";
22
import { omit } from "remeda";
3-
import { useConfig } from "~/lib/config";
43
import { usePackageManager } from "~/lib/package-manager";
54
import type { PackagesRegistry } from "~/lib/types";
65
import { writeManifest } from "../io";
@@ -17,7 +16,6 @@ export async function adaptInternalPackageManifests(
1716
isolateDir: string
1817
) {
1918
const packageManager = usePackageManager();
20-
const { forceNpm } = useConfig();
2119

2220
await Promise.all(
2321
internalPackageNames.map(async (packageName) => {
@@ -27,7 +25,7 @@ export async function adaptInternalPackageManifests(
2725
const strippedManifest = omit(manifest, ["scripts", "devDependencies"]);
2826

2927
const outputManifest =
30-
packageManager.name === "pnpm" && !forceNpm
28+
packageManager.name === "pnpm"
3129
? /**
3230
* For PNPM the output itself is a workspace so we can preserve the specifiers
3331
* with "workspace:*" in the output manifest.

0 commit comments

Comments
 (0)