Skip to content

A local-first personal finance app

fix yarn publish warning (#9073)

Matt Fiddaman74ae62609476
diff --git a/.yarn/plugins/strip-publish-config.cjs b/.yarn/plugins/strip-publish-config.cjs
new file mode 100644
index 0000000000..5a8ab24e90
--- /dev/null
+++ b/.yarn/plugins/strip-publish-config.cjs
@@ -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;
+ }
+ },
+ },
+ }),
+};
diff --git a/.yarnrc.yml b/.yarnrc.yml
index 86e89322e5..ba54747595 100644
--- a/.yarnrc.yml
+++ b/.yarnrc.yml
@@ -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
diff --git a/upcoming-release-notes/strip-publish-config.md b/upcoming-release-notes/strip-publish-config.md
new file mode 100644
index 0000000000..787867e1f3
--- /dev/null
+++ b/upcoming-release-notes/strip-publish-config.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [matt-fidd]
+---
+
+Remove the npm warning about unknown `publishConfig` fields when publishing packages.