-
Notifications
You must be signed in to change notification settings - Fork 25
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
ESM build for squiggle-lang; ESM-only components #1662
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Ignored Deployments
|
Some benefits of this change:
|
There are still issues. I managed to hack all (?) other cases, but d3 v7 is ESM-only, and it's a problem for CJS build. Here's the article about how authors of Victory wrapped/repackaged d3 as a workaround: link. My guess is that we should just make components ESM-only to avoid further headache. (It would also allow me to remove a few hacks in this PR around react-use). The downside of this decision is that if anyone depends on squiggle-components, they'd have to either upgrade to ESM too, or load any squiggle components in a lazy fashion, with |
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## develop #1662 +/- ##
===========================================
- Coverage 74.01% 71.22% -2.79%
===========================================
Files 93 92 -1
Lines 5099 4636 -463
Branches 856 855 -1
===========================================
- Hits 3774 3302 -472
- Misses 1300 1309 +9
Partials 25 25 see 86 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, happy to see this be implemented!
Storybook styles were broken, and storybook v7 got released just yesterday, which made me want to upgrade in hope that it would help, so I did that. Turned out CSS fix was caused by something else (postcss config format), but now we're on v7. Also Storybook now is configured with Vite, which fixes #1620. On ESM side, I removed CommonJS build from components, since it was broken, components are now ESM-only. |
Supersedes #1488; many more changes in this one, because:
"type": "module"
by default, but keeps the CommonJS build tooI had to change a lot of configuration for this to work.
Important notes:
uuid
for random ids because of this bug; fortunately, generation of random ids was easy to reimplementreact-use
because of this bug; react-use is currently imported as CJS (seehooks/react-use.ts
wrapper).js
extension at the end, because Typescript developers are stubborn and don't want to rewrite JS code in TS compiler (see this, this, etc.); this is the main reason why the diff on this PR is hugeexports
feature inpackage.json
works, it's now forbidden to import specific modules from squiggle-lang, e.g. it's impossible to doimport * as SymbolicDist from "@quri/squiggle-lang/dist/esm/src/dist/SymbolicDist.js"
; this is both a breaking change and inconvenience, and a feature (we can control the public API of squiggle-lang more precisely)