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

package import key leads to CJS code via proxy #639

Closed
dckc opened this issue Dec 3, 2023 · 2 comments
Closed

package import key leads to CJS code via proxy #639

dckc opened this issue Dec 3, 2023 · 2 comments

Comments

@dckc
Copy link

dckc commented Dec 3, 2023

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @bufbuild/protobuf@1.5.0 for the project I'm working on.

I'm using endo to bundle some generated code. It looked at exports and used the import key, which got proxy/index.js, which led to CJS code. Is that by design? It seems odd.

Here is the diff that solved my problem:

diff --git a/node_modules/cosmic-proto-es/node_modules/@bufbuild/protobuf/package.json b/node_modules/cosmic-proto-es/node_modules/@bufbuild/protobuf/package.json
index 81b39d9..177f75e 100644
--- a/node_modules/cosmic-proto-es/node_modules/@bufbuild/protobuf/package.json
+++ b/node_modules/cosmic-proto-es/node_modules/@bufbuild/protobuf/package.json
@@ -27,7 +27,7 @@
     ".": {
       "module": "./dist/esm/index.js",
       "require": "./dist/cjs/index.js",
-      "import": "./dist/proxy/index.js"
+      "import": "./dist/esm/index.js"
     }
   },
   "devDependencies": {

This issue body was partially generated by patch-package.

@smaye81
Copy link
Member

smaye81 commented Dec 4, 2023

Hi @dckc. We are actually in the process of fixing this issue with #611. You can check out that issue for more context.

Basically, the export map will become:

  "exports": {
    ".": {
      "node": {
        "import": "./dist/proxy/index.js",
        "require": "./dist/cjs/index.js"
      },
      "module": "./dist/esm/index.js",
      "import": "./dist/esm/index.js",
      "require": "./dist/cjs/index.js"
    }
  },

We've actually already landed this change in Connect-ES (#921) and will be landing the same change in this repo. Hope to get this landed within the next day or two.

@smaye81
Copy link
Member

smaye81 commented Dec 6, 2023

@dckc this should hopefully be fixed in v1.5.1 released today. The PR is here. Going to close this, but if you are still seeing issues, feel free to reopen.

@smaye81 smaye81 closed this as completed Dec 6, 2023
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

No branches or pull requests

2 participants