Skip to content

Move babel-standalone into main Babel repo#6029

Merged
Daniel15 merged 12 commits intobabel:7.0from
Daniel15:standalone
Aug 12, 2017
Merged

Move babel-standalone into main Babel repo#6029
Daniel15 merged 12 commits intobabel:7.0from
Daniel15:standalone

Conversation

@Daniel15
Copy link
Copy Markdown
Member

@Daniel15 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
Copy link
Copy Markdown

@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
Copy link
Copy Markdown
Member Author

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 [WIP] Move babel-standalone into main Babel repo Move babel-standalone into main Babel repo Jul 31, 2017
@Daniel15
Copy link
Copy Markdown
Member Author

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 xtuc added the PR: Internal 🏠 A type of pull request used for our changelog categories label Aug 1, 2017
@xtuc
Copy link
Copy Markdown
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": {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@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 😃

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

@hzoo
Copy link
Copy Markdown
Member

hzoo commented Aug 1, 2017

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

@hzoo hzoo mentioned this pull request Aug 1, 2017
@Daniel15
Copy link
Copy Markdown
Member Author

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 WIP label Aug 1, 2017
@Daniel15 Daniel15 self-assigned this Aug 6, 2017
@Daniel15
Copy link
Copy Markdown
Member Author

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
Copy link
Copy Markdown
Member Author

Daniel15 commented Aug 9, 2017

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

@xtuc
Copy link
Copy Markdown
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
Copy link
Copy Markdown
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
Copy link
Copy Markdown
Member Author

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
Copy link
Copy Markdown
Member Author

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.

Copy link
Copy Markdown
Member

@xtuc xtuc left a comment

Choose a reason for hiding this comment

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

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

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yeah should be able to run yarn with node 4 too

@Daniel15
Copy link
Copy Markdown
Member Author

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",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@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
Copy link
Copy Markdown
Member Author

IT BUILDS
SHIP IT

@Daniel15 Daniel15 merged commit a04c18a into babel:7.0 Aug 12, 2017
@Daniel15 Daniel15 deleted the standalone branch August 12, 2017 06:36
@hzoo hzoo mentioned this pull request Aug 15, 2017
jridgewell added a commit to jridgewell/babel that referenced this pull request Aug 19, 2017
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`.
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 6, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Internal 🏠 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants