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

Move babel-standalone into main Babel repo #6029

Merged
merged 12 commits into from Aug 12, 2017

Conversation

Projects
None yet
4 participants
@Daniel15
Member

Daniel15 commented Jul 30, 2017

Q A
Patch: Bug Fix? No
Major: Breaking Change? No
Minor: New Feature? No
Deprecations? No
Spec Compliancy? N/A
Tests Added/Pass? Yes / Yes
Fixed Tickets N/A
License MIT
Doc PR No

@hzoo and I both had the idea of showing a link to a copy of the REPL for every pull request in this repo, to allow pull requests to be more easily tested. Since the REPL uses babel-standalone, the first step is to get babel-standalone building with each PR. The easiest way of doing so is to merge babel-standalone into this repo and just build it as part of the regular build. This is what this PR aims to accomplish.

What I've done:

  • Copied most of the contents of the babel-standalone repo into packages/babel-standalone. The README and most of the code was copied across verbatim
  • Updated the test to use Mocha rather than Jest
  • Merged the babel-standalone Gulpfile into the main Babel Gulpfile
  • Updated CircleCI config to archive babel.js and babel.min.js as build artifacts. This is key to allowing the new build of babel-standalone to be loaded from the REPL. In a separate PR, I'll modify the REPL to allow it to load a built version from CircleCI

One thing that I haven't worked out yet is that the file size is varying significantly. When I build this on my computer, the version of babel-standalone built by this build process is about 1 MB larger than the one I build via the babel-standalone repo (5.58 MB vs 4.54 MB), which itself is much larger than the v6 version of babel-standalone (1.78 MB).

Building babel-standalone as part of the CircleCI build slows it down a bit, but once we upgrade to CircleCI 2.0 we could run the tests and the babel-standalone builds in parallel to improve things a bit.

Also note that I have not moved babili-standalone across yet.

Still to be done:

  • Work out why the file size is so different

cc @hzoo

@mention-bot

This comment has been minimized.

mention-bot commented Jul 30, 2017

@Daniel15, thanks for your PR! By analyzing the history of the files in this pull request, we identified @hzoo, @existentialism and @danez to be potential reviewers.

@Daniel15

This comment has been minimized.

Member

Daniel15 commented Jul 31, 2017

Build is working everywhere except on Node v4 on TravisCI, which I suspect is failing due to the very old version of npm being used (2.x).

@Daniel15 Daniel15 changed the title from [WIP] Move babel-standalone into main Babel repo to Move babel-standalone into main Babel repo Jul 31, 2017

@Daniel15

This comment has been minimized.

Member

Daniel15 commented Aug 1, 2017

Hmm, the resulting file is much bigger than the separate babel-standalone build. Webpack seems to be bundling multiple versions of lodash. I suspect webpack isn't properly deduping it, maybe due to something Lerna is doing. Will take a look.

@xtuc

This comment has been minimized.

Member

xtuc commented Aug 1, 2017

Does Babel-standalone also bundle Babylon?

Imagine someone implements a new proposal, how could we build a version of babel-standalone with both Babel and Babylon PRs?

