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

Add babel-preset-env 2.0 support. Controll version/build from the circle. #1415

Merged
merged 37 commits into from
Jan 20, 2018

Conversation

yavorsky
Copy link
Member

@yavorsky yavorsky commented Oct 10, 2017

Since we've moved babel-preset-env to the original repo and going to move babel-preset-env-standalone, we can take the same advantage like we're used with babel-standalone.

This PR:

  1. Add envVersion query param for babel-preset-env version, so /#?envVersion=2.0.0-beta.2 will use it for the repl.
  2. Allows testing preset-env changes after each PR by using build version to get artifacts from the Circle CI along with babel-standalone.
  3. Displays current version near the preset:
    screen shot 2017-10-10 at 13 04 42
  4. Fixes env preset checkbox state when initializing. Change text color inside textarea.
  5. Add the most features from the latest preset-env:
    • useBuiltIns: usage/entry
    • forceAllTransforms
    screen shot 2017-10-10 at 12 24 45
  6. All preset options are links to the documentation:
    ezgif com-video-to-gif 1

🚧 I've disabled debug option unless onPresetBuild support will be merged. I'll move PR to the monorepo today.

The next steps:

  • Enable debug
  • Add stage-3 option (babel-plugin-transform-async-generator-functions is large, so we need to lazy load it and register, but before we registered preset-env :/).
  • Since preset-env is 160kb, maybe load it right off the bat ?

@babel-bot
Copy link
Contributor

babel-bot commented Oct 10, 2017

Deploy preview for babel ready!

Built with commit 1b935a1

https://deploy-preview-1415--babel.netlify.com

@yavorsky yavorsky closed this Oct 10, 2017
@yavorsky yavorsky reopened this Oct 10, 2017
@yavorsky
Copy link
Member Author

Seems like netlify preview breaks down with new commits after the first successful build.

@existentialism
Copy link
Member

Let's set these dropdowns to normal font-weight:

image

const envPresetConfig: PluginConfig = {
label: "Env Preset",
package: "babel-preset-env-standalone",
version: "0",
version: "2.0.0-beta.2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we default this to 1.x since we default to Babel 6.x?

@yavorsky
Copy link
Member Author

yavorsky commented Oct 13, 2017

@existentialism Updated:
Now, babel-preset-env 1.6 is by default.
Also, we have different options according to the version:

For ^2.0:
screen shot 2017-10-13 at 12 59 33

For older versions:
screen shot 2017-10-13 at 12 55 09

@yavorsky yavorsky changed the title Add babel-preset-env 2.0 support. Controll version/build from the circle. [WIP] Add babel-preset-env 2.0 support. Controll version/build from the circle. Nov 14, 2017
@yavorsky
Copy link
Member Author

Changed status to WIP, because we need to land babel/babel#6438 firstly and then fit it there.

# Conflicts:
#	js/repl/Repl.js
#	js/repl/ReplOptions.js
#	js/repl/Worker.js
#	js/repl/WorkerApi.js
#	js/repl/loadBabel.js
#	js/repl/types.js
@yavorsky
Copy link
Member Author

yavorsky commented Nov 17, 2017

Seems like it's ready.

It works with babel-preset-env 2.0 betas and with circleci builds. So after each PR into experimental/babel-preset-env we could test preset's changes on the REPL also!
Tested with babel/babel#6438 (5831 build).

The only thing is that I need to test @babel/preset-env-standalone fetching when it will be npm published.

cc @hzoo @existentialism

(semver.valid(version) && semver.gte(version, "7.0.0-beta.4")) ||
version >= 7
? "@babel/standalone"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my thoughts: I kinda feel like it's easier to read/maintain with hardcoding this stuff? If we rename or anything like that I'm not sure I'd know where to look in this codebase with so much indirection? And in this case we can't substitute babel-standalone env in the same way because it won't be published until beta.33 not beta.4

@xtuc
Copy link
Member

xtuc commented Dec 25, 2017

Does bundle.run support externals yet?

We actually discussed about that a few months ago (Rich-Harris/packd#27) but I forgot about it.

Your point is still valid, I agree. I will work on it when I get a chance.

# Conflicts:
#	_data/users.yml
#	js/repl/CircleCI.js
#	js/repl/PluginConfig.js
#	js/repl/Repl.js
#	js/repl/ReplOptions.js
#	js/repl/compile.js
#	js/repl/replUtils.js
#	js/repl/types.js
@yavorsky yavorsky changed the title [WIP] Add babel-preset-env 2.0 support. Controll version/build from the circle. Add babel-preset-env 2.0 support. Controll version/build from the circle. Jan 5, 2018
@yavorsky
Copy link
Member Author

yavorsky commented Jan 5, 2018

I hope this is finished 🙄
screen shot 2018-01-05 at 15 32 14

Would be cool if someone will help to test it better

After, I could start work on the includes/excludes and size prediction bar.

@xtuc
Copy link
Member

xtuc commented Jan 10, 2018

Sorry I haven't followed this PR so much, what is the status of babel-standalone having the incorrect version of Babel?

@yavorsky
Copy link
Member Author

yavorsky commented Jan 10, 2018

@xtuc We can fix only publishing process, but it won't fully solve the problem because all versions published before this fix to npm will still return the previous version.

I've created PR for the website, which disables version overriding: #1488
There are some questions need to be resolved before we can merge this. For example, should we override non-semver values like (7). Currently, it prevent's overriding only semver values, but won't override master, 7, 6117 (build number).

@yavorsky
Copy link
Member Author

yavorsky commented Jan 10, 2018

This PR isn't blocked by this bug because it's already present on the https://babeljs.io


const stage3Plugins: Array<PluginConfig> = [
"proposal-async-generator-functions",
// "proposal-object-rest-spread",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, I probably confused you, but I meant to say that we should add a comment describing why we need stage3Plugins (i.e. proposal-async-generator-functions not available >= beta.36)

@@ -58,20 +112,26 @@ const replDefaults: ReplState = {
isPresetsTabExpanded: false,
isSettingsTabExpanded: true,
lineWrap: true,
presets: "es2015,react,stage-2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: why was this moved? I kinda prefer this being alpha sorted :) (no big deal)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I just merged crookedly. Will fix, thanks :)

code: persistedState.code,
compiled: null,
compileErrorMessage: null,
debugEnvPreset: persistedState.debug,
envConfig,
envPresetDebugInfo: null,
envPresetState: configToState(
envPresetState: persistedStateToEnvState(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker, but we should step back and re-think/clean up the state shape now that we have all a number of things that may or may not be loaded and depending on version, etc

<a
className={className}
target="_blank"
href={`https://github.com/babel/babel/tree/master/experimental/babel-preset-env#${section}`}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link needs updating

this.props.onEnvPresetSettingChange("electron", event.target.value);
};

_onShippedProposalsChange = (event: SyntheticInputEvent) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we could replace these with something more generic for the checkboxes:

_onEnvSettingChange = (event: SyntheticInputEvent) => {
  this.props.onEnvPresetSettingChange(event.target.name, event.target.checked)
}

import { BabelState } from "./types";
import WorkerApi from "./WorkerApi";

const SCOPED_CORE_VERSION_FROM = "7.0.0-beta.4";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The things we do to ourselves :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha exactly!

@existentialism existentialism merged commit 61e6378 into master Jan 20, 2018
@yavorsky
Copy link
Member Author

@existentialism Thanks for the review! 🎉

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

Successfully merging this pull request may close these issues.

None yet

6 participants