Move babel-standalone into main Babel repo#6029
Conversation
|
@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. |
4462a99 to
1e95fc2
Compare
|
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). |
|
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. |
|
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": { |
There was a problem hiding this comment.
Does standalone handle preset/plugin options? if so, you can just pass the preset with modules false, and same below for loose mode.
There was a problem hiding this comment.
@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 😃
There was a problem hiding this comment.
yeah can do separately, we can also break since this will be an alpha for v7 as well
|
@xtuc another reason why babylon should be in the monorepo too? |
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 |
|
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. |
|
I'll try to work on this again this next weekend if I get time. |
@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 |
|
can just name it babylon in packages/ (it used to be here before and got moved out actually) |
|
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 |
| 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 |
There was a problem hiding this comment.
What is the issue with npm2, could we fix it?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
This might not even be needed if we're using Yarn now. Hmm.
There was a problem hiding this comment.
yeah should be able to run yarn with node 4 too
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", |
There was a problem hiding this comment.
theres's a alpha.19 now, and probably don't want the ^
There was a problem hiding this comment.
Oh yeah, good point. I copied this from babel-standalone's repo and forgot to fix the version numbers.
There was a problem hiding this comment.
@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.
Remove deprecated packages to prevent Babel v6 files from being pulled in
- Remove Babili packages (they should be in separate babili-standalone) - Remove deprecated syntax-class-constructor-call
- Remove `babel-plugin-inline-replace-variables` for now as it pulls in Babel 6 stuff
|
IT BUILDS |
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`.

@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:
packages/babel-standalone. The README and most of the code was copied across verbatimbabel-standaloneGulpfile into the main Babel Gulpfilebabel.jsandbabel.min.jsas 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 CircleCIOne 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-standaloneacross yet.Still to be done:
cc @hzoo