esbuild is unable to tree-shake rxjs under node platform #6785
Replies: 3 comments 2 replies
-
If the node condition is important, another possibility is to rely on a sub-condition to give more control to the end-user. For instance, it is possible to add the sub-condition ...
"exports": {
".": {
"node": {
"module": "./dist/esm5/ajax/index.js",
"default": "./dist/cjs/index.js"
},
"es2015": ...,
"default": ...
},
.... |
Beta Was this translation helpful? Give feedback.
-
Just for clarity: Why would tree-shaking be required/desirable on a server? Generally, "node platform" would indicate that you're building something that's not being shipped over the wire. What are the negative impacts, so I can understand them? Is it just initial load/parse time? |
Beta Was this translation helpful? Give feedback.
-
@benlesh |
Beta Was this translation helpful? Give feedback.
-
Hi!
I discovered that esbuild is not able to tree-shake rxjs package when bundling under node platform.
esbuild priorizes exports condition 'node' over main-fields.
Demonstration
Note that we need to bundle for node since our project and most of our dependencies imports node-specific modules.
How to solve the issue?
rxjs should not use the condition "node".
It should use the condition "require":
instead of:
Beta Was this translation helpful? Give feedback.
All reactions