Skip to content

Commit

Permalink
Merge branch 'master' into feature/pipeline-operator-proposals
Browse files Browse the repository at this point in the history
* master: (140 commits)
  Update to beta.42 (babel#7609)
  Disable flow on transformClass, fix preset-env errors (babel#7605)
  Logical Assignment: ensure computed key isn't recomputed (babel#7604)
  Remove obsolete max-len eslint rule and reformat some stuff to fit (babel#7602)
  Centralize Babel's own compilation config to make it easier to follow. (babel#7599)
  Run prettier to format all JSON.
  Tweak es2015-related plugin order in preset-env (babel#7586)
  Refactored quirky inheritance in babel-plugin-transform-classes (babel#7444)
  Add RegExp support to include/exclude preset-env options (babel#7242)
  v7.0.0-beta.42
  Use strict namespace behavior for mjs files. (babel#7545)
  Remove outdated spec deviation note [skip ci] (babel#7571)
  Ensure that the backward-compat logic for plugin-utils copies over the version API properly. (babel#7580)
  Rename actual/expected test files to input/output (babel#7578)
  Use helper-module-import inside entry plugin too
  Use helper-module-imports instead of custom import (babel#7457)
  Fix "Module build failed: Error: Cannot find module '@babel/types'" (babel#7575)
  Wrap wrapNativeSuper helpers in redefining functions for better tree-shakeability (babel#7188)
  Favour extends helper over objectWithoutProperties when whole object gets copied anyway (babel#7390)
  Fix incorrect value of _cache in _wrapNativeSuper (babel#7570)
  ...
  • Loading branch information
mAAdhaTTah committed Mar 21, 2018
2 parents c30e4e9 + e80488f commit 7a5068e
Show file tree
Hide file tree
Showing 1,411 changed files with 15,320 additions and 7,451 deletions.
119 changes: 58 additions & 61 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,69 @@
"use strict";

// Thanks Logan for this.
// This works around https://github.com/istanbuljs/istanbuljs/issues/92 until
// we have a version of Istanbul that actually works with 7.x.
function istanbulHacks() {
return {
inherits: require("babel-plugin-istanbul").default,
visitor: {
Program: {
exit: function(path) {
if (!this.__dv__) return
module.exports = function(api) {
const env = api.env();

const node = path.node.body[0];
if (
node.type !== "VariableDeclaration" ||
node.declarations[0].id.type !== "Identifier" ||
!node.declarations[0].id.name.match(/cov_/) ||
node._blockHoist !== 3
) {
throw new Error("Something has gone wrong in Logan's hacks.");
}
const includeCoverage = process.env.BABEL_COVERAGE === "true";

// Gross hacks to put the code coverage block above all compiled
// import statement output.
node._blockHoist = 5;
},
},
},
const envOpts = {
loose: true,
modules: false,
exclude: ["transform-typeof-symbol"],
};
}

let envOpts = {
loose: true,
};
let convertESM = true;

switch (env) {
// Configs used during bundling builds.
case "babylon":
case "standalone":
convertESM = false;
break;
case "production":
// Config during builds before publish.
break;
case "development":
envOpts.debug = true;
envOpts.targets = {
node: "current",
};
break;
case "test":
envOpts.targets = {
node: "current",
};
break;
}

const config = {
comments: false,
presets: [
["@babel/env", envOpts],
],
plugins: [
// TODO: Use @babel/preset-flow when
// https://github.com/babel/babel/issues/7233 is fixed
"@babel/plugin-transform-flow-strip-types",
["@babel/proposal-class-properties", { loose: true }],
"@babel/proposal-export-namespace-from",
"@babel/proposal-numeric-separator",
["@babel/proposal-object-rest-spread", { useBuiltIns: true }],
],
overrides: [{
test: "packages/babylon",
const config = {
comments: false,
presets: [["@babel/env", envOpts]],
plugins: [
"babel-plugin-transform-charcodes",
["@babel/transform-for-of", { assumeArray: true }],
// TODO: Use @babel/preset-flow when
// https://github.com/babel/babel/issues/7233 is fixed
"@babel/plugin-transform-flow-strip-types",
["@babel/proposal-class-properties", { loose: true }],
"@babel/proposal-export-namespace-from",
"@babel/proposal-numeric-separator",
["@babel/proposal-object-rest-spread", { useBuiltIns: true }],
convertESM ? "@babel/transform-modules-commonjs" : null,
].filter(Boolean),
overrides: [
{
test: "packages/babylon",
plugins: [
"babel-plugin-transform-charcodes",
["@babel/transform-for-of", { assumeArray: true }],
],
},
],
}],
};

if (process.env.BABEL_ENV === "cov") {
config.auxiliaryCommentBefore = "istanbul ignore next";
config.plugins.push(istanbulHacks);
}

if (process.env.BABEL_ENV === "development") {
envOpts.targets = {
node: "current"
};
envOpts.debug = true;
}

module.exports = config;
// we need to do this as long as we do not test everything from source
if (includeCoverage) {
config.auxiliaryCommentBefore = "istanbul ignore next";
config.plugins.push("babel-plugin-istanbul");
}

return config;
};
16 changes: 0 additions & 16 deletions .babelrc.rollup.js

This file was deleted.

61 changes: 61 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
version: 2
aliases:
- &restore-node-modules-cache
keys:
- v1-yarn-deps-{{ checksum "yarn.lock" }}

- &restore-yarn-cache
keys:
- v1-yarn-cache

- &save-node-modules-cache
paths:
- node_modules
key: v1-yarn-deps-{{ checksum "yarn.lock" }}

- &save-yarn-cache
paths:
- ~/.yarn-cache
key: v1-yarn-cache

- &yarn-install
run: |
sudo npm i -g yarn@^1.5.1
yarn --version
- &artifact_babel
path: ~/babel/packages/babel-standalone/babel.js

- &artifact_babel_min
path: ~/babel/packages/babel-standalone/babel.min.js

- &artifact_env
path: ~/babel/packages/babel-preset-env-standalone/babel-preset-env.js

- &artifact_env_min
path: ~/babel/packages/babel-preset-env-standalone/babel-preset-env.min.js

jobs:
build:
working_directory: ~/babel
docker:
- image: circleci/node:9
steps:
- checkout
- restore-cache: *restore-yarn-cache
- restore-cache: *restore-node-modules-cache
- *yarn-install
- run: make test-ci-coverage
# Builds babel-standalone with the regular Babel config
- run: make build
# test-ci-coverage doesn't test babel-standalone, as trying to gather coverage
# data for a JS file that's several megabytes large is bound to fail. Here,
# we just run the babel-standalone test separately.
- run: ./node_modules/.bin/jest packages/babel-standalone/test/
- run: ./node_modules/.bin/jest packages/babel-preset-env-standalone/test/
- store_artifacts: *artifact_babel
- store_artifacts: *artifact_babel_min
- store_artifacts: *artifact_env
- store_artifacts: *artifact_env_min
- save_cache: *save-node-modules-cache
- save_cache: *save-yarn-cache
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/lib
/build
package.json
packages/babel-runtime
!packages/babel-runtime/scripts
!packages/babel-runtime/core-js.js
Expand All @@ -18,5 +20,4 @@ packages/babel-preset-env-standalone/babel-preset-env.js
packages/babel-preset-env-standalone/babel-preset-env.min.js
packages/babel-standalone/babel.js
packages/babel-standalone/babel.min.js
packages/babylon/build
packages/babylon/test/expressions
15 changes: 6 additions & 9 deletions .eslintrc → .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"root": true,
"extends": "babel",
"plugins": [
"prettier"
],
"plugins": ["prettier"],
"rules": {
"curly": ["error", "multi-line"],
"prettier/prettier": "error",
Expand All @@ -13,12 +12,10 @@
},
"overrides": [
{
"files": [
"packages/*/src/**/*.js",
"codemods/*/src/**/*.js"
],
"files": ["packages/*/src/**/*.js", "codemods/*/src/**/*.js"],
"rules": {
"no-undefined-identifier": "error"
"no-undefined-identifier": "error",
"no-deprecated-clone": "error"
}
},
{
Expand All @@ -28,7 +25,7 @@
"test/**/*.js"
],
"env": {
"mocha": true
"jest": true
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ codemods/*/src
[libs]
lib/file.js
lib/parser.js
lib/packages/babel-types/lib/index.js.flow
lib/third-party-libs.js.flow
packages/babel-types/lib/index.js.flow

[options]
include_warnings=true
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ package-lock.json
!/packages/babel-runtime/core-js/map.js
/packages/babel-runtime/helpers/*.js
!/packages/babel-runtime/helpers/toArray.js
!/packages/babel-runtime/helpers/iterableToArray.js
!/packages/babel-runtime/helpers/temporalRef.js
/packages/babel-runtime/helpers/builtin/*.js
!/packages/babel-runtime/helpers/builtin/toArray.js
!/packages/babel-runtime/helpers/builtin/iterableToArray.js
!/packages/babel-runtime/helpers/builtin/temporalRef.js
/packages/babel-runtime/helpers/builtin/es6/*.js
!/packages/babel-runtime/helpers/builtin/es6/toArray.js
!/packages/babel-runtime/helpers/builtin/es6/iterableToArray.js
!/packages/babel-runtime/helpers/builtin/es6/temporalRef.js
/packages/babel-runtime/helpers/es6/*.js
!/packages/babel-runtime/helpers/es6/toArray.js
!/packages/babel-runtime/helpers/es6/iterableToArray.js
!/packages/babel-runtime/helpers/es6/temporalRef.js
/packages/babel-register/test/.babel
/packages/babel-cli/test/tmp
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package.json
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"arrowParens": "avoid",
"trailingComma": "es5",
"useTabs": false,
"semi": true,
"singleQuote": false,
"bracketSpacing": true,
"jsxBracketSameLine": false,
"tabWidth": 2,
"parser": "babylon",
"printWidth": 80,
"overrides": [{
"files": [
"**/codemods/*/src/**/*.js",
Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ cache:
directories:
- node_modules
node_js:
# We test the latest version on circleci
- '8'
- '6'
- '4'
Expand All @@ -19,6 +20,8 @@ env:
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash

install: yarn --ignore-engines

before_script:
- 'if [ "$JOB" = "babylon-flow-tests" ]; then make bootstrap-flow; fi'
- 'if [ "$JOB" = "babylon-test262-tests" ]; then make bootstrap-test262; fi'
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ $ TEST_ONLY=babel-cli make test

```sh
# Run tests for the @babel/plugin-transform-classes package.
$ TEST_ONLY=es2015-class make test
$ TEST_ONLY=babel-plugin-transform-classes make test
```

Use the `TEST_GREP` variable to run a subset of tests by name:
Expand Down Expand Up @@ -175,7 +175,7 @@ For example, in [`@babel/plugin-transform-exponentiation-operator/test`](https:/

- In each subfolder, you can organize your directory structure by categories of tests. (Example: these folders can be named after the feature you are testing or can reference the issue number they fix)
- Generally, there are two kinds of tests for plugins
- The first is a simple test of the input and output produced by running Babel on some code. We do this by creating an [`input.js`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/binary/input.js) file and an [`output.js`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/binary/output.js) file.
  - The first is a simple test of the input and output produced by running Babel on some code. We do this by creating an [`input.js`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/binary/input.js) file and an [`output.js`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/binary/output.js) file. This kind of test only works in sub-subdirectories of `/fixtures`, i.e. `/fixtures/exponentian-operator/binary/input.js` and **not** `/fixtures/exponentian-operator/input.js`.
- If you need to expect an error, you can ignore creating the `output.js` file and pass a new `throws` key to the `options.json` that contains the error string that is created.
- The second and preferred type is a test that actually evaluates the produced code and asserts that certain properties are true or false. We do this by creating an [`exec.js`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/comprehensive/exec.js) file.

Expand Down Expand Up @@ -234,7 +234,7 @@ descriptive name, and add the following:
After writing tests for babylon, just build it by running:

```sh
$ make build-babylon
$ make build
```

Then, to run the tests, use:
Expand Down
3 changes: 2 additions & 1 deletion Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ function buildRollup(packages) {
format: "cjs",
plugins: [
rollupBabel({
envName: "babylon",
babelrc: false,
extends: "./.babelrc.rollup.js",
extends: "./.babelrc.js",
}),
rollupNodeResolve(),
],
Expand Down
Loading

0 comments on commit 7a5068e

Please sign in to comment.