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

Parser performance improvement: Combine the babel transpiles where possible to reduce the number of those we have to perform #5653

Open
Rheeseyb opened this issue May 9, 2024 · 0 comments
Assignees

Comments

@Rheeseyb
Copy link
Contributor

Rheeseyb commented May 9, 2024

We're doing multiple Babel transpiles:

  • We have one to insert data-uid into the code when parsing
  • We then actually transpile the code itself

See: https://github.com/concrete-utopia/utopia/blob/master/editor/src/core/workers/parser-printer/parser-printer-parsing.ts#L1740-L1757
And: https://github.com/concrete-utopia/utopia/blob/master/editor/src/core/workers/parser-printer/parser-printer-parsing.ts#L3951-L3970
So both of the above could certainly be squashed into a single step (I'm not sure if there really was a reason to do the two separately other than maybe it was easier at the time?). That would halve the babel transpiles and halve the amount of times we update source maps.

As well as this, we're also pretty dumb about how we wrap code before transpiling it. Sometimes we need to wrap in parens, sometimes we need to wrap in an anonymous function (because we're taking a small piece of code from the file and transpiling that in a way that might otherwise not make sense in the context).

See: https://github.com/concrete-utopia/utopia/blob/master/editor/src/core/workers/parser-printer/parser-printer-transpiling.ts#L637
Because we don't know which type of wrapping we need to use, we'll try one first and fall back to the other. So if we could know upfront, then we could save ourselves some extra transpiling there too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants