Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(build): add ignoreConditions option to BuildOptions #501

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

productdevbook
Copy link

@productdevbook productdevbook commented Feb 4, 2025

When we use custom Conditions, TypeScript throws errors when dealing with paths, etc. In reality, we only need this during development. That’s why we want to disable these Conditions during the build process. This is why I came up with this new structure.

diff --git a/dist/shared/unbuild.B2_7OVir.mjs b/dist/shared/unbuild.B2_7OVir.mjs
index 89838b3093726b0bdd864943be4eb480e74ecbea..48d45f6a36242042c1505b2400880c3a77c55912 100644
--- a/dist/shared/unbuild.B2_7OVir.mjs
+++ b/dist/shared/unbuild.B2_7OVir.mjs
@@ -329,6 +329,17 @@ function validatePackage(pkg, rootDir, ctx) {
   if (!pkg) {
     return;
   }
+  for (const item of ctx.options.ignoreConditions || []) {
+    if (typeof pkg.exports === 'object' && !Array.isArray(pkg.exports)) {
+      for (const key of Object.keys(pkg.exports)) {
+        const exportEntry = pkg.exports[key];
+        if (exportEntry && typeof exportEntry === 'object' 
+          && !Array.isArray(exportEntry) && exportEntry[item] !== undefined) {
+            delete exportEntry[item];
+          }
+      }
+    }
+  }
   const filenames = new Set(
     [
       ...typeof pkg.bin === "string" ? [pkg.bin] : Object.values(pkg.bin || {}),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant