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

Consider @babel/core being bundled to improve CLI startup times. #9575

Closed
stefanpenner opened this issue Feb 24, 2019 · 2 comments · Fixed by #14179
Closed

Consider @babel/core being bundled to improve CLI startup times. #9575

stefanpenner opened this issue Feb 24, 2019 · 2 comments · Fixed by #14179
Assignees
Labels
area: perf i: enhancement outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@stefanpenner
Copy link
Member

stefanpenner commented Feb 24, 2019

Feature Request

A cold require of @babel/core for the first time, can take 400ms->500ms even on a fast machine.
This is quite high, especially for smaller projects, as their complete babel compilation time may be less than that.

Idea

Thoughts on mimic'ing yarn, and bundling @babel/core with webpack? My experiments suggest this can lead to a nice boost, with relatively minimal cost.

// after a clean install
load babel-core.bundle.js: 79.151ms
load babel-core: 449.058ms
// once the disk is warm
load babel-core.bundle.js: 79.151ms
load babel-core: 170.081ms

early POC: https://github.com/stefanpenner/babel-core.bundle

Some issues

It does appear, additional configuration/cleanup will be required to ensure various internals resolve correctly. As doing so via my naive approach appears to break some babel plugins. This may or may not be a show stopper.

For example:

   Error: Cannot find module '/Users/spenner/src/babel/broccoli-babel-transpiler/node_modules/@babel/plugin-transform-strict-mode/lib/index.js'
      at r (node_modules/@babel/core/dist/babel-core.bundle.js:1:443324)
      at A (node_modules/@babel/core/dist/babel-core.bundle.js:1721:50205)
      at t.loadPlugin (node_modules/@babel/core/dist/babel-core.bundle.js:1721:48335)
      at m (node_modules/@babel/core/dist/babel-core.bundle.js:1:445869)
      at t.map (node_modules/@babel/core/dist/babel-core.bundle.js:1:445008)
      at Array.map (<anonymous>)
      at h (node_modules/@babel/core/dist/babel-core.bundle.js:1:444997)
      at d (node_modules/@babel/core/dist/babel-core.bundle.js:1:444947)
      at t (node_modules/@babel/core/dist/babel-core.bundle.js:1:444350)
      at /Users/spenner/src/babel/broccoli-babel-transpiler/node_modules/@babel/core/dist/babel-core.bundle.js:1:89995
      at plugins.n (node_modules/@babel/core/dist/babel-core.bundle.js:1:443820)
      at k (node_modules/@babel/core/dist/babel-core.bundle.js:1:451988)
      at O (node_modules/@babel/core/dist/babel-core.bundle.js:1:451411)
      at t.buildRootChain (node_modules/@babel/core/dist/babel-core.bundle.js:1:447284)
      at f (node_modules/@babel/core/dist/babel-core.bundle.js:1:459282)
      at t.default (node_modules/@babel/core/dist/babel-core.bundle.js:1721:51447)
      at a (node_modules/@babel/core/dist/babel-core.bundle.js:1721:58326)
      at Object.o (node_modules/@babel/core/dist/babel-core.bundle.js:1721:58138)

Question

So if this startup perf boost via bundling sounds appealing, I'll gladly explore/debug the above issues further.

Just let me know.

@nicolo-ribaudo
Copy link
Member

I think that we should bundle each package individually. This will bring big benefits to @babel/core, @babe/traverse and @babel/types, since they consists in multiple packages.

Maybe using rollup instead of webpack would be better, since we don't need most of webpack's features ans our files are es modules? We already have the logic to build @babel/parser using rollup, we just need to expand it to other packages.

@stefanpenner
Copy link
Member Author

stefanpenner commented Feb 24, 2019

@nicolo-ribaudo ya more granular bundles should achieve the same perf win, with less or no downside.

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Dec 17, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: perf i: enhancement outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants