[REPL] Allow loading latest build from specified branch#1356
[REPL] Allow loading latest build from specified branch#1356Daniel15 merged 2 commits intobabel:masterfrom
Conversation
|
Deploy preview ready! Built with commit 13d095a |
|
💯 🎉 That was fast! Thanks @Daniel15! |
Sure! I think I'll need to load a polyfill as some major browsers don't support it (IE 11, Android <= 4.4.4, iOS Safari <= 10.2, Safari <= 10), but there's some nice small polyfills. On the Yarn site we use unfetch, which is tiny. I'll change it before merging. |
|
@Daniel15 sounds good! |
Agreed! Great work! 😁 I've been wanting to use
Maybe I could add this once we're comfortable removing the "classic" link? |
| _setupBabel() { | ||
| loadBabel(this.state.babel, this._workerApi, babelState => { | ||
| this.setState(babelState); | ||
| async _setupBabel() { |
There was a problem hiding this comment.
async / await will require us to use the runtime polyfill, right? Which is pretty big.
I like the syntax much better than chaining promises but have been holding off for this reason.
There was a problem hiding this comment.
Yeah... I haven't measured the weight of it yet. I could switch it back to regular promises but async/await is so nice 😢 Particularly for code like this where you need to conditionally await something:
if (!isBuildNumeric) {
// Build in URL is *not* numeric, assume it's a branch name
// Get the latest build number for this branch
build = await loadLatestBuildNumberForBranch(
config.circleciRepo,
build
);
}
const url = await loadBuildArtifacts(config.circleciRepo, build, doLoad);
I figured the developer experience is worth the overhead, but I'll need to see exactly how large the overhead is.
There's an alternative transform that transforms them into generators instead, which is lighter but browser support isn't as good (https://caniuse.com/#feat=es6-generators).
There was a problem hiding this comment.
Yeah, I agree- the syntax is super nice. But babel-polyfill.min is 104.56 kB. That's why the new REPL only lazily loads it if the user selects "Evaluate"
There was a problem hiding this comment.
I'm not dead set against changing this. It just seemed...questionable.
If we decide it's okay to add that weight, I'll happily replace the other promises with async/await.
There was a problem hiding this comment.
I'm not loading babel-polyfill, I'm only loading the Regenerator runtime. It looks like that's 6.8 KB gzipped unminified (https://unpkg.com/regenerator-runtime@0.11.0/runtime.js) but I haven't checked the minified size yet.
There was a problem hiding this comment.
Oh! I didn't realize you could load just the regenerator runtime separately.
That's great then! Let's definitely do that.
There was a problem hiding this comment.
PS. With regard to babel-preset-env size, we're lazy-loading everything that we can in the new REPL. What we can't lazy-load (like Babel standalone and React) we're at least loading from a CDN.
Any ideas to improve this are welcome though!
There was a problem hiding this comment.
^ btw we should be using useBuiltIns if we are using env so it would remove polyfills that aren't used. also loose mode if you want a smaller bundle
There was a problem hiding this comment.
Using built-ins is a configurable option ^
|
I'm happy just using regular |
|
Nice!!!
In the future maybe add the toggle to show commit history with the ability to select one from the list to reload required Babel's build according to the selected commit? Also, we can switch the list's mode to show available versions/branches etc. |
I wonder if that's overkill for the REPL? 😅 Maybe you could open an issue for discussion on that? |
Maybe, but it's the way to ignore url query manipulation + allow to easy switching between versions to detect when something stopped worked :) I already have some work on this, but currently switched to implementing a normal standalone version of babel-preset-env 2.0. |
I assume you could reuse most of babel/babel-standalone#90 for this? I made the babel-standalone Gulpfile reusable for this use case - You can use the same Gulp tasks as part of the -env build. See babel/minify#679 for example. |
|
@Daniel15 Yes, the idea was to get rid of the babel-preset-env-standalone and use just original repo. There we wrap
The problem is simple and solvable. |
@yavorsky, awesome! Feel free to @-mention me on the PR
babel-standalone already exports all the plugins, so that should be doable right? |
So, |
|
To recap, here's some examples of valid URLs:
/version/xxxx/ loads published builds from npm (via Unpkg), while /build/xxxx/ loads CI builds from CircleCI. |
* [REPL] Allow loading latest build from specified branch * Use fetch

/repl/build/7.0/on prod,/repl/#?build=7.0on dev). When specified, the latest successful build from the given branch is used. The code assumes that a numeric value is a CircleCI build number, and anything else is a branch name.Test Plan:

Version number loads the given version:
Branch name loads the latest build from the branch:

Build number loads that build (eg. for a pull request):

Invalid branch name throws a relevant error:

No parameters loads latest stable:

Closes #1352