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: bundle recast #81

Merged
merged 13 commits into from
Sep 15, 2023
Merged

build: bundle recast #81

merged 13 commits into from
Sep 15, 2023

Conversation

antfu
Copy link
Member

@antfu antfu commented Sep 6, 2023

Install size from 8.5MB -> 5.2MB (mainly Babel), from 35 packages to 4 packages. Get rid of many es5 polyfills and ESM -> CJS -> ESM glues. Result in around 5% faster, tho the performance isn't very related to our use cases.

@pi0
Copy link
Member

pi0 commented Sep 6, 2023

It is a nice idea btw have you tried with impact on nuxi final size with double bundling of babel stuff?

might worth to have a subpath with optional non bundled version.

package.json Show resolved Hide resolved
@antfu
Copy link
Member Author

antfu commented Sep 6, 2023

Babel is not bundled. Only recast and ast-types are bundled from the source code, as their distribution targets Node 4 (es2015 and transpiled to CJS). This approach allows us to ship ESM directly without ESM -> CJS -> ESM convention.

scripts/vendor.ts Outdated Show resolved Hide resolved
src/helpers/vite.ts Outdated Show resolved Hide resolved
@pi0 pi0 changed the title chore: bundle recast build: bundle recast Sep 6, 2023
@codecov
Copy link

codecov bot commented Sep 6, 2023

Codecov Report

Merging #81 (56cb074) into main (0d65b23) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main      #81   +/-   ##
=======================================
  Coverage   92.40%   92.40%           
=======================================
  Files          23       23           
  Lines        1751     1751           
  Branches      322      322           
=======================================
  Hits         1618     1618           
  Misses        133      133           

package.json Show resolved Hide resolved
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Let's go ahead and introduce other improvements in next versions

@pi0
Copy link
Member

pi0 commented Sep 14, 2023

Small notes:

assert: resolve(__dirname, 'stubs/assert/index.js'), this from build.config seems unused

Enabling rollup.esbuild.minify: true reduces bundle size from 640kB to 380kB!

@antfu
Copy link
Member Author

antfu commented Sep 15, 2023

Screenshot 2023-09-15 at 10 17 13

After running pnpm pack, the size doesn't have that much different with gzip. I would think it would be better trade-off to avoid minification for better DX and debugging experience.

@antfu antfu merged commit a439ffa into main Sep 15, 2023
3 checks passed
@antfu antfu deleted the feat/bundle-recast branch September 15, 2023 07:50
@pi0
Copy link
Member

pi0 commented Sep 15, 2023

since we are not bundling babel stuff yet, yes it is not much different. anyway consider that when bundling more, the startup (and sometimes runtime) time also improves with modification + memory usage is always less.

@antfu
Copy link
Member Author

antfu commented Sep 15, 2023

Yeah, but I imagine we won't bundle Babel any sooner as it's quite big and commonly used, isn't it? I imagine we can bundle recast because it's a bit niche, and probably only used by magicast.

@pi0
Copy link
Member

pi0 commented Sep 15, 2023

Sure. That's what I wanted to share with you later about babel ;)

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.

2 participants