Missing something when transpiling transitive ESModule dependency #2652
Replies: 3 comments 9 replies
-
Inspired by this comment I've found a temporary solution to fix this issue using patch-package to force Snowpack to use CJS module instead of ESM module from Styled Components. Here the branch where I've applied the fix : https://github.com/Reeska/csa-react-typescript-atlaskit/tree/fix-styled-components-dep As explained in the README.md, I have:
|
Beta Was this translation helpful? Give feedback.
-
Nice workaround! Does adding |
Beta Was this translation helpful? Give feedback.
-
Hello, I tried with the latest version of Snowpack (3.8.3), and I have the same issue (in this branch https://github.com/Reeska/csa-react-typescript-atlaskit/tree/try-snowpack-3.8.3), so it seems the issue is still here. Today I check if there is a similar issue is with Vitejs (as it's also use esbuild), but it's work pretty well: https://github.com/Reeska/vite-react-typescript-atlaskit Is it possible to re-open the related issue #2908 @FredKSchott ? :-) |
Beta Was this translation helpful? Give feedback.
-
Hi,
These days I'm playing with Snowpack 3 and check if it can work for my current project. I can see it's very fast comparing to other bundlers, amazing ! So I hope to make it work with my existant code.
But I've encounter the following error with Styled Components that is used by Atlaskit :
But the same code is working in a fresh Create-React-App install, moreover if I use Styled Components directly in my code with Snowpack I don't have the issue, so it's seems to be an issue with how Snowpack compile/integrate Styled Components into Atlaskit component.
I've deep dive to try to understand what happens.
There is head of the styled-components' package.json:
I found that is this browser entry
./dist/styled-components.esm.js
that is used by Snowpack and integrate intonode_modules/.cache/snowpack/development/@atlaskit/toggle.js
:But even
styledComponents_browser_esm
is a ES6 module, it doesn't have the flag__esModule
whereas it was transpiled by Snowpack from ESM to CJS. This is ends withstyled_components_1
wrongly wrapped this way with an extradefault
:That explains the error :
Because as see above it is wrongly
styled_components_1.default.default.span
.But the behavior is different when I import styled-components directly in my code: no error.
Any help would be much appreciated :-).
Beta Was this translation helpful? Give feedback.
All reactions