Skip to content
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

Merge master into 7.0 #5368

Merged
merged 20 commits into from
Feb 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7dcc970
Manually bump and publish babel-runtime
loganfsmyth Feb 14, 2017
958f72d
Add name field to package.json (#5311) [skip ci]
chicoxyzzy Feb 15, 2017
b77c435
Ignore babel-register test artifacts (#5316) [skip ci]
existentialism Feb 15, 2017
ff2c24e
Add test for reference paths (#5296)
jasonLaster Feb 15, 2017
28853bf
Fix for-await printing (#5322)
danez Feb 15, 2017
7e59f86
Fix 'o' is undefined in example code (#5327) [skip ci]
ghthor Feb 16, 2017
69c6d27
Improve syntax highlighting in readme for JSX (#5331) [skip ci]
lencioni Feb 17, 2017
d55a775
Update CONTRIBUTING.md with respect to coverage check [skip ci] (#5329)
zjmiller Feb 17, 2017
07dd2b1
Shorthand properties examples (#5334)
bhoule Feb 17, 2017
7b63af0
Fix typo in CONTRIBUTING.md [skip ci]
existentialism Feb 20, 2017
2974a82
Add babel-bot to team (#5355) [skip ci]
danez Feb 21, 2017
b524699
Update CONTRIBUTING.md: include make build (#5349) [skip ci]
oleksandr-kuzmenko Feb 21, 2017
02f51fb
[skip ci] Add devEngines to package.json (#5312)
yavorsky Feb 22, 2017
8d9195f
Pass `dirname` as extra metadata to preset constructor. (#4834)
izaakschroeder Feb 22, 2017
2de4b08
Add test for passing arguments to babel-node (#5163) (#5342)
outsideris Feb 22, 2017
3a6d85e
Remove redundant NODE_ENV=test in Makefile (#5350)
aaronang Feb 22, 2017
c1c9ac4
Add section to CONTRIBUTING about debugging code (#5354) [skip ci]
aaronang Feb 22, 2017
be293bd
Enable codecov partial coverage (#5336)
danez Feb 22, 2017
6614a63
Wrap some generated do expressions in parens (#5339)
zjmiller Feb 22, 2017
d33d023
Merge remote-tracking branch 'origin/master' into merge-master
hzoo Feb 23, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
|
<strong><a href="#writing-tests">Writing tests</a></strong>
|
<strong><a href="#debugging-code">Debugging code</a></strong>
|
<strong><a href="#internals">Internals</a></strong>
</p>

Expand Down Expand Up @@ -127,7 +129,8 @@ $ TEST_DEBUG=true make test
To test the code coverage, use:

```sh
$ make test-cov
$ BABEL_ENV=cov make build
$ ./scripts/test-cov.sh
```

#### Writing tests
Expand Down Expand Up @@ -199,9 +202,46 @@ For both `babel-plugin-x` and `babylon`, you can easily generate an `expected.js
- expected.json (will be generated if not created)
```

#### Debugging code

A common approach to debugging JavaScript code is to walk through the code using the [Chrome DevTools](https://developers.google.com/web/tools/chrome-devtools/) debugger.
For illustration purposes, we are going to assume that we need to get a better understanding of [`Generator.generate()`](https://github.com/babel/babel/blob/b5246994b57f06af871be6a63dcc4c6fd41d94d6/packages/babel-generator/src/index.js#L32), which is responsible for generating code for a given AST.
To get a better understanding of what is actually going on for this particular piece of code, we are going to make use of breakpoints.

```diff
generate() {
+ debugger; // breakpoint
return super.generate(this.ast);
}
```

To include the changes, we have to make sure to build Babel:

```bash
$ make build
```

Next, we need to execute `Generator.generate()`, which can be achieved by running a test case in the `babel-generator` package.
For example, we can run the test case that tests the generation of class declarations:

```bash
$ TEST_DEBUG=true TEST_GREP=ClassDeclaration make test-only

./scripts/test.sh
Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/3cdaebd2-be88-4e7b-a94b-432950ab72d0
```

To start the debugging in Chrome DevTools, open the given URL.
The debugger starts at the first executed line of code, which is Mocha's first line by default.
Click _Resume script execution_ <img src="https://i.imgur.com/TmYBn9d.png" alt="Resume script execution button." width="16"> to jump to the set breakpoint.
Note that the code shown in Chrome DevTools is compiled code and therefore differs.

#### Internals
- AST spec ([babylon/ast/spec.md](https://github.com/babel/babylon/blob/master/ast/spec.md))
- Versionning ([doc/design/versioning.md](./doc/design/versioning.md))
- Versioning ([doc/design/versioning.md](./doc/design/versioning.md))
- Monorepo ([doc/design/monorepo.md](./doc/design/monorepo.md))
- Compiler environment support ([doc/design/compiler-environment-support.md](./doc/design/compiler-environment-support.md))
- Compiler assumptions ([doc/design/compiler-assumptions.md](./doc/design/compiler-assumptions.md))
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ test-only:
test: lint test-only

test-ci:
NODE_ENV=test make bootstrap
make bootstrap
make test-only

test-ci-coverage:
NODE_ENV=test BABEL_ENV=cov make bootstrap
BABEL_ENV=cov make bootstrap
./scripts/test-cov.sh
./node_modules/.bin/codecov -f coverage/coverage-final.json

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@ Babel | Daniel Tschinder | Logan Smyth | Henry Zhu |
| [@kangax](https://github.com/kangax) | [@kaicataldo](https://github.com/kaicataldo) | [@motiz88](https://github.com/motiz88) | [@xtuc](https://github.com/xtuc) |
| [@kangax](https://twitter.com/kangax) | [@kai_cataldo](https://twitter.com/kai_cataldo) | [@motiz88](https://twitter.com/motiz88) | [@svensauleau](https://twitter.com/svensauleau) |

### Non-Human Members

[<img src="https://github.com/babel/babel-bot/raw/master/babel-bot.png" height="64">](https://github.com/babel-bot) |
|---|
| Babel Bot |
| [@babel-bot](https://github.com/babel-bot) |
| [@babeljs](https://twitter.com/babeljs) |

### Inactive members

[![Amjad Masad](https://avatars.githubusercontent.com/u/587518?s=64)](https://github.com/amasad) | [![James Kyle](https://avatars.githubusercontent.com/u/952783?s=64)](https://github.com/thejameskyle) | [![Jesse McCarthy](https://avatars.githubusercontent.com/u/129203?s=64)](https://github.com/jmm) | [![Sebastian McKenzie](https://avatars.githubusercontent.com/u/853712?s=64)](https://github.com/kittens) (Creator) |
Expand Down
4 changes: 4 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage:
parsers:
javascript:
enable_partials: yes
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "babel",
"private": true,
"license": "MIT",
"scripts": {
Expand Down Expand Up @@ -44,6 +45,10 @@
"through2": "^2.0.0",
"uglify-js": "^2.4.16"
},
"devEngines": {
"node": ">= 0.10 <= 7.x",
"npm": "2.x || 3.x || 4.x"
},
"babel": {
"comments": false,
"presets": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log(process.argv[2]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": ["bar", "foo"],
"stdout": "foo"
}
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export default class OptionManager {
}
const presetFactory = this.getPresetFactoryForPreset(presetLoc || preset);

preset = presetFactory(context, options);
preset = presetFactory(context, options, { dirname });

if (onResolve) onResolve(preset, presetLoc);
} catch (e) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/babel-generator/src/generators/statements.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ const buildForXStatement = function (op) {
this.space();
}
this.token("(");

this.print(node.left, node);
this.space();
this.word(op);
Expand Down
4 changes: 4 additions & 0 deletions packages/babel-generator/src/node/parentheses.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export function ObjectExpression(node: Object, parent: Object, printStack: Array
return isFirstInStatement(printStack, { considerArrow: true });
}

export function DoExpression(node: Object, parent: Object, printStack: Array<Object>): boolean {
return isFirstInStatement(printStack);
}

export function Binary(node: Object, parent: Object): boolean {
if ((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node) {
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(do {
foo;
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(do {
foo;
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var o = { a, b, c };
**Out**

```js
var o = { a: a, b: b, c:c };
var o = { a: a, b: b, c: c };
```

**In**
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-plugin-transform-es2015-spread/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var a = ['a', 'b', 'c'];
var b = [...a, 'foo'];

var c = { foo: 'bar', baz: 42 };
var d = {...o, a: 2};
var d = {...c, a: 2};
```

**Out**
Expand All @@ -33,7 +33,7 @@ var a = [ 'a', 'b', 'c' ];
var b = [].concat(a, [ 'foo' ]);

var c = { foo: 'bar', baz: 42 };
var d = _extends({}, o, { a: 2 });
var d = _extends({}, c, { a: 2 });
```

## Installation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

**In**

```js
```jsx
const Hr = () => {
return <hr className="hr" />;
};
```

**Out**

```js
```jsx
const _ref = <hr className="hr" />;

const Hr = () => {
Expand All @@ -26,13 +26,13 @@ const Hr = () => {

- **Spread Operator**

```js
```jsx
<div {...foobar} />
```

- **Refs**

```js
```jsx
<div ref="foobar" />
<div ref={node => this.node = node} />
```
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-runtime",
"version": "6.22.0",
"version": "6.23.0",
"description": "babel selfContained runtime",
"license": "MIT",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-runtime",
Expand All @@ -11,6 +11,6 @@
},
"devDependencies": {
"babel-helpers": "^6.22.0",
"babel-plugin-transform-runtime": "^6.22.0"
"babel-plugin-transform-runtime": "^6.23.0"
}
}
21 changes: 21 additions & 0 deletions packages/babel-traverse/test/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ function getPath(code) {
return path;
}

function getIdentifierPath(code) {
const ast = parse(code);
let nodePath;
traverse(ast, {
Identifier: function(path) {
nodePath = path;
path.stop();
}
});

return nodePath;
}

describe("scope", function () {
describe("binding paths", function () {
it("function declaration id", function () {
Expand Down Expand Up @@ -67,5 +80,13 @@ describe("scope", function () {
_foo2: { }
`).scope.generateUid("foo"), "_foo3");
});

it("reference paths", function() {
const path = getIdentifierPath("function square(n) { return n * n}");
const referencePaths = path.context.scope.bindings.n.referencePaths;
assert.equal(referencePaths.length, 2);
assert.deepEqual(referencePaths[0].node.loc.start, { line: 1, column:28 });
assert.deepEqual(referencePaths[1].node.loc.start, { line: 1, column:32 });
});
});
});