Compare commits
81 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7af4302d07 | ||
|
|
543770960c | ||
|
|
a2975a72cc | ||
|
|
beb3fd51d8 | ||
|
|
9360860601 | ||
|
|
7d4ecea8fb | ||
|
|
a44831b3fa | ||
|
|
8357f3900f | ||
|
|
6b1c5bc358 | ||
|
|
3564309a77 | ||
|
|
c9518bb60d | ||
|
|
0f1215e33e | ||
|
|
d7b0b5bec0 | ||
|
|
3e5af404ab | ||
|
|
1818094577 | ||
|
|
6d712b3d14 | ||
|
|
11389fe165 | ||
|
|
0ee9531db3 | ||
|
|
1622d2498d | ||
|
|
b76e6f8e5b | ||
|
|
beac006832 | ||
|
|
20d7603c0b | ||
|
|
24b13c5e49 | ||
|
|
9e21074e88 | ||
|
|
9a825bced7 | ||
|
|
fcb78436c6 | ||
|
|
bb30a64f8d | ||
|
|
b483c16fe2 | ||
|
|
569f046045 | ||
|
|
4e969d3d92 | ||
|
|
0bca1de285 | ||
|
|
3a5bd06a7e | ||
|
|
66a908aaa7 | ||
|
|
cd0ed08237 | ||
|
|
dd84b554e6 | ||
|
|
b51411f090 | ||
|
|
4cc843ded3 | ||
|
|
47d253c732 | ||
|
|
09901274ab | ||
|
|
35196e20c7 | ||
|
|
35af771a29 | ||
|
|
dee80caa09 | ||
|
|
46b7cc0a72 | ||
|
|
3b189e22b7 | ||
|
|
6ca565d7fb | ||
|
|
64f5480f96 | ||
|
|
828fdc8769 | ||
|
|
6763c4415e | ||
|
|
fb30e79e03 | ||
|
|
85fb4304b0 | ||
|
|
c2da77d7ec | ||
|
|
c54c3d3c15 | ||
|
|
2a7c954155 | ||
|
|
3fb7f7c7cc | ||
|
|
c4b2818336 | ||
|
|
061561bfd8 | ||
|
|
d4944d606b | ||
|
|
736b689c3b | ||
|
|
e12b377014 | ||
|
|
5fd5b815ab | ||
|
|
92db8312f6 | ||
|
|
e080fe547d | ||
|
|
b967ecf063 | ||
|
|
365b7285d2 | ||
|
|
a40d532b0e | ||
|
|
0487bf911d | ||
|
|
57c72d1cd0 | ||
|
|
335bdffec2 | ||
|
|
e1d76a1dfe | ||
|
|
a4845323a2 | ||
|
|
792951b489 | ||
|
|
5adda836af | ||
|
|
4c2c3098c3 | ||
|
|
087c714098 | ||
|
|
5a33e4fe05 | ||
|
|
5f8667eaa7 | ||
|
|
31b4468514 | ||
|
|
2be9678bbe | ||
|
|
b5210877cf | ||
|
|
a8702be756 | ||
|
|
0995cc3f4e |
@@ -1,5 +1,8 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
node_js:
|
||||
- "0.12"
|
||||
- "iojs"
|
||||
|
||||
66
CHANGELOG.md
66
CHANGELOG.md
@@ -13,6 +13,72 @@ _Note: Gaps between patch versions are faulty/broken releases._
|
||||
|
||||
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
|
||||
|
||||
## 5.1.11
|
||||
|
||||
* **Bug Fix**
|
||||
* Memoise and bind member expression decorators.
|
||||
* Move JSX children cleaning to opening element visitor. Fixes elements not being cleaned in certain scenarios.
|
||||
* Consider `SwitchStatement`s to be `Scopable`.
|
||||
* Fix `bluebirdCoroutines` calling `interopRequireWildcard` before it's defined.
|
||||
* Add space to `do...while` code generation.
|
||||
* Validate `super` use before `this` on `super` exit rather than entrance.
|
||||
* **Polish**
|
||||
* Add Babel name to logger.
|
||||
|
||||
## 5.1.10
|
||||
|
||||
* **Bug Fix**
|
||||
* Remove `makePredicate` from acorn in favor of an `indexOf`.
|
||||
* Remove statements to expression explosion when inserting a block statement.
|
||||
* **Internal**
|
||||
* Remove runtime compatibility check.
|
||||
|
||||
## 5.1.9
|
||||
|
||||
* **Bug Fix**
|
||||
* Fix class property initializers with `undefined` values not being correctly writable.
|
||||
* Fix self inferring generators incorrectly causing a stack error.
|
||||
* Fix default export specifiers not triggering AMD `module` argument inclusion.
|
||||
* Fix assignments not having their module references properly remapped.
|
||||
* **Internal**
|
||||
* Upgrade to latest `acorn`.
|
||||
* **Polish**
|
||||
* Make invalid LHS pattern error messages nicer.
|
||||
|
||||
## 5.1.8
|
||||
|
||||
* **Bug Fix**
|
||||
* Only make parenthesized object pattern LHS illegal.
|
||||
|
||||
## 5.1.7
|
||||
|
||||
* **Internal**
|
||||
* Add `parse` node API.
|
||||
|
||||
## 5.1.6
|
||||
|
||||
* **Bug Fix**
|
||||
* Fix `runtime` built-in catchall not properly checking for local variables.
|
||||
|
||||
## 5.1.5
|
||||
|
||||
* **Internal**
|
||||
* Bump `core-js` version.
|
||||
|
||||
## 5.1.4
|
||||
|
||||
* **Polish**
|
||||
* Add missing `Reflect` methods to runtime transformer.
|
||||
|
||||
## 5.1.3
|
||||
|
||||
* **Internal**
|
||||
* Switch entirely to vanilla regenerator.
|
||||
* Clean up and make the parsing of decorators stateless.
|
||||
* **Bug Fix**
|
||||
* Don't do TCO on generators and async functions.
|
||||
* Add missing `core-js` runtime definitions.
|
||||
|
||||
## 5.1.2
|
||||
|
||||
* **Bug Fix**
|
||||
|
||||
@@ -1,9 +1,24 @@
|
||||
<p align="center">
|
||||
<strong><a href="#setup">Setup</a></strong>
|
||||
|
|
||||
<strong><a href="#running-tests">Running tests</a></strong>
|
||||
|
|
||||
<strong><a href="#workflow">Workflow</a></strong>
|
||||
|
|
||||
<strong><a href="#dependencies">Dependencies</a></strong>
|
||||
|
|
||||
<strong><a href="#code-standards">Code Standards</a></strong>
|
||||
</p>
|
||||
|
||||
----
|
||||
|
||||
# Contributing
|
||||
|
||||
Contributions are always welcome, no matter how large or small. Before
|
||||
contributing, please read the
|
||||
[code of conduct](https://github.com/babel/babel/blob/master/CODE_OF_CONDUCT.md).
|
||||
|
||||
|
||||
## Developing
|
||||
|
||||
#### Setup
|
||||
@@ -21,7 +36,9 @@ $ make watch-core
|
||||
```
|
||||
|
||||
This will compile Babel and then sit in the background and on file modification
|
||||
recompile the necessary files.
|
||||
recompile the necessary files. Babel itself is written in ES6. The source files
|
||||
reside in `src/` and transpile to `lib/`
|
||||
|
||||
|
||||
#### Running tests
|
||||
|
||||
@@ -44,6 +61,11 @@ Use mocha's `--grep` option to run a subset of tests by name:
|
||||
$ mocha test/core/transformation.js --grep es7
|
||||
```
|
||||
|
||||
If you don't have `mocha` installed globally, you can still use it from Babel's
|
||||
dependencies in `node_modules`, but make sure `node_modules/.bin` is added to
|
||||
your [`$PATH`](http://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path) environment variable.
|
||||
|
||||
|
||||
#### Workflow
|
||||
|
||||
* Fork the repository
|
||||
@@ -54,24 +76,91 @@ $ mocha test/core/transformation.js --grep es7
|
||||
* Ensure the test are passing (`make test`)
|
||||
* Create new pull request explaining your proposed change or reference an issue in your commit message
|
||||
|
||||
|
||||
#### Dependencies
|
||||
|
||||
+ [ast-types](http://ghub.io/ast-types) This is required to monkeypatch regenerators AST definitions. Could be improved in the future.
|
||||
|
||||
+ [chalk](http://ghub.io/chalk) This is used for terminal color highlighting for syntax errors.
|
||||
|
||||
+ [convert-source-map](http://ghub.io/convert-source-map) Turns a source map object into a comment etc.
|
||||
|
||||
+ [core-js](http://ghub.io/core-js) Used for the polyfill.
|
||||
|
||||
+ [debug](http://ghub.io/debug) Used to output debugging information when NODE_DEBUG is set to babel.
|
||||
|
||||
+ [detect-indent](http://ghub.io/detect-indent) This is used in the code generator so it can infer indentation.
|
||||
|
||||
+ [estraverse](http://ghub.io/estraverse) The only method on this is attachComments. I'd like to implement our own comment attachment algorithm eventually though.
|
||||
|
||||
+ [esutils](http://ghub.io/esutils) Various ES related utilities. Check whether something is a keyword etc.
|
||||
|
||||
+ [fs-readdir-recursive](http://ghub.io/fs-readdir-recursive) Recursively search a directory for.
|
||||
|
||||
+ [globals](http://ghub.io/globals) A list of JavaScript global variables. This is used by the scope tracking to check for colliding variables.
|
||||
|
||||
+ [is-integer](http://ghub.io/is-integer) Checks if something is an integer.
|
||||
|
||||
+ [js-tokens](http://ghub.io/js-tokens) This is used to get tokens for syntax error highlighting.
|
||||
|
||||
+ [leven](http://ghub.io/leven) A levenstein algorithm to determine how close a word is to another. This is used to offer suggestions when using the utility.undeclaredVariableCheck transformer.
|
||||
|
||||
+ [line-numbers](http://ghub.io/line-numbers) Used to produce the code frames in syntax errors.
|
||||
|
||||
+ [lodash](http://ghub.io/lodash) Used for various utilities.
|
||||
|
||||
+ [minimatch](http://ghub.io/minimatch) This is used to match glob-style ignore/only filters.
|
||||
|
||||
+ [output-file-sync](http://ghub.io/output-file-sync) Synchronously writes a file and create its ancestor directories if needed.
|
||||
|
||||
+ [path-is-absolute](http://ghub.io/path-is-absolute) Checks if a path is absolute. C:\foo and \foo are considered absolute.
|
||||
|
||||
+ [regenerator](http://ghub.io/regenerator) This is used to transform generators/async functions.
|
||||
|
||||
+ [regexpu](http://ghub.io/regexpu) Used to transform unicode regex patterns.
|
||||
|
||||
+ [repeating](http://ghub.io/repeating) Repeats a string.
|
||||
|
||||
+ [shebang-regex](http://ghub.io/shebang-regex) Literally just a regex that matches shebangs.
|
||||
|
||||
+ [slash](http://ghub.io/slash) Normalises path separators.
|
||||
|
||||
+ [source-map](http://ghub.io/source-map) Generates sourcemaps.
|
||||
|
||||
+ [source-map-support](http://ghub.io/source-map-support) Adds source map support to babel-node/babel/register.
|
||||
|
||||
+ [strip-json-comments](http://ghub.io/strip-json-comments) Remove comments from a JSON string. This is used for .babelrc files.
|
||||
|
||||
+ [to-fast-properties](http://ghub.io/to-fast-properties) A V8 trick to put an object into fast properties mode.
|
||||
|
||||
+ [trim-right](http://ghub.io/trim-right) Trims the rightside whitespace.
|
||||
|
||||
+ [user-home](http://ghub.io/user-home) Gets the users home directory. This is used to resolve the babel-node/babel/register cache.
|
||||
|
||||
|
||||
#### Code Standards
|
||||
|
||||
* **General**
|
||||
* Max of five arguments for functions
|
||||
* Max depth of four nested blocks
|
||||
* 2-spaced soft tabs
|
||||
|
||||
* **Naming**
|
||||
* CamelCase all class names
|
||||
* camelBack all variable names
|
||||
|
||||
* **Spacing**
|
||||
* Spaces after all keywords
|
||||
* Spaces before all left curly braces
|
||||
|
||||
* **Comments**
|
||||
* Use JSDoc-style comments for methods
|
||||
* Single-line comments for ambiguous code
|
||||
|
||||
* **Quotes**
|
||||
* Always use double quotes
|
||||
* Only use single quotes when the string contains a double quote
|
||||
|
||||
* **Declaration**
|
||||
* No unused variables
|
||||
* No pollution of global variables and prototypes
|
||||
|
||||
1
Makefile
1
Makefile
@@ -114,5 +114,4 @@ bootstrap:
|
||||
npm link
|
||||
cd packages/babel-cli && npm install && npm link && npm link babel-core
|
||||
git submodule update --init
|
||||
cd vendor/regenerator && npm install
|
||||
cd vendor/compat-table && npm install object-assign
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel-core",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "5.1.2",
|
||||
"version": "5.1.11",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"repository": "babel/babel",
|
||||
@@ -30,7 +30,7 @@
|
||||
"ast-types": "~0.7.0",
|
||||
"chalk": "^1.0.0",
|
||||
"convert-source-map": "^1.0.0",
|
||||
"core-js": "^0.8.1",
|
||||
"core-js": "^0.8.3",
|
||||
"debug": "^2.1.1",
|
||||
"detect-indent": "^3.0.0",
|
||||
"estraverse": "^3.0.0",
|
||||
@@ -46,7 +46,7 @@
|
||||
"output-file-sync": "^1.1.0",
|
||||
"path-is-absolute": "^1.0.0",
|
||||
"private": "^0.1.6",
|
||||
"regenerator": "https://github.com/sebmck/regenerator/archive/block-hoist.tar.gz",
|
||||
"regenerator": "^0.8.20",
|
||||
"regexpu": "^1.1.2",
|
||||
"repeating": "^1.1.2",
|
||||
"shebang-regex": "^1.0.0",
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "babel",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "5.1.1",
|
||||
"version": "5.1.10",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"repository": "babel/babel",
|
||||
"preferGlobal": true,
|
||||
"dependencies": {
|
||||
"babel-core": "^5.1.1",
|
||||
"babel-core": "^5.1.10",
|
||||
"chokidar": "^1.0.0",
|
||||
"commander": "^2.6.0",
|
||||
"fs-readdir-recursive": "^0.1.0",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel-runtime",
|
||||
"description": "babel selfContained runtime",
|
||||
"version": "5.1.1",
|
||||
"version": "5.1.10",
|
||||
"repository": "babel/babel",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"dependencies": {
|
||||
|
||||
@@ -70,8 +70,8 @@ each(File.helpers, function (helperName) {
|
||||
writeFile("helpers/" + helperName + ".js", buildHelper(helperName));
|
||||
});
|
||||
|
||||
writeFile("regenerator/index.js", readFile("regenerator-babel/runtime-module", true));
|
||||
writeFile("regenerator/runtime.js", selfContainify(readFile("regenerator-babel/runtime")));
|
||||
writeFile("regenerator/index.js", readFile("regenerator/runtime-module", true));
|
||||
writeFile("regenerator/runtime.js", selfContainify(readFile("regenerator/runtime")));
|
||||
|
||||
//
|
||||
|
||||
|
||||
@@ -104,10 +104,14 @@ pp.parseMaybeAssign = function(noIn, refShorthandDefaultPos, afterLeftParse) {
|
||||
refShorthandDefaultPos.start = 0 // reset because shorthand default was used correctly
|
||||
this.checkLVal(left)
|
||||
if (left.parenthesizedExpression) {
|
||||
let errorMsg
|
||||
if (left.type === "ObjectPattern") {
|
||||
this.raise(left.start, "You're trying to assign to a parenthesized expression, instead of `({ foo }) = {}` use `({ foo } = {})`");
|
||||
} else {
|
||||
this.raise(left.start, "Parenthesized left hand expressions are illegal");
|
||||
errorMsg = "`({a}) = 0` use `({a} = 0)`"
|
||||
} else if (left.type === "ArrayPattern") {
|
||||
errorMsg = "`([a]) = 0` use `([a] = 0)`"
|
||||
}
|
||||
if (errorMsg) {
|
||||
this.raise(left.start, `You're trying to assign to a parenthesized expression, eg. instead of ${errorMsg}`)
|
||||
}
|
||||
}
|
||||
this.next()
|
||||
@@ -509,22 +513,24 @@ pp.parseTemplate = function() {
|
||||
pp.parseObj = function(isPattern, refShorthandDefaultPos) {
|
||||
let node = this.startNode(), first = true, propHash = {}
|
||||
node.properties = []
|
||||
let decorators = []
|
||||
this.next()
|
||||
while (!this.eat(tt.braceR)) {
|
||||
if (!first) {
|
||||
this.expect(tt.comma)
|
||||
if (this.afterTrailingComma(tt.braceR)) break
|
||||
} else first = false
|
||||
|
||||
while (this.type === tt.at) {
|
||||
this.decorators.push(this.parseDecorator())
|
||||
decorators.push(this.parseDecorator())
|
||||
}
|
||||
|
||||
let prop = this.startNode(), isGenerator = false, isAsync = false, start
|
||||
if (decorators.length) {
|
||||
prop.decorators = decorators
|
||||
decorators = []
|
||||
}
|
||||
if (this.options.features["es7.objectRestSpread"] && this.type === tt.ellipsis) {
|
||||
prop = this.parseSpread()
|
||||
prop.type = "SpreadProperty"
|
||||
this.takeDecorators(prop)
|
||||
node.properties.push(prop)
|
||||
continue
|
||||
}
|
||||
@@ -550,10 +556,9 @@ pp.parseObj = function(isPattern, refShorthandDefaultPos) {
|
||||
}
|
||||
this.parseObjPropValue(prop, start, isGenerator, isAsync, isPattern, refShorthandDefaultPos);
|
||||
this.checkPropClash(prop, propHash)
|
||||
this.takeDecorators(prop)
|
||||
node.properties.push(this.finishNode(prop, "Property"))
|
||||
}
|
||||
if (this.decorators.length) {
|
||||
if (decorators.length) {
|
||||
this.raise(this.start, "You have trailing decorators with no property");
|
||||
}
|
||||
return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression")
|
||||
|
||||
@@ -9,41 +9,9 @@
|
||||
|
||||
function makePredicate(words) {
|
||||
words = words.split(" ")
|
||||
let f = "", cats = []
|
||||
out: for (let i = 0; i < words.length; ++i) {
|
||||
for (let j = 0; j < cats.length; ++j)
|
||||
if (cats[j][0].length == words[i].length) {
|
||||
cats[j].push(words[i])
|
||||
continue out
|
||||
}
|
||||
cats.push([words[i]])
|
||||
return function(str) {
|
||||
return words.indexOf(str) >= 0
|
||||
}
|
||||
function compareTo(arr) {
|
||||
if (arr.length == 1) return f += "return str === " + JSON.stringify(arr[0]) + ";"
|
||||
f += "switch(str){"
|
||||
for (let i = 0; i < arr.length; ++i) f += "case " + JSON.stringify(arr[i]) + ":"
|
||||
f += "return true}return false;"
|
||||
}
|
||||
|
||||
// When there are more than three length categories, an outer
|
||||
// switch first dispatches on the lengths, to save on comparisons.
|
||||
|
||||
if (cats.length > 3) {
|
||||
cats.sort((a, b) => b.length - a.length)
|
||||
f += "switch(str.length){"
|
||||
for (let i = 0; i < cats.length; ++i) {
|
||||
let cat = cats[i]
|
||||
f += "case " + cat[0].length + ":"
|
||||
compareTo(cat)
|
||||
}
|
||||
f += "}"
|
||||
|
||||
// Otherwise, simply generate a flat `switch` statement.
|
||||
|
||||
} else {
|
||||
compareTo(words)
|
||||
}
|
||||
return new Function("str", f)
|
||||
}
|
||||
|
||||
// Reserved word lists for various dialects of the language
|
||||
|
||||
@@ -471,14 +471,18 @@ pp.parseClass = function(node, isStatement) {
|
||||
var classBody = this.startNode()
|
||||
classBody.body = []
|
||||
this.expect(tt.braceL)
|
||||
let decorators = []
|
||||
while (!this.eat(tt.braceR)) {
|
||||
if (this.eat(tt.semi)) continue
|
||||
if (this.type === tt.at) {
|
||||
this.decorators.push(this.parseDecorator())
|
||||
decorators.push(this.parseDecorator())
|
||||
continue
|
||||
}
|
||||
var method = this.startNode()
|
||||
this.takeDecorators(method)
|
||||
if (decorators.length) {
|
||||
method.decorators = decorators
|
||||
decorators = []
|
||||
}
|
||||
var isGenerator = this.eat(tt.star), isAsync = false
|
||||
this.parsePropertyName(method)
|
||||
if (this.type !== tt.parenL && !method.computed && method.key.type === "Identifier" &&
|
||||
@@ -517,7 +521,7 @@ pp.parseClass = function(node, isStatement) {
|
||||
}
|
||||
this.parseClassMethod(classBody, method, isGenerator, isAsync)
|
||||
}
|
||||
if (this.decorators.length) {
|
||||
if (decorators.length) {
|
||||
this.raise(this.start, "You have trailing decorators with no method");
|
||||
}
|
||||
node.body = this.finishNode(classBody, "ClassBody")
|
||||
@@ -687,7 +691,6 @@ pp.parseImport = function(node) {
|
||||
if (this.type === tt.string) {
|
||||
node.specifiers = empty
|
||||
node.source = this.parseExprAtom()
|
||||
node.kind = ""
|
||||
} else {
|
||||
node.specifiers = []
|
||||
this.parseImportSpecifiers(node)
|
||||
|
||||
@@ -116,7 +116,7 @@ kw("do", {isLoop: true})
|
||||
kw("else", beforeExpr)
|
||||
kw("finally")
|
||||
kw("for", {isLoop: true})
|
||||
kw("function")
|
||||
kw("function", startsExpr)
|
||||
kw("if")
|
||||
kw("return", beforeExpr)
|
||||
kw("switch")
|
||||
|
||||
@@ -4,12 +4,11 @@ import * as acorn from "../../acorn";
|
||||
import * as util from "../util";
|
||||
import fs from "fs";
|
||||
|
||||
export { util, acorn };
|
||||
export { util, acorn, transform };
|
||||
export { canCompile } from "../util";
|
||||
|
||||
export { default as options } from "../transformation/file/options";
|
||||
export { default as Transformer } from "../transformation/transformer";
|
||||
export { default as transform } from "../transformation";
|
||||
export { default as traverse } from "../traversal";
|
||||
export { default as buildExternalHelpers } from "../tools/build-external-helpers";
|
||||
export { version } from "../../../package";
|
||||
@@ -54,3 +53,19 @@ export function transformFileSync(filename: string, opts?: Object = {}) {
|
||||
opts.filename = filename;
|
||||
return transform(fs.readFileSync(filename), opts);
|
||||
}
|
||||
|
||||
export function parse(code, opts = {}) {
|
||||
opts.sourceType = "module";
|
||||
opts.ecmaVersion = Infinity;
|
||||
opts.plugins = {
|
||||
flow: true,
|
||||
jsx: true
|
||||
};
|
||||
opts.features = {};
|
||||
|
||||
for (var key in transform.transformers) {
|
||||
opts.features[key] = true;
|
||||
}
|
||||
|
||||
return acorn.parse(code, opts);
|
||||
}
|
||||
|
||||
@@ -156,16 +156,3 @@ export default function (opts = {}) {
|
||||
|
||||
extend(transformOpts, opts);
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
try {
|
||||
var runtimePackage = require("babel-runtime/package");
|
||||
var version = require("../../../../package").version;
|
||||
if (runtimePackage.version !== version) {
|
||||
throw new ReferenceError(`The verison of babel-runtime of ${runtimePackage.runtime} that you have installed does not match the babel verison of ${version}`);
|
||||
}
|
||||
} catch (err) {
|
||||
if (err.code !== "MODULE_NOT_FOUND") throw err;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ export var ForInStatement = buildForXStatement("in");
|
||||
export var ForOfStatement = buildForXStatement("of");
|
||||
|
||||
export function DoWhileStatement(node, print) {
|
||||
this.keyword("do");
|
||||
this.push("do ");
|
||||
print(node.body);
|
||||
this.space();
|
||||
this.keyword("while");
|
||||
|
||||
@@ -44,11 +44,10 @@ export default function (loc, opts = {}) {
|
||||
find(up, rel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (opts.breakConfig !== true) {
|
||||
find(loc, rel);
|
||||
}
|
||||
|
||||
|
||||
return opts;
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@ import Logger from "./logger";
|
||||
import parse from "../../helpers/parse";
|
||||
import Scope from "../../traversal/scope";
|
||||
import slash from "slash";
|
||||
import clone from "lodash/lang/clone";
|
||||
import * as util from "../../util";
|
||||
import path from "path";
|
||||
import each from "lodash/collection/each";
|
||||
@@ -36,9 +37,9 @@ function checkNode(stack, node, scope) {
|
||||
|
||||
export default class File {
|
||||
constructor(opts = {}) {
|
||||
this.dynamicImportAbsoluteDefaults = [];
|
||||
this.dynamicImportIds = {};
|
||||
this.dynamicImports = [];
|
||||
this.dynamicImportTypes = {};
|
||||
this.dynamicImportIds = {};
|
||||
this.dynamicImports = [];
|
||||
|
||||
this.usedHelpers = {};
|
||||
this.dynamicData = {};
|
||||
@@ -85,7 +86,10 @@ export default class File {
|
||||
"default-props"
|
||||
];
|
||||
|
||||
static soloHelpers = [];
|
||||
static soloHelpers = [
|
||||
"ludicrous-proxy-create",
|
||||
"ludicrous-proxy-directory"
|
||||
];
|
||||
|
||||
static options = require("./options");
|
||||
|
||||
@@ -117,7 +121,9 @@ export default class File {
|
||||
throw new Error("Deprecated option " + key + ": " + option.deprecated);
|
||||
}
|
||||
|
||||
if (val == null) val = option.default || val;
|
||||
if (val == null) {
|
||||
val = clone(option.default);
|
||||
}
|
||||
|
||||
var optionParser = optionParsers[option.type];
|
||||
if (optionParser) val = optionParser(key, val);
|
||||
@@ -235,7 +241,10 @@ export default class File {
|
||||
var plugin;
|
||||
|
||||
if (name) {
|
||||
if (typeof name === "string") {
|
||||
if (typeof name === "object" && name.transformer) {
|
||||
plugin = name.transformer;
|
||||
position ||= name.position;
|
||||
} else if (typeof name === "string") {
|
||||
// this is a plugin in the form of "foobar" or "foobar:after"
|
||||
// where the optional colon is the delimiter for plugin position in the transformer stack
|
||||
|
||||
@@ -334,7 +343,7 @@ export default class File {
|
||||
return source;
|
||||
}
|
||||
|
||||
addImport(source: string, name?: string, absoluteDefault?: boolean): Object {
|
||||
addImport(source: string, name?: string, type?: string): Object {
|
||||
name ||= source;
|
||||
var id = this.dynamicImportIds[name];
|
||||
|
||||
@@ -345,7 +354,11 @@ export default class File {
|
||||
var specifiers = [t.importDefaultSpecifier(id)];
|
||||
var declar = t.importDeclaration(specifiers, t.literal(source));
|
||||
declar._blockHoist = 3;
|
||||
if (absoluteDefault) this.dynamicImportAbsoluteDefaults.push(declar);
|
||||
|
||||
if (type) {
|
||||
var modules = this.dynamicImportTypes[type] ||= [];
|
||||
modules.push(declar);
|
||||
}
|
||||
|
||||
if (this.transformers["es6.modules"].canTransform()) {
|
||||
this.moduleFormatter.importSpecifier(specifiers[0], declar, this.dynamicImports);
|
||||
|
||||
@@ -7,7 +7,7 @@ export default class Logger {
|
||||
}
|
||||
|
||||
_buildMessage(msg: string): string {
|
||||
var parts = this.filename;
|
||||
var parts = `[BABEL] ${this.filename}`;
|
||||
if (msg) parts += `: ${msg}`;
|
||||
return parts;
|
||||
}
|
||||
@@ -18,7 +18,7 @@ export default class Logger {
|
||||
|
||||
deprecate(msg) {
|
||||
if (!this.file.opts.suppressDeprecationMessages) {
|
||||
console.error(msg);
|
||||
console.error(this._buildMessage(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
"hidden": true
|
||||
},
|
||||
|
||||
"extra": {
|
||||
"hidden": true,
|
||||
"default": {}
|
||||
},
|
||||
|
||||
"moduleId": {
|
||||
"description": "specify a custom name for module ids",
|
||||
"type": "string"
|
||||
|
||||
@@ -57,6 +57,8 @@ export default function (exports, opts) {
|
||||
|
||||
exports.JSXOpeningElement = {
|
||||
exit(node, parent, scope, file) {
|
||||
parent.children = react.buildChildren(parent);
|
||||
|
||||
var tagExpr = node.name;
|
||||
var args = [];
|
||||
|
||||
@@ -144,10 +146,6 @@ export default function (exports, opts) {
|
||||
};
|
||||
|
||||
exports.JSXElement = {
|
||||
enter(node) {
|
||||
node.children = react.buildChildren(node);
|
||||
},
|
||||
|
||||
exit(node) {
|
||||
var callExpr = node.openingElement;
|
||||
|
||||
|
||||
33
src/babel/transformation/helpers/memoise-decorators.js
Normal file
33
src/babel/transformation/helpers/memoise-decorators.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import * as t from "../../types";
|
||||
|
||||
export default function (decorators, scope) {
|
||||
for (var i = 0; i < decorators.length; i++) {
|
||||
var decorator = decorators[i];
|
||||
var expression = decorator.expression;
|
||||
if (!t.isMemberExpression(expression)) continue;
|
||||
|
||||
var temp = scope.generateMemoisedReference(expression.object);
|
||||
var ref;
|
||||
|
||||
var nodes = [];
|
||||
|
||||
if (temp) {
|
||||
ref = temp;
|
||||
nodes.push(t.assignmentExpression("=", temp, expression.object));
|
||||
} else {
|
||||
ref = expression.object;
|
||||
}
|
||||
|
||||
nodes.push(t.callExpression(
|
||||
t.memberExpression(
|
||||
t.memberExpression(ref, expression.property, expression.computed),
|
||||
t.identifier("bind")
|
||||
),
|
||||
[ref]
|
||||
));
|
||||
|
||||
decorator.expression = t.sequenceExpression(nodes);
|
||||
}
|
||||
|
||||
return decorators;
|
||||
}
|
||||
5
src/babel/transformation/helpers/react.js
vendored
5
src/babel/transformation/helpers/react.js
vendored
@@ -34,9 +34,8 @@ function cleanJSXElementLiteralChild(child, args) {
|
||||
var lines = child.value.split(/\r\n|\n|\r/);
|
||||
|
||||
var lastNonEmptyLine = 0;
|
||||
var i;
|
||||
|
||||
for (i = 0; i < lines.length; i++) {
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if (lines[i].match(/[^ \t]/)) {
|
||||
lastNonEmptyLine = i;
|
||||
}
|
||||
@@ -44,7 +43,7 @@ function cleanJSXElementLiteralChild(child, args) {
|
||||
|
||||
var str = "";
|
||||
|
||||
for (i = 0; i < lines.length; i++) {
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
var line = lines[i];
|
||||
|
||||
var isFirstLine = i === 0;
|
||||
|
||||
@@ -49,11 +49,12 @@ var remapVisitor = {
|
||||
if (node._skipModulesRemap) {
|
||||
return this.skip();
|
||||
}
|
||||
},
|
||||
|
||||
exit(node, parent, scope, formatter) {
|
||||
if (t.isAssignmentExpression(node) && !node._ignoreModulesRemap) {
|
||||
var exported = formatter.getExport(node.left, scope);
|
||||
if (exported) {
|
||||
this.skip();
|
||||
return formatter.remapExportAssignment(node, exported);
|
||||
}
|
||||
}
|
||||
@@ -123,6 +124,11 @@ export default class DefaultFormatter {
|
||||
this.getLocalImports();
|
||||
}
|
||||
|
||||
isModuleType(node, type) {
|
||||
var modules = this.file.dynamicImportTypes[type];
|
||||
return modules && modules.indexOf(node) >= 0;
|
||||
}
|
||||
|
||||
transform() {
|
||||
this.remapAssignments();
|
||||
}
|
||||
|
||||
@@ -80,7 +80,9 @@ export default class AMDFormatter extends DefaultFormatter {
|
||||
this.defaultIds[key] = specifier.local;
|
||||
}
|
||||
|
||||
if (includes(this.file.dynamicImportAbsoluteDefaults, node)) {
|
||||
if (this.isModuleType(node, "absolute")) {
|
||||
// absolute module reference
|
||||
} else if (this.isModuleType(node, "absoluteDefault")) {
|
||||
// prevent unnecessary renaming of dynamic imports
|
||||
this.ids[node.source.value] = ref;
|
||||
ref = t.memberExpression(ref, t.identifier("default"));
|
||||
@@ -105,6 +107,7 @@ export default class AMDFormatter extends DefaultFormatter {
|
||||
|
||||
exportSpecifier(specifier, node, nodes) {
|
||||
if (this.doDefaultExportInterop(specifier)) {
|
||||
this.passModuleArg = true;
|
||||
nodes.push(util.template("exports-default-assign", {
|
||||
VALUE: specifier.local
|
||||
}, true));
|
||||
|
||||
@@ -45,7 +45,9 @@ export default class CommonJSFormatter extends DefaultFormatter {
|
||||
|
||||
// import foo from "foo";
|
||||
if (t.isSpecifierDefault(specifier)) {
|
||||
if (includes(this.file.dynamicImportAbsoluteDefaults, node)) {
|
||||
if (this.isModuleType(node, "absolute")) {
|
||||
// absolute module reference
|
||||
} else if (this.isModuleType(node, "absoluteDefault")) {
|
||||
this.internalRemap[variableName.name] = ref;
|
||||
} else if (this.noInteropRequireImport) {
|
||||
this.internalRemap[variableName.name] = t.memberExpression(ref, t.identifier("default"));
|
||||
@@ -104,13 +106,16 @@ export default class CommonJSFormatter extends DefaultFormatter {
|
||||
var call = t.callExpression(t.identifier("require"), [node.source]);
|
||||
var uid;
|
||||
|
||||
if (includes(this.file.dynamicImportAbsoluteDefaults, node)) {
|
||||
if (this.isModuleType(node, "absolute")) {
|
||||
// absolute module reference
|
||||
} else if (this.isModuleType(node, "absoluteDefault")) {
|
||||
call = t.memberExpression(call, t.identifier("default"));
|
||||
uid = node.specifiers[0].local;
|
||||
} else {
|
||||
uid = this.scope.generateUidBasedOnNode(node, "import");
|
||||
}
|
||||
|
||||
uid ||= node.specifiers[0].local;
|
||||
|
||||
var declar = t.variableDeclaration("var", [
|
||||
t.variableDeclarator(uid, call)
|
||||
]);
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
(function (proxy, directory) {
|
||||
directory.push(proxy);
|
||||
return proxy;
|
||||
})
|
||||
@@ -0,0 +1 @@
|
||||
[];
|
||||
@@ -1,6 +1,6 @@
|
||||
(function (FUNCTION_KEY) {
|
||||
function* FUNCTION_ID() {
|
||||
return yield* FUNCTION_ID.apply(this, arguments);
|
||||
return yield* FUNCTION_KEY.apply(this, arguments);
|
||||
}
|
||||
|
||||
FUNCTION_ID.toString = function () {
|
||||
|
||||
@@ -465,14 +465,14 @@ class BlockScoping {
|
||||
var declar;
|
||||
|
||||
//
|
||||
for (var i = 0; i < declarators.length; i++) {
|
||||
for (let i = 0; i < declarators.length; i++) {
|
||||
declar = declarators[i];
|
||||
extend(this.outsideLetReferences, t.getBindingIdentifiers(declar));
|
||||
}
|
||||
|
||||
//
|
||||
if (block.body) {
|
||||
for (i = 0; i < block.body.length; i++) {
|
||||
for (let i = 0; i < block.body.length; i++) {
|
||||
declar = block.body[i];
|
||||
if (isLet(declar, block)) {
|
||||
declarators = declarators.concat(declar.declarations);
|
||||
@@ -481,7 +481,7 @@ class BlockScoping {
|
||||
}
|
||||
|
||||
//
|
||||
for (i = 0; i < declarators.length; i++) {
|
||||
for (let i = 0; i < declarators.length; i++) {
|
||||
declar = declarators[i];
|
||||
var keys = t.getBindingIdentifiers(declar);
|
||||
extend(this.letReferences, keys);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import memoiseDecorators from "../../helpers/memoise-decorators";
|
||||
import ReplaceSupers from "../../helpers/replace-supers";
|
||||
import * as nameMethod from "../../helpers/name-method";
|
||||
import * as defineMap from "../../helpers/define-map";
|
||||
@@ -50,7 +51,7 @@ var verifyConstructorVisitor = traverse.explode({
|
||||
},
|
||||
|
||||
CallExpression: {
|
||||
enter(node, parent, scope, state) {
|
||||
exit(node, parent, scope, state) {
|
||||
if (this.get("callee").isSuper()) {
|
||||
state.hasBareSuper = true;
|
||||
state.bareSuper = this;
|
||||
@@ -292,6 +293,10 @@ class ClassTransformer {
|
||||
var node = classBody[i];
|
||||
var path = classBodyPaths[i];
|
||||
|
||||
if (node.decorators) {
|
||||
memoiseDecorators(node.decorators, this.scope);
|
||||
}
|
||||
|
||||
if (t.isMethodDefinition(node)) {
|
||||
var isConstructor = node.kind === "constructor";
|
||||
if (isConstructor) this.verifyConstructor(path);
|
||||
@@ -552,6 +557,11 @@ class ClassTransformer {
|
||||
this.instancePropBody.push(t.expressionStatement(
|
||||
t.assignmentExpression("=", t.memberExpression(t.thisExpression(), node.key), node.value)
|
||||
));
|
||||
|
||||
node.value = null;
|
||||
}
|
||||
|
||||
if (!node.value) {
|
||||
node.value = t.identifier("undefined");
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import map from "lodash/collection/map";
|
||||
import * as t from "../../../types";
|
||||
|
||||
exports.Function = function (node, parent, scope, file) {
|
||||
if (node.generator || node.async) return;
|
||||
var tailCall = new TailCallTransformer(this, scope, file);
|
||||
tailCall.run();
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import memoiseDecorators from "../../helpers/memoise-decorators";
|
||||
import * as defineMap from "../../helpers/define-map";
|
||||
import * as t from "../../../types";
|
||||
|
||||
@@ -24,7 +25,9 @@ export function ObjectExpression(node, parent, scope, file) {
|
||||
var mutatorMap = {};
|
||||
|
||||
for (var i = 0; i < node.properties.length; i++) {
|
||||
defineMap.push(mutatorMap, node.properties[i], null, file);
|
||||
var prop = node.properties[i];
|
||||
if (prop.decorators) memoiseDecorators(prop.decorators, scope);
|
||||
defineMap.push(mutatorMap, prop, null, file);
|
||||
}
|
||||
|
||||
var obj = defineMap.toClassObject(mutatorMap);
|
||||
|
||||
@@ -29,14 +29,13 @@ var immutabilityVisitor = {
|
||||
};
|
||||
|
||||
export function JSXElement(node, parent, scope, file) {
|
||||
if (node._ignoreConstant) return;
|
||||
if (node._hoisted) return;
|
||||
|
||||
var state = { isImmutable: true };
|
||||
this.traverse(immutabilityVisitor, state);
|
||||
this.skip();
|
||||
|
||||
if (state.isImmutable) {
|
||||
this.hoist();
|
||||
node._ignoreConstant = true;
|
||||
}
|
||||
if (state.isImmutable) this.hoist();
|
||||
|
||||
node._hoisted = true;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ exports.Function = function (node, parent, scope, file) {
|
||||
|
||||
return remapAsyncToGenerator(
|
||||
node,
|
||||
t.memberExpression(file.addImport("bluebird"), t.identifier("coroutine")),
|
||||
t.memberExpression(file.addImport("bluebird", null, "absolute"), t.identifier("coroutine")),
|
||||
scope
|
||||
);
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@ export var metadata = {
|
||||
optional: true
|
||||
};
|
||||
|
||||
// foo in bar
|
||||
export function BinaryExpression(node) {
|
||||
if (node.operator === "in") {
|
||||
return util.template("ludicrous-in", {
|
||||
@@ -14,6 +15,7 @@ export function BinaryExpression(node) {
|
||||
}
|
||||
}
|
||||
|
||||
// { 1: "foo" }
|
||||
export function Property(node) {
|
||||
var key = node.key;
|
||||
if (t.isLiteral(key) && typeof key.value === "number") {
|
||||
@@ -21,9 +23,44 @@ export function Property(node) {
|
||||
}
|
||||
}
|
||||
|
||||
// /foobar/g
|
||||
export function Literal(node) {
|
||||
if (node.regex) {
|
||||
node.regex.pattern = "foobar";
|
||||
node.regex.flags = "";
|
||||
}
|
||||
}
|
||||
|
||||
// foo.bar
|
||||
export function MemberExpression(node) {
|
||||
|
||||
}
|
||||
|
||||
// Object.setPrototypeOf
|
||||
// Object.preventExtensions
|
||||
// Object.keys
|
||||
// Object.isExtensible
|
||||
// Object.getOwnPropertyDescriptor
|
||||
// Object.defineProperty
|
||||
export function CallExpression(node) {
|
||||
|
||||
}
|
||||
|
||||
// delete foo.bar
|
||||
export function UnaryExpression(node) {
|
||||
|
||||
}
|
||||
|
||||
// foo.bar = bar;
|
||||
export function AssignmentExpression(node) {
|
||||
|
||||
}
|
||||
|
||||
// new Proxy
|
||||
export function NewExpression(node, parent, scope, file) {
|
||||
if (this.get("callee").isIdentifier({ name: "Proxy" })) {
|
||||
return t.callExpression(file.addHelper("proxy-create"), [node.arguments[0], file.addHelper("proxy-directory")]);
|
||||
} else {
|
||||
// possible proxy constructor
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
"unshift": "array/unshift",
|
||||
"values": "array/values"
|
||||
},
|
||||
|
||||
"Object": {
|
||||
"assign": "object/assign",
|
||||
"classof": "object/classof",
|
||||
@@ -65,13 +66,16 @@
|
||||
"setPrototypeOf": "object/set-prototype-of",
|
||||
"values": "object/values"
|
||||
},
|
||||
|
||||
"RegExp": {
|
||||
"escape": "regexp/escape"
|
||||
},
|
||||
|
||||
"Function": {
|
||||
"only": "function/only",
|
||||
"part": "function/part"
|
||||
},
|
||||
|
||||
"Math": {
|
||||
"acosh": "math/acosh",
|
||||
"asinh": "math/asinh",
|
||||
@@ -81,6 +85,7 @@
|
||||
"cosh": "math/cosh",
|
||||
"expm1": "math/expm1",
|
||||
"fround": "math/fround",
|
||||
"hypot": "math/hypot",
|
||||
"pot": "math/pot",
|
||||
"imul": "math/imul",
|
||||
"log10": "math/log10",
|
||||
@@ -91,11 +96,13 @@
|
||||
"tanh": "math/tanh",
|
||||
"trunc": "math/trunc"
|
||||
},
|
||||
|
||||
"Date": {
|
||||
"addLocale": "date/add-locale",
|
||||
"formatUTC": "date/format-utc",
|
||||
"format": "date/format"
|
||||
},
|
||||
|
||||
"Symbol": {
|
||||
"for": "symbol/for",
|
||||
"hasInstance": "symbol/for-instance",
|
||||
@@ -110,6 +117,49 @@
|
||||
"toPrimitive": "symbol/to-primitive",
|
||||
"toStringTag": "symbol/to-string-tag",
|
||||
"unscopables": "symbol/unscopables"
|
||||
},
|
||||
|
||||
"String": {
|
||||
"at": "string/at",
|
||||
"codePointAt": "string/code-point-at",
|
||||
"endsWith": "string/ends-with",
|
||||
"escapeHTML": "string/escape-html",
|
||||
"fromCodePoint": "string/from-code-point",
|
||||
"includes": "string/includes",
|
||||
"raw": "string/raw",
|
||||
"repeat": "string/repeat",
|
||||
"startsWith": "string/starts-with",
|
||||
"unescapeHTML": "string/unescape-html"
|
||||
},
|
||||
|
||||
"Number": {
|
||||
"EPSILON": "number/epsilon",
|
||||
"isFinite": "number/is-finite",
|
||||
"isInteger": "number/is-integer",
|
||||
"isNaN": "number/is-nan",
|
||||
"isSafeInteger": "number/is-safe-integer",
|
||||
"MAX_SAFE_INTEGER": "number/max-safe-integer",
|
||||
"MIN_SAFE_INTEGER": "number/min-safe-integer",
|
||||
"parseFloat": "number/parse-float",
|
||||
"parseInt": "number/parse-int",
|
||||
"random": "number/random"
|
||||
},
|
||||
|
||||
"Reflect": {
|
||||
"apply": "reflect/apply",
|
||||
"construct": "reflect/construct",
|
||||
"defineProperty": "reflect/define-property",
|
||||
"deleteProperty": "reflect/delete-property",
|
||||
"enumerate": "reflect/enumerate",
|
||||
"getOwnPropertyDescriptor": "reflect/get-own-property-descriptor",
|
||||
"getPrototypeOf": "reflect/get-prototype-of",
|
||||
"get": "reflect/get",
|
||||
"has": "reflect/has",
|
||||
"isExtensible": "reflect/is-extensible",
|
||||
"ownKeys": "reflect/own-keys",
|
||||
"preventExtensions": "reflect/prevent-extensions",
|
||||
"setPrototypeOf": "reflect/set-prototype-of",
|
||||
"set": "reflect/set"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import includes from "lodash/collection/includes";
|
||||
import traverse from "../../../../traversal";
|
||||
import * as util from "../../../../util";
|
||||
import has from "lodash/object/has";
|
||||
import * as t from "../../../../types";
|
||||
@@ -8,53 +9,88 @@ var isSymbolIterator = t.buildMatchMemberExpression("Symbol.iterator");
|
||||
|
||||
const RUNTIME_MODULE_NAME = "babel-runtime";
|
||||
|
||||
var astVisitor = {
|
||||
enter(node, parent, scope, file) {
|
||||
var prop;
|
||||
var astVisitor = traverse.explode({
|
||||
Identifier(node, parent, scope, file) {
|
||||
if (!this.isReferenced()) return;
|
||||
if (t.isMemberExpression(parent)) return;
|
||||
if (!has(definitions.builtins, node.name)) return;
|
||||
if (scope.getBindingIdentifier(node.name)) return;
|
||||
|
||||
if (this.isMemberExpression() && this.isReferenced()) {
|
||||
// Symbol() -> _core.Symbol(); new Promise -> new _core.Promise
|
||||
var modulePath = definitions.builtins[node.name];
|
||||
return file.addImport(`${RUNTIME_MODULE_NAME}/core-js/${modulePath}`, node.name, "absoluteDefault");
|
||||
},
|
||||
|
||||
CallExpression(node, parent, scope, file) {
|
||||
// arr[Symbol.iterator]() -> _core.$for.getIterator(arr)
|
||||
|
||||
var callee = node.callee;
|
||||
if (node.arguments.length) return;
|
||||
|
||||
if (!t.isMemberExpression(callee)) return;
|
||||
if (!callee.computed) return;
|
||||
|
||||
var prop = callee.property;
|
||||
if (!isSymbolIterator(prop)) return;
|
||||
|
||||
return t.callExpression(file.addImport(`${RUNTIME_MODULE_NAME}/core-js/get-iterator`, "getIterator", "absoluteDefault"), [callee.object]);
|
||||
},
|
||||
|
||||
BinaryExpression(node, parent, scope, file) {
|
||||
// Symbol.iterator in arr -> core.$for.isIterable(arr)
|
||||
|
||||
if (node.operator !== "in") return;
|
||||
|
||||
var left = node.left;
|
||||
if (!isSymbolIterator(left)) return;
|
||||
|
||||
return t.callExpression(
|
||||
file.addImport(`${RUNTIME_MODULE_NAME}/core-js/is-iterable`, "isIterable", "absoluteDefault"),
|
||||
[node.right]
|
||||
);
|
||||
},
|
||||
|
||||
MemberExpression: {
|
||||
enter(node, parent, scope, file) {
|
||||
// Array.from -> _core.Array.from
|
||||
|
||||
if (!this.isReferenced()) return;
|
||||
|
||||
var obj = node.object;
|
||||
prop = node.property;
|
||||
var prop = node.property;
|
||||
|
||||
if (!t.isReferenced(obj, node)) return;
|
||||
|
||||
if (node.computed) return;
|
||||
|
||||
if (!has(definitions.methods, obj.name)) return;
|
||||
if (!has(definitions.methods[obj.name], prop.name)) return;
|
||||
|
||||
var methods = definitions.methods[obj.name];
|
||||
if (!has(methods, prop.name)) return;
|
||||
|
||||
if (scope.getBindingIdentifier(obj.name)) return;
|
||||
|
||||
var modulePath = definitions.methods[obj.name][prop.name];
|
||||
return file.addImport(`${RUNTIME_MODULE_NAME}/core-js/${modulePath}`, `${obj.name}$${prop.name}`, true);
|
||||
} else if (this.isReferencedIdentifier() && !t.isMemberExpression(parent) && has(definitions.builtins, node.name) && !scope.getBindingIdentifier(node.name)) {
|
||||
// Symbol() -> _core.Symbol(); new Promise -> new _core.Promise
|
||||
var modulePath = definitions.builtins[node.name];
|
||||
return file.addImport(`${RUNTIME_MODULE_NAME}/core-js/${modulePath}`, node.name, true);
|
||||
} else if (this.isCallExpression()) {
|
||||
// arr[Symbol.iterator]() -> _core.$for.getIterator(arr)
|
||||
var modulePath = methods[prop.name];
|
||||
return file.addImport(`${RUNTIME_MODULE_NAME}/core-js/${modulePath}`, `${obj.name}$${prop.name}`, "absoluteDefault");
|
||||
},
|
||||
|
||||
var callee = node.callee;
|
||||
if (node.arguments.length) return false;
|
||||
exit(node, parent, scope, file) {
|
||||
if (!this.isReferenced()) return;
|
||||
|
||||
if (!t.isMemberExpression(callee)) return false;
|
||||
if (!callee.computed) return false;
|
||||
var prop = node.property;
|
||||
var obj = node.object;
|
||||
|
||||
prop = callee.property;
|
||||
if (!isSymbolIterator(prop)) return false;
|
||||
if (!has(definitions.builtins, obj.name)) return;
|
||||
if (scope.getBindingIdentifier(obj.name)) return;
|
||||
|
||||
return t.callExpression(file.addImport(`${RUNTIME_MODULE_NAME}/core-js/get-iterator`, "getIterator", true), [callee.object]);
|
||||
} else if (this.isBinaryExpression()) {
|
||||
// Symbol.iterator in arr -> core.$for.isIterable(arr)
|
||||
|
||||
if (node.operator !== "in") return;
|
||||
|
||||
var left = node.left;
|
||||
if (!isSymbolIterator(left)) return;
|
||||
|
||||
return t.callExpression(file.addImport(`${RUNTIME_MODULE_NAME}/core-js/is-iterable`, "isIterable", true), [node.right]);
|
||||
var modulePath = definitions.builtins[obj.name];
|
||||
return t.memberExpression(
|
||||
file.addImport(`${RUNTIME_MODULE_NAME}/core-js/${modulePath}`, `${obj.name}`, "absoluteDefault"),
|
||||
prop
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
exports.metadata = {
|
||||
optional: true
|
||||
@@ -66,11 +102,11 @@ exports.Program = function (node, parent, scope, file) {
|
||||
|
||||
exports.pre = function (file) {
|
||||
file.set("helperGenerator", function (name) {
|
||||
return file.addImport(`${RUNTIME_MODULE_NAME}/helpers/${name}`, name, true);
|
||||
return file.addImport(`${RUNTIME_MODULE_NAME}/helpers/${name}`, name, "absoluteDefault");
|
||||
});
|
||||
|
||||
file.setDynamic("regeneratorIdentifier", function () {
|
||||
return file.addImport(`${RUNTIME_MODULE_NAME}/regenerator`, "regeneratorRuntime", true);
|
||||
return file.addImport(`${RUNTIME_MODULE_NAME}/regenerator`, "regeneratorRuntime", "absoluteDefault");
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -78,6 +78,9 @@ traverse.removeProperties = function (tree) {
|
||||
traverse.explode = function (obj) {
|
||||
for (var type in obj) {
|
||||
var fns = obj[type];
|
||||
if (typeof fns === "function") {
|
||||
obj[type] = fns = { enter: fns };
|
||||
}
|
||||
|
||||
var aliases = t.FLIPPED_ALIAS_KEYS[type];
|
||||
if (aliases) {
|
||||
|
||||
@@ -19,7 +19,6 @@ var referenceVisitor = {
|
||||
if (bindingInfo && bindingInfo.constant) {
|
||||
state.bindings[node.name] = bindingInfo;
|
||||
} else {
|
||||
scope.dump();
|
||||
state.foundIncompatible = true;
|
||||
this.stop();
|
||||
}
|
||||
@@ -90,6 +89,10 @@ export default class PathHoister {
|
||||
}
|
||||
|
||||
run() {
|
||||
var node = this.path.node;
|
||||
if (node._hoisted) return;
|
||||
node._hoisted = true;
|
||||
|
||||
this.path.traverse(referenceVisitor, this);
|
||||
if (this.foundIncompatible) return;
|
||||
|
||||
|
||||
@@ -178,7 +178,6 @@ export default class TraversalPath {
|
||||
} else if (this.isStatementOrBlock()) {
|
||||
if (this.node) nodes.unshift(this.node);
|
||||
this.container[this.key] = t.blockStatement(nodes);
|
||||
this.replaceExpressionWithStatements(nodes);
|
||||
} else {
|
||||
throw new Error("We don't know what to do with this node type. We were previously a Statement but we can't fit in here?");
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"DoWhileStatement": ["Statement", "Loop", "While", "Scopable"],
|
||||
"IfStatement": ["Statement"],
|
||||
"ReturnStatement": ["Statement"],
|
||||
"SwitchStatement": ["Statement"],
|
||||
"SwitchStatement": ["Statement", "Scopable"],
|
||||
"ThrowStatement": ["Statement"],
|
||||
"TryStatement": ["Statement"],
|
||||
"WhileStatement": ["Statement", "Loop", "While", "Scopable"],
|
||||
|
||||
@@ -25,7 +25,7 @@ function registerType(type: string, skipAliasCheck?: boolean) {
|
||||
}
|
||||
|
||||
export var STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"];
|
||||
export var NATIVE_TYPE_NAMES = ["Array", "Object", "Number", "Boolean", "Date", "Array", "String", "Promise", "Set", "Map", "WeakMap", "WeakSet", "Uint16Array", "ArrayBuffer", "DataView", "Int8Array", "Uint8Array", "Uint8ClampedArray", "Uint32Array", "Int32Array", "Float32Array", "Int16Array", "Float64Array"];
|
||||
export var NATIVE_TYPE_NAMES = ["Array", "ArrayBuffer", "Boolean", "DataView", "Date", "Error", "EvalError", "Float32Array", "Float64Array", "Function", "Int8Array", "Int16Array", "Int32Array", "Map", "Number", "Object", "Proxy", "Promise", "RangeError", "ReferenceError", "RegExp", "Set", "String", "Symbol", "SyntaxError", "TypeError", "Uint8Array", "Uint8ClampedArray", "Uint16Array", "Uint32Array", "URIError", "WeakMap", "WeakSet"];
|
||||
export var FLATTENABLE_KEYS = ["body", "expressions"];
|
||||
export var FOR_INIT_KEYS = ["left", "init"];
|
||||
export var COMMENT_KEYS = ["leadingComments", "trailingComments"];
|
||||
|
||||
@@ -2,6 +2,14 @@ var test = require("./driver.js").test;
|
||||
var testFail = require("./driver.js").testFail;
|
||||
var testAssert = require("./driver.js").testAssert;
|
||||
|
||||
testFail("({a}) = 2;", "You're trying to assign to a parenthesized expression, eg. instead of `({a}) = 0` use `({a} = 0)` (1:1)", {
|
||||
ecmaVersion: 6
|
||||
});
|
||||
|
||||
testFail("([a]) = 2;", "You're trying to assign to a parenthesized expression, eg. instead of `([a]) = 0` use `([a] = 0)` (1:1)", {
|
||||
ecmaVersion: 6
|
||||
});
|
||||
|
||||
// ES7: Exponentiation Operator
|
||||
|
||||
test('a **= 2;', {
|
||||
@@ -2461,6 +2469,166 @@ test("class Foo { @foo @bar bar() {} }", {
|
||||
features: { "es7.decorators": true }
|
||||
});
|
||||
|
||||
test('@foo({ @bar foo: "bar" }) @bar class Foo {}', {
|
||||
"start": 0,
|
||||
"body": [{
|
||||
"start": 31,
|
||||
"decorators": [{
|
||||
"start": 0,
|
||||
"expression": {
|
||||
"start": 1,
|
||||
"callee": {
|
||||
"start": 1,
|
||||
"name": "foo",
|
||||
"type": "Identifier",
|
||||
"end": 4
|
||||
},
|
||||
"arguments": [{
|
||||
"start": 5,
|
||||
"properties": [{
|
||||
"start": 12,
|
||||
"decorators": [{
|
||||
"start": 7,
|
||||
"expression": {
|
||||
"start": 8,
|
||||
"name": "bar",
|
||||
"type": "Identifier",
|
||||
"end": 11
|
||||
},
|
||||
"type": "Decorator",
|
||||
"end": 11
|
||||
}],
|
||||
"method": false,
|
||||
"shorthand": false,
|
||||
"computed": false,
|
||||
"key": {
|
||||
"start": 12,
|
||||
"name": "foo",
|
||||
"type": "Identifier",
|
||||
"end": 15
|
||||
},
|
||||
"value": {
|
||||
"start": 17,
|
||||
"value": "bar",
|
||||
"raw": "\"bar\"",
|
||||
"type": "Literal",
|
||||
"end": 22
|
||||
},
|
||||
"kind": "init",
|
||||
"type": "Property",
|
||||
"end": 22
|
||||
}],
|
||||
"type": "ObjectExpression",
|
||||
"end": 24
|
||||
}],
|
||||
"type": "CallExpression",
|
||||
"end": 25
|
||||
},
|
||||
"type": "Decorator",
|
||||
"end": 25
|
||||
},
|
||||
{
|
||||
"start": 26,
|
||||
"expression": {
|
||||
"start": 27,
|
||||
"name": "bar",
|
||||
"type": "Identifier",
|
||||
"end": 30
|
||||
},
|
||||
"type": "Decorator",
|
||||
"end": 30
|
||||
}],
|
||||
"id": {
|
||||
"start": 37,
|
||||
"name": "Foo",
|
||||
"type": "Identifier",
|
||||
"end": 40
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"start": 41,
|
||||
"body": [],
|
||||
"type": "ClassBody",
|
||||
"end": 43
|
||||
},
|
||||
"type": "ClassDeclaration",
|
||||
"end": 43
|
||||
}],
|
||||
"sourceType": "script",
|
||||
"type": "Program",
|
||||
"end": 43
|
||||
}, {
|
||||
ecmaVersion: 6,
|
||||
features: { "es7.decorators": true }
|
||||
});
|
||||
|
||||
test('@bar class Foo extends @foo class Bar {} {}', {
|
||||
"start": 0,
|
||||
"body": [{
|
||||
"start": 5,
|
||||
"decorators": [{
|
||||
"start": 0,
|
||||
"expression": {
|
||||
"start": 1,
|
||||
"name": "bar",
|
||||
"type": "Identifier",
|
||||
"end": 4
|
||||
},
|
||||
"type": "Decorator",
|
||||
"end": 4
|
||||
}],
|
||||
"id": {
|
||||
"start": 11,
|
||||
"name": "Foo",
|
||||
"type": "Identifier",
|
||||
"end": 14
|
||||
},
|
||||
"superClass": {
|
||||
"start": 28,
|
||||
"decorators": [{
|
||||
"start": 23,
|
||||
"expression": {
|
||||
"start": 24,
|
||||
"name": "foo",
|
||||
"type": "Identifier",
|
||||
"end": 27
|
||||
},
|
||||
"type": "Decorator",
|
||||
"end": 27
|
||||
}],
|
||||
"id": {
|
||||
"start": 34,
|
||||
"name": "Bar",
|
||||
"type": "Identifier",
|
||||
"end": 37
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"start": 38,
|
||||
"body": [],
|
||||
"type": "ClassBody",
|
||||
"end": 40
|
||||
},
|
||||
"type": "ClassExpression",
|
||||
"end": 40
|
||||
},
|
||||
"body": {
|
||||
"start": 41,
|
||||
"body": [],
|
||||
"type": "ClassBody",
|
||||
"end": 43
|
||||
},
|
||||
"type": "ClassDeclaration",
|
||||
"end": 43
|
||||
}],
|
||||
"sourceType": "script",
|
||||
"type": "Program",
|
||||
"end": 43
|
||||
}, {
|
||||
ecmaVersion: 6,
|
||||
features: { "es7.decorators": true }
|
||||
});
|
||||
|
||||
testFail("@foo function bar() {}", "Leading decorators must be attached to a class declaration (1:5)", {
|
||||
ecmaVersion: 6,
|
||||
features: { "es7.decorators": true }
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
require("../../lib/babel/api/node");
|
||||
|
||||
var buildExternalHelpers = require("../../lib/babel/tools/build-external-helpers");
|
||||
var transform = require("../../lib/babel/transformation");
|
||||
var assert = require("assert");
|
||||
@@ -21,6 +23,15 @@ suite("api", function () {
|
||||
}, /Unknown helper foob/);
|
||||
});
|
||||
|
||||
test("extra options", function () {
|
||||
var file1 = new File({ extra: { foo: "bar" } });
|
||||
assert.equal(file1.opts.extra.foo, "bar");
|
||||
|
||||
var file2 = new File;
|
||||
var file3 = new File;
|
||||
assert.ok(file2.opts.extra !== file3.opts.extra);
|
||||
});
|
||||
|
||||
suite("buildExternalHelpers", function () {
|
||||
test("all", function () {
|
||||
var script = buildExternalHelpers();
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"optional": ["ludicrous"]
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
var proxied = function(){};
|
||||
var passed = false;
|
||||
var host = {
|
||||
method: new Proxy(proxied, {
|
||||
apply: function (t, thisArg, args) {
|
||||
passed = t === proxied && thisArg === host && args + "" === "foo,bar";
|
||||
}
|
||||
})
|
||||
};
|
||||
host.method("foo", "bar");
|
||||
assert.ok(passed);
|
||||
@@ -0,0 +1,9 @@
|
||||
var proxied = function(){};
|
||||
var passed = false;
|
||||
new new Proxy(proxied, {
|
||||
construct: function (t, args) {
|
||||
passed = t === proxied && args + "" === "foo,bar";
|
||||
return {};
|
||||
}
|
||||
})("foo","bar");
|
||||
assert.ok(passed);
|
||||
@@ -0,0 +1,13 @@
|
||||
var proxied = {};
|
||||
var passed = false;
|
||||
Object.defineProperty(
|
||||
new Proxy(proxied, {
|
||||
defineProperty: function (t, k, d) {
|
||||
passed = t === proxied && k === "foo" && d.value === 5;
|
||||
return true;
|
||||
}
|
||||
}),
|
||||
"foo",
|
||||
{ value: 5, configurable: true }
|
||||
);
|
||||
assert.ok(passed);
|
||||
@@ -0,0 +1,8 @@
|
||||
var proxied = {};
|
||||
var passed = false;
|
||||
delete new Proxy(proxied, {
|
||||
deleteProperty: function (t, k) {
|
||||
passed = t === proxied && k === "foo";
|
||||
}
|
||||
}).foo;
|
||||
assert.ok(passed);
|
||||
@@ -0,0 +1,13 @@
|
||||
var proxied = {};
|
||||
var passed = false;
|
||||
for (var i in
|
||||
new Proxy(proxied, {
|
||||
enumerate: function (t) {
|
||||
passed = t === proxied;
|
||||
return {
|
||||
next: function(){ return { done: true, value: null };}
|
||||
};
|
||||
}
|
||||
})
|
||||
) { }
|
||||
assert.ok(passed);
|
||||
@@ -0,0 +1,7 @@
|
||||
var proxied = { };
|
||||
var proxy = Object.create(new Proxy(proxied, {
|
||||
get: function (t, k, r) {
|
||||
return t === proxied && k === "foo" && r === proxy && 5;
|
||||
}
|
||||
}));
|
||||
assert.equal(proxy.foo, 5);
|
||||
@@ -0,0 +1,7 @@
|
||||
var proxied = {};
|
||||
var proxy = new Proxy(proxied, {
|
||||
get: function (t, k, r) {
|
||||
return t === proxied && k === "foo" && r === proxy && 5;
|
||||
}
|
||||
});
|
||||
assert.equal(proxy.foo, 5);
|
||||
@@ -0,0 +1,14 @@
|
||||
var proxied = {};
|
||||
var fakeDesc = { value: "foo", configurable: true };
|
||||
var returnedDesc = Object.getOwnPropertyDescriptor(
|
||||
new Proxy(proxied, {
|
||||
getOwnPropertyDescriptor: function (t, k) {
|
||||
return t === proxied && k === "foo" && fakeDesc;
|
||||
}
|
||||
}),
|
||||
"foo"
|
||||
);
|
||||
assert.equal(returnedDesc.value, fakeDesc.value);
|
||||
assert.equal(returnedDesc.configurable, fakeDesc.configurable);
|
||||
assert.equal(returnedDesc.writable, false);
|
||||
assert.equal(returnedDesc.enumerable, false);
|
||||
@@ -0,0 +1,8 @@
|
||||
var proxied = {};
|
||||
var fakeProto = {};
|
||||
var proxy = new Proxy(proxied, {
|
||||
getPrototypeOf: function (t) {
|
||||
return t === proxied && fakeProto;
|
||||
}
|
||||
});
|
||||
assert.equal(Object.getPrototypeOf(proxy), fakeProto);
|
||||
@@ -0,0 +1,8 @@
|
||||
var proxied = {};
|
||||
var passed = false;
|
||||
"foo" in Object.create(new Proxy(proxied, {
|
||||
has: function (t, k) {
|
||||
passed = t === proxied && k === "foo";
|
||||
}
|
||||
}));
|
||||
assert.ok(passed);
|
||||
@@ -0,0 +1,8 @@
|
||||
var proxied = {};
|
||||
var passed = false;
|
||||
"foo" in new Proxy(proxied, {
|
||||
has: function (t, k) {
|
||||
passed = t === proxied && k === "foo";
|
||||
}
|
||||
});
|
||||
assert.ok(passed);
|
||||
@@ -0,0 +1,10 @@
|
||||
var proxied = {};
|
||||
var passed = false;
|
||||
Object.isExtensible(
|
||||
new Proxy(proxied, {
|
||||
isExtensible: function (t) {
|
||||
passed = t === proxied; return true;
|
||||
}
|
||||
})
|
||||
);
|
||||
assert.ok(passed);
|
||||
@@ -0,0 +1,11 @@
|
||||
var proxied = {};
|
||||
var passed = false;
|
||||
Object.keys(
|
||||
new Proxy(proxied, {
|
||||
ownKeys: function (t) {
|
||||
passed = t === proxied; return [];
|
||||
}
|
||||
})
|
||||
);
|
||||
assert.ok(passed);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
var proxied = {};
|
||||
var passed = false;
|
||||
Object.preventExtensions(
|
||||
new Proxy(proxied, {
|
||||
preventExtensions: function (t) {
|
||||
passed = t === proxied;
|
||||
return Object.preventExtensions(proxied);
|
||||
}
|
||||
})
|
||||
);
|
||||
assert.ok(passed);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
var proxied = {};
|
||||
var passed = false;
|
||||
var proxy = Object.create(new Proxy(proxied, {
|
||||
set: function (t, k, v, r) {
|
||||
passed = t === proxied && k + v === "foobar" && r === proxy;
|
||||
}
|
||||
}));
|
||||
proxy.foo = "bar";
|
||||
assert.ok(passed);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
var proxied = {};
|
||||
var passed = false;
|
||||
var proxy = new Proxy(proxied, {
|
||||
set: function (t, k, v, r) {
|
||||
passed = t === proxied && k + v === "foobar" && r === proxy;
|
||||
}
|
||||
});
|
||||
proxy.foo = "bar";
|
||||
assert.ok(passed);
|
||||
@@ -0,0 +1,13 @@
|
||||
var proxied = {};
|
||||
var newProto = {};
|
||||
var passed = false;
|
||||
Object.setPrototypeOf(
|
||||
new Proxy(proxied, {
|
||||
setPrototypeOf: function (t, p) {
|
||||
passed = t === proxied && p === newProto;
|
||||
return true;
|
||||
}
|
||||
}),
|
||||
newProto
|
||||
);
|
||||
assert.ok(passed);
|
||||
@@ -1,8 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var _bluebird2 = require("bluebird");
|
||||
|
||||
var _bluebird3 = babelHelpers.interopRequireWildcard(_bluebird2);
|
||||
var _bluebird = require("bluebird");
|
||||
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
@@ -11,7 +9,7 @@ var Foo = (function () {
|
||||
|
||||
babelHelpers.createClass(Foo, [{
|
||||
key: "foo",
|
||||
value: _bluebird3["default"].coroutine(function* () {
|
||||
value: _bluebird.coroutine(function* () {
|
||||
var wat = yield bar();
|
||||
})
|
||||
}]);
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var _bluebird2 = require("bluebird");
|
||||
var _bluebird = require("bluebird");
|
||||
|
||||
var _bluebird3 = _interopRequireWildcard(_bluebird2);
|
||||
|
||||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
|
||||
|
||||
var foo = _bluebird3["default"].coroutine(function* () {
|
||||
var foo = _bluebird.coroutine(function* () {
|
||||
var wat = yield bar();
|
||||
});
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
var _bluebird2 = require("bluebird");
|
||||
|
||||
var _bluebird3 = _interopRequireWildcard(_bluebird2);
|
||||
var _bluebird = require("bluebird");
|
||||
|
||||
var _bar;
|
||||
|
||||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
|
||||
|
||||
var foo = _bar = _bluebird3["default"].coroutine(function* () {
|
||||
var foo = _bar = _bluebird.coroutine(function* () {
|
||||
console.log(_bar);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var _bluebird2 = require("bluebird");
|
||||
var _bluebird = require("bluebird");
|
||||
|
||||
var _bluebird3 = _interopRequireWildcard(_bluebird2);
|
||||
|
||||
var _interopRequireWildcard = function (obj) { return obj && obj.__esModule ? obj : { "default": obj }; };
|
||||
|
||||
var foo = _bluebird3["default"].coroutine(function* () {
|
||||
var foo = _bluebird.coroutine(function* () {
|
||||
var wat = yield bar();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
let a = true;
|
||||
let b = false;
|
||||
|
||||
switch (a) {
|
||||
case true:
|
||||
let b = 2;
|
||||
break;
|
||||
case false:
|
||||
let c = 3;
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
var a = true;
|
||||
var b = false;
|
||||
|
||||
switch (a) {
|
||||
case true:
|
||||
var b = 2;
|
||||
break;
|
||||
case false:
|
||||
var c = 3;
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Foo extends Bar {
|
||||
constructor() {
|
||||
super(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "'this' is not allowed before super()"
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var Foo = (function (_Bar) {
|
||||
function Foo() {
|
||||
babelHelpers.classCallCheck(this, Foo);
|
||||
|
||||
this.foo = "bar";
|
||||
babelHelpers.get(Object.getPrototypeOf(Foo.prototype), "constructor", this).call(this);
|
||||
}
|
||||
|
||||
babelHelpers.inherits(Foo, _Bar);
|
||||
return Foo;
|
||||
})(Bar);
|
||||
@@ -0,0 +1,2 @@
|
||||
var a = 1;
|
||||
export { a as default };
|
||||
@@ -0,0 +1,6 @@
|
||||
define(["exports", "module"], function (exports, module) {
|
||||
"use strict";
|
||||
|
||||
var a = 1;
|
||||
module.exports = a;
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
bar;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
babelHelpers.classCallCheck(this, Foo);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(Foo, [{
|
||||
key: "bar",
|
||||
value: undefined,
|
||||
enumerable: true
|
||||
}]);
|
||||
return Foo;
|
||||
})();
|
||||
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
static bar;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class Foo {
|
||||
static num;
|
||||
}
|
||||
|
||||
assert.equal("num" in Foo, true);
|
||||
assert.equal(Foo.num, undefined);
|
||||
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
babelHelpers.classCallCheck(this, Foo);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(Foo, null, [{
|
||||
key: "bar",
|
||||
value: undefined,
|
||||
enumerable: true
|
||||
}]);
|
||||
return Foo;
|
||||
})();
|
||||
@@ -0,0 +1,18 @@
|
||||
var foo = {
|
||||
bar: function () { assert.equal(this, foo); },
|
||||
foobar: {
|
||||
bar: function () { assert.equal(this, foo.foobar); },
|
||||
}
|
||||
};
|
||||
|
||||
(class {
|
||||
@foo.bar
|
||||
@foo.foobar.bar
|
||||
bar() {}
|
||||
});
|
||||
|
||||
({
|
||||
@foo.bar
|
||||
@foo.foobar.bar
|
||||
bar() {}
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
var HelloMessage = React.createClass({
|
||||
render: function() {
|
||||
return <div>Hello {this.props.name}</div>;
|
||||
}
|
||||
});
|
||||
|
||||
React.render(<HelloMessage name={
|
||||
<span>
|
||||
Sebastian
|
||||
</span>
|
||||
} />, mountNode);
|
||||
@@ -0,0 +1,18 @@
|
||||
var HelloMessage = React.createClass({
|
||||
displayName: "HelloMessage",
|
||||
|
||||
render: function render() {
|
||||
return React.createElement(
|
||||
"div",
|
||||
null,
|
||||
"Hello ",
|
||||
this.props.name
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
React.render(React.createElement(HelloMessage, { name: React.createElement(
|
||||
"span",
|
||||
null,
|
||||
"Sebastian"
|
||||
) }), mountNode);
|
||||
@@ -0,0 +1 @@
|
||||
Promise.resolve;
|
||||
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
var _Promise = require("babel-runtime/core-js/promise")["default"];
|
||||
|
||||
_Promise.resolve;
|
||||
@@ -1,24 +0,0 @@
|
||||
if (!process.env.ALL_BABEL_TESTS) return;
|
||||
|
||||
require("./_helper").assertVendor("regenerator");
|
||||
|
||||
var transform = require("../lib/babel/transformation");
|
||||
var fs = require("fs");
|
||||
var _ = require("lodash");
|
||||
|
||||
var regeneratorLoc = __dirname + "/../vendor/regenerator";
|
||||
|
||||
suite("regenerator", function () {
|
||||
setup(function () {
|
||||
require("../../register")({
|
||||
blacklist: ["strict"],
|
||||
stage: 0
|
||||
});
|
||||
});
|
||||
|
||||
_.each(["tests", "async"], function (filename) {
|
||||
var loc = regeneratorLoc + "/test/" + filename + ".es6.js";
|
||||
var code = fs.readFileSync(loc, "utf8");
|
||||
require(loc);
|
||||
});
|
||||
});
|
||||
1
vendor/regenerator
vendored
1
vendor/regenerator
vendored
Submodule vendor/regenerator deleted from ad87279a24
Reference in New Issue
Block a user