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

exports.node should be considered node platform #46

Closed
Tracked by #44
BasixKOR opened this issue Oct 13, 2022 · 3 comments
Closed
Tracked by #44

exports.node should be considered node platform #46

BasixKOR opened this issue Oct 13, 2022 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@BasixKOR
Copy link

Minimal reproduction: https://stackblitz.com/edit/node-h1e2ll (broken in browser; please download)

It seems like the platform of the entry doesn't take node condition into account.

@BasixKOR BasixKOR changed the title export.node should be considered node platform exports.node should be considered node platform Oct 13, 2022
@BasixKOR
Copy link
Author

Proposed patch:

diff --git a/bin.mjs b/bin.mjs
index 57bd96f6f8dff4f700b12a5a40572ea38f09b46d..929c72a9b9ae459cb0829ad6aac4567703641427 100644
--- a/bin.mjs
+++ b/bin.mjs
@@ -279,8 +279,12 @@ Or you may not need to specify "require" or "node" entries.
   }
   function addNodeEntry(key, output) {
     const ext = path.extname(output);
-    if (ext === ".js" || ext === ".cjs" || ext === ".node") {
-      addEntry(key, output, "node", "commonjs");
+    if (ext === ".js") {
+      addEntry(key, output, "node", defaultModule);
+    } else if (ext === ".cjs" || ext === ".node") {
+      addEntry(key, output, "node", "commonjs")
+    } else if (ext === ".mjs") {
+      addEntry(key, output, "node", "esmodule");
     }
   }
   if (config.main) {
@@ -299,6 +303,8 @@ Or you may not need to specify "require" or "node" entries.
             addModuleEntry(`exports["${key}"]`, output);
           } else if (key === "require") {
             addNodeEntry(`exports["${key}"]`, output);
+          } else if (key === "node") {
+            addNodeEntry(`exports["${key}"]`, output);
           } else {
             addMainEntry(`exports["${key}"]`, output);
           }

BasixKOR added a commit to planetarium/sphere that referenced this issue Oct 13, 2022
@cometkim
Copy link
Owner

cometkim commented Oct 13, 2022

This will be handled in #44

BasixKOR added a commit to planetarium/sphere that referenced this issue Oct 17, 2022
@cometkim cometkim added the bug Something isn't working label Nov 20, 2022
@cometkim cometkim mentioned this issue Nov 22, 2022
6 tasks
@cometkim cometkim closed this as completed Dec 4, 2022
@cometkim
Copy link
Owner

cometkim commented Dec 4, 2022

Hey @BasixKOR , nanobundle@rc is now available :)

@cometkim cometkim added this to the v1 milestone Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants