diff --git a/packages/babel-core/README.md b/packages/babel-core/README.md index 5b2f4d53d1..ebff1f1837 100644 --- a/packages/babel-core/README.md +++ b/packages/babel-core/README.md @@ -108,8 +108,8 @@ Following is a table of the options you can use: | `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, babylon | -| `plugins` | `[]` | List of [plugins](/docs/plugins/) to load and use. | -| `presets` | `[]` | List of [presets](/docs/plugins/#presets) (a set of plugins) to load and use. | +| `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) | | `resolveModuleSource` | `null` | Resolve a module source ie. `import "SOURCE";` to a custom value. Called as `resolveModuleSource(source, filename)`. | | `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. | diff --git a/packages/babel-generator/README.md b/packages/babel-generator/README.md index b71ee3c14f..016a1af985 100644 --- a/packages/babel-generator/README.md +++ b/packages/babel-generator/README.md @@ -37,6 +37,7 @@ minified | boolean | `false` | Should the output be minif 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 diff --git a/packages/babel-plugin-transform-es2015-function-name/test/fixtures/function-name/await/actual.js b/packages/babel-plugin-transform-es2015-function-name/test/fixtures/function-name/await/actual.js new file mode 100644 index 0000000000..8f9c647db8 --- /dev/null +++ b/packages/babel-plugin-transform-es2015-function-name/test/fixtures/function-name/await/actual.js @@ -0,0 +1,3 @@ +export {}; + +var obj = { await: function () {} }; diff --git a/packages/babel-plugin-transform-es2015-function-name/test/fixtures/function-name/await/expected.js b/packages/babel-plugin-transform-es2015-function-name/test/fixtures/function-name/await/expected.js new file mode 100644 index 0000000000..4289b26aa5 --- /dev/null +++ b/packages/babel-plugin-transform-es2015-function-name/test/fixtures/function-name/await/expected.js @@ -0,0 +1,3 @@ +export {}; + +var obj = { await: function _await() {} }; \ No newline at end of file diff --git a/packages/babel-types/src/validators.js b/packages/babel-types/src/validators.js index c5f25327bd..dc8143ae9d 100644 --- a/packages/babel-types/src/validators.js +++ b/packages/babel-types/src/validators.js @@ -167,6 +167,9 @@ export function isReferenced(node: Object, parent: Object): boolean { export function isValidIdentifier(name: string): boolean { if (typeof name !== "string" || esutils.keyword.isReservedWordES6(name, true)) { return false; + } else if (name === "await") { + // invalid in module, valid in script; better be safe (see #4952) + return false; } else { return esutils.keyword.isIdentifierNameES6(name); } diff --git a/packages/babel-types/test/validators.js b/packages/babel-types/test/validators.js index 2e7e55d085..ccc83f665b 100644 --- a/packages/babel-types/test/validators.js +++ b/packages/babel-types/test/validators.js @@ -26,5 +26,9 @@ suite("validators", function () { assert(t.isNodesEquivalent(parse(program), parse(program2)) === false); }); + + it("rejects 'await' as an identifier", function () { + assert(t.isValidIdentifier("await") === false); + }); }); });