fix yarn publish warning (#9073)

* fix yarn publish warning

* note
This commit is contained in:
Matt Fiddaman
2026-10-02 15:58:48 +00:00
committed by GitHub
parent 3a77479e14
commit 74ae626094
3 changed files with 44 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
const APPLIED_FIELDS = [
'type',
'main',
'browser',
'module',
'exports',
'imports',
'bin',
'types',
'typings',
];
module.exports = {
name: 'strip-publish-config',
factory: () => ({
hooks: {
beforeWorkspacePacking(workspace, rawManifest) {
const publishConfig = rawManifest.publishConfig;
if (!publishConfig) {
return;
}
for (const field of APPLIED_FIELDS) {
delete publishConfig[field];
}
if (Object.keys(publishConfig).length === 0) {
delete rawManifest.publishConfig;
}
},
},
}),
};
+5
View File
@@ -16,3 +16,8 @@ enableScripts: false
# days ago, giving the community time to catch compromised releases. Trusted
# packages that need immediate updates can be listed in npmPreapprovedPackages.
npmMinimalAgeGate: '3d'
# yarn pack applies publishConfig overrides but leaves them in the packed
# manifest, which npm publish warns about. Strip the applied fields.
plugins:
- path: .yarn/plugins/strip-publish-config.cjs
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [matt-fidd]
---
Remove the npm warning about unknown `publishConfig` fields when publishing packages.