-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
build: use esbuild #343
build: use esbuild #343
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit f66f187:
|
Yes, let's change it. |
Same apply here with the comment in valtio: pmndrs/valtio#129 (comment) |
@dai-shi I haven't seen this kind of thing before: |
There is one new issue that I don't quite understand: https://rollupjs.org/guide/en/#error-this-is-undefined |
Is it happening only for cjs build (esbuild + babel), or also module build (esbuild only)? Or, am I missing something totally. |
Just for the cjs bundle. It seems to be an issue of the conversion down to es5, but #343 (comment) fixes it |
@aulneau Thanks for your investigation. |
I am curious though, I think if we do not make this change, the resulting cjs bundle will not work if I understand what the issue is. Can I ask why you would prefer to keep arrow functions over non? isn't the result the same? |
I didn't take like that... It just seems a potential warning. I will read it again.
For the module bundle, arrow functions are not transpiled. I think the current code looks just right and don't want to prohibit unbound arrow functions for the future. |
I see, if it's just a warning then that should be fine. |
I'm assuming this is a warning not for us.
@aulneau once this is done, let's ask someone to help for trial in discord. |
@dai-shi sure thing! Question for you around the |
I think it's intentional. @AnatoleLucet can confirm. I don't mind adding |
Yes, it's intentional. I don't mind adding a |
Yep, just something I've noticed. So everything seems to be working now. I realized we actually don't need to use either |
@aulneau Awesome job with this PR. Using rollup-plugin-esbuild to parse TypeScript and concurrently to run the builds in parallel is great. I suspect a lot of the build time improvements are due to running them in parallel. In the future, we should look at using esbuild directly in place of rollup. It doesn't support ES5 output but if we plan on removing the iife bundle, do we need to output ES5? |
Both iife and cjs used to target ie11, and it doesn't change for cjs in this pr. We still use babel for cjs. |
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. Thanks for your work!
7a26795
to
a234671
Compare
] | ||
config.babelHelpers = 'runtime' | ||
config.plugins = [...config.plugins, '@babel/plugin-transform-regenerator'] | ||
config.babelHelpers = 'bundled' |
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.
Let me check how much this would affect the bundle size.
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.
'runtime' |
'bundled' |
diff | |
---|---|---|---|
index.js | 3760 | 3561 | -199 |
middleware.js | 8720 | 9147 | +427 |
shallow.js | 620 | 620 | 0 |
vanilla.js | 1798 | 1798 | 0 |
Okay, this is more or less what I expected.
We will probably be refactoring persist
in middleware.ts without async/await, so the diff is likely to be reduced in the future.
Let's go with bundled as cjs build is kind of fallback.
Hi there!
I made a PR for jotai a few days ago updating the build tooling to use esbuild as the typescript transpiler and @dai-shi requested I make PRs for zustand and valtio, so here we are! The main reason for this change is because of how much faster esbuild is at compiling javascript from typescript:
Before
✨ Done in 25.26s.
After
✨ Done in 6.80s.
There are also some very minor bundle size changes with this update.
General overview of changes
esbuild
androllup-plugin-esbuild
typescript
plugin increateESMConfig
,createCommonJSConfig
, andcreateIIFEConfig
to use esbuildid.includes('@babel/runtime')
to the externals check per this recommendation