// ES2015 preset with es2015-modules-commonjs removed
// Plugin list copied from babel-preset-es2015/index.js
"es2015-no-commonjs": {

This comment has been minimized.

@hzoo

hzoo Aug 1, 2017

Member

Does standalone handle preset/plugin options? if so, you can just pass the preset with modules false, and same below for loose mode.

This comment has been minimized.

@Daniel15

Daniel15 Aug 1, 2017

Member

@hzoo - I kept everything as-is just to maintain backwards compatibility with older versions of babel-standalone. Perhaps we could make es2015-no-commonjs into a "fake" preset that passes in the correct options. Let's do that separately though 😃

This comment has been minimized.

@hzoo

hzoo Aug 12, 2017

Member

yeah can do separately, we can also break since this will be an alpha for v7 as well

@hzoo

This comment has been minimized.

Member

hzoo commented Aug 1, 2017

@xtuc another reason why babylon should be in the monorepo too?

@hzoo hzoo referenced this pull request Aug 1, 2017

Merged

Create aug-02.md #29

@Daniel15

This comment has been minimized.

Member

Daniel15 commented Aug 1, 2017

Does Babel-standalone also bundle Babylon?

Imagine someone implements a new proposal, how could we build a version of babel-standalone with both Babel and Babylon PRs?

It only bundles Babel, and then Babel pulls in whatever other dependencies it needs (such as Babylon). It's hard to bundle a dev version of Babylon here since it'd need to link things across multiple Git repos. Using npm link should work for a local build, but it's tricky to do that correctly in a CI build (how would it know which version of Babylon to pull in?). Putting Babylon in the monorepo (like @hzoo suggested above) might be the easiest way to accomplish this.

@Daniel15 Daniel15 added the PR: WIP label Aug 1, 2017

@Daniel15 Daniel15 self-assigned this Aug 6, 2017

@Daniel15

This comment has been minimized.

Member

Daniel15 commented Aug 6, 2017

The main outstanding issue with this is that the resulting file is much larger than the one built from the separate babel-standalone repo. I was going to try to fix this, but I can't build Babel on my computer at the moment (I'm currently blocked by yarnpkg/yarn#4106). I'll take a look once I figure out how to unblock myself.

@Daniel15

This comment has been minimized.

Member

Daniel15 commented Aug 9, 2017

I'll try to work on this again this next weekend if I get time.

@xtuc

This comment has been minimized.

Member

xtuc commented Aug 9, 2017

@xtuc another reason why babylon should be in the monorepo too?

@hzoo yes, it would be simpler. I'm not particularly against it, I was just saying that it's good to have the distinct repos because of two different usages.

I guess it would become a package, right? We could make create a parser folder?

@hzoo

This comment has been minimized.

Member

hzoo commented Aug 9, 2017

can just name it babylon in packages/ (it used to be here before and got moved out actually)

@Daniel15

This comment has been minimized.

Member

Daniel15 commented Aug 10, 2017

I unblocked my local Babel build by disabling Yarn workspaces in the Lerna config.

I think I worked out that the issues I'm seeing with file size are caused by the fact that multiple different packages reference common packages (like lodash). Since Webpack doesn't include the dedupe plugin any more, it's no longer deduping these, and thus each one has its own copy of Lodash. There's like 10 different copies of Lodash in the Webpack bundle.

Based on webpack/webpack#3266 and webpack/webpack#985, it sounds like root-most-resolve-plugin should fix that as long as the packages are referenced at the root of the repo (which Lodash is). I'll try that soon and see.

@Daniel15 Daniel15 removed the PR: WIP label Aug 11, 2017

@Daniel15

This comment has been minimized.

Member

Daniel15 commented Aug 11, 2017

I think this is ready for review now! Using root-most-resolve-plugin got the file size down to a more reasonable 3.3 MB, and it seems to be actually working :D

CI build is failing for some reason - I need to work out why.

@xtuc

xtuc approved these changes Aug 11, 2017

lgtm, thanks @Daniel15. Most of the code was just moved from the old repo I guess.

@@ -20,6 +20,9 @@ before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.28.1
script:
# Babel doesn't build correctly with npm v2 (which comes bundled with Node v4)
# so we manually upgrade to a known working npm version.
- npm install --global npm@4

This comment has been minimized.

@xtuc

xtuc Aug 11, 2017

Member

What is the issue with npm2, could we fix it?

This comment has been minimized.

@Daniel15

Daniel15 Aug 12, 2017

Member

It's because of the giant directory structures it produces. We do warn about something similar on the Babel site:

Note: Running a Babel 6.x project using npm 2.x can cause performance problems because of the way npm 2.x installs dependencies. This problem can be eliminated by either switching to npm 3.x or running npm 2.x with the dedupe flag.

dedupe might work, but it was easiest to just upgrade npm. npm 5 is buggy so I stuck with 4.

This comment has been minimized.

@Daniel15

Daniel15 Aug 12, 2017

Member

This might not even be needed if we're using Yarn now. Hmm.

This comment has been minimized.

@hzoo

hzoo Aug 12, 2017

Member

yeah should be able to run yarn with node 4 too

@Daniel15

This comment has been minimized.

Member

Daniel15 commented Aug 12, 2017

Most of the code was just moved from the old repo I guess.

Yeah. We can improve it iteratively 😃

"babel-plugin-transform-undefined-to-void": "6.8.2",
"babel-plugin-undeclared-variables-check": "6.22.0",
"babel-preset-babili": "0.1.4",
"babel-preset-env": "^2.0.0-alpha.18",

This comment has been minimized.

@hzoo

hzoo Aug 12, 2017

Member

theres's a alpha.19 now, and probably don't want the ^

This comment has been minimized.

@Daniel15

Daniel15 Aug 12, 2017

Member

Oh yeah, good point. I copied this from babel-standalone's repo and forgot to fix the version numbers.

This comment has been minimized.

@Daniel15

Daniel15 Aug 12, 2017

Member

@hzoo Does Lerna bump these version numbers when a new version comes out? I don't really know a lot about how Lerna works, I've never used it.

Daniel15 added some commits Aug 1, 2017

Cherry-picking babel/babel-standalone@5721b2e
Remove deprecated packages to prevent Babel v6 files from being pulled in
- Fix version number
- Remove Babili packages (they should be in separate babili-standalone)
- Remove deprecated  syntax-class-constructor-call
- Remove more Babili packages
- Remove `babel-plugin-inline-replace-variables` for now as it pulls in Babel 6 stuff
@Daniel15

This comment has been minimized.

Member

Daniel15 commented Aug 12, 2017

IT BUILDS
SHIP IT

@Daniel15 Daniel15 merged commit a04c18a into babel:7.0 Aug 12, 2017

2 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Daniel15 Daniel15 deleted the Daniel15:standalone branch Aug 12, 2017

@hzoo hzoo referenced this pull request Aug 15, 2017

Merged

Create aug-16.md #32

jridgewell added a commit to jridgewell/babel that referenced this pull request Aug 19, 2017

Remove babel-standalone
This reverts babel#6029 due to issues in babel#6120.

We need to first move `babel-loader` into the monorepo (and update its
dependencies on `babel-core`). Afterwards, we can re-add
`babel-standalone`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment