Compare commits
61 Commits
v7.0.0-bet
...
v7.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3af623678f | ||
|
|
96528d36df | ||
|
|
5de12c26f6 | ||
|
|
4b5a55d937 | ||
|
|
036c429ce1 | ||
|
|
3c46e75b8f | ||
|
|
106907e605 | ||
|
|
387cda8fbb | ||
|
|
86c10ff4f3 | ||
|
|
6d5392554f | ||
|
|
0b25e3327c | ||
|
|
b6455c611b | ||
|
|
313960e601 | ||
|
|
9e4c56f990 | ||
|
|
119db23ee3 | ||
|
|
3432792568 | ||
|
|
cc4ee350e4 | ||
|
|
5bd79c70a5 | ||
|
|
01f6f4c66d | ||
|
|
000fa83b9e | ||
|
|
efb34aa7dc | ||
|
|
ab928713af | ||
|
|
3de053cc6c | ||
|
|
110779e9f3 | ||
|
|
8070a2204d | ||
|
|
9f4e2f81d8 | ||
|
|
415d79bdfe | ||
|
|
62eb32677c | ||
|
|
7da7e760a6 | ||
|
|
bd44902024 | ||
|
|
6480ae4a9f | ||
|
|
80b3362fcc | ||
|
|
8bc0182489 | ||
|
|
e9d861537f | ||
|
|
153ad4c6f3 | ||
|
|
218d69007e | ||
|
|
f838a7e9f1 | ||
|
|
6349118bed | ||
|
|
8bbb10c021 | ||
|
|
f614809002 | ||
|
|
b445b79734 | ||
|
|
b6eaaa2496 | ||
|
|
e2471337f4 | ||
|
|
826edd0bd5 | ||
|
|
f434a50829 | ||
|
|
5895277b32 | ||
|
|
62114b807b | ||
|
|
2abd7839e1 | ||
|
|
b8dcd6f593 | ||
|
|
fe556c502d | ||
|
|
ab62a94399 | ||
|
|
d83d141e00 | ||
|
|
cb17f07ac9 | ||
|
|
21b9b2e42d | ||
|
|
2a8ebbe7ae | ||
|
|
9add6d88f5 | ||
|
|
2d2f37fa6c | ||
|
|
7846eaebaa | ||
|
|
d45ee5e025 | ||
|
|
f699f1bbbf | ||
|
|
f0283572a5 |
@@ -34,7 +34,7 @@ jobs:
|
||||
build:
|
||||
working_directory: ~/babel
|
||||
docker:
|
||||
- image: circleci/node:9
|
||||
- image: circleci/node:10
|
||||
steps:
|
||||
- checkout
|
||||
- restore-cache: *restore-yarn-cache
|
||||
|
||||
@@ -8,6 +8,7 @@ cache:
|
||||
- node_modules
|
||||
node_js:
|
||||
# We test the latest version on circleci
|
||||
- '9'
|
||||
- '8'
|
||||
- '6'
|
||||
|
||||
|
||||
6
Makefile
6
Makefile
@@ -1,6 +1,6 @@
|
||||
MAKEFLAGS = -j1
|
||||
FLOW_COMMIT = 395e045c18d537fcbbc552a96ef2cdcd70b4ab52
|
||||
TEST262_COMMIT = 40883f4c6ae17e073dfd03e34f73a6bf8c855595
|
||||
TEST262_COMMIT = f90a52b39609a620c0854e0bd0b3a906c930fd17
|
||||
|
||||
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
|
||||
export FORCE_COLOR = true
|
||||
@@ -17,8 +17,6 @@ build: clean clean-lib
|
||||
# generate flow and typescript typings
|
||||
node scripts/generators/flow.js > ./packages/babel-types/lib/index.js.flow
|
||||
node scripts/generators/typescript.js > ./packages/babel-types/lib/index.d.ts
|
||||
# generate docs
|
||||
node scripts/generators/docs.js > ./packages/babel-types/README.md
|
||||
ifneq ("$(BABEL_COVERAGE)", "true")
|
||||
make build-standalone
|
||||
make build-preset-env-standalone
|
||||
@@ -52,8 +50,6 @@ lint:
|
||||
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' '**/.*.js' --format=codeframe --rulesdir="./scripts/eslint_rules"
|
||||
|
||||
fix:
|
||||
# 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/plugin-codemod-object-assign-to-object-spread",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Transforms Object.assign into object spread syntax",
|
||||
"repository": "https://github.com/babel/babel/tree/master/codemods/babel-plugin-codemod-object-assign-to-object-spread",
|
||||
"license": "MIT",
|
||||
@@ -10,14 +10,14 @@
|
||||
"@babel/plugin"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/plugin-syntax-object-rest-spread": "7.0.0-beta.49"
|
||||
"@babel/plugin-syntax-object-rest-spread": "7.0.0-beta.50"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "7.0.0-beta.49"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.0.0-beta.49",
|
||||
"@babel/helper-plugin-test-runner": "7.0.0-beta.49"
|
||||
"@babel/core": "7.0.0-beta.50",
|
||||
"@babel/helper-plugin-test-runner": "7.0.0-beta.50"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/plugin-codemod-optional-catch-binding",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Remove unused catch bindings",
|
||||
"repository": "https://github.com/babel/babel/tree/master/codemods/babel-plugin-codemod-remove-unused-catch-binding",
|
||||
"license": "MIT",
|
||||
@@ -10,13 +10,13 @@
|
||||
"@babel/plugin"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/plugin-syntax-optional-catch-binding": "7.0.0-beta.49"
|
||||
"@babel/plugin-syntax-optional-catch-binding": "7.0.0-beta.50"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "7.0.0-beta.49"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.0.0-beta.49",
|
||||
"@babel/helper-plugin-test-runner": "7.0.0-beta.49"
|
||||
"@babel/core": "7.0.0-beta.50",
|
||||
"@babel/helper-plugin-test-runner": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"lerna": "2.0.0-rc.4",
|
||||
"version": "7.0.0-beta.49",
|
||||
"lerna": "2.11.0",
|
||||
"version": "7.0.0-beta.50",
|
||||
"changelog": {
|
||||
"repo": "babel/babel",
|
||||
"cacheDir": ".changelog",
|
||||
|
||||
@@ -166,3 +166,9 @@ declare module "convert-source-map" {
|
||||
generateMapFileComment(path: string, options?: ?{ multiline: boolean }): string,
|
||||
};
|
||||
}
|
||||
|
||||
declare module "js-levenshtein" {
|
||||
declare module.exports: {
|
||||
(string, string): number,
|
||||
};
|
||||
}
|
||||
|
||||
10
package.json
10
package.json
@@ -31,8 +31,8 @@
|
||||
"eslint": "^4.18.2",
|
||||
"eslint-config-babel": "^7.0.2",
|
||||
"eslint-plugin-flowtype": "^2.20.0",
|
||||
"eslint-plugin-prettier": "^2.5.0",
|
||||
"flow-bin": "^0.66.0",
|
||||
"eslint-plugin-prettier": "^2.6.0",
|
||||
"flow-bin": "^0.73.0",
|
||||
"graceful-fs": "^4.1.11",
|
||||
"gulp": "^4.0.0",
|
||||
"gulp-babel": "^8.0.0-beta.2",
|
||||
@@ -45,19 +45,19 @@
|
||||
"gulp-watch": "^5.0.0",
|
||||
"husky": "^0.14.3",
|
||||
"jest": "^22.4.2",
|
||||
"lerna": "2.0.0",
|
||||
"lerna": "^2.11.0",
|
||||
"lerna-changelog": "^0.5.0",
|
||||
"lint-staged": "^6.0.1",
|
||||
"lodash": "^4.17.5",
|
||||
"merge-stream": "^1.0.1",
|
||||
"output-file-sync": "^2.0.0",
|
||||
"prettier": "1.11.1",
|
||||
"prettier": "1.13.2",
|
||||
"pump": "^1.0.2",
|
||||
"rimraf": "^2.4.3",
|
||||
"rollup-plugin-babel": "^4.0.0-beta.0",
|
||||
"rollup-plugin-node-resolve": "^3.0.2",
|
||||
"rollup-stream": "^1.24.1",
|
||||
"test262-stream": "^1.1.0",
|
||||
"test262-stream": "^1.2.0",
|
||||
"through2": "^2.0.0",
|
||||
"uglify-js": "^2.4.16",
|
||||
"vinyl-buffer": "^1.0.1",
|
||||
|
||||
@@ -2,20 +2,18 @@
|
||||
|
||||
> Babel command line.
|
||||
|
||||
In addition, various entry point scripts live in the top-level package at `@babel/cli/bin`.
|
||||
|
||||
There is a shell-executable utility script, `babel-external-helpers.js`, and the main Babel cli script, `babel.js`.
|
||||
See our website [@babel/cli](https://new.babeljs.io/docs/en/next/babel-cli.html) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20cli%22+is%3Aopen) associated with this package.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/core @babel/cli
|
||||
```
|
||||
|
||||
## Usage
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
babel script.js
|
||||
npm install --save @babel/cli
|
||||
```
|
||||
|
||||
For more in depth documentation see: http://babeljs.io/docs/usage/cli/
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/cli
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/cli",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Babel command line.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -32,8 +32,8 @@
|
||||
"@babel/core": "7.0.0-beta.49"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.0.0-beta.49",
|
||||
"@babel/helper-fixtures": "7.0.0-beta.49"
|
||||
"@babel/core": "7.0.0-beta.50",
|
||||
"@babel/helper-fixtures": "7.0.0-beta.50"
|
||||
},
|
||||
"bin": {
|
||||
"babel": "./bin/babel.js",
|
||||
|
||||
@@ -73,8 +73,14 @@ export default async function({ cliOptions, babelOptions }) {
|
||||
|
||||
function outputDestFolder(outDir) {
|
||||
const outDirPath = path.resolve(outDir);
|
||||
if (!fs.existsSync(outDirPath)) {
|
||||
|
||||
try {
|
||||
fs.mkdirSync(outDirPath);
|
||||
} catch (err) {
|
||||
// Testing for the directory and then creating it can lead to race
|
||||
// conditions if there are multiple processes, so we try to create it
|
||||
// and bail if it already exists.
|
||||
if (err.code !== "EEXIST") throw err;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,141 +2,18 @@
|
||||
|
||||
> Generate errors that contain a code frame that point to source locations.
|
||||
|
||||
See our website [@babel/code-frame](https://new.babeljs.io/docs/en/next/babel-code-frame.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/code-frame
|
||||
npm install --save @babel/code-frame
|
||||
```
|
||||
|
||||
## Usage
|
||||
or using yarn:
|
||||
|
||||
```js
|
||||
import { codeFrameColumns } from '@babel/code-frame';
|
||||
|
||||
const rawLines = `class Foo {
|
||||
constructor()
|
||||
}`;
|
||||
const location = { start: { line: 2, column: 16 } };
|
||||
|
||||
const result = codeFrameColumns(rawLines, location, { /* options */ });
|
||||
|
||||
console.log(result);
|
||||
```
|
||||
|
||||
```
|
||||
1 | class Foo {
|
||||
> 2 | constructor()
|
||||
| ^
|
||||
3 | }
|
||||
```
|
||||
|
||||
If the column number is not known, you may omit it.
|
||||
|
||||
You can also pass an `end` hash in `location`.
|
||||
|
||||
```js
|
||||
import { codeFrameColumns } from '@babel/code-frame';
|
||||
|
||||
const rawLines = `class Foo {
|
||||
constructor() {
|
||||
console.log("hello");
|
||||
}
|
||||
}`;
|
||||
const location = { start: { line: 2, column: 17 }, end: { line: 4, column: 3 } };
|
||||
|
||||
const result = codeFrameColumns(rawLines, location, { /* options */ });
|
||||
|
||||
console.log(result);
|
||||
```
|
||||
|
||||
```
|
||||
1 | class Foo {
|
||||
> 2 | constructor() {
|
||||
| ^
|
||||
> 3 | console.log("hello");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
> 4 | }
|
||||
| ^^^
|
||||
5 | };
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
### `highlightCode`
|
||||
|
||||
`boolean`, defaults to `false`.
|
||||
|
||||
Toggles syntax highlighting the code as JavaScript for terminals.
|
||||
|
||||
|
||||
### `linesAbove`
|
||||
|
||||
`number`, defaults to `2`.
|
||||
|
||||
Adjust the number of lines to show above the error.
|
||||
|
||||
### `linesBelow`
|
||||
|
||||
`number`, defaults to `3`.
|
||||
|
||||
Adjust the number of lines to show below the error.
|
||||
|
||||
### `forceColor`
|
||||
|
||||
`boolean`, defaults to `false`.
|
||||
|
||||
Enable this to forcibly syntax highlight the code as JavaScript (for non-terminals); overrides `highlightCode`.
|
||||
|
||||
### `message`
|
||||
|
||||
`string`, otherwise nothing
|
||||
|
||||
Pass in a string to be displayed inline (if possible) next to the highlighted
|
||||
location in the code. If it can't be positioned inline, it will be placed above
|
||||
the code frame.
|
||||
|
||||
```
|
||||
1 | class Foo {
|
||||
> 2 | constructor()
|
||||
| ^ Missing {
|
||||
3 | };
|
||||
```
|
||||
|
||||
## Upgrading from prior versions
|
||||
|
||||
Prior to version 7, the only API exposed by this module was for a single line and optional column pointer. The old API will now log a deprecation warning.
|
||||
|
||||
The new API takes a `location` object, similar to what is available in an AST.
|
||||
|
||||
This is an example of the deprecated (but still available) API:
|
||||
|
||||
```js
|
||||
import codeFrame from '@babel/code-frame';
|
||||
|
||||
const rawLines = `class Foo {
|
||||
constructor()
|
||||
}`;
|
||||
const lineNumber = 2;
|
||||
const colNumber = 16;
|
||||
|
||||
const result = codeFrame(rawLines, lineNumber, colNumber, { /* options */ });
|
||||
|
||||
console.log(result);
|
||||
```
|
||||
|
||||
To get the same highlighting using the new API:
|
||||
|
||||
```js
|
||||
import { codeFrameColumns } from '@babel/code-frame';
|
||||
|
||||
const rawLines = `class Foo {
|
||||
constructor() {
|
||||
console.log("hello");
|
||||
}
|
||||
}`;
|
||||
const location = { start: { line: 2, column: 16 } };
|
||||
|
||||
const result = codeFrameColumns(rawLines, location, { /* options */ });
|
||||
|
||||
console.log(result);
|
||||
```sh
|
||||
yarn add --save @babel/code-frame
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/code-frame",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Generate errors that contain a code frame that point to source locations.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -8,7 +8,7 @@
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-code-frame",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/highlight": "7.0.0-beta.49"
|
||||
"@babel/highlight": "7.0.0-beta.50"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chalk": "^2.0.0",
|
||||
|
||||
@@ -2,249 +2,18 @@
|
||||
|
||||
> Babel compiler core.
|
||||
|
||||
See our website [@babel/core](https://new.babeljs.io/docs/en/next/babel-core.html) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20core%22+is%3Aopen) associated with this package.
|
||||
|
||||
```javascript
|
||||
var babel = require("@babel/core");
|
||||
import { transform } from "@babel/core";
|
||||
import * as babel from "@babel/core";
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/core
|
||||
```
|
||||
|
||||
All transformations will use your local configuration files (`.babelrc` or in `package.json`). See [options](#options) to disable it.
|
||||
or using yarn:
|
||||
|
||||
|
||||
## babel.transform(code: string, [options?](#options): Object, callback: Function)
|
||||
|
||||
Transforms the passed in `code`. Calling a callback with an object with the generated code,
|
||||
source map, and AST.
|
||||
|
||||
```js
|
||||
babel.transform(code, options, function(err, result) {
|
||||
result; // => { code, map, ast }
|
||||
});
|
||||
```sh
|
||||
yarn add --save @babel/core
|
||||
```
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
babel.transform("code();", options, function(err, result) {
|
||||
result.code;
|
||||
result.map;
|
||||
result.ast;
|
||||
});
|
||||
```
|
||||
|
||||
### Compat Note:
|
||||
|
||||
In Babel 6, this method was synchronous and `transformSync` did not exist. For backward-compatibility,
|
||||
this function will behave synchronously if no callback is given. If you're starting with Babel 7
|
||||
and need synchronous behavior, please use `transformSync` since this backward-compat may be dropped in
|
||||
future major versions of Babel.
|
||||
|
||||
|
||||
## babel.transformSync(code: string, [options?](#options): Object)
|
||||
|
||||
Transforms the passed in `code`. Returning an object with the generated code,
|
||||
source map, and AST.
|
||||
|
||||
```js
|
||||
babel.transformSync(code, options) // => { code, map, ast }
|
||||
```
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
var result = babel.transformSync("code();", options);
|
||||
result.code;
|
||||
result.map;
|
||||
result.ast;
|
||||
```
|
||||
|
||||
|
||||
## babel.transformFile(filename: string, [options?](#options): Object, callback: Function)
|
||||
|
||||
Asynchronously transforms the entire contents of a file.
|
||||
|
||||
```js
|
||||
babel.transformFile(filename, options, callback)
|
||||
```
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
babel.transformFile("filename.js", options, function (err, result) {
|
||||
result; // => { code, map, ast }
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## babel.transformFileSync(filename: string, [options?](#options): Object)
|
||||
|
||||
Synchronous version of `babel.transformFile`. Returns the transformed contents of
|
||||
the `filename`.
|
||||
|
||||
```js
|
||||
babel.transformFileSync(filename, options) // => { code, map, ast }
|
||||
```
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
babel.transformFileSync("filename.js", options).code;
|
||||
```
|
||||
|
||||
|
||||
## babel.transformFromAst(ast: Object, code?: string, [options?](#options): Object, callback: Function): FileNode | null
|
||||
|
||||
Given an [AST](https://astexplorer.net/), transform it.
|
||||
|
||||
```js
|
||||
const sourceCode = "if (true) return;";
|
||||
const parsedAst = babel.parse(sourceCode, { allowReturnOutsideFunction: true });
|
||||
babel.transformFromAst(parsedAst, sourceCode, options, function(err, result) {
|
||||
const { code, map, ast } = result;
|
||||
});
|
||||
```
|
||||
|
||||
### Compat Note:
|
||||
|
||||
In Babel 6, this method was synchronous and `transformFromAstSync` did not exist. For backward-compatibility,
|
||||
this function will behave synchronously if no callback is given. If you're starting with Babel 7
|
||||
and need synchronous behavior, please use `transformFromAstSync` since this backward-compat may be dropped in
|
||||
future major versions of Babel.
|
||||
|
||||
|
||||
## babel.transformFromAstSync(ast: Object, code?: string, [options?](#options): Object)
|
||||
|
||||
Given an [AST](https://astexplorer.net/), transform it.
|
||||
|
||||
```js
|
||||
const sourceCode = "if (true) return;";
|
||||
const parsedAst = babel.parse(sourceCode, { allowReturnOutsideFunction: true });
|
||||
const { code, map, ast } = babel.transformFromAstSync(parsedAst, sourceCode, options);
|
||||
```
|
||||
|
||||
## babel.parse(code: string, [options?](#options): Object)
|
||||
|
||||
Given some code, parse it using Babel's standard behavior. Referenced presets and
|
||||
plugins will be loaded such that optional syntax plugins are automatically
|
||||
enabled.
|
||||
|
||||
|
||||
## Advanced APIs
|
||||
|
||||
Many systems that wrap Babel like to automatically inject plugins and presets,
|
||||
or override options. To accomplish this goal, Babel exposes several functions
|
||||
that aid in loading the configuration part-way without transforming.
|
||||
|
||||
### babel.loadOptions([options?](#options): Object)
|
||||
|
||||
Resolve Babel's options fully, resulting in an options object where:
|
||||
|
||||
* `opts.plugins` is a full list of `Plugin` instances.
|
||||
* `opts.presets` is empty and all presets are flattened into `opts`.
|
||||
* It can be safely passed back to Babel. Fields like `babelrc` have been set to
|
||||
false so that later calls to Babel will not make a second attempt to load
|
||||
config files.
|
||||
|
||||
`Plugin` instances aren't meant to be manipulated directly, but often
|
||||
callers will serialize this `opts` to JSON to use it as a cache key representing
|
||||
the options Babel has received. Caching on this isn't 100% guaranteed to
|
||||
invalidate properly, but it is the best we have at the moment.
|
||||
|
||||
|
||||
### babel.loadPartialConfig([options?](#options): Object): PartialConfig
|
||||
|
||||
To allow systems to easily manipulate and validate a user's config, this function
|
||||
resolves the plugins and presets and proceeds no further. The expectation is
|
||||
that callers will take the config's `.options`, manipulate it as then see fit
|
||||
and pass it back to Babel again.
|
||||
|
||||
* `babelrc: string | void` - The path of the `.babelrc` file, if there was one.
|
||||
* `babelignore: string | void` - The path of the `.babelignore` file, if there was one.
|
||||
* `options: ValidatedOptions` - The partially resolved options, which can be manipulated and passed back to Babel again.
|
||||
* `plugins: Array<ConfigItem>` - See below.
|
||||
* `presets: Array<ConfigItem>` - See below.
|
||||
* It can be safely passed back to Babel. Fields like `babelrc` have been set
|
||||
to false so that later calls to Babel will not make a second attempt to
|
||||
load config files.
|
||||
* `hasFilesystemConfig(): boolean` - Check if the resolved config loaded any settings from the filesystem.
|
||||
|
||||
[`ConfigItem`](#configitem-type) instances expose properties to introspect the values, but each
|
||||
item should be treated as immutable. If changes are desired, the item should be
|
||||
removed from the list and replaced with either a normal Babel config value, or
|
||||
with a replacement item created by `babel.createConfigItem`. See that
|
||||
function for information about `ConfigItem` fields.
|
||||
|
||||
|
||||
### babel.createConfigItem(value: string | {} | Function | [string | {} | Function, {} | void], { dirname?: string, type?: "preset" | "plugin" }): ConfigItem
|
||||
|
||||
Allows build tooling to create and cache config items up front. If this function
|
||||
is called multiple times for a given plugin, Babel will call the plugin's function itself
|
||||
multiple times. If you have a clear set of expected plugins and presets to
|
||||
inject, pre-constructing the config items would be recommended.
|
||||
|
||||
|
||||
### `ConfigItem` type
|
||||
|
||||
Each `ConfigItem` exposes all of the information Babel knows. The fields are:
|
||||
|
||||
* `value: {} | Function` - The resolved value of the plugin.
|
||||
* `options: {} | void` - The options object passed to the plugin.
|
||||
* `dirname: string` - The path that the options are relative to.
|
||||
* `name: string | void` - The name that the user gave the plugin instance, e.g. `plugins: [ ['env', {}, 'my-env'] ]`
|
||||
* `file: Object | void` - Information about the plugin's file, if Babel knows it.
|
||||
* `request: string` - The file that the user requested, e.g. `"@babel/env"`
|
||||
* `resolved: string` - The full path of the resolved file, e.g. `"/tmp/node_modules/@babel/preset-env/lib/index.js"`
|
||||
|
||||
|
||||
## Options
|
||||
|
||||
<blockquote class="babel-callout babel-callout-info">
|
||||
<h4>Babel CLI</h4>
|
||||
<p>
|
||||
You can pass these options from the Babel CLI like so:
|
||||
</p>
|
||||
<p>
|
||||
<code>babel --option-name<span class="o">=</span>value</code>
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
Following is a table of the options you can use:
|
||||
|
||||
| Option | Default | Description |
|
||||
| ------------------------ | -------------------- | ------------------------------- |
|
||||
| `ast` | `false` | Include the AST in the returned object |
|
||||
| `auxiliaryCommentAfter` | `null` | Attach a comment after all non-user injected code |
|
||||
| `auxiliaryCommentBefore` | `null` | Attach a comment before all non-user injected code |
|
||||
| `root` | `"."` | Specify the "root" folder that defines the location to search for "babel.config.js", and the default folder to allow `.babelrc` files inside of.|
|
||||
| `configFile` | `undefined` | The config file to load Babel's config from. Defaults to searching for "babel.config.js" inside the "root" folder. `false` will disable searching for config files.|
|
||||
| `babelrc` | `true` | Specify whether or not to use .babelrc and .babelignore files. Not available when using the CLI, [use `--no-babelrc` instead](https://babeljs.io/docs/usage/cli/#babel-ignoring-babelrc) |
|
||||
| `babelrcRoots` | `(root)` | Specify which packages should be search for .babelrc files when they are being compiled. `true` to _always_ search, or a path string or an array of paths to packages to search inside of. Defaults to only searching the "root" package. |
|
||||
| `envName` | env vars | Defaults to environment variable `BABEL_ENV` if set, or else `NODE_ENV` if set, or else it defaults to `"development"` |
|
||||
| `code` | `true` | Enable code generation |
|
||||
| `comments` | `true` | Output comments in generated output |
|
||||
| `compact` | `"auto"` | Do not include superfluous whitespace characters and line terminators. When set to `"auto"` compact is set to `true` on input sizes of >500KB |
|
||||
| `env` | `{}` | This is an object of keys that represent different environments. For example, you may have: `{ env: { production: { /* specific options */ } } }` which will use those options when the `envName` is `production` |
|
||||
| `extends` | `null` | A path to a `.babelrc` file to extend |
|
||||
| `filename` | `"unknown"` | Filename for use in errors etc |
|
||||
| `filenameRelative` | `(filename)` | Filename relative to `sourceRoot` |
|
||||
| `generatorOpts` | `{}` | An object containing the options to be passed down to the babel code generator, @babel/generator |
|
||||
| `getModuleId` | `null` | Specify a custom callback to generate a module id with. Called as `getModuleId(moduleName)`. If falsy value is returned then the generated module id is used |
|
||||
| `highlightCode` | `true` | ANSI highlight syntax error code frames |
|
||||
| `ignore` | `null` | Opposite to the `only` option. `ignore` is disregarded if `only` is specified |
|
||||
| `inputSourceMap` | `null` | A source map object that the output source map will be based on |
|
||||
| `minified` | `false` | Should the output be minified (not printing last semicolons in blocks, printing literal string values instead of escaped ones, stripping `()` from `new` when safe) |
|
||||
| `moduleId` | `null` | Specify a custom name for module ids |
|
||||
| `moduleIds` | `false` | If truthy, insert an explicit id for modules. By default, all modules are anonymous. (Not available for `common` modules) |
|
||||
| `moduleRoot` | `(sourceRoot)` | Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions |
|
||||
| `only` | `null` | A [glob](https://github.com/isaacs/minimatch), regex, or mixed array of both, matching paths to **only** compile. Can also be an array of arrays containing paths to explicitly match. When attempting to compile a non-matching file it's returned verbatim |
|
||||
| `parserOpts` | `{}` | An object containing the options to be passed down to the babel parser, @babel/parser |
|
||||
| `plugins` | `[]` | List of [plugins](https://babeljs.io/docs/plugins/) to load and use |
|
||||
| `presets` | `[]` | List of [presets](https://babeljs.io/docs/plugins/#presets) (a set of plugins) to load and use |
|
||||
| `retainLines` | `false` | Retain line numbers. This will lead to wacky code but is handy for scenarios where you can't use source maps. (**NOTE:** This will not retain the columns) |
|
||||
| `shouldPrintComment` | `null` | An optional callback that controls whether a comment should be output or not. Called as `shouldPrintComment(commentContents)`. **NOTE:** This overrides the `comment` option when used |
|
||||
| `sourceFileName` | `(filenameRelative)` | Set `sources[0]` on returned source map |
|
||||
| `sourceMaps` | `false` | If truthy, adds a `map` property to returned output. If set to `"inline"`, a comment with a sourceMappingURL directive is added to the bottom of the returned code. If set to `"both"` then a `map` property is returned as well as a source map comment appended. **This does not emit sourcemap files by itself!** To have sourcemaps emitted using the CLI, you must pass it the `--source-maps` option |
|
||||
| `sourceRoot` | `(moduleRoot)` | The root from which all sources are relative |
|
||||
| `sourceType` | `"module"` | Indicate the mode the code should be parsed in. Can be one of "script", "module", or "unambiguous". `"unambiguous"` will make Babel attempt to _guess_, based on the presence of ES6 `import` or `export` statements. Files with ES6 `import`s and `export`s are considered `"module"` and are otherwise `"script"`. |
|
||||
| `wrapPluginVisitorMethod`| `null` | An optional callback that can be used to wrap visitor methods. **NOTE:** This is useful for things like introspection, and not really needed for implementing anything. Called as `wrapPluginVisitorMethod(pluginAlias, visitorType, callback)`.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/core",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Babel compiler core.",
|
||||
"main": "lib/index.js",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
@@ -30,24 +30,24 @@
|
||||
"./lib/transform-file.js": "./lib/transform-file-browser.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "7.0.0-beta.49",
|
||||
"@babel/generator": "7.0.0-beta.49",
|
||||
"@babel/helpers": "7.0.0-beta.49",
|
||||
"@babel/parser": "7.0.0-beta.49",
|
||||
"@babel/template": "7.0.0-beta.49",
|
||||
"@babel/traverse": "7.0.0-beta.49",
|
||||
"@babel/types": "7.0.0-beta.49",
|
||||
"@babel/code-frame": "7.0.0-beta.50",
|
||||
"@babel/generator": "7.0.0-beta.50",
|
||||
"@babel/helpers": "7.0.0-beta.50",
|
||||
"@babel/parser": "7.0.0-beta.50",
|
||||
"@babel/template": "7.0.0-beta.50",
|
||||
"@babel/traverse": "7.0.0-beta.50",
|
||||
"@babel/types": "7.0.0-beta.50",
|
||||
"convert-source-map": "^1.1.0",
|
||||
"debug": "^3.1.0",
|
||||
"json5": "^0.5.0",
|
||||
"lodash": "^4.17.5",
|
||||
"micromatch": "^2.3.11",
|
||||
"micromatch": "^3.1.10",
|
||||
"resolve": "^1.3.2",
|
||||
"semver": "^5.4.1",
|
||||
"source-map": "^0.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-transform-fixture-test-runner": "7.0.0-beta.49",
|
||||
"@babel/register": "7.0.0-beta.49"
|
||||
"@babel/helper-transform-fixture-test-runner": "7.0.0-beta.50",
|
||||
"@babel/register": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,11 +236,13 @@ function babelrcLoadEnabled(
|
||||
return micromatch(pkgData.directories, babelrcPatterns).length > 0;
|
||||
}
|
||||
|
||||
const validateConfigFile = makeWeakCache((file: ConfigFile): ValidatedFile => ({
|
||||
filepath: file.filepath,
|
||||
dirname: file.dirname,
|
||||
options: validate("configfile", file.options),
|
||||
}));
|
||||
const validateConfigFile = makeWeakCache(
|
||||
(file: ConfigFile): ValidatedFile => ({
|
||||
filepath: file.filepath,
|
||||
dirname: file.dirname,
|
||||
options: validate("configfile", file.options),
|
||||
}),
|
||||
);
|
||||
|
||||
const validateBabelrcFile = makeWeakCache(
|
||||
(file: ConfigFile): ValidatedFile => ({
|
||||
@@ -250,11 +252,13 @@ const validateBabelrcFile = makeWeakCache(
|
||||
}),
|
||||
);
|
||||
|
||||
const validateExtendFile = makeWeakCache((file: ConfigFile): ValidatedFile => ({
|
||||
filepath: file.filepath,
|
||||
dirname: file.dirname,
|
||||
options: validate("extendsfile", file.options),
|
||||
}));
|
||||
const validateExtendFile = makeWeakCache(
|
||||
(file: ConfigFile): ValidatedFile => ({
|
||||
filepath: file.filepath,
|
||||
dirname: file.dirname,
|
||||
options: validate("extendsfile", file.options),
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Build a config chain for just the programmatic options passed into Babel.
|
||||
|
||||
@@ -198,8 +198,9 @@ const readConfigJS = makeStrongCache(
|
||||
|
||||
const packageToBabelConfig = makeWeakCache(
|
||||
(file: ConfigFile): ConfigFile | null => {
|
||||
if (typeof file.options.babel === "undefined") return null;
|
||||
const babel = file.options.babel;
|
||||
const babel = file.options[("babel": string)];
|
||||
|
||||
if (typeof babel === "undefined") return null;
|
||||
|
||||
if (typeof babel !== "object" || Array.isArray(babel) || babel === null) {
|
||||
throw new Error(`${file.filepath}: .babel property must be an object`);
|
||||
|
||||
@@ -12,6 +12,11 @@ Object.defineProperty(exports, "__esModule", {
|
||||
|
||||
exports.default = function () {
|
||||
return {
|
||||
plugins: [require('../../../../../babel-plugin-syntax-decorators')]
|
||||
plugins: [
|
||||
[
|
||||
require('../../../../../babel-plugin-syntax-decorators'),
|
||||
{ legacy: true }
|
||||
],
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
exports.__esModule = true;
|
||||
module.exports = function() {
|
||||
return {
|
||||
plugins: [require('../../../../../babel-plugin-syntax-decorators')]
|
||||
plugins: [
|
||||
[
|
||||
require('../../../../../babel-plugin-syntax-decorators'),
|
||||
{ legacy: true }
|
||||
],
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
module.exports = function () {
|
||||
return {
|
||||
plugins: [
|
||||
require('../../../../../babel-plugin-syntax-decorators'),
|
||||
[
|
||||
require('../../../../../babel-plugin-syntax-decorators'),
|
||||
{ legacy: true }
|
||||
],
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
module.exports = function() {
|
||||
return {
|
||||
plugins: [
|
||||
require('../../../../../babel-plugin-syntax-decorators'),
|
||||
[
|
||||
require('../../../../../babel-plugin-syntax-decorators'),
|
||||
{ legacy: true }
|
||||
],
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"expression": {
|
||||
"type": "Identifier",
|
||||
"start": 1,
|
||||
"end": 11,
|
||||
|
||||
@@ -1,78 +1,19 @@
|
||||
# @babel/generator
|
||||
|
||||
> Turns the [babel AST](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md) into code.
|
||||
> Turns an AST into code.
|
||||
|
||||
See our website [@babel/generator](https://new.babeljs.io/docs/en/next/babel-generator.html) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20generator%22+is%3Aopen) associated with this package.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/generator
|
||||
npm install --save @babel/generator
|
||||
```
|
||||
|
||||
## Usage
|
||||
or using yarn:
|
||||
|
||||
```js
|
||||
import {parse} from '@babel/parser';
|
||||
import generate from '@babel/generator';
|
||||
|
||||
const code = 'class Example {}';
|
||||
const ast = parse(code);
|
||||
|
||||
const output = generate(ast, { /* options */ }, code);
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
Options for formatting output:
|
||||
|
||||
name | type | default | description
|
||||
-----------------------|----------|-----------------|--------------------------------------------------------------------------
|
||||
auxiliaryCommentBefore | string | | Optional string to add as a block comment at the start of the output file
|
||||
auxiliaryCommentAfter | string | | Optional string to add as a block comment at the end of the output file
|
||||
shouldPrintComment | function | `opts.comments` | Function that takes a comment (as a string) and returns `true` if the comment should be included in the output. By default, comments are included if `opts.comments` is `true` or if `opts.minifed` is `false` and the comment contains `@preserve` or `@license`
|
||||
retainLines | boolean | `false` | Attempt to use the same line numbers in the output code as in the source code (helps preserve stack traces)
|
||||
retainFunctionParens | boolean | `false` | Retain parens around function expressions (could be used to change engine parsing behavior)
|
||||
comments | boolean | `true` | Should comments be included in output
|
||||
compact | boolean or `'auto'` | `opts.minified` | Set to `true` to avoid adding whitespace for formatting
|
||||
minified | boolean | `false` | Should the output be minified
|
||||
concise | boolean | `false` | Set to `true` to reduce whitespace (but not as much as `opts.compact`)
|
||||
filename | string | | Used in warning messages
|
||||
jsonCompatibleStrings | boolean | `false` | Set to true to run `jsesc` with "json": true to print "\u00A9" vs. "©";
|
||||
|
||||
Options for source maps:
|
||||
|
||||
name | type | default | description
|
||||
-----------------------|----------|-----------------|--------------------------------------------------------------------------
|
||||
sourceMaps | boolean | `false` | Enable generating source maps
|
||||
sourceRoot | string | | A root for all relative URLs in the source map
|
||||
sourceFileName | string | | The filename for the source code (i.e. the code in the `code` argument). This will only be used if `code` is a string.
|
||||
|
||||
## AST from Multiple Sources
|
||||
|
||||
In most cases, Babel does a 1:1 transformation of input-file to output-file. However,
|
||||
you may be dealing with AST constructed from multiple sources - JS files, templates, etc.
|
||||
If this is the case, and you want the sourcemaps to reflect the correct sources, you'll need
|
||||
to pass an object to `generate` as the `code` parameter. Keys
|
||||
should be the source filenames, and values should be the source content.
|
||||
|
||||
Here's an example of what that might look like:
|
||||
|
||||
```js
|
||||
import {parse} from '@babel/parser';
|
||||
import generate from '@babel/generator';
|
||||
|
||||
const a = 'var a = 1;';
|
||||
const b = 'var b = 2;';
|
||||
const astA = parse(a, { sourceFilename: 'a.js' });
|
||||
const astB = parse(b, { sourceFilename: 'b.js' });
|
||||
const ast = {
|
||||
type: 'Program',
|
||||
body: [].concat(astA.program.body, astB.program.body)
|
||||
};
|
||||
|
||||
const { code, map } = generate(ast, { sourceMaps: true }, {
|
||||
'a.js': a,
|
||||
'b.js': b
|
||||
});
|
||||
|
||||
// Sourcemap will point to both a.js and b.js where appropriate.
|
||||
```sh
|
||||
yarn add --save @babel/generator
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/generator",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Turns an AST into code.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -11,14 +11,14 @@
|
||||
"lib"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/types": "7.0.0-beta.49",
|
||||
"@babel/types": "7.0.0-beta.50",
|
||||
"jsesc": "^2.5.1",
|
||||
"lodash": "^4.17.5",
|
||||
"source-map": "^0.5.0",
|
||||
"trim-right": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-fixtures": "7.0.0-beta.49",
|
||||
"@babel/parser": "7.0.0-beta.49"
|
||||
"@babel/helper-fixtures": "7.0.0-beta.50",
|
||||
"@babel/parser": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@ import * as t from "@babel/types";
|
||||
|
||||
export function ClassDeclaration(node: Object, parent: Object) {
|
||||
if (
|
||||
!t.isExportDefaultDeclaration(parent) &&
|
||||
!t.isExportNamedDeclaration(parent)
|
||||
!this.format.decoratorsBeforeExport ||
|
||||
(!t.isExportDefaultDeclaration(parent) &&
|
||||
!t.isExportNamedDeclaration(parent))
|
||||
) {
|
||||
this.printJoin(node.decorators, node);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ export function Super() {
|
||||
|
||||
export function Decorator(node: Object) {
|
||||
this.token("@");
|
||||
this.print(node.callee, node);
|
||||
this.print(node.expression, node);
|
||||
this.newline();
|
||||
}
|
||||
|
||||
|
||||
@@ -472,6 +472,10 @@ export function ObjectTypeIndexer(node: Object) {
|
||||
}
|
||||
|
||||
export function ObjectTypeProperty(node: Object) {
|
||||
if (node.proto) {
|
||||
this.word("proto");
|
||||
this.space();
|
||||
}
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
|
||||
@@ -57,7 +57,10 @@ export function ExportAllDeclaration(node: Object) {
|
||||
}
|
||||
|
||||
export function ExportNamedDeclaration(node: Object) {
|
||||
if (t.isClassDeclaration(node.declaration)) {
|
||||
if (
|
||||
this.format.decoratorsBeforeExport &&
|
||||
t.isClassDeclaration(node.declaration)
|
||||
) {
|
||||
this.printJoin(node.declaration.decorators, node);
|
||||
}
|
||||
|
||||
@@ -67,7 +70,10 @@ export function ExportNamedDeclaration(node: Object) {
|
||||
}
|
||||
|
||||
export function ExportDefaultDeclaration(node: Object) {
|
||||
if (t.isClassDeclaration(node.declaration)) {
|
||||
if (
|
||||
this.format.decoratorsBeforeExport &&
|
||||
t.isClassDeclaration(node.declaration)
|
||||
) {
|
||||
this.printJoin(node.declaration.decorators, node);
|
||||
}
|
||||
|
||||
|
||||
@@ -132,10 +132,7 @@ export function StringLiteral(node: Object) {
|
||||
}
|
||||
|
||||
// ensure the output is ASCII-safe
|
||||
const opts = {
|
||||
quotes: "double",
|
||||
wrap: true,
|
||||
};
|
||||
const opts = this.format.jsescOption;
|
||||
if (this.format.jsonCompatibleStrings) {
|
||||
opts.json = true;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,12 @@ function normalizeOptions(code, opts): Format {
|
||||
style: " ",
|
||||
base: 0,
|
||||
},
|
||||
decoratorsBeforeExport: !!opts.decoratorsBeforeExport,
|
||||
jsescOption: {
|
||||
quotes: "double",
|
||||
wrap: true,
|
||||
...opts.jsescOption,
|
||||
},
|
||||
};
|
||||
|
||||
if (format.minified) {
|
||||
|
||||
@@ -25,6 +25,7 @@ export type Format = {
|
||||
style: string,
|
||||
base: number,
|
||||
},
|
||||
decoratorsBeforeExport: boolean,
|
||||
};
|
||||
|
||||
export default class Printer {
|
||||
|
||||
3
packages/babel-generator/test/fixtures/decoratorsBeforeExport/false-to-false/input.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/decoratorsBeforeExport/false-to-false/input.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default @dec class Foo {}
|
||||
|
||||
export @dec class Bar {}
|
||||
6
packages/babel-generator/test/fixtures/decoratorsBeforeExport/false-to-false/options.json
vendored
Normal file
6
packages/babel-generator/test/fixtures/decoratorsBeforeExport/false-to-false/options.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
["decorators", { "decoratorsBeforeExport": false }]
|
||||
],
|
||||
"decoratorsBeforeExport": false
|
||||
}
|
||||
4
packages/babel-generator/test/fixtures/decoratorsBeforeExport/false-to-false/output.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/decoratorsBeforeExport/false-to-false/output.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export default @dec
|
||||
class Foo {}
|
||||
export @dec
|
||||
class Bar {}
|
||||
3
packages/babel-generator/test/fixtures/decoratorsBeforeExport/false-to-true/input.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/decoratorsBeforeExport/false-to-true/input.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default @dec class Foo {}
|
||||
|
||||
export @dec class Bar {}
|
||||
6
packages/babel-generator/test/fixtures/decoratorsBeforeExport/false-to-true/options.json
vendored
Normal file
6
packages/babel-generator/test/fixtures/decoratorsBeforeExport/false-to-true/options.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
["decorators", { "decoratorsBeforeExport": false }]
|
||||
],
|
||||
"decoratorsBeforeExport": true
|
||||
}
|
||||
4
packages/babel-generator/test/fixtures/decoratorsBeforeExport/false-to-true/output.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/decoratorsBeforeExport/false-to-true/output.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
@dec
|
||||
export default class Foo {}
|
||||
@dec
|
||||
export class Bar {}
|
||||
5
packages/babel-generator/test/fixtures/decoratorsBeforeExport/true-to-false/input.js
vendored
Normal file
5
packages/babel-generator/test/fixtures/decoratorsBeforeExport/true-to-false/input.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
@dec
|
||||
export default class Foo {}
|
||||
|
||||
@dec
|
||||
export class Bar {}
|
||||
6
packages/babel-generator/test/fixtures/decoratorsBeforeExport/true-to-false/options.json
vendored
Normal file
6
packages/babel-generator/test/fixtures/decoratorsBeforeExport/true-to-false/options.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
["decorators", { "decoratorsBeforeExport": true }]
|
||||
],
|
||||
"decoratorsBeforeExport": false
|
||||
}
|
||||
4
packages/babel-generator/test/fixtures/decoratorsBeforeExport/true-to-false/output.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/decoratorsBeforeExport/true-to-false/output.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export default @dec
|
||||
class Foo {}
|
||||
export @dec
|
||||
class Bar {}
|
||||
5
packages/babel-generator/test/fixtures/decoratorsBeforeExport/true-to-true/input.js
vendored
Normal file
5
packages/babel-generator/test/fixtures/decoratorsBeforeExport/true-to-true/input.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
@dec
|
||||
export default class Foo {}
|
||||
|
||||
@dec
|
||||
export class Bar {}
|
||||
6
packages/babel-generator/test/fixtures/decoratorsBeforeExport/true-to-true/options.json
vendored
Normal file
6
packages/babel-generator/test/fixtures/decoratorsBeforeExport/true-to-true/options.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
["decorators", { "decoratorsBeforeExport": true }]
|
||||
],
|
||||
"decoratorsBeforeExport": true
|
||||
}
|
||||
4
packages/babel-generator/test/fixtures/decoratorsBeforeExport/true-to-true/output.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/decoratorsBeforeExport/true-to-true/output.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
@dec
|
||||
export default class Foo {}
|
||||
@dec
|
||||
export class Bar {}
|
||||
@@ -32,15 +32,15 @@ class Foo {
|
||||
|
||||
}
|
||||
|
||||
@foo
|
||||
export default class Foo {
|
||||
export default @foo
|
||||
class Foo {
|
||||
bar() {
|
||||
class Baz {}
|
||||
}
|
||||
|
||||
}
|
||||
@foo
|
||||
export class Foo {
|
||||
export @foo
|
||||
class Foo {
|
||||
bar() {
|
||||
class Baz {}
|
||||
}
|
||||
|
||||
@@ -1,40 +1,19 @@
|
||||
# @babel/helper-annotate-as-pure
|
||||
|
||||
## API
|
||||
> Helper function to annotate paths and nodes with #__PURE__ comment
|
||||
|
||||
```js
|
||||
declare export default annotateAsPure(nodeOrPath: Node | NodePath);
|
||||
See our website [@babel/helper-annotate-as-pure](https://new.babeljs.io/docs/en/next/babel-helper-annotate-as-pure.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-annotate-as-pure
|
||||
```
|
||||
|
||||
## Usage
|
||||
or using yarn:
|
||||
|
||||
```js
|
||||
import traverse from "@babel/traverse";
|
||||
import annotateAsPure from "@babel/helper-annotate-as-pure";
|
||||
|
||||
// ...
|
||||
|
||||
traverse(file, {
|
||||
CallExpression(path) {
|
||||
annotateAsPure(path);
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
## Caveat with UglifyJS pre v3.1.0
|
||||
|
||||
`@babel/helper-annotate-as-pure` will append any existing leading comments to the `#__PURE__` annotation. Versions of UglifyJS prior to v3.1.0 will **ignore** these annotations, as they only check the _last_ leading comment for the annotation.
|
||||
|
||||
For example, using the `Usage` snippet above:
|
||||
|
||||
**In**
|
||||
|
||||
```js
|
||||
const four = /* foo */ add(2, 2);
|
||||
```
|
||||
|
||||
**Out**
|
||||
|
||||
```js
|
||||
const four = /* #__PURE__ */ /* foo */ add(2, 2);
|
||||
```sh
|
||||
yarn add --save @babel/helper-annotate-as-pure
|
||||
```
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "@babel/helper-annotate-as-pure",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to annotate paths and nodes with #__PURE__ comment",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-annotate-as-pure",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/types": "7.0.0-beta.49"
|
||||
"@babel/types": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
# @babel/helper-bindify-decorators
|
||||
|
||||
## API
|
||||
```javascript
|
||||
declare export default bindifyDecorators(decorators: Array<NodePath>);
|
||||
```
|
||||
## Usage
|
||||
> Helper function to bindify decorators
|
||||
|
||||
TODO
|
||||
See our website [@babel/helper-bindify-decorators](https://new.babeljs.io/docs/en/next/babel-helper-bindify-decorators.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-bindify-decorators
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-bindify-decorators
|
||||
```
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@babel/helper-bindify-decorators",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to bindify decorators",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-bindify-decorators",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/traverse": "7.0.0-beta.49",
|
||||
"@babel/types": "7.0.0-beta.49"
|
||||
"@babel/traverse": "7.0.0-beta.50",
|
||||
"@babel/types": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# @babel/helper-builder-binary-assignment-operator-visitor
|
||||
|
||||
## Usage
|
||||
> Helper function to build binary assignment operator visitors
|
||||
|
||||
TODO
|
||||
See our website [@babel/helper-builder-binary-assignment-operator-visitor](https://new.babeljs.io/docs/en/next/babel-helper-builder-binary-assignment-operator-visitor.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-builder-binary-assignment-operator-visitor
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-builder-binary-assignment-operator-visitor
|
||||
```
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@babel/helper-builder-binary-assignment-operator-visitor",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to build binary assignment operator visitors",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-builder-binary-assignment-operator-visitor",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/helper-explode-assignable-expression": "7.0.0-beta.49",
|
||||
"@babel/types": "7.0.0-beta.49"
|
||||
"@babel/helper-explode-assignable-expression": "7.0.0-beta.50",
|
||||
"@babel/types": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,19 @@
|
||||
# @babel/helper-builder-react-jsx
|
||||
|
||||
## Usage
|
||||
> Helper function to build react jsx
|
||||
|
||||
```javascript
|
||||
type ElementState = {
|
||||
tagExpr: Object; // tag node
|
||||
tagName: string; // raw string tag name
|
||||
args: Array<Object>; // array of call arguments
|
||||
call?: Object; // optional call property that can be set to override the call expression returned
|
||||
};
|
||||
See our website [@babel/helper-builder-react-jsx](https://new.babeljs.io/docs/en/next/babel-helper-builder-react-jsx.html) for more information.
|
||||
|
||||
require("@babel/helper-builder-react-jsx")({
|
||||
filter: function (element: JSXElement) {
|
||||
// if returns false, the element isn't transformed
|
||||
},
|
||||
## Install
|
||||
|
||||
pre: function (state: ElementState) {
|
||||
// function called with (state: ElementState) before building attribs
|
||||
},
|
||||
Using npm:
|
||||
|
||||
post: function (state: ElementState) {
|
||||
// function called with (state: ElementState) after building attribs
|
||||
},
|
||||
|
||||
compat?: boolean // true if React is in compat mode
|
||||
});
|
||||
```sh
|
||||
npm install --save @babel/helper-builder-react-jsx
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-builder-react-jsx
|
||||
```
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@babel/helper-builder-react-jsx",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to build react jsx",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-builder-react-jsx",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/types": "7.0.0-beta.49",
|
||||
"@babel/types": "7.0.0-beta.50",
|
||||
"esutils": "^2.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,14 +89,14 @@ You can turn on the 'throwIfNamespace' flag to bypass this warning.`,
|
||||
}
|
||||
}
|
||||
|
||||
if (t.isValidIdentifier(node.name.name)) {
|
||||
if (t.isJSXNamespacedName(node.name)) {
|
||||
node.name = t.stringLiteral(
|
||||
node.name.namespace.name + ":" + node.name.name.name,
|
||||
);
|
||||
} else if (esutils.keyword.isIdentifierNameES6(node.name.name)) {
|
||||
node.name.type = "Identifier";
|
||||
} else {
|
||||
node.name = t.stringLiteral(
|
||||
t.isJSXNamespacedName(node.name)
|
||||
? node.name.namespace.name + ":" + node.name.name.name
|
||||
: node.name.name,
|
||||
);
|
||||
node.name = t.stringLiteral(node.name.name);
|
||||
}
|
||||
|
||||
return t.inherits(t.objectProperty(node.name, value), node);
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# @babel/helper-call-delegate
|
||||
|
||||
## Usage
|
||||
> Helper function to call delegate
|
||||
|
||||
TODO
|
||||
See our website [@babel/helper-call-delegate](https://new.babeljs.io/docs/en/next/babel-helper-call-delegate.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-call-delegate
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-call-delegate
|
||||
```
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "@babel/helper-call-delegate",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to call delegate",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-call-delegate",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/helper-hoist-variables": "7.0.0-beta.49",
|
||||
"@babel/traverse": "7.0.0-beta.49",
|
||||
"@babel/types": "7.0.0-beta.49"
|
||||
"@babel/helper-hoist-variables": "7.0.0-beta.50",
|
||||
"@babel/traverse": "7.0.0-beta.50",
|
||||
"@babel/types": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# @babel/helper-define-map
|
||||
|
||||
## Usage
|
||||
> Helper function to define a map
|
||||
|
||||
TODO
|
||||
See our website [@babel/helper-define-map](https://new.babeljs.io/docs/en/next/babel-helper-define-map.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-define-map
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-define-map
|
||||
```
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "@babel/helper-define-map",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to define a map",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-define-map",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/helper-function-name": "7.0.0-beta.49",
|
||||
"@babel/types": "7.0.0-beta.49",
|
||||
"@babel/helper-function-name": "7.0.0-beta.50",
|
||||
"@babel/types": "7.0.0-beta.50",
|
||||
"lodash": "^4.17.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# @babel/helper-explode-assignable-expression
|
||||
|
||||
## Usage
|
||||
> Helper function to explode an assignable expression
|
||||
|
||||
TODO
|
||||
See our website [@babel/helper-explode-assignable-expression](https://new.babeljs.io/docs/en/next/babel-helper-explode-assignable-expression.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-explode-assignable-expression
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-explode-assignable-expression
|
||||
```
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@babel/helper-explode-assignable-expression",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to explode an assignable expression",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-explode-assignable-expression",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/traverse": "7.0.0-beta.49",
|
||||
"@babel/types": "7.0.0-beta.49"
|
||||
"@babel/traverse": "7.0.0-beta.50",
|
||||
"@babel/types": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# @babel/helper-explode-class
|
||||
|
||||
## Usage
|
||||
> Helper function to explode class
|
||||
|
||||
TODO
|
||||
See our website [@babel/helper-explode-class](https://new.babeljs.io/docs/en/next/babel-helper-explode-class.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-explode-class
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-explode-class
|
||||
```
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "@babel/helper-explode-class",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to explode class",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-explode-class",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/helper-bindify-decorators": "7.0.0-beta.49",
|
||||
"@babel/traverse": "7.0.0-beta.49",
|
||||
"@babel/types": "7.0.0-beta.49"
|
||||
"@babel/helper-bindify-decorators": "7.0.0-beta.50",
|
||||
"@babel/traverse": "7.0.0-beta.50",
|
||||
"@babel/types": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,19 @@
|
||||
# @babel/helper-fixtures
|
||||
|
||||
**NOTE:** This is an internal Babel module and may not work outside. Use at your own risk.
|
||||
> Helper function to support fixtures
|
||||
|
||||
## Usage
|
||||
See our website [@babel/helper-fixtures](https://new.babeljs.io/docs/en/next/babel-helper-fixtures.html) for more information.
|
||||
|
||||
```javascript
|
||||
import getFixtures from "@babel/helper-fixtures";
|
||||
## Install
|
||||
|
||||
type TestFile = {
|
||||
loc: string;
|
||||
code: string;
|
||||
filename: string;
|
||||
};
|
||||
Using npm:
|
||||
|
||||
type Test = {
|
||||
title: string;
|
||||
disabled: boolean;
|
||||
options: Object;
|
||||
exec: TestFile;
|
||||
actual: TestFile;
|
||||
expected: TestFile;
|
||||
};
|
||||
|
||||
type Suite = {
|
||||
options: Object;
|
||||
tests: Array<Test>;
|
||||
title: string;
|
||||
filename: string;
|
||||
};
|
||||
|
||||
let fixtures: Array<Suite> = getFixtures("/User/sebmck/Projects/babel-something/test/fixtures");
|
||||
```sh
|
||||
npm install --save @babel/helper-fixtures
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-fixtures
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-fixtures",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to support fixtures",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# @babel/helper-function-name
|
||||
|
||||
## Usage
|
||||
> Helper function to change the property 'name' of every function
|
||||
|
||||
TODO
|
||||
See our website [@babel/helper-function-name](https://new.babeljs.io/docs/en/next/babel-helper-function-name.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-function-name
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-function-name
|
||||
```
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "@babel/helper-function-name",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to change the property 'name' of every function",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-function-name",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/helper-get-function-arity": "7.0.0-beta.49",
|
||||
"@babel/template": "7.0.0-beta.49",
|
||||
"@babel/types": "7.0.0-beta.49"
|
||||
"@babel/helper-get-function-arity": "7.0.0-beta.50",
|
||||
"@babel/template": "7.0.0-beta.50",
|
||||
"@babel/types": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
# @babel/helper-get-function-arity
|
||||
|
||||
Function that returns the number of arguments that a function takes.
|
||||
* Examples of what is considered an argument can be found at [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length)
|
||||
> Helper function to get function arity
|
||||
|
||||
## Usage
|
||||
See our website [@babel/helper-get-function-arity](https://new.babeljs.io/docs/en/next/babel-helper-get-function-arity.html) for more information.
|
||||
|
||||
```javascript
|
||||
import getFunctionArity from "@babel/helper-get-function-arity";
|
||||
## Install
|
||||
|
||||
function wrap(state, method, id, scope) {
|
||||
// ...
|
||||
if (!t.isFunction(method)) {
|
||||
return false;
|
||||
}
|
||||
Using npm:
|
||||
|
||||
const argumentsLength = getFunctionArity(method);
|
||||
|
||||
// ...
|
||||
}
|
||||
```sh
|
||||
npm install --save @babel/helper-get-function-arity
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-get-function-arity
|
||||
```
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "@babel/helper-get-function-arity",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to get function arity",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-get-function-arity",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/types": "7.0.0-beta.49"
|
||||
"@babel/types": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
# @babel/helper-hoist-variables
|
||||
|
||||
## Installation
|
||||
> Helper function to hoist variables
|
||||
|
||||
See our website [@babel/helper-hoist-variables](https://new.babeljs.io/docs/en/next/babel-helper-hoist-variables.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install @babel/helper-hoist-variables --save
|
||||
npm install --save @babel/helper-hoist-variables
|
||||
```
|
||||
|
||||
## API
|
||||
or using yarn:
|
||||
|
||||
```javascript
|
||||
declare export default hoistVariables(path: NodePath, emit: Function, kind: "var" | "let" = "var");
|
||||
```sh
|
||||
yarn add --save @babel/helper-hoist-variables
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
TODO
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "@babel/helper-hoist-variables",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to hoist variables",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-hoist-variables",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/types": "7.0.0-beta.49"
|
||||
"@babel/types": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ const visitor = {
|
||||
}
|
||||
|
||||
for (const name in declar.getBindingIdentifiers()) {
|
||||
state.emit(t.identifier(name), name);
|
||||
state.emit(t.identifier(name), name, declar.node.init !== null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,75 +1,19 @@
|
||||
# @babel/helper-member-expression-to-functions
|
||||
|
||||
Helper function to replace certain member expressions with function calls
|
||||
> Helper function to replace certain member expressions with function calls
|
||||
|
||||
## Usage
|
||||
See our website [@babel/helper-member-expression-to-functions](https://new.babeljs.io/docs/en/next/babel-helper-member-expression-to-functions.html) for more information.
|
||||
|
||||
> Designed for internal Babel use.
|
||||
## Install
|
||||
|
||||
Traverses the `path` using the supplied `visitor` and an augmented `state`.
|
||||
Using npm:
|
||||
|
||||
```js
|
||||
const visitor = {
|
||||
MemberExpression(memberPath, state) {
|
||||
|
||||
if (someCondition(memberPath)) {
|
||||
|
||||
// The handle method is supplied by memberExpressionToFunctions.
|
||||
// It should be called whenever a MemberExpression should be
|
||||
// converted into the proper function calls.
|
||||
state.handle(memberPath);
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
// The helper requires three special methods on state: `get`, `set`, and
|
||||
// `call`.
|
||||
// Optionally, a special `memoise` method may be defined, which gets
|
||||
// called if the member is in a self-referential update expression.
|
||||
// Everything else will be passed through as normal.
|
||||
const state = {
|
||||
get(memberPath) {
|
||||
// Return some AST that will get the member
|
||||
return t.callExpression(
|
||||
this.file.addHelper('superGet'),
|
||||
[t.thisExpression(), memberPath.node.property]
|
||||
);
|
||||
},
|
||||
|
||||
set(memberPath, value) {
|
||||
// Return some AST that will set the member
|
||||
return t.callExpression(
|
||||
this.file.addHelper('superSet'),
|
||||
[t.thisExpression(), memberPath.node.property, value]
|
||||
);
|
||||
},
|
||||
|
||||
call(memberPath, args) {
|
||||
// Return some AST that will call the member with the proper context
|
||||
// and args
|
||||
return t.callExpression(
|
||||
t.memberExpression(this.get(memberPath), t.identifier("apply")),
|
||||
[t.thisExpression(), t.arrayExpression(args)]
|
||||
);
|
||||
},
|
||||
|
||||
memoise(memberPath) {
|
||||
const { node } = memberPath;
|
||||
if (node.computed) {
|
||||
MEMOISED.set(node, ...);
|
||||
}
|
||||
},
|
||||
|
||||
// The handle method is provided by memberExpressionToFunctions.
|
||||
// handle(memberPath) { ... }
|
||||
|
||||
// Other state stuff is left untouched.
|
||||
someState: new Set(),
|
||||
};
|
||||
|
||||
// Replace all the special MemberExpressions in rootPath, as determined
|
||||
// by our visitor, using the state methods.
|
||||
memberExpressionToFunctions(rootPath, visitor, state);
|
||||
```sh
|
||||
npm install --save @babel/helper-member-expression-to-functions
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-member-expression-to-functions
|
||||
```
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@babel/helper-member-expression-to-functions",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to replace certain member expressions with function calls",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-member-expression-to-functions",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"author": "Justin Ridgewell <justin@ridgewell.name>",
|
||||
"dependencies": {
|
||||
"@babel/types": "7.0.0-beta.49"
|
||||
"@babel/types": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,77 +1,19 @@
|
||||
# @babel/helper-module-imports
|
||||
|
||||
## Installation
|
||||
> Babel helper functions for inserting module loads
|
||||
|
||||
See our website [@babel/helper-module-imports](https://new.babeljs.io/docs/en/next/babel-helper-module-imports.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install @babel/helper-module-imports --save
|
||||
npm install --save @babel/helper-module-imports
|
||||
```
|
||||
|
||||
## Usage
|
||||
or using yarn:
|
||||
|
||||
### `import "source"`
|
||||
|
||||
```js
|
||||
import { addSideEffect } from "@babel/helper-module-imports";
|
||||
addSideEffect(path, 'source');
|
||||
```
|
||||
|
||||
### `import { named } from "source"`
|
||||
|
||||
```js
|
||||
import { addNamed } from "@babel/helper-module-imports";
|
||||
addNamed(path, 'named', 'source');
|
||||
```
|
||||
|
||||
### `import { named as _hintedName } from "source"`
|
||||
|
||||
```js
|
||||
import { addNamed } from "@babel/helper-module-imports";
|
||||
addNamed(path, 'named', 'source', { nameHint: "hintedName" });
|
||||
```
|
||||
|
||||
### `import _default from "source"`
|
||||
|
||||
```js
|
||||
import { addDefault } from "@babel/helper-module-imports";
|
||||
addDefault(path, 'source');
|
||||
```
|
||||
|
||||
### `import hintedName from "source"`
|
||||
|
||||
```js
|
||||
import { addDefault } from "@babel/helper-module-imports";
|
||||
addDefault(path, 'source', { nameHint: "hintedName" })
|
||||
```
|
||||
|
||||
### `import * as _namespace from "source"`
|
||||
|
||||
```js
|
||||
import { addNamespace } from "@babel/helper-module-imports";
|
||||
addNamespace(path, 'source');
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Adding a named import
|
||||
|
||||
```js
|
||||
import { addNamed } from "@babel/helper-module-imports";
|
||||
|
||||
export default function({ types: t }) {
|
||||
return {
|
||||
visitor: {
|
||||
ReferencedIdentifier(path) {
|
||||
let importName = this.importName;
|
||||
if (importName) {
|
||||
importName = t.cloneDeep(importName);
|
||||
} else {
|
||||
// require('bluebird').coroutine
|
||||
importName = this.importName = addNamed(path, 'coroutine', 'bluebird');
|
||||
}
|
||||
|
||||
path.replaceWith(importName);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
```sh
|
||||
yarn add --save @babel/helper-module-imports
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-module-imports",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Babel helper functions for inserting module loads",
|
||||
"author": "Logan Smyth <loganfsmyth@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -8,10 +8,10 @@
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-module-imports",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/types": "7.0.0-beta.49",
|
||||
"@babel/types": "7.0.0-beta.50",
|
||||
"lodash": "^4.17.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.0.0-beta.49"
|
||||
"@babel/core": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# @babel/helper-module-transforms
|
||||
|
||||
## Usage
|
||||
> Babel helper functions for implementing ES6 module transformations
|
||||
|
||||
TODO
|
||||
See our website [@babel/helper-module-transforms](https://new.babeljs.io/docs/en/next/babel-helper-module-transforms.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-module-transforms
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-module-transforms
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-module-transforms",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Babel helper functions for implementing ES6 module transformations",
|
||||
"author": "Logan Smyth <loganfsmyth@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -8,11 +8,11 @@
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-module-transforms",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/helper-module-imports": "7.0.0-beta.49",
|
||||
"@babel/helper-simple-access": "7.0.0-beta.49",
|
||||
"@babel/helper-split-export-declaration": "7.0.0-beta.49",
|
||||
"@babel/template": "7.0.0-beta.49",
|
||||
"@babel/types": "7.0.0-beta.49",
|
||||
"@babel/helper-module-imports": "7.0.0-beta.50",
|
||||
"@babel/helper-simple-access": "7.0.0-beta.50",
|
||||
"@babel/helper-split-export-declaration": "7.0.0-beta.50",
|
||||
"@babel/template": "7.0.0-beta.50",
|
||||
"@babel/types": "7.0.0-beta.50",
|
||||
"lodash": "^4.17.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# @babel/helper-optimise-call-expression
|
||||
|
||||
## Usage
|
||||
> Helper function to optimise call expression
|
||||
|
||||
TODO
|
||||
See our website [@babel/helper-optimise-call-expression](https://new.babeljs.io/docs/en/next/babel-helper-optimise-call-expression.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-optimise-call-expression
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-optimise-call-expression
|
||||
```
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "@babel/helper-optimise-call-expression",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to optimise call expression",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-optimise-call-expression",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/types": "7.0.0-beta.49"
|
||||
"@babel/types": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
# @babel/helper-plugin-test-runner
|
||||
|
||||
**NOTE:** This is an internal Babel module and may not work outside. Use at your own risk.
|
||||
> Helper function to support test runner
|
||||
|
||||
## Usage:
|
||||
See our website [@babel/helper-plugin-test-runner](https://new.babeljs.io/docs/en/next/babel-helper-plugin-test-runner.html) for more information.
|
||||
|
||||
> Check Babel for an example: https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-exponentiation-operator/test
|
||||
## Install
|
||||
|
||||
1. Inside a `/test` directory, add an `index.js` with the contents
|
||||
```js
|
||||
import runner from "@babel/helper-plugin-test-runner";
|
||||
Using npm:
|
||||
|
||||
runner(__dirname);
|
||||
```sh
|
||||
npm install --save @babel/helper-plugin-test-runner
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-plugin-test-runner
|
||||
```
|
||||
2. Inside `/test/fixtures`, create a folder for each suite (eg; one suite for each feature of your plugin).
|
||||
3. Suite folders may contain files and folders. Files will be transformed and run; use `expect()` assertions to verify correct behavior. Folders may contain `input.js`, `output.js`, and/or `exec.js`. The output of transforming `input.js` will be checked to match the contents of `output.js`. `exec.js`, if it exists, will be transformed and run, as with a file in the suite folder.
|
||||
3. To run a specific test, run `TEST_GREP=testName make test`. [Read more](https://github.com/babel/babel/blob/master/CONTRIBUTING.md#running-lintingtests).
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "@babel/helper-plugin-test-runner",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to support test runner",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-plugin-test-runner",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/helper-transform-fixture-test-runner": "7.0.0-beta.49"
|
||||
"@babel/helper-transform-fixture-test-runner": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,41 +1,19 @@
|
||||
# @babel/helper-plugin-utils
|
||||
|
||||
The intention of this module is to provide a place for us to expose a
|
||||
standardized API layer over top of what Babel's core API provides on its own.
|
||||
> General utilities for plugins to use
|
||||
|
||||
This is not aiming to implement APIs that are missing on a given Babel version,
|
||||
but it is means to provide clear error messages if a plugin is run on a version
|
||||
of Babel that doesn't have the APIs that the plugin is trying to use.
|
||||
See our website [@babel/helper-plugin-utils](https://new.babeljs.io/docs/en/next/babel-helper-plugin-utils.html) for more information.
|
||||
|
||||
Every one of Babel's core plugins and presets will use this module, and ideally
|
||||
because of that its size should be kept to a miminum because this may or may
|
||||
not be deduplicated when installed.
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import { declare } from "@babel/helper-plugin-utils";
|
||||
|
||||
export default declare((api, options, dirname) => {
|
||||
return {};
|
||||
});
|
||||
```sh
|
||||
npm install --save @babel/helper-plugin-utils
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
## What this does
|
||||
|
||||
Currently, this plugin provides a few services to ensure that plugins function
|
||||
well-enough to throw useful errors.
|
||||
|
||||
### `options` is always passed
|
||||
|
||||
Babel 6 does not pass a second parameter. This frequently means that plugins
|
||||
written for Babel 7 that use `options` will attempt to destructure options
|
||||
out of an `undefined` value. By supplying the default, we avoid that risk.
|
||||
|
||||
### `api.assertVersion` always exists
|
||||
|
||||
Babel 6 and early betas of Babel 7 do not have `assertVersion`, so this
|
||||
wrapper ensures that it exists and throws a useful error message when not
|
||||
supplied by Babel itself.
|
||||
```sh
|
||||
yarn add --save @babel/helper-plugin-utils
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-plugin-utils",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "General utilities for plugins to use",
|
||||
"author": "Logan Smyth <loganfsmyth@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# @babel/helper-regex
|
||||
|
||||
## Usage
|
||||
> Helper function to check for literal RegEx
|
||||
|
||||
TODO
|
||||
See our website [@babel/helper-regex](https://new.babeljs.io/docs/en/next/babel-helper-regex.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-regex
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-regex
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-regex",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to check for literal RegEx",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-regex",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# @babel/helper-remap-async-to-generator
|
||||
|
||||
## Usage
|
||||
> Helper function to remap async functions to generators
|
||||
|
||||
TODO
|
||||
See our website [@babel/helper-remap-async-to-generator](https://new.babeljs.io/docs/en/next/babel-helper-remap-async-to-generator.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-remap-async-to-generator
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-remap-async-to-generator
|
||||
```
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
{
|
||||
"name": "@babel/helper-remap-async-to-generator",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to remap async functions to generators",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-remap-async-to-generator",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/helper-annotate-as-pure": "7.0.0-beta.49",
|
||||
"@babel/helper-wrap-function": "7.0.0-beta.49",
|
||||
"@babel/template": "7.0.0-beta.49",
|
||||
"@babel/traverse": "7.0.0-beta.49",
|
||||
"@babel/types": "7.0.0-beta.49"
|
||||
"@babel/helper-annotate-as-pure": "7.0.0-beta.50",
|
||||
"@babel/helper-wrap-function": "7.0.0-beta.50",
|
||||
"@babel/template": "7.0.0-beta.50",
|
||||
"@babel/traverse": "7.0.0-beta.50",
|
||||
"@babel/types": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# @babel/helper-replace-supers
|
||||
|
||||
## Usage
|
||||
> Helper function to replace supers
|
||||
|
||||
TODO
|
||||
See our website [@babel/helper-replace-supers](https://new.babeljs.io/docs/en/next/babel-helper-replace-supers.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-replace-supers
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-replace-supers
|
||||
```
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "@babel/helper-replace-supers",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper function to replace supers",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-replace-supers",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/helper-member-expression-to-functions": "7.0.0-beta.49",
|
||||
"@babel/helper-optimise-call-expression": "7.0.0-beta.49",
|
||||
"@babel/traverse": "7.0.0-beta.49",
|
||||
"@babel/types": "7.0.0-beta.49"
|
||||
"@babel/helper-member-expression-to-functions": "7.0.0-beta.50",
|
||||
"@babel/helper-optimise-call-expression": "7.0.0-beta.50",
|
||||
"@babel/traverse": "7.0.0-beta.50",
|
||||
"@babel/types": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,19 @@
|
||||
# @babel/helper-simple-assignment
|
||||
# @babel/helper-simple-access
|
||||
|
||||
There are many cases where it is hard to perform transformations because a
|
||||
piece of code is using complex structures. Say you want to rewrite all accesses
|
||||
to a given variable, and there are cases like
|
||||
> Babel helper for ensuring that access to a given value is performed through simple accesses
|
||||
|
||||
```
|
||||
i += 1
|
||||
--i;
|
||||
See our website [@babel/helper-simple-access](https://new.babeljs.io/docs/en/next/babel-helper-simple-access.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-simple-access
|
||||
```
|
||||
|
||||
It is difficult to work with.
|
||||
|
||||
This helper can handle converting these to simple access patterns of standard
|
||||
assignment. This plugin does _not_ handle
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-simple-access
|
||||
```
|
||||
{ a } = foo;
|
||||
```
|
||||
|
||||
so assignment to patterns still needs to be handled when you are processing
|
||||
updates to values.
|
||||
|
||||
## Usage
|
||||
|
||||
TODO
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-simple-access",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Babel helper for ensuring that access to a given value is performed through simple accesses",
|
||||
"author": "Logan Smyth <loganfsmyth@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -8,8 +8,8 @@
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-simple-access",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/template": "7.0.0-beta.49",
|
||||
"@babel/types": "7.0.0-beta.49",
|
||||
"@babel/template": "7.0.0-beta.50",
|
||||
"@babel/types": "7.0.0-beta.50",
|
||||
"lodash": "^4.17.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
# @babel/helper-split-export-declaration
|
||||
|
||||
## API
|
||||
>
|
||||
|
||||
```js
|
||||
declare export default splitExportDeclaration(path: NodePath);
|
||||
See our website [@babel/helper-split-export-declaration](https://new.babeljs.io/docs/en/next/babel-helper-split-export-declaration.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-split-export-declaration
|
||||
```
|
||||
|
||||
## Usage
|
||||
or using yarn:
|
||||
|
||||
```js
|
||||
import traverse from "@babel/traverse";
|
||||
import splitExportDeclaration from "@babel/helper-split-export-declaration";
|
||||
|
||||
// ...
|
||||
|
||||
traverse(file, {
|
||||
ExportDefaultDeclaration(path) {
|
||||
if (!path.get("declaration").isClassDeclaration()) return;
|
||||
splitExportDeclaration(path);
|
||||
},
|
||||
});
|
||||
```sh
|
||||
yarn add --save @babel/helper-split-export-declaration
|
||||
```
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "@babel/helper-split-export-declaration",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-split-export-declaration",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/types": "7.0.0-beta.49"
|
||||
"@babel/types": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
# @babel/helper-transform-fixture-test-runner
|
||||
|
||||
**NOTE:** This is an internal Babel module and may not work outside. Use at your own risk.
|
||||
> Transform test runner for @babel/helper-fixtures module
|
||||
|
||||
## Usage
|
||||
See our website [@babel/helper-transform-fixture-test-runner](https://new.babeljs.io/docs/en/next/babel-helper-transform-fixture-test-runner.html) for more information.
|
||||
|
||||
```javascript
|
||||
import runFixtures from "@babel/helper-transform-fixture-test-runner";
|
||||
## Install
|
||||
|
||||
runFixtures("/User/sebmck/Projects/babel-something/test/fixtures");
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-transform-fixture-test-runner
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add --save @babel/helper-transform-fixture-test-runner
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-transform-fixture-test-runner",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Transform test runner for @babel/helper-fixtures module",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -8,10 +8,10 @@
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-transform-fixture-test-runner",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "7.0.0-beta.49",
|
||||
"@babel/core": "7.0.0-beta.49",
|
||||
"@babel/helper-fixtures": "7.0.0-beta.49",
|
||||
"@babel/polyfill": "7.0.0-beta.49",
|
||||
"@babel/code-frame": "7.0.0-beta.50",
|
||||
"@babel/core": "7.0.0-beta.50",
|
||||
"@babel/helper-fixtures": "7.0.0-beta.50",
|
||||
"@babel/polyfill": "7.0.0-beta.50",
|
||||
"jest": "^22.4.2",
|
||||
"jest-diff": "^22.4.0",
|
||||
"lodash": "^4.17.5",
|
||||
|
||||
@@ -62,12 +62,10 @@ function runModuleInTestContext(id: string, relativeFilename: string) {
|
||||
const src = fs.readFileSync(filename, "utf8");
|
||||
const code = `(function (exports, require, module, __filename, __dirname) {${src}\n});`;
|
||||
|
||||
vm
|
||||
.runInContext(code, testContext, {
|
||||
filename,
|
||||
displayErrors: true,
|
||||
})
|
||||
.call(module.exports, module.exports, req, module, filename, dirname);
|
||||
vm.runInContext(code, testContext, {
|
||||
filename,
|
||||
displayErrors: true,
|
||||
}).call(module.exports, module.exports, req, module, filename, dirname);
|
||||
|
||||
return module.exports;
|
||||
}
|
||||
|
||||
@@ -1,27 +1,19 @@
|
||||
# @babel/helper-wrap-function
|
||||
|
||||
This helper wraps a function within a call expression. It works with any function: statements, expressions and methods; both named and anonymous.
|
||||
> Helper to wrap functions inside a function call.
|
||||
|
||||
## Example
|
||||
See our website [@babel/helper-wrap-function](https://new.babeljs.io/docs/en/next/babel-helper-wrap-function.html) for more information.
|
||||
|
||||
**In**
|
||||
## Install
|
||||
|
||||
```js
|
||||
(function () {
|
||||
}());
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-wrap-function
|
||||
```
|
||||
|
||||
**Out**
|
||||
or using yarn:
|
||||
|
||||
```js
|
||||
_wrapper(function () {
|
||||
})();
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import wrapFunction from "@babel/helper-wrap-function";
|
||||
|
||||
wrapFunction(nodePathOfTheFunction, nodeWhichReferencesToTheWrapper);
|
||||
```sh
|
||||
yarn add --save @babel/helper-wrap-function
|
||||
```
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "@babel/helper-wrap-function",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Helper to wrap functions inside a function call.",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-wrap-function",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/helper-function-name": "7.0.0-beta.49",
|
||||
"@babel/template": "7.0.0-beta.49",
|
||||
"@babel/traverse": "7.0.0-beta.49",
|
||||
"@babel/types": "7.0.0-beta.49"
|
||||
"@babel/helper-function-name": "7.0.0-beta.50",
|
||||
"@babel/template": "7.0.0-beta.50",
|
||||
"@babel/traverse": "7.0.0-beta.50",
|
||||
"@babel/types": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,55 +2,18 @@
|
||||
|
||||
> Collection of helper functions used by Babel transforms.
|
||||
|
||||
See our website [@babel/helpers](https://new.babeljs.io/docs/en/next/babel-helpers.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/helpers
|
||||
npm install --save @babel/helpers
|
||||
```
|
||||
|
||||
## Usage
|
||||
or using yarn:
|
||||
|
||||
Direct:
|
||||
|
||||
```js
|
||||
import * as helpers from '@babel/helpers';
|
||||
import * as t from '@babel/types';
|
||||
|
||||
const typeofHelper = helpers.get('typeof');
|
||||
|
||||
t.isExpressionStatement(typeofHelper);
|
||||
// true
|
||||
```
|
||||
|
||||
Inside a plugin:
|
||||
|
||||
```js
|
||||
export default {
|
||||
visitor: {
|
||||
UnaryExpression(path) {
|
||||
// The .addHelper function adds, if needed, the helper to the file
|
||||
// and returns an expression which references the helper
|
||||
const typeofHelper = this.addHelper("typeof");
|
||||
t.isExpression(typeofHelper); // true
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
## Defining Helpers
|
||||
|
||||
> **NOTE**: This package is only meant to be used by the packages inluded in this repository. There is currently no way for third-party plugins to define an helper.
|
||||
|
||||
Helpers are defined in the `src/helpers.js` file, and they must be valid modules which follow these guidelines:
|
||||
- They must have a default export, which is their entry-point.
|
||||
- They can import other helpers, exclusively by using default imports.
|
||||
- They can't have named exports.
|
||||
|
||||
```js
|
||||
helpers.customHelper = defineHelper(`
|
||||
import dep from "dependency";
|
||||
const foo = 2;
|
||||
export default function getFooTimesDepPlusX(x) {
|
||||
return foo * dep() + x;
|
||||
}
|
||||
`);
|
||||
```sh
|
||||
yarn add --save @babel/helpers
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helpers",
|
||||
"version": "7.0.0-beta.49",
|
||||
"version": "7.0.0-beta.50",
|
||||
"description": "Collection of helper functions used by Babel transforms.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -8,11 +8,11 @@
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helpers",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/template": "7.0.0-beta.49",
|
||||
"@babel/traverse": "7.0.0-beta.49",
|
||||
"@babel/types": "7.0.0-beta.49"
|
||||
"@babel/template": "7.0.0-beta.50",
|
||||
"@babel/traverse": "7.0.0-beta.50",
|
||||
"@babel/types": "7.0.0-beta.50"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-plugin-test-runner": "7.0.0-beta.49"
|
||||
"@babel/helper-plugin-test-runner": "7.0.0-beta.50"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,7 +449,7 @@ helpers.construct = () => template.program.ast`
|
||||
if (Reflect.construct.sham) return false;
|
||||
|
||||
// Proxy can't be polyfilled. Every browser implemented
|
||||
// proxies before or at the same time of Reflect.construct,
|
||||
// proxies before or at the same time as Reflect.construct,
|
||||
// so if they support Proxy they also support Reflect.construct.
|
||||
if (typeof Proxy === "function") return true;
|
||||
|
||||
@@ -488,8 +488,8 @@ helpers.construct = () => template.program.ast`
|
||||
|
||||
// Based on https://github.com/WebReflection/babel-plugin-transform-builtin-classes
|
||||
helpers.wrapNativeSuper = () => template.program.ast`
|
||||
import _gPO from "getPrototypeOf";
|
||||
import _sPO from "setPrototypeOf";
|
||||
import getPrototypeOf from "getPrototypeOf";
|
||||
import setPrototypeOf from "setPrototypeOf";
|
||||
import construct from "construct";
|
||||
|
||||
export default function _wrapNativeSuper(Class) {
|
||||
@@ -505,7 +505,7 @@ helpers.wrapNativeSuper = () => template.program.ast`
|
||||
_cache.set(Class, Wrapper);
|
||||
}
|
||||
function Wrapper() {
|
||||
return _construct(Class, arguments, _gPO(this).constructor)
|
||||
return construct(Class, arguments, getPrototypeOf(this).constructor)
|
||||
}
|
||||
Wrapper.prototype = Object.create(Class.prototype, {
|
||||
constructor: {
|
||||
@@ -516,7 +516,7 @@ helpers.wrapNativeSuper = () => template.program.ast`
|
||||
}
|
||||
});
|
||||
|
||||
return _sPO(Wrapper, Class);
|
||||
return setPrototypeOf(Wrapper, Class);
|
||||
}
|
||||
|
||||
return _wrapNativeSuper(Class)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user