diff --git a/.changeset/shaggy-lamps-greet.md b/.changeset/shaggy-lamps-greet.md new file mode 100644 index 00000000..3dfd5797 --- /dev/null +++ b/.changeset/shaggy-lamps-greet.md @@ -0,0 +1,5 @@ +--- +'bob-the-bundler': patch +--- + +Remove engines.pnpm/yarn/npm in the the output package.json diff --git a/CHANGELOG.md b/CHANGELOG.md index f91f551c..1afab523 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -316,16 +316,16 @@ | false | { /** Files to copy from the package root to dist */ - copy?: Array; - }; + copy?: Array + } /** Whether the package should be checked. */ check?: | false | { /** Exports within the package that should not be checked. */ - skip?: Array; - }; - }; + skip?: Array + } + } ``` ## 2.0.0 diff --git a/src/commands/build.ts b/src/commands/build.ts index dc824d43..6ceea338 100644 --- a/src/commands/build.ts +++ b/src/commands/build.ts @@ -373,6 +373,15 @@ function rewritePackageJson(pkg: Record) { fields.forEach(field => { if (pkg[field] !== undefined) { newPkg[field] = pkg[field]; + if (field === 'engines') { + // remove all package managers from engines field + const ignoredPackageManagers = ['npm', 'yarn', 'pnpm']; + for (const packageManager of ignoredPackageManagers) { + if (newPkg[field][packageManager]) { + delete newPkg[field][packageManager]; + } + } + } } }); diff --git a/test/__fixtures__/simple/package.json b/test/__fixtures__/simple/package.json index fe1b804c..6e9236a3 100644 --- a/test/__fixtures__/simple/package.json +++ b/test/__fixtures__/simple/package.json @@ -2,7 +2,8 @@ "name": "simple", "type": "module", "engines": { - "node": ">= 12.0.0" + "node": ">= 12.0.0", + "pnpm": ">= 8.0.0" }, "main": "dist/cjs/index.js", "module": "dist/esm/index.js",