Skip to content
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 plugin #129

Merged
merged 1 commit into from
Apr 1, 2021
Merged

build: use esbuild plugin #129

merged 1 commit into from
Apr 1, 2021

Conversation

aulneau
Copy link
Contributor

@aulneau aulneau commented Mar 26, 2021

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 24.54s.

After
✨ Done in 9.38s.

There are also some very minor bundle size changes with this update.

General overview of changes

  • added esbuild and rollup-plugin-esbuild
  • replaced the typescript plugin in createESMConfig and createCommonJSConfig to use esbuild
  • added id.includes('@babel/runtime') to the externals check per this recommendation
  • updated the node version used in the codesandbox ci to 12 (due to esbuild requirement)
  • added tslib as a dev dependency due to it being missing for the typescript plugin

@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 26, 2021

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 289b7ce:

Sandbox Source
React Configuration
React Typescript Configuration

@dai-shi
Copy link
Member

dai-shi commented Mar 26, 2021

Hi, thanks for your work!
Would you also apply the same rollup config and concurrently technique in jotai here?

Two reasons:

  • that would speed up even more
  • we want to have the same structure for all three libs for better maintainability (which wasn't the case before.)

@aulneau
Copy link
Contributor Author

aulneau commented Mar 26, 2021

Two reasons:

  • that would speed up even more
  • we want to have the same structure for all three libs for better maintainability (which wasn't the case before.)

Done! I actually think the speed element is the same, but I agree, it's better to have consistent structure between each.

@thelinuxlich
Copy link
Contributor

I hope that esbuild can replace babel macro in the future :)

rollup.config.js Outdated Show resolved Hide resolved
babel.config.js Outdated
@@ -16,6 +16,7 @@ module.exports = (api, targets) => {
],
],
plugins: [
'@babel/plugin-transform-runtime',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be wrong, but I think we do -> pmndrs/jotai#378 (comment)

I set this as I wanted to get rid of the warning when bundling.

Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dai-shi dai-shi merged commit 0524196 into pmndrs:master Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants