Split regeneratorRuntime into multiple helpers#17238
Split regeneratorRuntime into multiple helpers#17238nicolo-ribaudo merged 27 commits intobabel:regenerator-refactorfrom
regeneratorRuntime into multiple helpers#17238Conversation
regeneratorRuntime into multiple helpers
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/59131 |
|
I still need to figure out the e2e failure, but this is ready for review. |
| if (helpers.isInternal(name)) { | ||
| throw new Error("Cannot use internal helper " + name); | ||
| } | ||
| return this.#addHelper(name); |
There was a problem hiding this comment.
Since this file will be compiled to Node.js 6, can we turn on the privateFieldsAsProperties assumption in the build config?
There was a problem hiding this comment.
I'm using privateFieldsAsSymbols instead, just to avoid potential conflicts.
1d55e87 to
d1264fa
Compare
|
Oh the e2e tests are catching an existing bug: compiling private fields with Babel 7.0.0 and a newer version of the plugin does not work, because the plugin assumes that I'll just avoid using |
There was a problem hiding this comment.
I should probably write something to remove the useless files in this directory.
liuxingbaoyu
left a comment
There was a problem hiding this comment.
Great work!
_regenerator _tryCatch _regeneratorValues _regeneratorDefineIM _regeneratorDefine
_regeneratorAsync _regeneratorAsyncGen _regeneratorAsyncIterator _awaitAsyncGenerator _OverloadYield _regenerator _tryCatch _regeneratorValues _regeneratorDefineIM _regeneratorDefine
_regeneratorAsyncGen _regeneratorAsyncIterator _awaitAsyncGenerator _OverloadYield _regenerator _tryCatch _regeneratorValues _regeneratorDefineIM _regeneratorDefine
_regeneratorKeys _regenerator _tryCatch _regeneratorValues _regeneratorDefineIM _regeneratorDefine
These are helpers used in all four examples, do you mind if I merge some of it in a subsequent PR to make the output cleaner and mangle the function names better?
Also can you merge it into a new branch? I'd like to take this opportunity to improve context a bit. :)
|
Done, in |
Fixes #1, Fixes #2Ignore the
=== PR STARTS HERE ===commit, it's just wrong. All commits are relevant :)This PR splits the
regeneratorRuntimehelper into multiple helpers, so that only the necessary ones are loaded. There are now multiple "entry points":regenerator, always usedregeneratorKeys, only used when there is ayieldinside afor-inregeneratorAsyncGen, only used forasync function* ()andasync function ()(when transpiling them through regenerator)regeneratorAsync, only used forasync function ()(when transpiling them through regenerator)There are a bunch of new internal helpers, I added a
@internalmarker to not expose them as part of the public@babel/runtimeAPI.These are the size differences, when using inline helpers and only
@babel/plugin-transform-regenerator, after giving the output to Terser: