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 to speedup building vite package #17299

Merged
merged 4 commits into from
Jun 10, 2024
Merged

Conversation

ArnaudBarre
Copy link
Member

@ArnaudBarre ArnaudBarre commented May 24, 2024

Build

  • Keep current rollup configuration, but used it only for build.
  • Switch to esbuild to transpile TS
  • Remove client source maps. This is something we discussed a long ago with @patak-dev in a meeting with some members of Google devtools team. It will make vite client less prominent in the devtools and stacktrace for us will still be fine, the current output is still very close of the code source
  • Types:
    • generate types for src/node: avoid lib check, also avoid using features not available in node18
    • roll: no change, use esbuild to load the config
    • tsc check: reduce typing scope
  • Build time on my machine: 20.5s -> 8s

I manually diffed the two dist folders, changes are only a matter of line breaks, less comments, use double quote or other esbuild related formatting

Dev

  • Use esbuild with external dev deps (as before) but without chunking. It generates two index.js & cli.js of ~600kbs which is fine
  • The only downside is the handling of require call inlined worker. This is one of the many reason that we can't use esbuild for build until we get a full ESM story for Vite I think
  • Startup time: 8s to 300ms
  • Rebuild: 4s to instant
  • Types: not working (because directory output too nested) -> add a small proxy to the source code types

The full test suite is passing with the dev mode on

Copy link

stackblitz bot commented May 24, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@ArnaudBarre ArnaudBarre changed the title chore: improve vite dev & build speed build: use esbuild to speedup building vite package May 24, 2024
@ArnaudBarre ArnaudBarre force-pushed the arnaud/build-speed branch from fd34a9e to 562fe23 Compare May 24, 2024 11:52
package.json Outdated Show resolved Hide resolved
@ArnaudBarre ArnaudBarre force-pushed the arnaud/build-speed branch 2 times, most recently from 6c9ad7c to 9692926 Compare May 25, 2024 13:29
packages/vite/package.json Outdated Show resolved Hide resolved
packages/vite/scripts/dev.ts Outdated Show resolved Hide resolved
packages/vite/scripts/dev.ts Show resolved Hide resolved
packages/vite/scripts/dev.ts Outdated Show resolved Hide resolved
packages/vite/scripts/dev.ts Outdated Show resolved Hide resolved
@bluwy bluwy added the p1-chore Doesn't change code behavior (priority) label May 27, 2024
@ArnaudBarre ArnaudBarre force-pushed the arnaud/build-speed branch from b495a62 to c65de67 Compare May 27, 2024 21:58
antfu
antfu previously approved these changes May 28, 2024
@ArnaudBarre ArnaudBarre force-pushed the arnaud/build-speed branch from 2dc3278 to d1c8c00 Compare June 9, 2024 23:31
bluwy
bluwy previously approved these changes Jun 10, 2024
@bluwy bluwy merged commit 6db2515 into main Jun 10, 2024
11 checks passed
@bluwy bluwy deleted the arnaud/build-speed branch June 10, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p1-chore Doesn't change code behavior (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants