* grammar correction of an option description
(missed in #10589)
* changed description to be consistent with others
Co-Authored-By: Huáng Jùnliàng <jlhwung@gmail.com>
* ran prettier
* [parser] Add support for TS declare modifier on fields (#10484)
* [parser] Add support for TS declare modifier on fields
* Use Object.create(null)
* Comment
* Add support for TS declare types to types and generator (#10544)
* Transform TypeScript "declare" fields (#10546)
* Transform TypeScript "declare" fields
* Remove multiple spaces
* declareFields -> allowDeclareFields
* Update after rebase
* Add error recovery support to @babel/parser
* Update @babel/parser tests to always recover from errors
* Update this.raise usage in @babel/parser:
- expression.js
- lval.js
- statement.js
- estree.js
- flow.js
- jsx/index.js
- tokenizer/index.js
* Update @babel/parser fixtures with recovered errors
* Fix tests out of @babel/parser
* Do not use try/catch for control flow
* Update invalid fixtures
* Do not report invalid lhs in toAssignable
* Do not validate function id multiple times
* Dedupe reserved await errors
* Remove duplicate errors about strict reserved bindings
* Remove duplicated error about yield/await inside params
* Don't error twice for methods in object patterns
* Don't report invalid super() twice
* Remove dup error about reserved param for expr arrows
* Remove double escapes in migrated tests
* Dedupe errors about invalid escapes in identifiers
* Remove duplicated error about decorated constructor
* Remove duplicated error about spread in flow class
* Don't throw for invalid super usage
* Don't fail for object decorators with stage 2
* Fix flow inexact type errors
* Fix flow
* Fix errors about escapes in keywords (ref: #10455)
* Update after rebase
* Fix todo
* Remove duplicated error when using += for defaults
* Remove unnecessary throw
* Nit: use ??
This PR allows legacy decorators to work with strict class fields, which
are now stage 3 and have shipped in a number of browsers. Allowing this will
allow users of the legacy transform (which is currently recommended by the
champions of the decorator proposal) to use the proper class field semantics
for non-decorated fields, which should help prevent breakage later on.
This change is not a breaking change, since users had to explicitly opt into
loose mode in class fields before. This just gives them the option to remove
that opt-in.
* [transform-react-jsx] Add useSpread option to transform JSX
* Add validation for default option
* Add error when using useSpread and useBuiltIns at the same time
* Move useSpread to convertAttribute helper function
* Add useSpread option to presect-react
* Remove casting useSpread to boolean in preset-react option.
Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
* feat: implement create-regexp-features-plugin
* fix: test input is not effective
* refactor: leverage create-regexp-features-plugin
* test: add more test cases
* test: update test fixture
* chore: add type annotation to features
* test: add regression test for issue 9892
* add regression test for issue 9199
* address review comments from Nicolò
* address review comments from Brian
* small tweaks
* Enable dotAllFlag when flags includes u
* Flow enums parsing
* Parse exporting enums
* Enums parsing remove lookahead, other improvements
* Enums: add EnumBody and EnumMember aliases, change boolean members to use BooleaLiteral value
* Fix enum member init flow type, now that boolean members have a BooleanLiteral value
* Flow enums: use contextual utils, change members length checks to use logic operators, remove reserved word logic modification
* Flow enums: remove unnecessary code in generator, fix error message
* 🐛 fixed missing errors on assignment pattern in object expression
* ♻️ remove a non-needed comment
* 🐛 missed adding comma in the test input
* 🐛 fixed the failing valid-property-initializer test
* Changes UMD callsite to be more likely to pass in the intended object.
Fixes#10476
Note: This PR should be considered pseudocode and used as an illustration of the proposed fix. I do not know nearly enough about this project to know if this is an appropriate solution to the problem, nor do I have the confidence to update the tests appropriately.
* Update tests
* Make dir for babel --out-file
Currently there's unexpected regression after upgrade from babel 6.
On creating file with any depth like dist/index.js the error about
not existing directory is thrown.
In this diff I modified babel-cli to create deep directory for out-file
command.
I also replaced `mkdirp` with more supported `make-dir` package which
also have official promise support.
* Fix test
* fix: [#10561] _interopRequireWildcard should cache object only
* fix: narrow down cache restriction to object/function type
* test: add interop require null module case
* docs: add homepage link
Adds a homepage link to populate npmjs.com.
Update the repository property syntax.
* Update the repository link
Point to the root repo plus a reference to the subdirectory.
* style: drop HTML extension
The results of these tests will be stored in build artifacts which will be used to compare with test262 runs on PR (future work!). Robin has also done a
lot of work to ensure all babel packages are properly linked to the
test runner. Additionally, Nicolo has helped in mentorship and
contributions to babel-test262-runner which is used here.
We're no longer giving xunit output to CircleCI because once it sees failing tests it will mark babel's master as broken. As a stopgap, it will render the test results in the mocha spec format, which is human readable.
Co-Authored-By: Robin Ricard <rricard2@bloomberg.net>
Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
* Exclude catch clause from let identifier error
* Disallow let binding based on parameter
* Add test
* Remove unused getter
* Update packages/babel-parser/src/parser/statement.js
Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
* fix: disable caching when babel could not read/write cache
* emit warning when cache folder resides in readonly fs
* fix: always register save handler
* cache: maintain old behaviour
* test: add more test case
* fix: next tick tasks are FIFO
* test: disable test on Windows
* Inject corejs3 imports in Program:exit instead of post
This allows them to be requeued and transformed by other plugins.
* Also entry
* Rebase
* Update packages/babel-preset-env/src/polyfills/corejs3/entry-plugin.js [skip ci]
Co-Authored-By: Brian Ng <bng412@gmail.com>
For some reason, it looks like that the rimraf call didn't properly delete
the folder:
EEXIST: file already exists, mkdir 'C:\Users\travis\build\babel\babel\packages\babel-node\test\tmp'
150 | process.chdir(__dirname);
151 | if (fs.existsSync(tmpLoc)) rimraf.sync(tmpLoc);
> 152 | fs.mkdirSync(tmpLoc);
| ^
153 | process.chdir(tmpLoc);
154 | };
Lets try to reuse the existing folder rather than deleting and recreating it
* Allow duplicate __proto__ keys in patterns, simple case (#6705)
* Update test262 whitelist
* Rename checkDuplicatedProto's parameter and adjust type
* Store first __proto__ redefinition's position
* Don't use args rest/spread to hoist super method calls
* Hoist this in hoisted super method calls
* Make the code more readable
Review by edoardocavazza
* fix: should not remove let binding even it is wrapped in closure
Fixes#10339
* fix: remove bindings defined in blockScope when wrapped in closure
* Move test assertions to the top level to ensure that they run
This adds lots of missing declarations to the types of @babel/types,
including many utility functions useful to plugin authors.
With the typescript types, I tried to make them as useful as possible
for control flow analysis / inference, but Flow doesn't seem to
support overloads and I'm not as familiar with it anyway so it has
simpler types.
* build: add build-babel-types task
* chore: revamp Makefile to for parallel builds
* chore: style fix
* chore: skip install step as we handle yarn in makefile
* test job execution order
When users see errors like
```
Duplicate plugin/preset detected.
If you'd like to use two separate instances of a plugin,
they need separate names, e.g.
plugins: [
['some-plugin', {}],
['some-plugin', {}, 'some unique name'],
]
```
It can be difficult to determine the source of the conflict, especially
in a larger build system.
This commit outputs what is known about the plugins that actually
conflict, which can be helpful for users to determine the root cause of
the conflict.
Partially addresses #9778
* fix: typo
* declare name for flow interface
* add test case for export overload function, typescript
* test: add test
Fixes#10044
* test: update test
* test(flow): add multiple declarations regression test
* re-enable flow test case
# Conflicts:
# packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/def-site-variance/input.js
# packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-declare-statements/input.js
# packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-interfaces-module-and-script/input.js
# packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-iterator/input.js
* test: disable two flow dupl-decl test
* fix: do not declare name for declare function until we figure out a better way
* test: duplicate declare function and function would not throw
* Add windows to travis
* Update
* Do not use sh file on windows
* Fix whitespace
* Unify command
* ./ doesn't work on windows
* Remove all ./ usages
* Run windows test before others
* fix: normalize filename when generating sources
sources should be URL.
* fix: replace normalized path to cwd
* chore: add nodePlatform task options
* fix: normalize preset-env filename output
* chore: replace normalized path to CWD on win32 platform
* limit transform-react-source to run on linux and darwin
* test: escapeRegExp on testcases
* test: add test for babel --filename on windows
* test: double babel-node/cli test timeout
* chore: workaround windows build does not stop
* chore: remove redundant condition
* refactor: rename `nodePlatform` to `os`
* Add test
* Add nonOctalDecimal verification
* Update regex and code style
* Refactor non octal detection
* Add numeric separator test
* Disallow numeric separators in non octals
* Update whitelist
* Better test naming
* Disallow numeric separators in non oct for all numbers
* Specific error above the general error
* Add test for invalid leading zero in num separator
* Add start position to error
* [parser] Disallow numeric separator in unicode scape sequences (#10460)
* raise error only when numeric separator plugin is set
* Adds argument for checking numeric separator
* Fix condition for readability
* Add test for hex escape sequence and rephrase error message
* Remove exposure for allowNumSeparator in readHexChar method
* 🚀 added check to disallow super.private variable access and test case added
* ♻️ change the other linting change back to how it was
* ♻️ change the other linting change back to how it was
* ♻️ added newline at the end test output.json file
* ♻️ changed the linting style to the way it was
* ♻️ updated error message, removed super private member access test cases from whitelist of flow and test 262 suite
* ♻️ added newline in output.json
* Disallow static fields named `constructor` in a class
- Disallowed static fields named `constructor` in a class (previously only non-static were disallowed)
- Updated the text for the error for one consolidated warning, for both static and non-static fields
- Added a test
- Updated an existing test in the `flow` test suite of the parser to reflect the parse error.
Strangely, the test used to pass and started failing when inlining the `isNonstaticConstructor` method, without any changes.
In that test, `constructor` was a field, so in theory it should never have passed.
Would appreciate some feedback on this, as I'm not 100% sure if this is somehow related to Flow
* Update test262 whitelist
* Add comment and fix && operator
Flow maybe types state;
> Maybe types accept the provided type as well as null or undefined. So ?number would mean number, null, or undefined.
So in this case, explicitly allow the type, null, or undefined in the
typescript definition.
Fixes#10403
* feat: v8intrinsic syntax plugin
Implement V8 Intrinsic Syntax Extension. Here we check the execution branch inside the parseSubscript to make sure the V8IntrinsicIdentifier is immediately followed by a call expression.
* feat: disable combining placeholders and v8intrisic
per https://github.com/babel/babel/issues/10104#issuecomment-506950969
* test: add more error cases
* refactor: parse v8 intrinsic in parseExprAtom
This approach is identical to V8’s implementation. Move the test cases as the behaviour changes.
* fix: plugin-name typo
* test: add yield-expression test case
* feat: require startsExpr on modulo for v8intrinsic
* perf: skip eof and braceR check as they must return false
* Print V8IntrinsicIdentifier
* feat: add v8intrinsic to parser typings
* Add generated type helpers
* fix: incorrect type definition
* fix: allow V8IntrinsicIdentifier to be callee
* ♻️ added condition to check for left and right of nullish coalescing operator and if any is a logical expression without a paren then throw an error
* 🐛 bugs fixed and test cases updated for babel parser
* ♻️ code comments added
* 🐛 spell error rectified
* ♻️ failing test updated
* 🐛 push tests after make build
* Skip nullish-coalescing flow precedence tests
They're now incorrect
* ♻️ error message updated, binop priority of other logical operators +1 from ?? and
* ♻️ increaed the binOp for in and instanceOf, added logic to print the brackets in an ?? && || expression, test cases added
* 🐛 failing test fixed and comments updated
* ♻️ new lines added between tests
* ♻️ basic tests for checking the binOp of instanceOf, in and relational operators to be equal added
* ♻️ new lines added in between tests
* fix: transform name capturing regex once
* refactor: early return when pattern contains only lookbehind
* chore: simplify test regex
* chore: run test on >=8.0.0
* Refactor trailing comment adjustment
Following up from https://github.com/babel/babel/pull/10369
- Unify the logic for adjusting trailing comments into a separate
function
- Use it for all three cases, which fixes a bug for ObjectExpressions
and CallExpressions
- Update tests to check for the fixed bug
* Fix tests
- Only modify trailingComments if necessary
- Update snapshots of a couple of affected tests
* Drop the underscore in adjustCommentsAfterTrailingComma_
* Handle ArrayPattern
* Handle ObjectPattern
* Handle import and export declarations
These have to be handled a bit differently, because the node is visited after the and before the declaration. So we intercept when we are going from the last specifier to the source node.
* Remove unnecessary check
* Retain trailing comments in array expressions
This is a proposed fix for https://github.com/babel/babel/issues/10368
with a simple test.
* Move lastElement in the block where it's used
* Test trailing comment after array expression
* Don't move comments after the array expression
* Retain trailing comment after the array expression
Eg, `namespace:foo.bar` used to parse but is invalid in the [spec](https://facebook.github.io/jsx/).
Also, allow `JSXNamespacedName` in the `JSXOpeningElement`/`JSXClosingElement` builders.
Instead of using `convert-source-map`'s `removeComments` method before
parsing the file, we can first parse the file with `@babel/parser` and then
analyze the comments.
This is needed because it is not possible to reliabily detect comments in
JavaScript without fully parsing the file:
https://github.com/thlorenz/convert-source-map/issues/63
* Fix issues in flow-comments to preserve comments and there order (fixes#10324)
* Add support in flow-comments for extends in class declarations (fixes#10323, #10321)
* Refactoring and cleanup of flow-comments plugin
* Fix comments preservation logic of flow-comments
* Fix flow-comments where comments are class identifier and extends keyword
* Add support for logs to transform-fixture-test-runner
* Test some warnings
* Use stderr/stdout, and add a validateLogs test option
* Normalize CWD in logs and rename vars
* Silence preset-env tests
* Restore old methods
* Adds note about two approval policy to PR template
* Adds qualifier to approval policy
Because, although two approvals is the general case, some PRs maybe merged with more or fewer approvals
[skip ci]
Adds a badge showing the number of people helping this repo on CodeTriage.
[](https://www.codetriage.com/babel/babel)
## What is CodeTriage?
CodeTriage is an Open Source app that is designed to make contributing to Open Source projects easier. It works by sending subscribers a few open issues in their inbox. If subscribers get busy, there is an algorithm that backs off issue load so they do not get overwhelmed
[Read more about the CodeTriage project](https://www.codetriage.com/what).
## Why am I getting this PR?
Your project was picked by the human, @schneems. They selected it from the projects submitted to https://www.codetriage.com and hand edited the PR. How did your project get added to [CodeTriage](https://www.codetriage.com/what)? Roughly over 3 years ago, [iamsolankiamit](https://github.com/iamsolankiamit) added this project to CodeTriage in order to start contributing. Since then, 94 people have subscribed to help this repo.
## What does adding a badge accomplish?
Adding a badge invites people to help contribute to your project. It also lets developers know that others are invested in the longterm success and maintainability of the project.
You can see an example of a CodeTriage badge on these popular OSS READMEs:
- [](https://www.codetriage.com/rails/rails) https://github.com/rails/rails
- [](https://www.codetriage.com/crystal-lang/crystal) https://github.com/crystal-lang/crystal
## Have a question or comment?
While I am a bot, this PR was manually reviewed and monitored by a human - @schneems. My job is writing commit messages and handling PR logistics.
If you have any questions, you can reply back to this PR and they will be answered by @schneems. If you do not want a badge right now, no worries, close the PR, you will not hear from me again.
Thanks for making your project Open Source! Any feedback is greatly appreciated.
* Improves the logic to import objects in helpers
* Modified to work with more cases.
* Modified by considering exception cases
* Fixed not using bundler's polyfill
Co-Authored-By: Jordan Harband <ljharb@gmail.com>
* Updated test output files
* Changes to cache logic
* Modified to use if statement
* Decorators legacy: register inserted declaration
For compatibility with the Typescript plugin
Fixes#10264
* Register declaration but also keep replaceWithMultiple
* lint fix
* switch inside do expression
* review comments
* review comments
* make min diff
* adding more test
* review changes
* review changes
* handle block statement and added more test cases
* fix implementation and add more test cases
* fix last swtich case
* disable block fallthrough case
* fix nitpick reviews
* added 'placeholders', 'logicalAssignment', 'partialApplication' to the ParserPlugin type. closes#10186
* put the ParserPlugin names in alphabetical order
* Add ";" token to the end of TS construct signature declaration
* Add ";" token to the end of TS call signature declaration. Update construct signature test fixtures
* Better tdz tests
- Use jest's expect.toThrow/expect.not.toThrow
- Add input/output tests
* Fix basic tdz (a = 2; let a)
Fixes#6848
* Make _guessExecutionStatusRelativeTo more robust
* Add tests
* Return less "unkown" execution status
* "function" execution status does not exist
* Fix recursive functions
* Update helper version
* "finally" blocks are always executed
* Typo
* destructuring private fields with array pattern / object pattern
* wip: new test cases
* destrucuring and rest for private properties
* test case for loose private-loose
* add transform-desturcturing for exec
* update test case
* remove getPrototypeOf imports from get and set
* wip: destructure super assignment
* throw "Destructuring to a super field is not supported yet."
* fix tests and fix assignment pattern
* remove CallExpression from AssignmentPattern
* Create @babel/plugin-proposal-dynamic-import
* Use airbnb/babel-plugin-dynamic-import-node
Do not duplicate code, which will unavoidably lead
to bugs being fixed in one plugin and not in the other.
* Update error message
* Add error callback to amd interop
* Update babel-plugin-dynamic-import-node
* Transform for F#-style await
Inludes support for optimizing single-parameter arrow functions
* Wait until optimization before pushing placeholder into scope
* [legacy decorators] Allow decorating generator methods
The old proposal used LeftHandSideExpression (instead of
AssignmentExpression) to satisfy this usecase:
e240cbc91a
* Update flow whitelist
* fix exportKind types declaration for ExportNamedDeclaration and DeclareExportAllDeclaration in babel-types
* revert `let` in exportKind in babel-parser types
* flow - allow type parameter defaults in function declarations
* fix flow test
* add intern_comments option
* fix flow parser test
* remove allowdefault from flowParseTypeParameterDeclaration
* rename test cases
* Change root package.json#name
I'm pretty sure GitHub's new Dependants feature is based on this package.json. I'm updating it here so it will reflect the new name for the core package.
* Update package.json
This also fixes enum not adding the respective declaration to the scope
during the typescript visitation.
Rewrites:
2080042808b18b005fb54aeaf9ab708f64cb1005 #9944
a6392bd636d07c41579ea5ab443152a09943e096 #10019
* test case for insertBefore for jsx
* fix unshiftContainer and insertBefore
* use path.scope.push
* add test making sure computedKeys var declaration at the right block
* add comment
* nit [skip ci]
This reverts commit 43b83f8ed7545b9c049eeed85541fa162842fb8f.
Fix objectSpread helper breaking old codes
remove tests to regenerate later
renamed output
new name
try using word
add comment as requested
revert inline name changes
add 2 for consistency
Update packages/babel-helpers/src/helpers.js
Co-Authored-By: Daniel Tschinder <daniel@tschinder.de>
* Fix location with optional params in arrow functions
* add test
* Ensure rollup replaces NODE_ENV and create sourcemap in dev
* Ensure finishNod*() is never called twice on a node
* Fix check for already finished nodes
* fix(typescript): erase type exports
* use Set instead of array for tracking and checking TS type declarations
* add a test for an interface exported before its declaration
* Fixed null error in plugin opts and added a test for it
* Remove !opts and add opts === null check to avoid confusion with false and undefined cases
Co-Authored-By: divbhasin <divbest99@gmail.com>
GitHub actions are too slow for this, it takes more than 15 mins.
Publishing to npm from GH actions is a cool idea, but it's a lot faster to
publish locally.
Also, I think that since when I introduced this action I
always killed it; either because it was to slow or because I had to
make some manual tweaks during the release.
* [parser] Allow plugins to extend ScopeHandler
* Directly extend Scope
* Don't use new.target to get the ScopeHandler
* [parser] Add TS enum support to the Scope
* Remove duplicated options in tests
* Fix
* Fix flow
* Rename tests
* Add tests
* Full typescript support in scope
* Remove BIND_SIMPLE_CATCH
SCOPE_SIMPLE_CATCH was used instead
* Export TS types
* Register function declarations
* Fix body-less functions and namespaces
1) Move this.scope.exit() for functions from parseFunctionBody to the callers.
Otherwise the scope of body-less functions was never closed.
Also, it is easier to track scope.exit() if it is near to scope.enter()
2) Register namespace ids for export
* Disallow redeclaration of enum with const enum
This PR fixes a bug in support of JSX pragma in Typescript (introduced in https://github.com/babel/babel/pull/9095).
We've noticed this bug while building a large codebase with webpack+babel+typescript. Some files from our projects are using `/** @jsx h*/` to use a custom function for JSX syntax; and some others are using the React syntax.
We've noticed that our react imports were being removed by babel because the plugin instance was being reused by `babel-loader` and webpack; and it was causing an error :
```
ReferenceError: React is not defined
```
This PR resets the `jsxPragma` being used to the initial value for each new file being processed.
I can't add a unit test for this bug because it requires processing 2 files (one with `/** @jsx something */` then one with the react syntax).
I've tested a build of this PR and it correctly fixes the issue for us.
* Fix super method call in private instance method calling overridden method
* Change return value in test fixtures
* Update tests to verify that overridden method is not called
This fixes an issue where destructuring assignments eligible for the "array unpacking" optimization would fail to compile when the array literal on the right-hand side of the expression contained holes.
Example input:
```js
[a, b] = [, 2];
; // Avoid completion record special case
```
The error message was `Property right of AssignmentExpression expected node to be of a type ["Expression"] but instead got null`.
Now the above code compiles to:
```js
a = void 0;
b = 2;
;
```
This PR also adds a couple of related test cases that were missing, to ensure the change doesn't regress them:
* Normal assignment expression with unpacking
* Declaration with unpacking and a hole on RHS
* @babel/traverse: Fix NodePath.getData
Currently, if the obtained value is `false`, it will be replaced by the given default value, which is invalid. This makes sure that we only set the default value when the value is `undefined`, instead of falsy.
* Add test and fix object protoype
* Allow false as default value
Currently, the "Trigger GitHub release" and "Publish to npm" actions
are run in parallel. Publishing to npm takes about 15 mins (it needs to
run `make bootstrap`), so everyone watching the npm repo for
releases would get the notification before that the new version is
available on npm.
This commit marks the automatically generated GitHub releases as draft,
which then need to be manually "finalized" by real people. This will also
avoid notifying people when for some reason a publish fails.
### `@babel/runtime`
- Added `@babel/runtime-corejs3` package and `corejs: 3` options to `@babel/plugin-transform-runtime`.
- Added support of instance methods, fixes#8928.
- Added flag `proposals` (in `corejs: { version: 3, proposals: true }` format) for support all proposals polyfills from `core-js`.
- Used separate directories in runtime for `core-js` entry points with proposals and without.
- Used `get-iterator-method` helper for getting iterators, fixes#2500.
- As a cheap bonus, added support of IE8- (except some cases of `regenerator`).
### `@babel/polyfill`
- Should be deprecated in favor of separate usage required features from `core-js` and `regenerator-runtime` with an informative message.
### `@babel/preset-env`
- Uses for built-ins data from [`core-js-compat`](https://github.com/zloirock/core-js/tree/master/packages/core-js-compat) instead of `compat-table` since information from `compat-table` [is not enough](https://github.com/zloirock/core-js/tree/master/packages/core-js-compat).
- `useBuilIns` now requires direct setting of `corejs` version option, without it will be used `2` by default and shown deprecation warning.
- Added support of minor `core-js` versions for simplify updating in the future.
- For preventing some order-related problems, polyfills in the both `core-js@3` plugins added on `post` stage in the order of `core-js-compat` data.
- Divided plugins and polyfills parts of `preset-env`, instead of 2 internal plugins for adding polyfills, we have 6: usage and entry versions of plugins for `core-js@2`, ### Current state:
`core-js@3`, `regenerator-runtime`.
- Added support `samsung` target (for Samsung Internet) since `core-js-compat` and `compat-table` now contains mapping for this, fixes#6602.
#### `useBuilIns: entry` with `corejs: 3`
- No longer transforms `@babel/polyfill`.
- Transforms **all possible** `core-js` entry points to import of related modules (based on data from [`core-js-compat`](https://unpkg.com/core-js-compat@3.0.0-beta.15/entries.json)).
- Since of this, we no longer need `shippedProposals` / `proposals` flags with `useBuilIns: entry`.
- Removes `regenerator-runtime/runtime` import where it's not required.
#### `useBuilIns: usage` with `corejs: 3`
- In addition to `shippedProposals`, added flag `proposals` (in `corejs: { version: 3, proposals: true }` format) for polyfill all proposals from `core-js`.
- Fixed list of dependencies in built-in definitions.
- Improved the way of determination method / built-in name and source of this method.
- Adds import of required polyfills on `MemberExpression`, `ObjectPattern`, `in` operator.
- Adds import of required polyfills on access to global object properties.
- Adds import of all required common iterators on all syntax features which use iterators protocol (`for-of`, destructuring, spread, `yield` delegation, etc.).
- Adds import of promises on syntax features which use promises (async functions/generators, dynamic import, etc.), fixes#9250, #7402, etc.
### `core-js@2` stuff
I didn't want to tough `core-js@2`-related stuff, however
- Fixed some serious errors in definitions which breaks `Object.getOwnPropertySymbols`, `Symbol.toStringTag` logic, `Promise#finally`, `Array#forEach`, etc.
- `Array#flatMap` and trim methods moved to stable features as a part of ES2019 and loaded by deprecated `@babel/polyfill` and `@babel/preset-env` with `corejs: 2` option.
This is the last step to make https://github.com/babel/babel/pull/9364 usable in Babel. I'm sorry for opening this PR so late, but I hope to get it in v7.4.
In this PR I added a new option to `@babel/template`, `syntacticPlaceholders: ?boolean`, which toggles between `%%foo%%` placeholders (when `true`) and `FOO` placeholders. If it isn't specified, Babel tries to be "smart" to avoid breaking backward compat: if `%%foo%%` is used `syntacticPlaceholders` defaults to `true`, otherwise to `false`.
0e58e252913efe84eba926cc9c9c19fb18d5c620 commit shows how some templates we used could be simplified by using this new placeholders syntax (we can't actually do it yet because we are importing `template` from `@babel/core` which could be an older version).
NOTE: Since I wanted to keep this PR as small as possible to make it easier to review, I didn't migrate `template.ast` to internally use the new syntax. It is an implementation detail, so it will be possible to change it in a patch release.
Usage of "@babel/plugin-proposal-decorators" with legacy
support causes "abstract" keyword to be preserved.
This fixes it by moving "abstract" node property removal
from "ClassDeclaration" visitor to "Class". Resolves#8172
When traversing a tree parsing for TypeScript syntax and hitting a `TSFunctionType` node, the `typeParameters` and `typeAnnotation` fields are correctly visited but the `parameters` field isn't. As a result visitors by default don't visit `foo` below:
```
var x: (foo) => void; // foo is never visited
```
```
module.exports = function() {
return {
visitor: {
Identifier(path) {
if (path.node.name == "foo") {
// Never hit because it's nested within TSFunctionType.parameters
path.node.name = "bar";
}
}
}
};
}
```
It appears to be a bug in babel-types/src/definitions/typescript.js which omits `parameters` in the visitors list for `fnOrCtr`. Fixed by adding it.
* add partial application syntax and some tests
remove unnecessary error message and hasPartial function from parseNewArguments
add types for PartialExpression
Update the tests
rename PartialExpression to Partial
move Partial from expressions to types and rename to ArgumentPlaceholder
add tests for ArgumentPlaceholder in babel-generator
rename Partial to ArgumentPlaceholder
update the tests
remove alias from the type and undo changes in generated folder
adds a nice error message
better definition for the type
auto-generated files
update the conditional for allowPlaceholder message and tests
update CallExpression definition to accept ArgumentPlaceholder
change description
clean up
indent ArgumentPlaceholder entry and revert unwanted changes
* add Partial Application Plugin
* update unwrapArguments function and add replacePlaceholders.
* update the tests
* remove unnecessary clone
* update readme and description an package.json
* put options.json one level up and add test for not assigned and chained
* add await to fix the test
* use Promise in the test instead of async await
* remove unnecessary method test [#9474]
* push sequenceExpressions to an array [#9474]
* Add parser createParenthesizedExpressions option …
When set to `true` we create `ParenthesizedExpression` nodes instead of
setting `extra.parenthesized`.
* Also update babel-parser.d.ts
* Disallow escape sequences in async
* Disallow escape sequences in get, set and async in class
* invalid escape tests
* Update whitelist
* tests for async in parens
* Add test for invalid newline between params and arrow
* Move canInsertSemilcolon() into shouldPArseAsyncArrow
* add partial application syntax and some tests
* remove unnecessary error message and hasPartial function from parseNewArguments
* add types for PartialExpression
* Update the tests
* rename PartialExpression to Partial
* move Partial from expressions to types and rename to ArgumentPlaceholder
* add tests for ArgumentPlaceholder in babel-generator
* rename Partial to ArgumentPlaceholder
* update the tests
* remove alias from the type and undo changes in generated folder
* adds a nice error message
* better definition for the type
* auto-generated files
* update the conditional for allowPlaceholder message and tests
* update CallExpression definition to accept ArgumentPlaceholder
* change description
* clean up
* indent ArgumentPlaceholder entry and revert unwanted changes
* fix: strip type imports used in Enums and object types
* chore: update failing snapshot
* docs: correct TSPropertySignature comment
* fix: enum value should be considered a reference
* chore: add tests for TSPropertySignature and TSEnumMember
* Refactor parsing object members
* Ensure decorators on rest don’t swallow decorators silently
* Use hasPrecedingLineBreak
* Add test for async with linebreak
* Update flow whitelist
* preset-env: minimally supporting version
This changes the "does browser support X" algorithm to "lowest version such that all higher versions support it".
Eg, given `{ chrome70: true, chrome60: false, chrome50: true }`, the lowest version is chrome70, not chrome50.
This is done to remove Tagged Template Literal support from Safari, which introduced a bug in Safari 12 but correctly implemented the feature in Safari 11-9.
* Add tests
* Fix tests
* Fix comment
Likely because of implicit `equals` (ie, Safari 12 support implies iOS Safari 12), the versions in the `res` hash are not always sorted in version order.
Doing a semver sort reveals some builtins have actually been supported a little longer than we thought!
In https://github.com/babel/babel/issues/9511 (and #9495 is another symptom), @PavelKastornyy reported a node crash becaue the JavaScript heap run out of memory. The problem was that their code was adding enumerable properties to `Object.prototype`: it is something that shouldn't be done, but Babel shouldn't make node crash if someone adds them.
I reduced down the problem to `for...in` loops in `@babel/traverse` that grew the memory consumption exponentially because of that unexpected properties.
* Introduce scope tracking
* Fix tests
* Add new tests
* Remove constructor-super check from transform as it is now in parser
* Correctly handle class properties and class scope
* Fix duplicate name check
* Convert scope identifier storage to array
* Enter a new scope in typescript module blocks
* Add test for duplicate declaration
* Rename error for duplicate exports
* Treat class declarations as lexical declaration
* Update whitelist
* Add tests
* Fix scope tracking for function declarations
* Migrate try-catch duplicate error
* Fix test
* More tests
* One more test
* Make scope a separate class and fix review comments
* Do not allow new.target in top scope arrow function
* Correctly enter new scope for declare module and treat type aliases as lexical declarations
* Tests for typescript scope tracking to not mark type aliases as duplicate
* Fix flow scope tracking
* Remove ident from test names as redundant
* Add test case for var and function
* Improve error messages
* Improve literal regex
* Add parser createParenthesizedExpressions option …
When set to `true` we create `ParenthesizedExpression` nodes instead of
setting `extra.parenthesized`.
* Also update babel-parser.d.ts
* babel-types is* type checks accept null | undefiend as value TS type
* Use | null | undefined instead of any, make Flow type nullable
* Also change flow types of generated src
chokidar 2.0.3 pulled in an older version of braces which is vulnerable to https://www.npmjs.com/advisories/786, this upgrades chokidar up a patch version where its dependencies have been updated resolving this vulnerability.
* Migrate try-catch duplicate error
* Remove exception for functions and let in the same scope
* Migrate duplicate bindings tests to traverse
* Add test for subscope and let/const
* Add more test cases
Bumps to 7.3.2 the version of `@babel/plugin-transform-typescript` used by `@babel/preset-typescript`.
This allows us to use `@babel/preset-typescript` and pick up at least one useful bug fix (#9095).
A similar PR (#9181) was closed as it bumped to a version that didn't have changes. However reading the comments from that PR, I get the sense that bumping the version in this manner should not be necessary, and should be handled by Lerna. Is this correct?
Please let me know if I can make any improvements to this PR, the description or if there's anything else I can do to help.
This reflects how I have been releasing the last versions (https://github.com/babel/notes/issues/78#issuecomment-449519007).
In the future, we'll only need to run `make new-version && git push --tags` and it will run `make publish` from CI/Actions.
Co-authored-by: Henry Zhu <hi@henryzoo.com>
* Remove types on program exit in typescript transform
* Revert changes to typescript transform
* Correctly add visitors for param decorators
* Fix plugin for node 6
* add isSpread field
* use argument
* t.booleanLiteral
* fix typo
* push empty-argument object
* .object
* .value
* object field should be an expression
* lint
* update outputs
* isSpread for the second argument is redundant
* add test
* alternating spread
When the `runtime` flag is on (by default), this plugin adds a new helper which wraps the native `RegExp` class to provide groups support. People nees to use a polyfill (I implemented it in core-js) for browsers that don't support ES6 regexps.
fix#9189
Obviously this code is intended to throw an error if someone tries to reference a class before it's defined, like:
```js
class Foo {
someField = Foo;
}
```
But there's no problem with referencing the class in a type annotation before it's defined, and this is often necessary for tree structures:
```js
class Foo {
[someSymbol]: Foo;
}
```
* check for spaces and tabs before a flow comment
* fix issue with using string index and shift interchangably
* update tests
* Use update charcodes version
* Disallow flow-comments in flow-comments and check for unterminated comments
* Fix running flow on travis and update flow
- ensure bootstrap is run before running flow as we need some generated files for correctly doing typechecks
- ensure that we only ignore the build directory inside the babel folder as currently we ignore everything because travis checks out into ‘/home/travis/build/’
* Fix all flow errors
* Ignore fixture directories that do not contain input or exec
* Fix parser test fixtures structures for some imported esprima tests.
* Warn on test folders that are not empty and do not contain testfiles
* Make @babel/plugin-class-features a normal helper package
This effectively disallows using it directly.
* Rename helper
* Style
* Don't add prefix to plugin name
* Move private methods plugin
When I was reading the code, I see `parent` is not used in `_getComments` function.
so it make me confused why we delivery the `parent` in those functions.
If I'm wrong, please correct me.
* Fix optional chaining bug regarding spread in function calls
* Revamp optional-chain to be top down
Instead of going both upwards and downwards from the first real optional expression, we can just start from the top down.
* Add more tests
* handle disordered rest parameter in function expressions
* remove spaces [lint]
* polish function parameters validation
* add test with arrow function and comma after rest parameter [babel-parser]
* [decorators] Correctly insert `_initialize(this)` after `super()`.
This commit fixes to problem:
1) After `super();` statements, `_initialize(this)` was inserted without
a trailing semicolon.
2) `(0, super())` causes an infinite recursion.
* Fix tests
* Add test
* feat: validate the positions of rest elements and optional elements in tuple types
Adds a validation step to the parser which raises syntax errors if a rest param is not at the end of a tuple, or if a mandatory param follows an optional parameter
* Fix spread after optional case; add test case
These are now enabled by default:
- objectRestSpread (2018)
- asyncGenerators (2018)
- optionalCatchBInding (2019)
- jsonStrings (2019)
TODO (after this commit):
- [ ] Deprecate the `@babel/plugin-syntax-*` packages.
- [ ] Deprecate the `@babel/plugin-proposal-*` packages.
- [ ] Create the `@babel/plugin-transform-*` packages.
* [flow] Add support for parsing as implicit instantiation in call/new
* Update flow tests and fix underscore being a reserved type
* Rebase onto flow-test
* Fix flow commit hash
* master: (222 commits)
Set correct methods name
Use toPropertyKey in the "decorate" helper
Allow function types in type params within arrow return types (#8954)
Fix message when plugin of a wrong type is passed (#8950)
rename colliding let bindings with for loop init (#8937)
edge incomplete support for arrow destructuring (babel #8349) (#8926)
fix single-arg async arrows when retainLines=true (#8868)
[flow] Explicit inexact objects with `...` (#8884)
Update preset-env data (#8898)
Treat break inside block inside loop (#8914)
fixed "source map" formatting in comment (#8878) [skip ci]
fix typo in contributing guidelines (#8901) [skip ci]
fix: Expression x === 'y' && '' should not evaluate to undefined. (#8880)
fixed an extra word
Fixes#8865 (#8866)
v7.1.4
v7.1.3
Bump Babel deps (#8770)
flow-bin@0.82.0 (#8832)
Insertafter jsx fix (#8833)
...
# Conflicts:
# packages/babel-parser/src/tokenizer/index.js
# packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-numeric-literal/options.json
# packages/babel-parser/test/fixtures/experimental/pipeline-operator/invalid-proposal/options.json
* rename colliding let bindings with for loop init
* added complex test case to check if loop init collisions were handled correctly
* updated test files
The babel-parser output documentation has been moved to the babeljs.io website, but the link in CONTRIBUTING.md is still pointing to the repository itself.
This is similar to ec69b4bb1256c061ac76f53dfed09c4283ec6a31, which
was about private instance fields.
Private properties can be non-writable (thanks to decorators), or have
get/set accessors. If we stored this information on the `privateClass`
object, we would need to always use `Object.getOwnPropertyDescriptor`
before reading or writing a property because accessors need to be called
with the correct `this` context (it should be the actual class, not the
object hat stores the private properties). This commit simplifies that
operation a bit by removing the container object.
It also have another advantage, which instance fields already have
thanks to the use of separate weakmaps: unused private static fields
can be tree-shaken away or garbage-collected, while properties of an
object can't. Also, they can be easilier minified.
* Add static Math methods to plugin-transform-runtime
* Remove methods which are not part of TC39 standard
* Use semver to conditionally include Math module
* Fix version badges in monorepo README
Badges caching disabled by removing the maxAge parameter from image URLs to ensure that always the latest version of package is displayed.
* adjust version badges cache time to one hour
* Private Static Class Fields Implementation
* Redo testing without class transform for static private
* Add a call() test for private static
* Use Object.defineProperty in loose mode
* Update parser whitespace for clarity
Has the nice benefit of not requiring a charCode to String conversion.
* Remove test262 exceptions
Per https://github.com/tc39/ecma262/pull/1218#issuecomment-395340891,
ECMA262 follows whatever the latest Unicode version specifies for Zs
Space_Separator category. MONGOLIAN VOWEL SEPARATOR was moved to the Cf
Other_Format category in Unicode 8.
Usage of a `finally` instance method should trigger import of the `es7.promise.finally` polyfill, but it doesn't. This PR adds the missing definition and a test.
The default import is replaced with only polyfills that are Stage 4; this is in alignment with how we have removed the Stage presets. This also would mean we would need to add new imports when necessary, but that can be in a future release.
PR #8418 introduced some new logic that uses the third parameter of `fs-readdir-recursive`'s `filter` option, the current directory, but missed that our dependencies only required `^1.0.0`, while that parameter was actually added in `1.1.0`. This means that if some other dependency forced a downgrade in the version to satisfy some range, or the user already had 1.0.0 module installed locally, it could cause problems,
In Babel 6, we had `@babel/runtime` which _always_ uses `core-js` in its helpers, meaning that anyone who wants to use our helpers in a centralized modular way had to also use core-js, which isn't always ideal.
Early in the Babel 7 alpha, we added a `useBuiltins: true` option that would use separate copies of the helpers that would skip loading `core-js`, but this _still_ requires users to have an indirect npm dependency on `core-js`.
This PR splits our setup into two separate runtimes:
* ```
'plugins': [
['transform-runtime'],
]
```
with `npm install --save @babel/runtime` that just includes our helpers, and relies on users to globally polyfill any APIs they need.
* ```
'plugins': [
['transform-runtime', { corejs: 2 }],
]
```
with `npm install --save @babel/runtime-corejs2` that includes everything `@babel/runtime` does, but also includes a passthrough API for `corejs@2.x` and rewrites all of the helper modules to reference `core-js`.
* Fix private property parsing in Flow
* Flow tests updated
* Fix type error
* Appropriate name was given to test folder
* Fix
* Empty
* Correct type annotation
* Add required changes in generator package
* Add required changes in flow-strip-types
<!--
Before making a PR, please read our contributing guidelines
https://github.com/babel/babel/blob/master/CONTRIBUTING.md
For issue references: Add a comma-separated list of a [closing word](https://help.github.com/articles/closing-issues-via-commit-messages/) followed by the ticket number fixed by the PR. (it should be underlined in the preview if done correctly)
If you are making a change that should have a docs update: submit another PR to https://github.com/babel/website
-->
| Q | A <!--(Can use an emoji 👍) -->
| ------------------------ | ---
| Fixed Issues? | Fixes#7118
| Patch: Bug Fix? | Y
| Major: Breaking Change? | N
| Minor: New Feature? | N
| Tests Added + Pass? | Yes
| Documentation PR Link |
| Any Dependency Changes? |
| License | MIT
* Add sourcemap examples for identifiers in code generator.
* Generate sourcemaps with exact mappings for identifiers, even if leading/trailing tokens also use that location.
* Save full descriptor instead of only value for private fields.
Decorators can make private fields non-writable, so we need to store this
information somewhere.
The descriptor can also be used to implement private accessors.
| Q | A
| ------------------------ | ---
| Fixed Issues? | #7747 (partly)
| Patch: Bug Fix? |
| Major: Breaking Change? |
| Minor: New Feature? | Yes
| Tests Added + Pass? | Yes
| Documentation PR |
| Any Dependency Changes? |
| License | MIT
@JamesHenry This changes the AST format. CC @DanielRosenwasser for review.
Supports parsing type arguments on tagged template calls.
Should wait on Microsoft/TypeScript#23430 to be merged so we're sure we have the final syntax.
Previously, if the optional `opts` parameter wasn't passed, the _intent_ was to move the function it held into the `callback` parameter and null out the `opts` param - but instead, it was nulling both.
Set whether we're in a pipeline in order to determine how to parse the
hash. The error message changes as a result, since the `hash` never
enters the block.
Just default to pipeline "minimal" and true for decorators for ease of use. We are going to remove the stage presets next so it's fine since it will error when using the plugin individually later.
| Q | A <!--(Can use an emoji 👍) -->
| ------------------------ | ---
| Fixed Issues? | Fixes https://github.com/babel/babel-loader/issues/642
| Patch: Bug Fix? | Y
| Major: Breaking Change? | N
| Minor: New Feature? |
| Tests Added + Pass? | Yes
| Documentation PR Link | <!-- If only readme change, add `[skip ci]` to your commits -->
| Any Dependency Changes? |
| License | MIT
Since these were getting left in, things that loaded the config, and then passed in back to Babel would get `test` and such _twice_, which could lead to either bad configuration merging, or no configuration at all if the patterns were relative to different directories, as was the case in https://github.com/babel/babel-loader/issues/642.
Original PR: https://github.com/babel/babel/pull/8038
Ref Issue: https://github.com/babel/babel/issues/8184
Windows paths are broken so wanted to get a fix out since I don't see us fixing it correctly soon enough? I think that's more important than fixing the security warnings that don't apply to us until we can actually handle the change, otherwise need a version of the code that doesn't use the old dep but doesn't change the windows behavior or just remove the matching which will take some time.
Fixes#8163
The `isNodesEquivalent()` algorithm incorrectly assumes that any object properties must themselves be AST nodes, which is not the case here, causing the error.
| Q | A <!--(Can use an emoji 👍) -->
| ------------------------ | ---
| Fixed Issues? | Fixes#8272 <!-- remove the (`) quotes to link the issues -->
| Patch: Bug Fix? | Yes
| Major: Breaking Change? |
| Minor: New Feature? |
| Tests Added + Pass? | Yes
| Documentation PR | <!-- If so, add `[skip ci]` to your commit message to skip CI -->
| Any Dependency Changes? |
| License | MIT
The visitor for `typeArguments` in function calls wasn't set in the definition, so type annotations added there weren't visited.
This is required to fix https://github.com/babel/babel-eslint/issues/644
This is going to be required so we can add support for other proposals,
as well as later set the accepted proposal as the default.
Update stage-0 and stage-1 presets with `pipelineProposal` to thread down to
the plugin.
* babel/parser: test helpers: when test fails with an exception and both reference output file and options.json file do not exist, write a simple options.json with the error message to expect when such a file doesn't exist yet. This completes the `jest -u` capability for new tests which are expected to *fail*.
This allows the new parser package to be used in TypeScript projects, with static type checking and auto-completions. IDEs like VSCode will use this to show auto completions even in JavaScript projects, which is a huge benefit to users wanting to use the parser directly.
This PR follows the auto-generated .d.ts that was added to @babel/types in #7101
- took outdated DefinitelyTyped babylon .d.ts and updated it using new site's documentation.
- added "typings" folder to package, with the new .d.ts
- connected new .d.ts via package.json's "types" field. also adjusted "files" so folder will be published.
- definition file uses TypeScript 2.9's new `import('package').Type` syntax.
| Q | A <!--(Can use an emoji 👍) -->
| ------------------------ | ---
| Fixed Issues? | None
| Patch: Bug Fix? | No
| Major: Breaking Change? | No
| Minor: New Feature? | No
| Tests Added + Pass? | Existing tests pass
| Documentation PR | No
| Any Dependency Changes? | `regenerator-transform` in `@babel/plugin-transform-regenerator`
| License | MIT
I recently updated `regenerator`, `regenerator-transform`, and `regenerator-preset` to fix a number of vulnerabilities surfaced by `npm audit`. There was no need to update `regenerator-runtime`, as it does not have any dependencies of its own. I'm happy to report the latest versions of these packages have zero vulnerability warnings according to `npm audit`.
While I was at it, I also updated all dependencies of these packages to their Babel 7 equivalents, so there should hopefully be fewer legacy package dependencies installed because of Regenerator.
<!--
Before making a PR please make sure to read our contributing guidelines
https://github.com/babel/babel/blob/master/CONTRIBUTING.md
For issue references: Add a comma-separated list of a [closing word](https://help.github.com/articles/closing-issues-via-commit-messages/) followed by the ticket number fixed by the PR. It should be underlined in the preview if done correctly.
-->
| Q | A <!--(Can use an emoji 👍) -->
| ------------------------ | ---
| Fixed Issues? | --
| Patch: Bug Fix? |
| Major: Breaking Change? |
| Minor: New Feature? |
| Tests Added + Pass? | Yes
| Documentation PR | <!-- If so, add `[skip ci]` to your commit message to skip CI -->
| Any Dependency Changes? |
| License | MIT
Good ol' plugin ordering 🙃
Ref: https://github.com/babel/babel/pull/7065#issuecomment-395959112
Fix a ReferenceError caused by a typo (`_construct` instead of
`construct`) in the external `wrapNativeSuper` helper. (The typo
doesn't usually cause an error in inline helpers because `_construct`
happens to be the default name given to the `construct` helper
function.)
The extra field parenthesizedArgument was never set to true. It was
always set to false and the code that read this was incorrectly
checking if extra was present.
Fixes#7957
Given the following
```js
a = <F new/>
```
We used to generate:
```js
a = React.createElement(F, {"new": true})
```
but now we generate
```js
a = React.createElement(F, {new: true})
```
If you need to quote these (ie for ES3 you can use
transform-property-literals)
<!--
Before making a PR please make sure to read our contributing guidelines
https://github.com/babel/babel/blob/master/CONTRIBUTING.md
For issue references: Add a comma-separated list of a [closing word](https://help.github.com/articles/closing-issues-via-commit-messages/) followed by the ticket number fixed by the PR. It should be underlined in the preview if done correctly.
-->
| Q | A <!--(Can use an emoji 👍) -->
| ------------------------ | ---
| Fixed Issues? | <!-- remove the (`) quotes to link the issues -->
| Patch: Bug Fix? |
| Major: Breaking Change? | No
| Minor: New Feature? | Yes
| Tests Added + Pass? | Yes
| Documentation PR | <!-- If so, add `[skip ci]` to your commit message to skip CI -->
| Any Dependency Changes? |
| License | MIT
See eb815be907 for more information about this feature.
The proto modifier indicates that a property declared using `x: T` syntax is actually present on the prototype object of the class, rather than an own property.
The proto and static modifiers are mutually exclusive, as class declarations don't simultaneously define the static prototype object, as they do the instance prototype.
This syntax is only supported on declared classes, not object types, interfaces, or runtime class declarations, and as such should only appear in library definitions.
Fixes gh-8041
<!--
Before making a PR please make sure to read our contributing guidelines
https://github.com/babel/babel/blob/master/CONTRIBUTING.md
For issue references: Add a comma-separated list of a [closing word](https://help.github.com/articles/closing-issues-via-commit-messages/) followed by the ticket number fixed by the PR. It should be underlined in the preview if done correctly.
-->
| Q | A <!--(Can use an emoji 👍) -->
| ------------------------ | ---
| Fixed Issues? | #8041
| Patch: Bug Fix? |👍
| Major: Breaking Change? |
| Minor: New Feature? |
| Tests Added + Pass? | Yes
| Documentation PR | <!-- If so, add `[skip ci]` to your commit message to skip CI -->
| Any Dependency Changes? |
| License | MIT
<!-- Describe your changes below in as much detail as possible -->
* Parsing is now ~30% faster thanks to [marijnh/acorn@7264bc0178e7e6af7cfe02e9e0c6b26ee0e6007f](https://github.com/marijnh/acorn/commit/7264bc0178e7e6af7cfe02e9e0c6b26ee0e6007f).
* Parsing is now ~30% faster thanks to [marijnh/acorn@7264bc0178e7e6af7cfe02e9e0c6b26ee0e6007f](https://github.com/marijnh/acorn/commit/7264bc0178e7e6af7cfe02e9e0c6b26ee0e6007f).
* **New Feature**
* **New Feature**
* Optional `es6.blockScopingTDZ` is now completely functional and handles all edgecases.
* Optional `es6.blockScopingTDZ` is now completely functional and handles all edgecases.
* Allow `inputSourceMap` to be set to `false` to skip the source map inference.
* Infer computed literal property names.
* **Bug Fix**
* Fix nested labeled for-ofs.
* Fix block scoping `break` colliding with the parent switch case.
* **Internal**
* Upgrade `acorn-babel`.
## 4.7.8
* **Bug Fix**
* Fix computed classes not properly setting symbols.
## 4.7.7
* **Bug Fix**
* Fix `types` API exposure.
## 4.7.6
* **Bug Fix**
* Fix non-Identifier/Literal computed class methods.
* **Polish**
* Add a fallback if `stack` on an error is unconfigurable.
* Hoist `esModule` module declarations to the top of the file to handle circular dependencies better.
## 4.7.5
* **Bug Fix**
* Don't remap` break`s to call the iterator return.
* **Polish**
* Use a different helper for computed classes for much nicer output. Also fixes a bug in symbols being non-enumerable so they wouldn't be set on the class.
## 4.7.4
* **Bug Fix**
* Rewrite named function expressions in optional async function transformers.
* Hoist directives.
* Remove `Number` from the list of valid `runtime` constructors.
* **Internal**
* `spec.typeofSymbol` transformer has been renamed to `es6.symbols`.
## 4.7.2
* **New Feature**
* `"both"` option for `sourceMap`.
* Add output types to external helpers. Thanks [@neVERberleRfellerER](https://github.com/neVERberleRfellerER)!
* **Bug Fix**
* Fix node duplication sometimes resulting in a recursion error.
* Ignore `break`s within cases inside `for...of`.
* **Polish**
* Split up variable declarations and export declarations to allow easier transformation.
## 4.7.0
* **Bug Fix**
* Add `alternate` to list of `STATEMENT_OR_BLOCK` keys.
* Add support for module specifiers to `t.isReferenced`.
* **New Feature**
* Add `inputSourceMap` option.
* **Polish**
* Throw an error on different `babel` and `babel-runtime` versions.
* Replicate module environment for `babel-node` eval.
* Clean up classes output.
* **Spec Compliance**
* Make it illegal to use a rest parameter on a setter.
## 4.6.6
* **Bug Fix**
* Fix incorrect method call in `utility.deadCodeElimination` transformer.
* `useStrict` transformer has been renamed to `strict`.
## 4.6.4
* **Bug Fix**
* Fix `ForOfStatement` not properly inheriting labels.
* When in closure mode in block scoping transformer, properly check for variable shadowing.
* **New Feature**
* New `utility.inlineEnvironmentVariables` and `utility.inlineExpression` transformers.
## 4.6.3
* **Bug Fix**
* Fix `arguments` being incorrectly aliased in arrow function rest parameter optimisation.
* Make deoptimisation trigger safer.
* **New Feature**
* Flow types are now retained when blacklisting the `flow` transformer.
## 4.6.1
* **Bug Fix**
* Fix generators in template directory being transformed.
* Fix exposure of `util` for plugins.
## 4.6.0
* **New Feature**
* Desugar sticky regexes to a new constructor expression so it can be handled by a polyfill.
* **Spec Compliance**
* `for...of` now outputs in a lengthy `try...catch` this is to ensure spec compliance in regards to iterator returns and abrupt completions. See [google/traceur-compiler#1773](https://github.com/google/traceur-compiler/issues/1773) and [babel/babel/#838](https://github.com/babel/babel/issues/838) for more information.
* **Polish**
* Rest parameters that are only referred to via number properties on member expressions are desugared into a direct `arguments` reference. Thanks [@neVERberleRfellerER](https://github.com/neVERberleRfellerER)!
* `$ babel` no longer exits on syntax errors.
* **Internal**
* Upgrade `browserify`.
* Upgrade `source-map`.
* Publicly expose more internals.
## 4.5.5
* **Polish**
* Delete old extensions when overriding them in `babel/register`.
## 4.5.3
* **Bug Fix**
* Fix whitelisting logic for helper build script.
## 4.5.2
* **New Feature**
* `returnUsedHelpers` option and add whitelist to `buildHelpers`.
* **Bug Fix**
* Fix function arity on self referencing inferred named functions.
* Republish to get fix for runtime `typeof-react-element` helper.
## 5.8.25
* **Internal**
* Rename `define` method to avoid webpack assuming those files are AMD.
## 5.8.24
* **Spec Compliance**
* Updated `optimisation.react.inlineElements` transformer to React 0.14 output. Thanks [@spicyj](https://github.com/spicyj)!
* **Polish**
* Add support for evaluating more static nodes. Thanks [@hzoo](https://github.com/hzoo)!
## 5.8.23
* **Bug Fix**
* Fix a bug where pushed scope bindings weren't properly being registered.
## 5.8.22
* **Bug Fix**
* Fix bug causing regexes to cause a syntax error after a block.
* **Internal**
* Expose `File`.
## 5.8.21
* **New Feature**
* Add support for Flow export types.
* **Bug Fix**
* Fix flow type annotations on object properties being lost.
* Fix bug effecting nested arrow functions.
* Check valid `export default``function`/`class` token when parsing export default before converting to a declaration to avoid turning expressions into declarations.
* **Polish**
* Add an exception to non-existent bindings when checking if we need to wrap block scoping blocks in a closure.
* Make comment retainment for multiple replacement nodes more predictable.
* **Internal**
* Remove `operator` property from `AssignmentPattern` nodes.
* Update `es7.asyncFunctions` and `es7.objectRestSpread` to stage 2.
## 5.8.13-5.8.20
**The CHANGELOG was broken for these releases. Git tags were not pushed in the correct order and are therefore incorrect. It's recommended you NOT use any versions within this range.**
* **New Feature**
* Add `es6.spec.modules` transformer.
* **Bug Fix**
* Don't register export declarations as a module binding.
* Register import bindings to the specifier instead of the declaration.
* `export *` should not export `default`.
* Clear `rawValue from JSX attribute values to avoid outputting the raw source verbatim.
* Add support for boolean flow literals.
* Fix bug where files that babel can compile weren't being written when ignored with the `--copy-files` flag.
* Create new raw identifiers instead of cloning the original user one when exploding export specifiers to fix source map issues resulting in incorrect locations.
* Break on hitting a terminator paren triggering character to avoid pushing multiple starting parens.
* Consider comment starting character to be a terminatorless separator to avoid starting comments breaking terminatorless nodes.
* **Internal**
* Use `json5` for parsing `.babelrc` files and `JSON` for `package.json`.
* Update Regenerator dependency to `0.8.35`.
* Remove flow types from being scope tracked.
* **Polish**
* Only register export declarations in scope tracking if they're of a valid type.
* Only output code frame and message on syntax errors in CLI.
* Set decorated initialisers that have no `initialiser` to `undefined`.
* Optimise common `typeof` cases in `es6.spec.symbols` transformer.
## 5.8.12
* **Bug Fix**
* Fix bug in lookahead causing decorators to be cleared.
## 5.8.11
* **Bug Fix**
* Check if module options are nully instead of falsy to allow empty strings as `moduleRoot` etc.
* Fix bug where reassigning the rest parameter wouldn't result in a deoptimisation.
## 5.8.9
* **Bug Fix**
* Fix issue in parser where the flow plugin wasn't using state to refer to whether it as in a type or not causing lookaheads to cause breakages.
## 5.8.8
* **Bug Fix**
* Fix comments not being attached if they're touching the start of their node.
## 5.8.7
* Never published, environment issues, again.
## 5.8.6
* **Bug Fix**
* Remove `rawValue` for JSX inner text.
## 5.8.5
* **Polish**
* Rewrite parentheses insertion for terminatorless nodes such as `BreakStatement` to be much more stable and cleaner.
* Use `Object.setPrototypeOf` and fallback to `__proto__` in `inherits` helper.
## 5.8.2-5.8.4
Issues with publish process.
## 5.8.1
* **Bug Fix**
* Fix regression where async arrow functions couldn't have type annotation parameters.
* Output type annotations of type instantiation parameters.
* **Polish**
* Prepend to highest loop when performing rest parameter allocation optimisation.
* Add comment attachment to parser.
* Add support for retaining inner comments of empty blocks.
## 5.8.0
* Never released due to publish environment issues.
## 5.7.4
* **Bug Fix**
* Fix comments containg `@flow` being completely removed from output rather than just the specific directive.
## 5.7.3
* **Bug Fix**
* Add shim file for broken file path that old versions of the CLI would attempt to use.
## 5.7.2
* **Bug Fix**
* Fix performance issue in code generator when comment columns would attempt to match up in `compact` mode causing large amounts of whitespace.
* Fix single line comments not outputting a newline in `compact` mode.
* **Polish**
* Add support for flow return types for arrow functions.
## 5.7.1
* **Bug Fix**
* Add back mistakenly removed `replaceWithSourceString` method.
## 5.7.0
* **Bug Fix**
* Deopt on spread elements when performing array destructuring unpack optimisation.
* **New Feature**
* Add `shouldPrintComment` option to control comment output.
* Add `.babelignore` file to be consistent with other tools.
* Allow `.babelrc` configs to be specified via `package.json`.
* **Polish**
* Don't ignore comments when using `compact: true` option.
* Add support for Flow `import typeof`.
* Fix incorrect inheritance method position when using loose mode classes and constructor isn't the first item.
* **Internal**
* Completely fork Acorn with `babylon`.
* Rewrite build system to accommodate for multiple packages.
## 5.6.17
* **Bug Fix**
* Fix `CodeGenerator.findCommonStringDelimiter` causing a stack overflow.
## 5.6.16
* **Internal**
* Fix `recast` version to avoid pulling in a newer version.
* **New Feature**
* Add support for functions in `util.shouldIgnore`.
* **Polish**
* Strip flow directives in flow transformer.
* Add a check for out of bounds default parameters, drastically improving performance and removes engine deoptimisations.
* Various performance optimisations by [@samccone](https://github.com/samccone) 💅✨
* Delay `this` assignment when referencing this inside an arrow function pre-bare super in derived class constructors.
* Split up class body pushing if the constructor is in the wrong order.
* **Bug Fix**
* Fix hoisting of `ForInStatement``init` variables in `system` module formatter.
* `PathHoister`: Don't hoist to the same function as their original paths function parent.
* `PathHoister`: Push each violation paths ancestry to the breakOnScopePaths collection to avoid constant hoisting to nested paths.fix tail call recursion on functions with less arguments than parameters.
* Disallow `super.*` before `super()` in derived class constructors.
* Properly regenerate scope for replaced nodes. Thanks [@loganfsmyth](https://github.com/loganfsmyth)!
* Move up template literal simplification logic to avoid breaking on single elements.
## 5.6.13-5.6.15
* Setting up automatic Travis releases.
## 5.6.12
* **Bug Fix**
* Fix finding parent for top-level shadowed functions.
## 5.6.11
** **Internal**
* Merge `es6.parameters.rest` and `es6.parameters.default` transformers. See commit [c0fd4c1f9e0b18231f585c4fa793e4cb0e01aed1](https://github.com/babel/babel/commit/c0fd4c1f9e0b18231f585c4fa793e4cb0e01aed1) for more info.
## 5.6.10
* **Bug Fix**
* Fix faulty internal require check.
* **Polish**
* Add support for trailing commas in arrow function parameter lists.
## 5.6.8
* **Bug Fix**
* Fix binary expressions colliding with unary expression operators in compact mode.
* Fix node properties being set to `null` when using computed properties.
## 5.6.7
* **Bug Fix**
* Fix hoisting of `ForXStatement``left``var`s when inserting a block scoping IIFE.
* **Polish**
* Combine all leading computed property initialisers into the root object in loose mode.
* **Internal**
* Deprecate returning of replacement strings from visitor methods.
## 5.6.6
* **Bug Fix**
* Fix weird parser bug where `void` type annotations were being parsed as keywords causing the tokeniser to lose track of context.
## 5.6.5
* **Bug Fix**
* Fix nested functions causing rest parameter optimisation to not properly detect when it should deopt on a reference.
* **Internal**
* Update Regenerator `0.8.31`.
## 5.6.4
* **Internal**
* Add `ParenthesizedExpression` node type.
## 5.6.3
* **Bug Fix**
* Fix rest parameter array allocation loop being incorrectly aliased.
## 5.6.2
* **Bug Fix**
* Fix method key literals not turning into computed member expression in loose mode.
* Elect rest parameters in spread element position as candidates instead of replacing them in place.
## 5.6.0
* **Bug Fix**
* Fix istanbul interop for register hook when registering for non-existence extension.
* Fix super class constructor call differing for no constructor in derived classes.
* Disable module import receiver when in loose mode.
* Fix duplicate filenames when using `babel` CLI when passing multiple matching patterns.
* Register labels as bindings to fix undeclared variable checks.
* **Polish**
* Remove unnecessary string binary expressions when transforming template literals.
* Support module live bindings in arbitrary positions not in Program statement position.
* Throw error when attempting to replace a `Program` root node with another node not of type `Program`.
* Optimise rest parameters in spread element position and allocate rest array at the earliest common ancestor of all references.
* Generate original number representation when value was not changed.
* Check for invalid binding identifiers when generating inferred method names.
* Don't terminate CLI when watching files fail compilation on init.
* **New Feature**
* Add new plugin API.
* **Internal**
* Split react displayName addition into a plugin.
* Add check for `JSXMemberExpression` to `t.isReferenced`.
* Remove extremely unprofessional and harsh error message for those hotlinking to `resolve-rc`.
## 5.5.7
* **Bug Fix**
* Push newline after decorators when doing code gen.
* Rewriting error handling to normalise options before merging them.
* Remove duplicate keys in `alias-keys.json` causing errors in strict mode.
* Fix `$ babel --help` not showing optional transformers as such.
* **New Feature**
* Add `auxiliaryCommentBefore` and `auxiliaryCommentAfter` options.
## 5.5.6
* **Bug Fix**
* Fix `let` binding collision in loop head not properly replacing `AssignmentExpression`s.
## 5.5.5
* **Bug Fix**
* Fix `file.opts` not being set before `file.log.deprecate` was called causing a `ReferenceError` as it was checking for a property on it.
## 5.5.4
* **Bug Fix**
* Add back missing `shouldIgnore` check.
* Log message on deprecated options rather than throw an error.
* Fix name of `auxiliaryComment` option when attempting Istanbul interop in `babel/register`.
## 5.5.3
* **Bug Fix**
* Fix weird state bug when traversing overa `node``ClassProperty` instead of `path` in the `es6.classes` transformer.
## 5.5.2
* **Bug Fix**
* Fix `NodePath#isPure` on `Property` nodes.
* Use cwd instead of entry file directory when working out relative directory for `babel/register`.
* **Internal**
* Add scary warning for those few who choose to use the WIP experimental transformers.
## 5.5.1
* **Bug Fix**
* Remove `ClassProperty` nodes always in the `Flow` transformer. This is fine now since class properties aren't supported in any engine that supports classes but the `es7.classProperties` transformer will need to be updated in the future to desugar to ES6 classes instead of relying on the `es6.classes` transformer from being ran.
## 5.5.0
* **Bug Fix**
* Allow pushing declarations to `SwitchStatement`s.
* Fix `minification.removeDebugger` to remove `DebuggerStatement`s rather than `ExpressionStatement`s with an identifier of `debugger`.
* Check LHS in `ForInStatement` and `ForOfStatement` for constant violations.
* Register function `id` as a reference when naming methods to avoid collisions.
* Support key literals when checking for the existence of `displayName` property when attempting to add it for `React.createClass`.
* Remove `ExportDefaultSpecifier` check from `t.isDefaultSpecifier`.
* Don't consider `JSXIdentifier` HTML tag identifiers to be references.
* **Polish**
* Update `minification.deadCodeElimination` transformer to remove all statements after completion statements.
* Update `minification.deadCodeElimination` transformer to not inline single used bindings that exist in different scopes.
* When performing Istanbul interop in `babel/register`, add the auxiliary comment `"istanbul ignore text"` to get more accurate coverage.
* Add `--nolazy` argument to `babel-node`.
* Add support for `cluster` forking.
* Perform scope tracking in a single pass instead of multiple.
* Smarten up type inferrence and resolution to support the whole array of language constructs.
* Optimise module metadata retrieval into a single pass.
* Ignore trailing commas when inferring newlines.
* Rename `minification.inlineExpressions` transformer to `minification.constantFolding`.
* Check path relative to entry file when checking to see if we're inside `node_modules` when using `babel/register`.
* Upgrade `regenerator`.
## 5.4.7
* **Bug Fix**
* Don't consider `JSXAttribute``names` to be valid `ReferencedIdentifier`s.
## 5.4.6
* **Bug Fix**
* Fix `spec.functionName` transformer incorrectly attempting to rename a binding that doesn't exist as it's a global.
* **Internal**
* Deprecate custom module formatters.
## 5.4.5
* **Bug Fix**
* Add `JSXIdentifier` as a valid `ReferencedIdentifier` visitor virtual type.
* Ignore `CallExpression``_prettyCall` when the `retainLines` option is enabled.
* Inherit comments to new declaration node when exploding module declarations.
* Fix `es6.tailCall` transformer failing on calls that exceed the max parameters of the function.
## 5.4.4
* **Bug Fix**
* Fix bug where replacing variable declarations in the head of a `for` loop would turn them into `ExpressionStatement`s.
* Fix renaming of assignment expressions that were non-identifiers ie. patterns.
* Force space before `class``id` to avoid breaking named classes when using `compact` mode.
* Add assignment pattern explosion to avoid initial duplicate nodes.
* Ignore this and arguments when performing TCO on shadowed functions.
* **Polish**
* Rename `sourceMapName` option to `sourceMapTarget`. Thanks [@getify](https://github.com/getify)!
* Better detection of completion records, ignore those in `Function`s.
* Clarified descriptions of the options that are enabled by default.
* Resolve `\`babel-plugin-${name}\`` plugin names **before** just checking the `name`. Thanks [@jquense](https://github.com/jquense)!
* Update AMD module formatter to add import default remapping.
## 5.4.3
* **Bug Fix**
* Fix `module` being incorrectly rewritten when used as in an export declaration.
* When performing single-reference inlining, ensure that the single reference isn't a child of the binding itself.
* Fix a bug in `minification.deadCodeElimination` where a new binding instance was being created for local class bindings instead of just inheriting the parent one.
* Fix bug with paren printing in `compact` and `retainLines` mode where a left paren was already printed before catching up.
* **Internal**
* Handle contexts for paths much better. This will ensure that the path node location info is in sync.
## 5.4.2
* **Polish**
* `ignore` and `only` patterns are now **very** liberal. The pattern can now exist anywhere in the path.
* Clean up `shouldIgnore` algorithm to work how you'd expect rather than being a hacky piece of shit. It now crawls the entire path, checking each section of it against the input ignore/only patterns. This means that the pattern `foo` will ignore the paths `foo/bar.js`, `bar/foo` etc.
* Added `env` option. Especially handy when using the `.babelrc`.
* **Bug Fix**
* Fix files not properly being ignored when `babel.transform` ignores them when using `$ babel`.
* Fix scope tracking registering loop head bindings to their `VariableDeclaration` instead of `VariableDeclarator`.
* **Polish**
* Normalise path separators for souce map paths when using `$ babel`.
* Rework `PathHoister` to ignore global references and to not deopt on reassignments to referenced bindings, instead it tries to hoist to the highest scope.
* Allow trailing param commas for methods when using the `es7.trailingCommas` transformer.
* **Bug Fix**
* Fix `es6.blockScoping` transformer not properly ignoring `break` in `SwitchCase`.
* Fix lookahead context saving to avoid weird tokenizer state.
* Explode duplicate identifiers in export/import specifiers and property shorthand to create unique objects.
* Skip loose mode for class methods when they have decorators.
* When removing nodes, share their comments with their siblings.
* Properly hoist temp param declarations when doing TCO.
* **Internal**
* Add `--harmony_generators` flag to `$ babel-node`.
* Internal AST traversals have been minimised **drastically**. Transformers have been grouped together which means entire tree traversals are much fewer. Visiting nodes is now also skipped if the traversal context can detect that the handler is a noop. This sames precious cycles as it avoids constructing traversal paths and creating a new traversal context. See issues [#1472](https://github.com/babel/babel/issues/1472) and [#1486](https://github.com/babel/babel/issues/1486) for related discussion.
* **Polish**
* Move many `utility` transformers to `minification`.
## 5.2.17
* **Bug Fix**
* Fix auxiliary comments not properly being attached to function declaration helpers.
* Add `Super` node type to `ast-types` patch.
* Ignore parameter bindings when attempting to inline them in the `minification.deadCodeElimination` transformer.
* Correct `extensions` arguments when using the Babel CLI.
## 5.2.16
* **Bug Fix**
* Fix plugins being disabled when using the whitelist.
* Fix correct function scope being passed to `nameMethod.property` when inferring the function name for class methods.
* Fix incorrect extensions reference causing weird issues when using the Babel CLI.
* Fix destructuring param reference replacements not inheriting from their original param.
* **Spec Compliance**
* Fix order that method decorators are ran in.
## 5.2.15
* **Bug Fix**
* Fix initializer descriptor add attempt if it doesn't exist.
## 5.2.14
* **Bug Fix**
* Fix bug with initializer decorators where the descriptors weren't being defined if there was no `initializer` property.
* **Internal**
* Expose `retainLines` option to CLI.
* Fix `retainLines` option not being taken into consideration when doing multiple variable declaration declarators generation.
* Expose minified and unminified copies of dist scripts.
## 5.2.13
* **Bug Fix**
* Fix `ExportDeclaration`s being incorrectly removed when using the `utility.deadCodeElimination` transformer.
* Fix position of `utility` transformers.
* **New Feature**
* Add built-in `esquery` support.
* **Internal**
* Consolidate notion of "virtual types".
## 5.2.12
* **Polish**
* Make UID generation based on module declarations **much** nicer.
* **Internal**
* Remove internal check for traversal path replacement of self. This is a pattern that **could** come up in the wild and it could lead to pretty nasty code and may lead to internal regressions as the test coverage isn't 100% :( Instead, just put it in the fast path.
## 5.2.11
* **Internal**
* Rename `getModuleName` option to `getModuleId`, doh.
## 5.2.10
* **Bug Fix**
* Fix numerous issues in `replaceWithSourceString`. Thanks [@pangratz](https://github.com/pangratz)!
* Fix `_blockHoist` transformer incorrectly sorting nodes on shitty environments that aren't spec compliant in their key order.
* Fix broken `parse` API method reference to an undeclared import.
## 5.2.7
* **Bug Fix**
* Move `utility.deadCodeElimination` transformer up to avoid race conditions.
* Fix shorthand property scope binding renaming.
* **Polish**
* Turn helper variable declarations into function declarations if possible.
* **Internal**
* Removed native inheritance support from classes.
* Added `replaceWithSourceString` path API.
* Split up `es3.propertyLiterals` and `es3.memberExpressionLiterals` transformers to `minification.propertyLiterals` and `es3.memberExpressionLiterals`.
## 5.2.6
* **Internal**
* Fix transformer aliases being accidentally set as deprecated ones.
* Expose `Pipeline` as `TransformerPipeline` instead.
## 5.2.5
* **Bug Fix**
* Fix `parse` API not adding all the correct pipeline transformers.
## 5.2.4
* **Bug Fix**
* Fix race condition with the Node API being loaded awkwardly and not being able to initialise itself when used in the browser.
* **Internal**
* Expose `transform.pipeline`.
## 5.2.3
* **Bug Fix**
* Fix plugin containers being called with an undefined import. Thanks [@timbur](https://github.com/timbur)!
* Allow Flow object separators to be commas. Thanks [@monsanto](https://github.com/monsanto)!
* Add missing `Statement` and `Declaration` node aliases to flow types.
## 5.2.2
* **Internal**
* Allow `util.arrayify` to take arbitrary types and coerce it into an array.
## 5.2.1
* **Bug Fix**
* Fix regression in `node/register` that caused `node_modules` to not be ignored.
## 5.2.0
* **Bug Fix**
* Fix plugin strings splitting arbitrarily on `:` which caused full paths on Windows to fail as they include `:` after the drive letter.
* Call class property `initializer`s with their target instead of their descriptor.
* Fix `ignore` and `only` not properly working on Windows path separators. Thanks [@stagas](https://github.com/stagas)!
* Fix shorthand properties not correctly being target for `isReferenced` checks. Thanks [@monsanto](https://github.com/monsanto)!
* **Polish**
* Allow passing an array of globs to `babel/register``only` and `ignore` options. Thanks [@Mark-Simulacrum](https://github.com/Mark-Simulacrum)!
* When inferring function names that collide with upper bindings, instead of doing the wrapper, instead rename them.
* Consider constant-like variable declaration functions to always refer to themselves so TOC can be performed.
* Process globs manually when using `$ babel` as some shells such as Windows don't explode them. Thanks [@jden](https://github.com/jden)!
* Add alternative way to execute plugins via a closure that's called with the current Babel instance.
* **Internal**
* Remove multiple internal transformers in favor of directly doing things when we need to. Previously, declarations such as `_ref` that we needed to create in specific scopes were done at the very end via the `_declarations` transformer. Now, they're done and added to the scope **right** when they're needed. This gets rid of the crappy `_declarations` property on scope nodes and fixes the crappy regenerator bug where it was creating a new `BlockStatement` so the declarations were being lost.
* Rework transformer traversal optimisation. Turns out that calling a `check` function for **every single node** in the AST is ridiculously expensive. 300,000 nodes timesed by ~30 transformers meant that it took tens of seconds to perform while it's quicker to just do the unnecessary traversal. Seems obvious in hindsight.
* **New Feature**
* Add `jscript` transformer that turns named function expressions into function declarations to get around [JScript's horribly broken function expression semantics](https://kangax.github.io/nfe/#jscript-bugs). Thanks [@kondi](https://github.com/kondi)!
* Add `@@hasInstance` support to objects when using the `es6.spec.symbols` transformer.
* Add `retainLines` option that retains the line (but not the columns!) of the input code.
## 5.1.13
* **Polish**
* Remove symbol check from `defineProperty` helper.
## 5.1.12
* **Bug Fix**
* Fix `resolveModuleSource` not being ran on `ExportAllDeclaration`s.
* Fix `.babelrc` being resolved multiple times when using the require hook.
* Fix parse error on spread properties in assignment position.
* Fix `externalHelpers` option being incorrectly listed as type `string`.
* **Internal**
* Upgrade `core-js` to `0.9.0`.
* **Spec Compliance**
* Fix object decorators not using the `initializer` pattern.
For issue references: Add a comma-separated list of a [closing word](https://help.github.com/articles/closing-issues-via-commit-messages/) followed by the ticket number fixed by the PR. It should be underlined in the preview if done correctly.
Please note that the Babel Team requires two approvals before merging most PRs.
For issue references: Add a comma-separated list of a [closing word](https://help.github.com/articles/closing-issues-via-commit-messages/) followed by the ticket number fixed by the PR. (it should be underlined in the preview if done correctly)
If you are making a change that should have a docs update: submit another PR to https://github.com/babel/website
-->
-->
| Q | A <!--(Can use an emoji 👍) -->
| Q | A <!--(Can use an emoji 👍) -->
| ------------------------ | ---
| ------------------------ | ---
| Fixed Issues? | `Fixes #1, Fixes #2`<!-- remove the (`) quotes to link the issues -->
| Fixed Issues? | `Fixes #1, Fixes #2`<!-- remove the (`) quotes and write "Fixes" before the number to link the issues -->
| Patch: Bug Fix? |
| Patch: Bug Fix? |
| Major: Breaking Change? |
| Major: Breaking Change? |
| Minor: New Feature? |
| Minor: New Feature? |
| Tests Added + Pass? | Yes
| Tests Added + Pass? | Yes
| Documentation PR | <!-- If so, add `[skip ci]` to your commit message to skip CI -->
| Documentation PR Link | <!-- If only readme change, add `[skip ci]` to your commits -->
In the interest of fostering an open and welcoming environment, we as
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
nationality, personal appearance, race, religion, or sexual identity and
@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
## Enforcement
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting hzoo, thejameskyle, sebastian, orloganfsmyth on [Slack](https://slack.babeljs.io/). All
reported by contacting Henry Zhu <hi@henryzoo.com>, Logan Smyth <loganfsmyth@gmail.com> or one of the other [Babel core team members](https://babeljs.io/team). All
complaints will be reviewed and investigated and will result in a response that
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
obligated to maintain confidentiality with regard to the reporter of an incident.
- If you aren't just making a documentation change, you'll probably want to learn a bit about a few topics.
- If you aren't just making a documentation change, you'll probably want to learn a bit about a few topics.
- [ASTs](https://en.wikipedia.org/wiki/Abstract_syntax_tree) (Abstract Syntax Tree): The Babel AST [spec](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md) is a bit different from [ESTree](https://github.com/estree/estree). The differences are listed [here](https://github.com/babel/babel/tree/master/packages/babel-parser#output).
- [ASTs](https://en.wikipedia.org/wiki/Abstract_syntax_tree) (Abstract Syntax Tree): The Babel AST [spec](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md) is a bit different from [ESTree](https://github.com/estree/estree). The differences are listed [here](https://babeljs.io/docs/en/next/babel-parser.html#output).
- Check out [`/doc`](https://github.com/babel/babel/tree/master/doc) for information about Babel's internals
- Check out [`/doc`](https://github.com/babel/babel/tree/master/doc) for information about Babel's internals
- Check out [the Babel Plugin Handbook](https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-plugin-handbook) - core plugins are written the same way as any other plugin!
- Check out [the Babel Plugin Handbook](https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-plugin-handbook) - core plugins are written the same way as any other plugin!
- Check out [AST Explorer](http://astexplorer.net/#/scUfOmVOG5) to learn more about ASTs or make your own plugin in the browser
- Check out [AST Explorer](http://astexplorer.net/#/scUfOmVOG5) to learn more about ASTs or make your own plugin in the browser
@ -32,6 +32,7 @@ contributing, please read the
- Follow along with what we are working on by joining our [Slack](https://babeljs.slack.com) (you can sign-up [here](https://slack.babeljs.io/)
- Follow along with what we are working on by joining our [Slack](https://babeljs.slack.com) (you can sign-up [here](https://slack.babeljs.io/)
for an invite), following our announcements on [Twitter](https://twitter.com/babeljs), and reading (or participating!) in our [meeting notes](https://github.com/babel/notes).
for an invite), following our announcements on [Twitter](https://twitter.com/babeljs), and reading (or participating!) in our [meeting notes](https://github.com/babel/notes).
- Check out our [website](http://babeljs.io/) and the [repo](https://github.com/babel/website)
- Check out our [website](http://babeljs.io/) and the [repo](https://github.com/babel/website)
- You can contribute by triaging issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to babel on CodeTriage](https://www.codetriage.com/babel/babel). [](https://www.codetriage.com/babel/babel)
## Chat
## Chat
@ -186,7 +187,7 @@ For example, in [`@babel/plugin-transform-exponentiation-operator/test`](https:/
- If you need to expect an error, you can ignore creating the `output.js` file and pass a new `throws` key to the `options.json` that contains the error string that is created.
- If you need to expect an error, you can ignore creating the `output.js` file and pass a new `throws` key to the `options.json` that contains the error string that is created.
- The second and preferred type is a test that actually evaluates the produced code and asserts that certain properties are true or false. We do this by creating an [`exec.js`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/comprehensive/exec.js) file.
- The second and preferred type is a test that actually evaluates the produced code and asserts that certain properties are true or false. We do this by creating an [`exec.js`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/comprehensive/exec.js) file.
In a fixture test, you simply write out the code you want transformed in `input.js`.
In a fixture test, you simply write out the code you want to transform in `input.js`.
```js
```js
// input.js
// input.js
@ -230,7 +231,7 @@ If the test requires a minimum Node version, you can add `minNodeVersion` (must
Writing tests for the babel parser is very
Writing tests for the babel parser is very
similar to the other packages.
similar to the other packages.
Inside the `packages/babel-parser/tests/fixtures` folder are categories/groupings of test fixtures (es2015, flow,
Inside the `packages/babel-parser/test/fixtures` folder are categories/groupings of test fixtures (es2015, flow,
etc.). To add a test, create a folder under one of these groupings (or create a new one) with a
etc.). To add a test, create a folder under one of these groupings (or create a new one) with a
descriptive name, and add the following:
descriptive name, and add the following:
@ -310,7 +311,7 @@ Note that the code shown in Chrome DevTools is compiled code and therefore diffe
- Create a new issue that describes the proposal (ex: [#538](https://github.com/babel/babylon/issues/538)). Include any relevant information like proposal repo/author, examples, parsing approaches, meeting notes, presentation slides, and more.
- Create a new issue that describes the proposal (ex: [#538](https://github.com/babel/babylon/issues/538)). Include any relevant information like proposal repo/author, examples, parsing approaches, meeting notes, presentation slides, and more.
- The pull request should include:
- The pull request should include:
- [ ] An update to the [plugins](https://github.com/babel/babel/tree/master/packages/babel-parser#plugins) part of the readme. Add a new entry to that list for the new plugin flag (and link to the proposal)
- [ ] An update to the [plugins](https://github.com/babel/babel/tree/master/packages/babel-parser#plugins) part of the readme. Add a new entry to that list for the new plugin flag (and link to the proposal)
- [ ] If any new nodes or modifications need to be added to the AST, update [ast/spec.md](https://github.com/babel/babel/bloc/master/packages/babel-parser/ast/spec.md)
- [ ] If any new nodes or modifications need to be added to the AST, update [ast/spec.md](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md)
- [ ] Make sure you use the `this.hasPlugin("plugin-name-here")` check in the babel parser so that your new plugin code only runs when that flag is turned on (not default behavior)
- [ ] Make sure you use the `this.hasPlugin("plugin-name-here")` check in the babel parser so that your new plugin code only runs when that flag is turned on (not default behavior)
- [ ] Add failing/passing tests according to spec behavior
- [ ] Add failing/passing tests according to spec behavior
<ahref="https://twitter.com/intent/follow?screen_name=babeljs"><imgalt="Follow on Twitter"src="https://img.shields.io/twitter/follow/babeljs.svg?style=social&label=Follow"></a>
Babel is a community-driven project used by many companies and projects, and is maintained by a group of [volunteers](https://babeljs.io/team). If you'd like to help support the future of the project, please consider:
Babel (pronounced ["babble"](https://soundcloud.com/sebmck/how-to-pronounce-babel)) is a community-driven project used by many companies and projects, and is maintained by a group of [volunteers](https://babeljs.io/team). If you'd like to help support the future of the project, please consider:
- Giving developer time on the project. (Message us on [Twitter](https://twitter.com/babeljs) or [Slack](https://slack.babeljs.io/) for guidance!)
- Giving developer time on the project. (Message us on [Twitter](https://twitter.com/babeljs) or [Slack](https://slack.babeljs.io/) for guidance!)
- Giving funds by becoming a sponsor (see below)!
- Giving funds by becoming a sponsor on [Open Collective](https://opencollective.com/babel) or [Patreon](https://www.patreon.com/henryzhu)!
## Open Collective Sponsors
## Sponsors
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/babel#sponsor)]
Our top sponsors are shown below! [[Become a sponsor](https://opencollective.com/babel#sponsor)]
@ -99,15 +85,15 @@ Try it out at our [REPL](https://babeljs.io/repl/build/master#?code_lz=NoRgNATGD
### Who maintains Babel?
### Who maintains Babel?
Mostly a handful of volunteers! Please check out our [team page](https://babeljs.io/team)!
Mostly a handful of volunteers, funded by you! Please check out our [team page](https://babeljs.io/team)!
### Looking for support?
For questions and support please visit join our [Slack Community](https://slack.babeljs.io/) (you can sign-up [here](https://slack.babeljs.io/) for an invite), ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/babeljs), or ping us on [Twitter](https://twitter.com/babeljs).
### Is there a Babel song?
### Is there a Babel song?
I'm so glad you asked: [Hallelujah —— In Praise of Babel](SONG.md) by [@angus-c](https://github.com/angus-c). Tweet us your recordings!
I'm so glad you asked: [Hallelujah —— In Praise of Babel](SONG.md) by [@angus-c](https://github.com/angus-c), [audio version](https://youtu.be/40abpedBKK8) by [@swyx](https://twitter.com/@swyx). Tweet us your recordings!
### Looking for support?
For questions and support please join our [Slack Community](https://slack.babeljs.io/) (you can sign-up [here](https://slack.babeljs.io/) for an invite), ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/babeljs), or ping us on [Twitter](https://twitter.com/babeljs).
### Where are the docs?
### Where are the docs?
@ -119,12 +105,19 @@ Please read through our [CONTRIBUTING.md](CONTRIBUTING.md) and fill out the issu
### Want to contribute to Babel?
### Want to contribute to Babel?
Check out our [CONTRIBUTING.md](CONTRIBUTING.md) to get started with setting up the repo.
Check out:
- If you have already joined Slack, join our [#development](https://babeljs.slack.com/messages/development) channel and say hi!
- Our [#development](https://babeljs.slack.com/messages/development) Slack channel and say hi ([signup](https://slack.babeljs.io))!
- Check out the issues with the [good first issue](https://github.com/babel/babel/labels/good%20first%20issue) and [help wanted](https://github.com/babel/babel/labels/help%20wanted) label. We suggest also looking at the closed ones to get a sense of the kinds of issues you can tackle.
- Issues with the [good first issue](https://github.com/babel/babel/labels/good%20first%20issue) and [help wanted](https://github.com/babel/babel/labels/help%20wanted) label. We suggest also looking at the [closed ones](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aclosed+label%3A%22good+first+issue%22) to get a sense of the kinds of issues you can tackle.
Some resources:
- Our [CONTRIBUTING.md](CONTRIBUTING.md) to get started with setting up the repo.
[`@babel/core`](/packages/babel-core) is the Babel compiler itself; it exposes the `babel.transform` method, where `transformedCode = transform(src).code`.
[`@babel/core`](/packages/babel-core) is the Babel compiler itself; it exposes the `babel.transform` method, where `transformedCode = transform(src).code`.
@ -36,14 +36,14 @@ Check out the [`babel-handbook`](https://github.com/thejameskyle/babel-handbook/
- [`@babel/cli`](/packages/babel-cli) is the CLI tool that runs `@babel/core` and helps with outputting to a directory, a file, stdout and more (also includes `@babel/node` cli). Check out the [docs](https://babeljs.io/docs/usage/cli/).
- [`@babel/cli`](/packages/babel-cli) is the CLI tool that runs `@babel/core` and helps with outputting to a directory, a file, stdout and more (also includes `@babel/node` cli). Check out the [docs](https://babeljs.io/docs/usage/cli/).
- [`@babel/types`](/packages/babel-types) is used to validate, build and change AST nodes.
- [`@babel/types`](/packages/babel-types) is used to validate, build and change AST nodes.
@ -62,7 +62,7 @@ The transformer[s] used in Babel are the independent pieces of code that transfo
| Package | Version | Dependencies | Description |
| Package | Version | Dependencies | Description |
|--------|-------|------------|---|
|--------|-------|------------|---|
| [`@babel/preset-env`](/packages/babel-preset-env) | [](https://www.npmjs.com/package/@babel/preset-env) | [](https://david-dm.org/babel/babel?path=packages/babel-preset-env) | automatically determines plugins and polyfills you need based on your supported environments |
| [`@babel/preset-env`](/packages/babel-preset-env) | [](https://www.npmjs.com/package/@babel/preset-env) | [](https://david-dm.org/babel/babel?path=packages/babel-preset-env) | automatically determines plugins and polyfills you need based on your supported environments |
> You can find community maintained presets on [npm](https://www.npmjs.com/search?q=babel-preset)
> You can find community maintained presets on [npm](https://www.npmjs.com/search?q=babel-preset)
In addition, various entry point scripts live in the top-level package at `@babel/cli/bin`.
See our website [@babel/cli](https://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.
There is a shell-executable utility script, `babel-external-helpers.js`, and the main Babel cli script, `babel.js`.
## Install
## Install
```sh
Using npm:
npm install --save-dev @babel/core@babel/cli
```
## Usage
```sh
```sh
babel script.js
npm install --save-dev @babel/cli
```
```
For more in depth documentation see: http://babeljs.io/docs/usage/cli/
{"version":3,"sources":["stdin"],"names":[],"mappings":";;AAAA,GAAG,CAAC,GAAG,CAAC,UAAA,CAAC;SAAI,CAAC,GAAG,CAAC;CAAA,CAAC,CAAC","file":"test.js","sourcesContent":["arr.map(x => x * x);"]}
{"version":3,"sources":["../src/foo.js"],"names":["arr","map","x","MULTIPLIER"],"mappings":";;AAAAA,IAAIC,GAAJ,CAAQ;AAAA,SAAKC,IAAIC,UAAT;AAAA,CAAR","sourcesContent":["arr.map(x => x * MULTIPLIER);"],"file":"foo.js"}
{"version":3,"sources":["../src/foo.js"],"names":["arr","map","x","MULTIPLIER"],"mappings":";;AAAAA,GAAG,CAACC,GAAJ,CAAQ,UAAAC,CAAC;AAAA,SAAIA,CAAC,GAAGC,UAAR;AAAA,CAAT","sourcesContent":["arr.map(x => x * MULTIPLIER);"],"file":"foo.js"}
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.