package import key leads to CJS code via proxy
dckc opened this issue Β· comments
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.
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.