-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Use babel for transpiling rather than closure compiler #20879
Conversation
d402f66
to
7b1da18
Compare
7b1da18
to
cb744c2
Compare
Agreed on the logic of selecting babel. This is not a code path that needs to be super-fast since normally we don't need to transpile for older browsers, so picking something simpler and smaller seems best. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any changes to code size or compile times?
@@ -13130,7 +13130,6 @@ def check_for_es6(filename, expect): | |||
self.assertContained('foo(arg="hello")', js) | |||
self.assertContained(['() => 2', '()=>2'], js) | |||
self.assertContained('const ', js) | |||
self.assertContained('let ', js) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
babel doesn't strip comments by default when transpiling.. and we have comments that contains the string ".. let ..." making this hacky check fail. I think its find to drop it rather than try to get clever here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. sgtm
cb744c2
to
d0d1498
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with a suggestion for slightly improving the version checking function.
d0d1498
to
a8fa1c3
Compare
In terms of performance it does looks like babel is slow on large inputs. I measured using babel: time 7.778, size 666625 I think the size difference here is because we are doing SIMPLE_OPTIMIZATIONS in the closure case so there is DCE happening. If I run the same thing with babel: time 8.706s, size 61776 So I guess the babel polyfills could be more expensive or less DCE friendly. |
a8fa1c3
to
35a3f73
Compare
Yeah this is pretty much the problem that swc is meant to fix. |
I wonder, could you install it lazily on first emcc invocation that needs transpiling? There is an existing precedent in fetching libraries via |
We don't care that much since most folks won't be using this path, and using closure was already really slow. |
canvas size in pixels, while `glfwGetWindowSize` returns the canvas size is | ||
screen size. By default, this feature is disabled. You can enable it before |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last part seems broken: "canvas size is screen size".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a formatting change to the existing changelog entry. I don't want to mess with it as part of this PR really.
Slower speed is not great, obviously, but it seems fine to me here, since it's not a big regression compared to closure, and it avoids a large regression in the total sdk size. |
35a3f73
to
8f4e858
Compare
I don't think it worth the extra engineering effort to build that out. The cost of adding babel to node_modules is pretty marginal (~20Mb uncompressed). I'd also like to move away from the linker doing magical extra work like downloading and building stuff. |
Hopefully as a followup we can now remove some of our own pollyfills that we have accumulated over the years. |
7f2ddf3
to
2486bda
Compare
We recently switch from using closure-compiler with `WHITESPACE_ONLY` to closure-compiler with `SIMPLE_OPTIMIZATIONS`. However this had the negative side effect that all input need to be free of closure compiler warnings, and this turned out not to be practical for all users. See emscripten-core#20810 for more on this When selecting a transpilation tool use I also evaluated `swx` (written in rust) and `esbuild` (written in go). `esbuild` was rejected because the simply don't support ES5 (evanw/esbuild#297). `swx` was rejected because it almost doubled the side of our `node_modules` directory by adding two 50mb binary files.
2486bda
to
53bb926
Compare
We recently switch from using closure-compiler with
WHITESPACE_ONLY
to closure-compiler withSIMPLE_OPTIMIZATIONS
. However this had the negative side effect that all input need to be free of closure compiler warnings, and this turned out not to be practical for all users. See #20810 for more on thisWhen selecting a transpilation tool use I also evaluated
swx
(written in rust) andesbuild
(written in go).esbuild
was rejected because the simply don't support ES5(evanw/esbuild#297).
swx
was rejected because it almost doubled the side of ournode_modules
directory by adding two 50mb binary files.Fixes: #20810