Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/valtech-nyc/babel into fe…
Browse files Browse the repository at this point in the history
…ature/pipe-await

* 'master' of https://github.com/valtech-nyc/babel: (131 commits)
  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)
  [transform-classes] Fix typo in _wrapNativeSuper helper
  [typeof-symbol] Guard against undefined built-in globals
  update to beta.41 (babel#7568)
  v7.0.0-beta.41
  Fix import of type ConfigItem (babel#7561)
  Run node 9 on circleci and remove from travis (babel#7560)
  docs: [skip ci] fix proposal link text
  update preset-env after build-data (babel#7543)
  Re-add TEST_ONLY and use Jest's -t for TEST_GREP. (babel#7556)
  ...
  • Loading branch information
mAAdhaTTah committed Mar 18, 2018
2 parents a644d6b + d260bfa commit 82e2500
Show file tree
Hide file tree
Showing 1,397 changed files with 13,987 additions and 6,297 deletions.
78 changes: 27 additions & 51 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,48 @@
"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

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.");
}

// Gross hacks to put the code coverage block above all compiled
// import statement output.
node._blockHoist = 5;
},
},
},
};
}

let envOpts = {
const env = process.env.BABEL_ENV || process.env.NODE_ENV;
const envOpts = {
loose: true,
};

switch (env) {
case "development":
envOpts.debug = true;
// fall-through
case "test":
case "cov":
envOpts.targets = {
node: "current",
};
}

const config = {
comments: false,
presets: [
["@babel/env", envOpts],
],
presets: [["@babel/env", envOpts]],
plugins: [
// TODO: Use @babel/preset-flow when
// 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",
plugins: [
"babel-plugin-transform-charcodes",
["@babel/transform-for-of", { assumeArray: true }],
],
}],
overrides: [
{
test: "packages/babylon",
plugins: [
"babel-plugin-transform-charcodes",
["@babel/transform-for-of", { assumeArray: true }],
],
},
],
};

if (process.env.BABEL_ENV === "cov") {
// we need to do this as long as we do not test everything from source
if (env === "cov") {
config.auxiliaryCommentBefore = "istanbul ignore next";
config.plugins.push(istanbulHacks);
}

if (process.env.BABEL_ENV === "development") {
envOpts.targets = {
node: "current"
};
envOpts.debug = true;
config.plugins.push("babel-plugin-istanbul");
}

module.exports = config;
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
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MAKEFLAGS = -j1
FLOW_COMMIT = 622bbc4f07acb77eb1109830c70815f827401d90
TEST262_COMMIT = 1282e842febf418ca27df13fa4b32f7e5021b470
TEST262_COMMIT = 52f70e2f637731aae92a9c9a2d831310c3ab2e1e

export NODE_ENV = test

Expand Down Expand Up @@ -41,16 +41,24 @@ build-dist: build

watch: clean
make clean-lib

# Ensure that build artifacts for types are created during local
# development too.
BABEL_ENV=development ./node_modules/.bin/gulp build-no-bundle
node ./packages/babel-types/scripts/generateTypeHelpers.js
node scripts/generators/flow.js > ./packages/babel-types/lib/index.js.flow
BABEL_ENV=development ./node_modules/.bin/gulp watch

flow:
./node_modules/.bin/flow check --strip-root

lint:
./node_modules/.bin/eslint scripts $(SOURCES) *.js --format=codeframe --rulesdir="./scripts/eslint_rules"
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' '**/.*.js' --format=codeframe --rulesdir="./scripts/eslint_rules"

fix:
./node_modules/.bin/eslint scripts $(SOURCES) *.js --format=codeframe --fix --rulesdir="./scripts/eslint_rules"
# The config is hardcoded because otherwise prettier searches for it and also picks up some broken package.json files from tests
./node_modules/.bin/prettier --config .prettierrc --write --ignore-path .eslintignore '**/*.json'
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' '**/.*.js' --format=codeframe --fix --rulesdir="./scripts/eslint_rules"

clean: test-clean
rm -rf packages/babel-polyfill/browser*
Expand All @@ -75,7 +83,7 @@ test-ci:
test-ci-coverage: SHELL:=/bin/bash
test-ci-coverage:
BABEL_ENV=cov make bootstrap
./scripts/test-cov.sh
TEST_TYPE=cov ./scripts/test-cov.sh
bash <(curl -s https://codecov.io/bash) -f coverage/coverage-final.json

bootstrap-flow:
Expand Down Expand Up @@ -124,8 +132,8 @@ publish:

bootstrap:
make clean-all
yarn
./node_modules/.bin/lerna bootstrap
yarn --ignore-engines
./node_modules/.bin/lerna bootstrap -- --ignore-engines
make build
cd packages/babel-runtime; \
node scripts/build-dist.js
Expand Down
30 changes: 0 additions & 30 deletions circle.yml

This file was deleted.

Loading

0 comments on commit 82e2500

Please sign in to comment.