Compare commits

..

152 Commits

Author SHA1 Message Date
Henry Zhu
adca165ee9 v7.0.0-beta.55 2018-07-28 18:06:42 -04:00
Henry Zhu
fa86b2ddf0 Remove our own use of stage presets (#8397)
- also update the stage preset error message/readme's to point to the new blog post
2018-07-28 11:24:53 -04:00
Logan Smyth
5eb193c61f Ensure that Identifier source mappings explicitly start and stop on the generated range (#8380)
* Add sourcemap examples for identifiers in code generator.

* Generate sourcemaps with exact mappings for identifiers, even if leading/trailing tokens also use that location.
2018-07-27 16:27:33 -04:00
Nicolò Ribaudo
ec69b4bb12 Save full descriptor instead of only value for private fields. (#8318)
* 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.
2018-07-27 16:24:57 -04:00
Brian Ng
5fdcd29ef9 Ensure preset-env doesn't clobber browserslist defaults (#8391) 2018-07-26 15:22:26 -04:00
Andy
8ee24fdfc0 TypeScript: Support type arguments on tagged templates (#7754)
| 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.
2018-07-26 10:44:43 -05:00
Qix
db2a9fc96e Fix order of optional argument reordering (#8376)
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.
2018-07-26 11:25:35 -04:00
Sven Sauleau
75767e9273 Merge pull request #8381 from wtgtybhertgeghgtwtg/babelrcroots-array
Allow an Array for `babelrcRoots`.
2018-07-25 11:36:57 +02:00
wtgtybhertgeghgtwtg
4346a95b88 Perform check on each member of babelrcroots. 2018-07-24 16:57:24 -07:00
Maximilian Berkmann
26cbbb569f Bumped lodash to 4.17.10 (#8377) 2018-07-24 12:57:43 -04:00
Kevin Gibbons
a811cf78e1 Correctly parse interface methods named 'static' (#8374) 2018-07-24 09:25:55 +02:00
Henry Zhu
c70a32ab9d Throw when using Stage presets (#8293)
* inline stage presets into standalone, throw error with using Stage presets
2018-07-23 22:22:52 -04:00
Thiago Arrais
6f3a800677 Do not mutate ast (#8342)
This clones the given ast prior to working on it to avoid mutating the AST given to `transformFromAST`.
2018-07-23 22:20:55 -04:00
Kevin Gibbons
d781e207c8 Docs: fix typo in path (#8372) [skip ci] 2018-07-23 20:32:44 -04:00
dnalborczyk
8b10a44fe1 remove .then from dynamic import parser exception message (#8355) 2018-07-21 08:26:17 +02:00
dnalborczyk
adae1501ac update jest (major), babel-jest (major) (#8341)
updated `jest` and `babel-jest` to `v23`

fixed breaking change in `jest`:
- https://github.com/facebook/jest/blob/master/CHANGELOG.md#2300
- https://github.com/facebook/jest/pull/5558

_edit:_
forgot to mention. test runner fix is based on: https://github.com/babel/babel/blob/master/packages/babel-parser/test/helpers/runFixtureTests.js#L11
2018-07-19 10:43:35 -04:00
dnalborczyk
c8038f69fe update prettier (#8339) 2018-07-19 09:08:45 -05:00
dnalborczyk
30ea328e97 bump flow (#8338) 2018-07-19 09:41:09 -04:00
dnalborczyk
16b1f8c427 updates eslint, babel-eslint, eslint-plugin-flowtype, eslint-plugin-prettier (#8337) 2018-07-19 09:36:52 -04:00
Henry Zhu
a582cc5bd8 update changelog for .53/.54 [skip ci] 2018-07-18 08:54:05 -04:00
Henry Zhu
84282f199b v7.0.0-beta.54 2018-07-16 13:59:43 -04:00
Logan Smyth
52a569056c Merge pull request #8327 from loganfsmyth/drop-pattern-matching
Treat string ignore/only/test/include/exclude values as paths with only basic pattern matching
2018-07-16 10:11:23 -07:00
Henry Zhu
7446d06911 also default stage 2 to decoratorsLegacy true [skip ci] 2018-07-16 13:07:17 -04:00
James DiGioia
8817fcf03e Fix stage-0/1 import of pipeline/decorators proposals (#8317)
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.
2018-07-16 13:02:54 -04:00
Logan Smyth
6d177ba4c5 Remove micromatch and use a simple pattern matching utility. 2018-07-16 09:57:14 -07:00
Logan Smyth
935533cff3 Ensure that the wildcard interop is used with re-export + default. (#8316) 2018-07-14 12:49:31 -07:00
Logan Smyth
c4f67bfa57 Leave it to users to clear the require cache if they want to. 2018-07-14 12:48:58 -07:00
Logan Smyth
2854a187be Remove dependency on barely-used package. 2018-07-14 12:41:36 -07:00
rugk
62ee1adc85 Add link to audio version of song (#8320) 2018-07-13 15:34:40 -05:00
Logan Smyth
fd9ebf9e1d Remove option-filtering options from the final options results. (#8315)
| 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.
2018-07-13 07:01:11 -07:00
Daniel Tschinder
dca6125128 Update pirates to 4.0 (#8308) 2018-07-11 16:04:27 -04:00
Henry Zhu
093483c399 remove yearly preset folders [skip ci] 2018-07-11 11:08:33 -04:00
Henry Zhu
b89234b1a2 v7.0.0-beta.53 2018-07-11 09:39:52 -04:00
Ryan Tsao
f2fd9e982e Make env preset build-data scripts reproducible (#8299) 2018-07-10 20:43:45 -05:00
Andy
301db1b921 TypeScript: Support type arguments on JSX opening and self-closing tags (#7799) 2018-07-10 17:19:42 -05:00
James DiGioia
19a1705293 Support pipeline proposal flag in @babel/parser (#8291) 2018-07-09 16:59:56 -04:00
Henry Zhu
10910a10f5 Remove yearly presets from repo, inline in standalone (#8274)
These were already deprecated in v6, just didn't remove the folders?
2018-07-09 14:23:25 -04:00
Henry Zhu
dd6da3b3af rm extra changelog [skip ci] 2018-07-07 18:44:43 -04:00
Henry Zhu
d2d2118a44 Move v4, v5, v6 changelogs to separate files [skip ci] (#8286) 2018-07-07 18:43:34 -04:00
Mateusz Burzyński
21de1581aa Fixed fixture tests after merge (#8287) 2018-07-07 18:40:15 -04:00
Mateusz Burzyński
b5e64cb66e Remove unused bindings when excluding keys with rest in loose mode (#8264) 2018-07-07 19:54:51 +02:00
Alan Pierce
44f738bcbf Upgrade upath to avoid yarn failure on node 10 (#8283) [skip ci]
upath 1.0.4 doesn't support node 10, and this was fixed in later versions
( https://github.com/anodynos/upath/pull/15 )
2018-07-07 10:52:55 -04:00
Henry Zhu
13153ede92 add changelog for 6.23.1-3 [skip ci] 2018-07-07 10:28:01 -04:00
Mateusz Burzyński
c0c13ae30f Introduce objectWithoutPropertiesLoose helper (#8261) 2018-07-06 15:03:44 -04:00
Henry Zhu
cea562c009 Revert micromatch upgrade (regression) [skip ci] (#8281)
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.
2018-07-06 14:28:02 -04:00
James DiGioia
f93fa28c90 Improve error messages around pipeline option (#8279) 2018-07-06 13:01:35 -04:00
Brian Ng
430a105ae7 Compile against beta 52 (#8282) 2018-07-06 12:12:19 -04:00
Tatsuyuki Ishi
3e71108f82 Invoke Jest main file directly (#8187) 2018-07-06 10:09:49 -04:00
Tim Kendrick
e9184ed05e [babel-types] Fix isNodesEquivalent() behavior for TemplateElements (#8165)
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.
2018-07-06 08:45:25 -04:00
Henry Zhu
663c96db04 v7.0.0-beta.52 2018-07-05 20:59:03 -04:00
Rubén Norte
85b7154f91 Add visitor key for Flow typeArguments in call expressions (#8273)
| 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
2018-07-05 14:58:15 -05:00
Henry Zhu
f70d7c8dfe update template [skip ci]
link to babel/website
2018-07-05 14:19:15 -04:00
Justin Ridgewell
e229ebbb8a Optimize async to generator (#8267)
* Optimize async to generator

We can reuse the step function, avoiding a closure on every invocation.

* Rename step
2018-07-05 10:51:16 -04:00
dnalborczyk
db1385fb82 upgrades eslint v5 (major), babel-eslint, eslint-plugin-flowtype, eslint-plugin-prettier (#8259)
* upgrade eslint v5 (major), babel-eslint (minor), eslint-plugin-flowtype (minor), eslint-plugin-prettier (patch)

* fix makefile: remove (default) .js file extension, remove non-existing glob pattern

* fix linting errors

* add '*.js' glob back to include babel.config.js for linting
2018-07-05 09:17:01 -05:00
Logan Smyth
b6eba87daa Rename some test fixtures so they run properly. (#8265) 2018-07-04 18:33:26 -07:00
Logan Smyth
2cf2fd544b Ensure that we don't get unexpected output files for tests that throw. (#8208) 2018-07-04 16:06:58 -07:00
Logan Smyth
9bd4b46fd6 Merge pull request #8198 from loganfsmyth/sourcemap-loading
Prefer explicit object maps, and properly load relative maps.
2018-07-04 15:39:42 -07:00
Pierre-Marie Dartus
4d125c391a Typescript: Avoid stripping class properties when a decorator is set (#8238)
The `babel-plugin-transform-typescript` removes class properties without value regardless if decorators are assigned to it or not.
2018-07-04 07:44:33 -04:00
dnalborczyk
afa1207224 upgrade flow to v0.75.0 (#8256) 2018-07-03 11:23:32 -05:00
Rodolfo Rodriguez
c6a4108e57 Update READMEs for yarn (#8215) [skip ci]
Closes https://github.com/babel/babel/pull/8255
2018-07-03 09:03:18 -04:00
John Buffington
236bd9309c remove emojis from cli output (#8243) (#8250) 2018-07-02 09:34:55 +02:00
James DiGioia
eac4c5bc17 Add proposal flag to pipeline plugin (#8196)
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.
2018-06-28 01:19:40 +02:00
Mateusz Burzyński
e1662759ed Remove regenerator hacks in checkDuplicatedNodes (#8220) 2018-06-24 15:40:47 +02:00
Ben Newman
12c75cc08c Update regenerator-{runtime,transform} to latest versions. (#8219)
https://github.com/facebook/regenerator/pull/347
https://github.com/facebook/regenerator/pull/349
https://github.com/facebook/regenerator/pull/350
2018-06-24 10:19:21 +02:00
Sven Sauleau
9283efaeb7 Merge pull request #8197 from loganfsmyth/babel-plugin-allowed
Allow @foo/babel-plugin as an unexpanded plugin name, and @foo as a shorthand for it.
2018-06-20 16:36:03 +02:00
Logan Smyth
532c25c8db Ensure that file-path sourcemaps load relative to the file containing the comment. 2018-06-18 22:06:08 -07:00
Logan Smyth
3c90baaf6c Prefer object sourcemaps over file-inlined sourcemaps. 2018-06-18 21:49:23 -07:00
Logan Smyth
add5f8d0fe Allow @foo/babel-plugin as an unexpanded plugin name, and @foo as a shorthand for it. 2018-06-18 21:36:02 -07:00
Soumya Himanish Mohapatra
cb79473499 remove regression to support output of full directory hierarchy with --out-dir (#8189)
* remove regression to support output of full directory hierarchy with --out-dir

* add mkdirp to package.json
2018-06-18 21:19:46 -07:00
Brian Ng
d383659ca6 Compile against beta 51 (#8158) 2018-06-15 10:28:15 -04:00
Ger Hobbelt
e86d1e0d6a babel/parser: test helpers: write expected throw message to options.json ~ complete jest -u functionality (#8178) [skip ci]
* 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*.
2018-06-15 10:27:19 -04:00
Ger Hobbelt
a2cd264211 jest binary is a bash shell script, not a nodeJS file. (#8179) [skip ci] 2018-06-15 10:18:14 -04:00
Sven Sauleau
8f8b4e8e82 Switch new website in READMEs (#8181) [skip ci] 2018-06-15 10:13:20 -04:00
Ger Hobbelt
07c88e6f0b Use charCodes at more places in the parser (#8176) 2018-06-15 13:21:32 +02:00
Ger Hobbelt
ba98cf782a Removed constant condition in parser (#8177) 2018-06-15 13:14:14 +02:00
kenju
bc64e02bf8 fix issue number of link for #3508 in CHANGELOG (#8175) [skip ci] 2018-06-15 12:12:21 +02:00
dnalborczyk
814fce946d bump flow to v0.74.0 (#8162) 2018-06-13 15:00:09 -04:00
dnalborczyk
6894465df8 fix flow typeof refinement (#8161) [skip ci] 2018-06-13 14:59:57 -04:00
Ben Newman
60c4f30c71 Update regenerator-transform to latest version (0.13.0). (#8154)
| 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.
2018-06-13 09:36:27 -05:00
Henry Zhu
c313b267f7 v7.0.0-beta.51 2018-06-12 17:18:28 -04:00
Henry Zhu
eb54adb755 use a semver range for core peerDep [skip ci] 2018-06-12 17:10:15 -04:00
Henry Zhu
e0ef50c00f Use older semver range since lerna update does not change peerDeps on publish [skip ci] (#8152) 2018-06-12 16:45:10 -04:00
Henry Zhu
3af623678f v7.0.0-beta.50 2018-06-12 15:46:05 -04:00
Henry Zhu
96528d36df keep lerna version 2018-06-12 15:22:34 -04:00
Henry Zhu
5de12c26f6 update to latest 2.x lerna 2018-06-12 15:02:56 -04:00
Henry Zhu
4b5a55d937 fix merge issue again 2018-06-12 13:59:43 -04:00
Guy Bedford
036c429ce1 system hoisting and export refinements (#8104) 2018-06-12 13:45:53 -04:00
Nicolò Ribaudo
3c46e75b8f Don't split an exported class when renaming an inner binding (#8051) 2018-06-12 13:45:21 -04:00
晏兵兵
106907e605 fix: import Parser as type (#8146) [skip ci] 2018-06-12 13:42:10 -04:00
Nicolò Ribaudo
387cda8fbb isConstantExpression should return true for immuable bindings (#8122)
* isConstantExpression should return true for immuable bindings

* New test

* Don't return undefined
2018-06-12 13:40:52 -04:00
Henry Zhu
86c10ff4f3 fix merge issue 2018-06-12 13:33:07 -04:00
Miguel Albernaz
6d5392554f Adds JSXFragment to plugin-transform-typescript check for the presence of jsx (#7996) 2018-06-12 13:17:25 -04:00
Alexey Zaslavsky
0b25e3327c Fix 'Missing class properties transform' error when parsing class properties with Typescript syntax (#8007) 2018-06-12 13:13:30 -04:00
Brian Ng
b6455c611b Allow ts modifier names to be used as function argument names (#8030) 2018-06-12 08:38:38 -05:00
Yuri Karadzhov
313960e601 Remove preset-env outdated test (#8149) 2018-06-12 08:51:11 -04:00
Yuri Karadzhov
9e4c56f990 Fix Safari TP and regular versions comparison (#8132) 2018-06-11 14:36:45 -04:00
Nicolò Ribaudo
119db23ee3 Don't regenerate babel-types docs in the readme (#8142) 2018-06-11 14:35:21 -04:00
Vincent Chan
3432792568 add jsesc options support (#8143) 2018-06-11 14:34:41 -04:00
Brian Ng
cc4ee350e4 Ensure regex-dot-all runs before unicode-regex in preset-env (#8138)
<!--
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
2018-06-11 08:09:44 -05:00
Sven Sauleau
5bd79c70a5 Merge pull request #8144 from BeniCheni/add-labels-to-readmes
Add Labels to READMEs Generator & Update README's w. Links To Open Issues (for some pkg's)
2018-06-11 07:32:34 +02:00
BeniCheni
01f6f4c66d Revert babel-types README to "master" 2018-06-11 01:19:18 -04:00
BeniCheni
000fa83b9e For selective packages, update READMES w. links for open issues
babel-generator; babel-node; babel-standalone; babel-template
2018-06-11 00:16:48 -04:00
BeniCheni
efb34aa7dc For selective packages, add items for labels mapping of pkg => labels & update READMES w. links for open issues
babel-generator; babel-node; babel-standalone; babel-template
2018-06-10 23:41:55 -04:00
Brian Ng
ab928713af Bump test262-stream and update test262 tests (#8139) 2018-06-10 10:55:40 +02:00
Serhii Nanovskyi
3de053cc6c Validate @babel/preset-env options (#8031) 2018-06-09 18:38:14 -05:00
Sven Sauleau
110779e9f3 Merge pull request #8133 from alexzherdev/8131-open-issues-link
Link to open issues in READMEs [skip ci]
2018-06-09 15:03:49 +02:00
Alex Zherdev
8070a2204d Link to open issues in READMEs [skip ci] 2018-06-08 20:54:44 -07:00
Nicolò Ribaudo
9f4e2f81d8 [class-properties] Remove unnecessary return and temp variable (#8123)
* Remove unnecessary temp variable

* Update tests
2018-06-08 07:02:36 +02:00
Mathias Bynens
415d79bdfe Update plugin-proposal-unicode-property-regex for Unicode v11 (#8127)
Ref. https://github.com/tc39/ecma262/pulls/1218.
Ref. https://github.com/tc39/ecma262/issues/1219.
2018-06-07 21:54:44 +02:00
Mathias Bynens
62eb32677c ECMAScript follows the latest version of the Unicode Standard. Earlier this week, Unicode v11 was officially released. This patch updates babel-parser to support the new identifier characters. (#8125)
Ref. https://github.com/tc39/ecma262/issues/1219.
2018-06-07 21:54:12 +02:00
Guy Bedford
7da7e760a6 support import.meta in system transform 2018-06-07 13:24:19 -05:00
hassanAli321
bd44902024 update fixture 2018-06-07 13:22:45 -05:00
hassanAli321
6480ae4a9f fix flow-double-nullable-type-cant-be-parsed 2018-06-07 13:22:45 -05:00
Marco Massarotto
80b3362fcc update micromatch to ^3.1.10 (#8038) 2018-06-06 12:44:02 +02:00
Sven SAULEAU
8bc0182489 Merge pull request #8119 from palashmon/fix-package-readmes
fix(typo): in readmes package label
2018-06-05 19:24:25 +02:00
Palash Mondal
e9d861537f [skip ci] updated babel-register readme 2018-06-05 22:43:46 +05:30
Palash Mondal
153ad4c6f3 fix(typo): in readmes package label
"babel-regiser" to "babel-register" and "pkg: regiser" to "pkg: register"
2018-06-05 21:19:51 +05:30
Sven SAULEAU
218d69007e Merge pull request #8112 from babel/feat-add-issues-link-in-readmes
Feat add issues link in readmes
2018-06-05 07:39:41 +02:00
Nicolò Ribaudo
f838a7e9f1 Test on node 10 (#7908)
* Use node 10 on circle an node 9 on travis

* Update v8flag
2018-06-04 22:22:30 +02:00
Nicolò Ribaudo
6349118bed Change decoratorsBeforeExport default to false (#8113) 2018-06-04 21:12:01 +02:00
Sven SAULEAU
8bbb10c021 chore: [skip ci] regen READMEs 2018-06-04 17:33:21 +02:00
Sven SAULEAU
f614809002 feat: [skip ci] add link to issues in READMEs 2018-06-04 17:33:16 +02:00
Sven SAULEAU
b445b79734 Refactor move docs (#8108)
* feat: [skip] generate readme script

* docs: [skip ci] update READMEs

* docs: [skip ci] fix code block type

* chore: [skip ci] move generator script
2018-06-04 10:32:39 -04:00
Sven SAULEAU
b6eaaa2496 Merge pull request #8107 from babel/xtuc-patch-3
docs: [skip ci] update polyfill README
2018-06-04 08:46:51 +02:00
Sven SAULEAU
e2471337f4 docs: [skip ci] update polyfill README 2018-06-04 08:46:08 +02:00
Sven SAULEAU
826edd0bd5 Merge pull request #8106 from babel/xtuc-patch-3
update runtime README
2018-06-04 08:43:15 +02:00
Sven SAULEAU
f434a50829 docs: update runtime README 2018-06-04 08:42:48 +02:00
Brian Ng
5895277b32 Bump prettier to v1.13.2 2018-06-03 07:54:39 -05:00
Brian Ng
62114b807b Remove unneeded prettier call in make fix 2018-06-03 07:54:39 -05:00
chocolateboy
2abd7839e1 Fix ReferenceError in the wrapNativeSuper helper (#8100)
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.)
2018-06-02 18:00:02 +02:00
Nicolò Ribaudo
b8dcd6f593 Remove parser support for decorators optional parentheses (#8037)
* Remove parser support for decorators optional parentheses

* Update fixtures
2018-06-02 13:07:15 +02:00
dnalborczyk
fe556c502d fix folder name (#8074) 2018-06-01 17:58:37 +02:00
Peter Leonov
ab62a94399 make isReferenced() recognise ObjectTypeProperty (#8060)
fixes #8057
2018-05-31 00:07:56 +02:00
Nicolò Ribaudo
d83d141e00 Move tests from babylon/ to babel-parserr/ 2018-05-30 22:12:33 +02:00
Nicolò Ribaudo
cb17f07ac9 Update syntax-decorators options (#7938)
* Add decoratorsBeforeExport to the syntax plugin
* Require legacy: true, like in the transform plugin
2018-05-30 22:00:18 +02:00
Logan Smyth
21b9b2e42d Avoid a race condition in CLI directory creation. (#8082) 2018-05-30 10:35:08 -07:00
Erik Arvidsson
2a8ebbe7ae Remove parenthesizedArgument (#7981)
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
2018-05-29 13:58:21 -07:00
Brian Ng
9add6d88f5 Update regenerator version and test retain lines fixture (#8072) 2018-05-29 10:46:05 -07:00
ilya
2d2f37fa6c Update core-js to v2.5.7 (#8064) 2018-05-29 09:47:15 -05:00
Erik Arvidsson
7846eaebaa Do not quote JSX attribute keys for IdentifierName (#8045)
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)
2018-05-27 12:48:18 -04:00
Nicolò Ribaudo
d45ee5e025 Add "decoratorsBeforeExport" option to @babel/generator (#7948)
* Add "decoratorsBeforeExport" option to @babel/generator

* Docs
2018-05-27 08:50:26 +02:00
Brian Ng
f699f1bbbf flow@0.73.0 (#8032) 2018-05-25 16:53:23 -05:00
Sam Goldman
f0283572a5 Support Flow's proto modifier syntax for declared classes (#7978)
<!--
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.
2018-05-25 15:40:56 -05:00
Logan Smyth
90566103a6 v7.0.0-beta.49 2018-05-25 09:00:02 -07:00
Logan Smyth
cf8058e5b6 Handle kebab-case args in babel-node. (#8046) 2018-05-25 08:40:52 -07:00
Nicolò Ribaudo
90a174e7c4 Transform decorated classes from the export visitor (#8047)
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 -->
2018-05-25 08:36:30 -07:00
Logan Smyth
9c707f9670 Update docs 2018-05-24 20:57:44 -07:00
Logan Smyth
53e4d74ebe Treat all filenames as absolute paths. (#8044) 2018-05-24 20:56:19 -07:00
Logan Smyth
98ff2ce877 Merge pull request #8023 from loganfsmyth/sync-async
Add a promise-returning *Async version of the transform and parse fns
2018-05-24 19:04:38 -07:00
Henry Zhu
0ffc8ed209 Compile against beta 48 (#8036) 2018-05-24 16:25:39 -07:00
Logan Smyth
0bc3027554 Add a promise version of each of Babel's transform functions. 2018-05-23 21:18:17 -07:00
Logan Smyth
6f3093b557 Track the sync and async implementations in the same files. 2018-05-23 21:18:15 -07:00
1491 changed files with 16901 additions and 33004 deletions

View File

@@ -34,7 +34,7 @@ jobs:
build:
working_directory: ~/babel
docker:
- image: circleci/node:9
- image: circleci/node:10
steps:
- checkout
- restore-cache: *restore-yarn-cache

287
.github/CHANGELOG-v4.md vendored Normal file
View File

@@ -0,0 +1,287 @@
# Babel v4 Changelog
## 4.7.16
* **Bug Fix**
* Fix constructor spreading of typed arrays.
* Fix break/continue/return aliasing of non-loops in block scoping transformer.
## 4.7.15
* **Bug Fix**
* Fix constructor spreading of collections.
## 4.7.14
* **Bug Fix**
* Fix constructor spreading of `Promise`.
* **Internal**
* Deprecate remaining playground transformers and abstract references.
## 4.7.13
* **Bug Fix**
* Handle comments on use strict directives.
* Fix assignment patterns with a left side pattern.
* **Polish**
* Special case `this` when doing expression memoisation.
## 4.7.12
* **Bug Fix**
* Deprecate `playground.methodBinding`.
## 4.7.11
* **Bug Fix**
* Fix unicode regexes stripping their unicode flag before being passed on two `regexpu`.
## 4.7.10
* **Internal**
* Deprecate `playground.methodBinding` and `playground.objectGetterMemoization`.
* **Bug Fix**
* Fix `inputSourceMap` option. Thanks [@Rich-Harris](https://github.com/Rich-Harris)!
## 4.7.9
* **Polish**
* 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 Compliancy**
* Make it illegal to use a rest parameter on a setter.
## 4.6.6
* **Bug Fix**
* Fix incorrect method call in `utility.deadCodeElimination` transformer.
* Fix `es6.blockScopingTDZ` transformer duplicating binding nodes.
## 4.6.5
* **Internal**
* `useStrict` transformer has been renamed to `strict`.
## 4.6.4
* **Bug Fix**
* Fix `ForOfStatement` not proplery 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 Compliancy**
* `for...of` now outputs in a lengthy `try...catch` this is to ensure spec compliancy 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 refered 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.
* **Internal**
* Bump `acorn-babel`.
* Start converting source to ES6...
## 4.5.1
**Babel now compiles itself!**
![holy shit](http://gifsec.com/wp-content/uploads/GIF/2014/03/OMG-GIF_2.gif)
## 4.5.0
* **New Feature**
* Add `.babelrc` support.
* **Bug Fix**
* Move use strict directives to the module formatter bodies.
* **Internal**
* Make default `bin/babel` behaviour to ignore non-compilable files and add a `--copy-files` flag to revert to the old behaviour.
## 4.4.6
* **Bug Fix**
* Fix extending a class expression with no methods/only constructor. Thanks [@neVERberleRfellerER](https://github.com/neVERberleRfellerER)!
* Allow `MemberExpression` as a valid `left` of `ForOfStatement`.
* **Polish**
* Throw an error when people try and transpile code with the `@jsx React.DOM` pragma as it conflicts with the custom jsx constructo method detection.
* Crawl all comments for `@jsx` pragma.
* **Internal**
* Upgrade `chalk`.
* Upgrade `core-js`.
## 4.4.5
* **Internal**
* Remove function self reference optimisation.
## 4.4.4
* **Bug Fix**
* Handle inferred function ids to be reassigned and deopt to a slower but working equivalent.
* Don't unpack array patterns that have more elements than their right hand array expression.
* **Polish**
* Improve syntax highlighting in the code frame. Thanks [@lydell](https://github.com/lydell)!
* **Internal**
* Upgrade `acorn-babel`.
## 4.4.3
* **Bug Fix**
* Fix `for...of` iterator break returns being duplicated.
* Only call `return` on the iterator if it exists.
* **Internal**
* Rename `selfContained` transformer to `runtime`.
## 4.4.2
* **New Feature**
* Add `moduleId` option for specifying a custom module id.
## 4.4.0
* **New Feature**
* `/*** @jsx NAMESPACE **/` comments are now honored by the `react` transformer.
* `getModuleName` option.
* Infer function expression names. Thanks [@RReverser](https://github.com/RReverser)!
* **Bug Fix**
* Add proper control flow for tail recursion optimisation.
* **Internal**
* Remove useless `format` options and move the `format.compact` option to `format`.
* **Polish**
* Newline handling of the code generator has been heavily improved.
* Code generator now deopts whitespace if the input size is >100KB.
## 4.3.0
* **Breaking Change**
* Remove `commonStandard` module formatter and make it the default behaviour of all the strict module formatters.
## 4.2.1
* **Polish**
* Add auxiliary comment to let scoping closure flow control.
## 4.2.0
* **Polish**
* Use an assignment instead of a define for `__esModule` in loose mode.
* **Internal**
* Add error for `eval();` usage and enable strict mode for parsing.
## 4.1.0
* **New Feature**
* Add `BABEL_CACHE_PATH` and `BABEL_DISABLE_CACHE` environment variables.
* **Internal**
* Replace many internal util functions with modules. Thanks [@sindresorhus](https://github.com/sindresorhus)!
## 4.0.2
* **Bug Fix**
* Fix generators not properly propagating their internal declarations.
* **Polish**
* Update setter param length error message.
* Use ranges on dependencies.
## 4.0.0
* 6to5 is now known as Babel.
* Global helpers/runtime has now been given the more descriptive name of "external helpers".

839
.github/CHANGELOG-v5.md vendored Normal file
View File

@@ -0,0 +1,839 @@
# Babel v5 Changelog
## 5.8.26
* **Internal**
* 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 Compliancy**
* 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 arbitary positions not in Program statement position.
* Throw error when attemping 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`.
* Move `validation.undeclaredVariableCheck` transformer up.
* Start great core-to-plugin exodus.
* Add `BindingIdentifier` virtual type.
* Hidden class optimisations.
* Array allocation optimisations.
* Update `regenerator`.
* Update `js-tokens`.
* Sync with upstream Acorn.
## 5.5.8
* **Internal**
* 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.
## 5.4.1
* **Bug Fix**
* Add missing `slash` dependency. Thanks [@browncolyn](https://github.com/browncolyn)!
* **Polish**
* 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.
## 5.4.0
* **New Feature**
* Added [function bind syntax](https://github.com/zenparsing/es-function-bind) behind stage 0. Thanks [@RReverser](https://github.com/rreverser)!
* 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.
* Added missing exponential operator inlining. Thanks [@nkt](https://github.com/nkt)!
* Optimise `regenerator` transformer. Thanks [@benjamn](https://github.com/benjamn)!
## 5.3.3
* **Bug Fix**
* Fix `minification.deadCodeElimination` transformer incorrectly trying to inline import declarations.
* Fix `minification.inlineExpression` transformer getting into an infinite loop.
## 5.3.2
* **Bug Fix**
* Fix patterns not being considered when hoisting variables in the `es6.blockScoping` transformer.
## 5.3.1
* **Bug Fix**
* Fix unique export specifiers not being cloned when exploding class and function exports,
* **Polish**
* Turn import remaps to sequence expressions to remove their context and improve performance.
## 5.3.0
**Speeeeeeed**
![gifs lol](https://31.media.tumblr.com/568205a0e37ae15eca510fa639589a59/tumblr_n8kw8kpcSb1sg6cg8o1_500.gif)
* **Spec Compliancy**
* 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 Compliancy**
* 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)!
* **New Feature**
* Add `getModuleName` option. Thanks [@jayphelps](https://github.com/jayphelps)!
## 5.2.9
* **Bug Fix**
* 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 `minfication.propertyLiterals` and `es3.memberExpressionLiterals`.
## 5.2.6
* **Internal**
* Fix transformer aliases being accidently 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 `resolveRc` running on files twice causing issues. Thanks [@lukescott](https://github.com/lukescott)!
* 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 Compliancy**
* Fix object decorators not using the `initializer` pattern.
* Remove property initializer descriptor reflection.
## 5.1.11
* **Bug Fix**
* Memoise and bind member expression decorators.
* Move JSX children cleaning to opening element visitor. Fixes elements not being cleaned in certain scenarios.
* Consider `SwitchStatement`s to be `Scopable`.
* Fix `bluebirdCoroutines` calling `interopRequireWildcard` before it's defined.
* Add space to `do...while` code generation.
* Validate `super` use before `this` on `super` exit rather than entrance.
* **Polish**
* Add Babel name to logger.
## 5.1.10
* **Bug Fix**
* Remove `makePredicate` from acorn in favor of an `indexOf`.
* Remove statements to expression explosion when inserting a block statement.
* **Internal**
* Remove runtime compatibility check.
## 5.1.9
* **Bug Fix**
* Fix class property initializers with `undefined` values not being correctly writable.
* Fix self inferring generators incorrectly causing a stack error.
* Fix default export specifiers not triggering AMD `module` argument inclusion.
* Fix assignments not having their module references properly remapped.
* **Internal**
* Upgrade to latest `acorn`.
* **Polish**
* Make invalid LHS pattern error messages nicer.
## 5.1.8
* **Bug Fix**
* Only make parenthesized object pattern LHS illegal.
## 5.1.7
* **Internal**
* Add `parse` node API.
## 5.1.6
* **Bug Fix**
* Fix `runtime` built-in catchall not properly checking for local variables.
## 5.1.5
* **Internal**
* Bump `core-js` version.
## 5.1.4
* **Polish**
* Add missing `Reflect` methods to runtime transformer.
## 5.1.3
* **Internal**
* Switch entirely to vanilla regenerator.
* Clean up and make the parsing of decorators stateless.
* **Bug Fix**
* Don't do TCO on generators and async functions.
* Add missing `core-js` runtime definitions.
## 5.1.2
* **Bug Fix**
* Add `getIterator` and `isIterable` to `babel-runtime` build script.
## 5.1.1
* **Bug Fix**
* Add missing runtime symbol definitions.
## 5.1.0
* **Bug Fix**
* Fix super reference when using decorators.
* Don't do array unpack optimisation when member expressions are present.
* Add missing descriptors for undecorated class properties.
* Don't consider `arguments` and `eval` valid function names when doing function name inferrence.
* Fix scope tracking of constants in loop heads.
* Parse `AwaitExpression` as a unary instead of an assignment.
* Fix regex evaluation when attempting static evaluation.
* Don't emit tokens when doing a lookahead.
* Add missing `test` declaration to `utility.deadCodeElimination` transformer.
* **Internal**
* Upgrade `regenerator` to the latest and use my branch with the hope of eventually switching to vanilla regenerator.
* Add support for the replacement of for loop `init`s with statements.
* Upgrade dependencies.
* **Polish**
* When adding the scope IIFE when using default parameters, don't shadow the function expression, just `apply` `this` and `arguments` if necessary.
* Use path basename as non-default import fallback.
* **New Feature**
* Add [trailing function comma proposal](https://github.com/jeffmo/es-trailing-function-commas). Thanks [@AluisioASG](https://github.com/AluisioASG)!
* Add support for object literal decorators.
* Make core-js modular when using the `runtime` transformer.
## 5.0.12
* **Bug Fix**
* Fix incorrect remapping of module references inside of a function id redirection container.
## 5.0.11
* **Bug Fix**
* Fix new `for...of` loops not properly inheriting their original loop.
* **Internal**
* Disable scope instance cache.
* **Polish**
* Allow comments in `.babelrc` JSON.
## 5.0.9
* **Polish**
* Use `moduleId` for UMD global name if available.
* **Bug Fix**
* Fix UMD global `module` variable shadowing the `amd`/`common` `module` variable.
* Fix Flow param type annotation regression.
* Fix function name collision `toString` wrapper. Thanks [@alawatthe](https://github.com/alawatthe)!
## 5.0.8
* **Bug Fix**
* Fix falsy static class properties not being writable.
* Fix block scoping collisions not properly detecting modules and function clashes.
* Skip `this` before `super` for derived constructors on functions.
## 5.0.7
* **New Feature**
* Add `--ignore` and `--only` support to the CLI.
* **Bug Fix**
* Remove `HOMEPATH` environment variable from home resolution in `babel/register` cache.
* **Internal**
* Disable WIP path resolution introducing infinite recursion in some code examples.
* **Polish**
* Add live binding to CommonJS default imports.
## 5.0.6
* **Bug Fix**
* Fix mangling of import references that collide with properties on `Object.prototype`.
* Fix duplicate declarations incorrectly being reported for `var`.
## 5.0.5
* **Internal**
* Upgrade `core-js`.
* **Bug Fix**
* Fix arrays not being supported in `util.list`.
## 5.0.4
* **Polish**
* Check for top level `breakConfig` in `resolveRc`.
## 5.0.3
* **Bug Fix**
* Make relative location absolute before calling `resolveRc`.
* **Internal**
* Switch to global UID registry.
* Add `breakConfig` option to prevent Babel from erroring when hitting that option.
## 5.0.1
* **Bug Fix**
* Fix duplicate declaration regression.
* Fix not being able to call non-writable methods.
## 5.0.0
* **New Feature**
* Decorators based on [@wycat's](https://github.com/wycats) [stage 1 proposal](https://github.com/wycats/javascript-decorators).
* Class property initializers based on [@jeffmo's](https://github.com/jeffmo) [stage 0 proposal](https://gist.github.com/jeffmo/054df782c05639da2adb).
* Export extensions based on [@leebyron's](https://github.com/leebyron) [stage 1 proposal](https://github.com/leebyron/ecmascript-more-export-from).
* UMD module formatter now supports globals.
* Add `es3.runtime`, `optimisation.react.inlineElements` and `optimisation.react.constantElements` transformers.
* Add stage option that replaces the experimental one.
* Allow ES7 transformer to be enabled via `optional` instead of only via `stage`.
* Infer string quotes to use in the code generator.
* Consider `export { foo as default };` to be the same as `export default foo;`.
* Add `nonStandard` option that can be set to `false` to remove parser support for JSX and Flow.
* Add `jsxPragma` option.
* Automatically generate CLI options based on internal API options.
* Add support for `.babelrc` on absolute paths.
* Plugin API!
* **Internal**
* Export `options` in browser API.
* Rewritten parser.
* Don't block hoist when runtime transformer is enabled in system module formatter.
* Rewritten the internal traversal and node replacement API to use "paths" that abstracts out node relationships.
* **Polish**
* JSX output is now more inline with the official JSX transformer.
* Hoist block scoping IIFE - this improves memory usage and performance.
* Better IIFE detection - references are now checked to see if they're referencing the binding we're searching for.
* Check for import reassignments in constants transformer.
* Make method definitions with expression bodies illegal.
* Save register cache on tick instead of `SIGINT`.
* Enable strict mode on babel-node eval flag.
* **Bug Fixes**
* Add support for live bindings. This change also increases the reliablity of export specifier renaming.
* Add support for super update and non equals assignment expressions.
* Rename shadow constructor binding in classes.
* Seed next iteration bindings with previous fresh bindings when reassinging loop block scoped variables.
* Fix new expression spread referencing the wrong constructor.
* Call `resolveModuleSource` on dynamic imports.
* Added `param` to list of duplicate declaration kinds.
* **Breaking Changes**
* The Babel playground has been removed.
* ES7 Abstract References have been removed.
* Experimental option has been removed in favor of a stage option.
* Rename `returnUsedHelpers` to `metadataUsedHelpers`.

4016
.github/CHANGELOG-v6.md vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,10 @@
<!--
Before making a PR please make sure to read our contributing guidelines
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.
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 👍) -->
@@ -12,7 +14,7 @@ For issue references: Add a comma-separated list of a [closing word](https://hel
| Major: Breaking Change? |
| Minor: New Feature? |
| 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 -->
| Any Dependency Changes? |
| License | MIT

View File

@@ -8,6 +8,7 @@ cache:
- node_modules
node_js:
# We test the latest version on circleci
- '9'
- '8'
- '6'

File diff suppressed because it is too large Load Diff

View File

@@ -230,7 +230,7 @@ If the test requires a minimum Node version, you can add `minNodeVersion` (must
Writing tests for the babel parser is very
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
descriptive name, and add the following:

View File

@@ -1,6 +1,6 @@
MAKEFLAGS = -j1
FLOW_COMMIT = 395e045c18d537fcbbc552a96ef2cdcd70b4ab52
TEST262_COMMIT = 40883f4c6ae17e073dfd03e34f73a6bf8c855595
TEST262_COMMIT = f90a52b39609a620c0854e0bd0b3a906c930fd17
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
export FORCE_COLOR = true
@@ -17,8 +17,6 @@ build: clean clean-lib
# generate flow and typescript typings
node scripts/generators/flow.js > ./packages/babel-types/lib/index.js.flow
node scripts/generators/typescript.js > ./packages/babel-types/lib/index.d.ts
# generate docs
node scripts/generators/docs.js > ./packages/babel-types/README.md
ifneq ("$(BABEL_COVERAGE)", "true")
make build-standalone
make build-preset-env-standalone
@@ -49,12 +47,10 @@ flow:
./node_modules/.bin/flow check --strip-root
lint:
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' '**/.*.js' --format=codeframe --rulesdir="./scripts/eslint_rules"
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe --rulesdir="./scripts/eslint_rules"
fix:
# The config is hardcoded because otherwise prettier searches for it and also picks up some broken package.json files from tests
./node_modules/.bin/prettier --config .prettierrc --write --ignore-path .eslintignore '**/*.json'
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' '**/.*.js' --format=codeframe --fix --rulesdir="./scripts/eslint_rules"
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe --fix --rulesdir="./scripts/eslint_rules"
clean: test-clean
rm -rf packages/babel-polyfill/browser*

View File

@@ -107,7 +107,7 @@ For questions and support please visit join our [Slack Community](https://slack.
### 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!
### Where are the docs?

View File

@@ -1,5 +1,7 @@
## Hallelujah—In Praise of Babel
➤ [🎶 Audio version here!](https://youtu.be/40abpedBKK8)
I heard there was a clever trick
That rewrote all your JavaScript
But you dont really care for magic, do you

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/plugin-codemod-object-assign-to-object-spread",
"version": "7.0.0-beta.48",
"version": "7.0.0-beta.55",
"description": "Transforms Object.assign into object spread syntax",
"repository": "https://github.com/babel/babel/tree/master/codemods/babel-plugin-codemod-object-assign-to-object-spread",
"license": "MIT",
@@ -10,14 +10,14 @@
"@babel/plugin"
],
"dependencies": {
"@babel/plugin-syntax-object-rest-spread": "7.0.0-beta.48"
"@babel/plugin-syntax-object-rest-spread": "7.0.0-beta.55"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.48"
"@babel/core": ">=7.0.0-beta.50 <7.0.0-rc.0"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.48",
"@babel/helper-plugin-test-runner": "7.0.0-beta.48"
"@babel/core": "7.0.0-beta.55",
"@babel/helper-plugin-test-runner": "7.0.0-beta.55"
},
"publishConfig": {
"access": "public"

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/plugin-codemod-optional-catch-binding",
"version": "7.0.0-beta.48",
"version": "7.0.0-beta.55",
"description": "Remove unused catch bindings",
"repository": "https://github.com/babel/babel/tree/master/codemods/babel-plugin-codemod-remove-unused-catch-binding",
"license": "MIT",
@@ -10,13 +10,13 @@
"@babel/plugin"
],
"dependencies": {
"@babel/plugin-syntax-optional-catch-binding": "7.0.0-beta.48"
"@babel/plugin-syntax-optional-catch-binding": "7.0.0-beta.55"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.48"
"@babel/core": ">=7.0.0-beta.50 <7.0.0-rc.0"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.48",
"@babel/helper-plugin-test-runner": "7.0.0-beta.48"
"@babel/core": "7.0.0-beta.55",
"@babel/helper-plugin-test-runner": "7.0.0-beta.55"
}
}

View File

@@ -1,6 +1,6 @@
{
"lerna": "2.0.0-rc.4",
"version": "7.0.0-beta.48",
"lerna": "2.11.0",
"version": "7.0.0-beta.55",
"changelog": {
"repo": "babel/babel",
"cacheDir": ".changelog",

View File

@@ -160,9 +160,15 @@ declare module "convert-source-map" {
fromComment(str: string): Converter,
fromMapFileComment(str: string): Converter,
fromSource(str: string): Converter,
fromMapFileSource(str: string): Converter,
fromMapFileSource(str: string, dir: string): Converter,
removeComments(str: string): string,
removeMapFileComments(str: string): string,
generateMapFileComment(path: string, options?: ?{ multiline: boolean }): string,
};
}
declare module "js-levenshtein" {
declare module.exports: {
(string, string): number,
};
}

View File

@@ -10,30 +10,31 @@
"test": "make test"
},
"devDependencies": {
"@babel/cli": "7.0.0-beta.46",
"@babel/core": "7.0.0-beta.46",
"@babel/plugin-transform-modules-commonjs": "7.0.0-beta.46",
"@babel/preset-env": "7.0.0-beta.46",
"@babel/preset-flow": "7.0.0-beta.46",
"@babel/preset-stage-0": "7.0.0-beta.46",
"@babel/register": "7.0.0-beta.46",
"@babel/cli": "7.0.0-beta.52",
"@babel/core": "7.0.0-beta.52",
"@babel/plugin-proposal-class-properties": "7.0.0-beta.52",
"@babel/plugin-proposal-export-namespace-from": "7.0.0-beta.52",
"@babel/plugin-proposal-numeric-separator": "7.0.0-beta.52",
"@babel/plugin-transform-modules-commonjs": "7.0.0-beta.52",
"@babel/preset-env": "7.0.0-beta.52",
"@babel/preset-flow": "7.0.0-beta.52",
"@babel/register": "7.0.0-beta.52",
"babel-core": "^7.0.0-0",
"babel-eslint": "^8.0.1",
"babel-jest": "^22.4.1",
"babel-eslint": "^8.2.6",
"babel-jest": "^23.4.0",
"babel-loader": "8.0.0-beta.0",
"babel-plugin-transform-charcodes": "^0.1.0",
"babylon": "7.0.0-beta.46",
"browserify": "^13.1.1",
"bundle-collapser": "^1.2.1",
"chalk": "^2.3.2",
"charcodes": "^0.1.0",
"derequire": "^2.0.2",
"enhanced-resolve": "^3.0.0",
"eslint": "^4.18.2",
"eslint": "^5.1.0",
"eslint-config-babel": "^7.0.2",
"eslint-plugin-flowtype": "^2.20.0",
"eslint-plugin-prettier": "^2.5.0",
"flow-bin": "^0.66.0",
"eslint-plugin-flowtype": "^2.50.0",
"eslint-plugin-prettier": "^2.6.2",
"flow-bin": "^0.76.0",
"graceful-fs": "^4.1.11",
"gulp": "^4.0.0",
"gulp-babel": "^8.0.0-beta.2",
@@ -45,20 +46,20 @@
"gulp-util": "^3.0.7",
"gulp-watch": "^5.0.0",
"husky": "^0.14.3",
"jest": "^22.4.2",
"lerna": "2.0.0",
"jest": "^23.4.1",
"lerna": "^2.11.0",
"lerna-changelog": "^0.5.0",
"lint-staged": "^6.0.1",
"lodash": "^4.17.5",
"lodash": "^4.17.10",
"merge-stream": "^1.0.1",
"output-file-sync": "^2.0.0",
"prettier": "1.11.1",
"prettier": "^1.13.7",
"pump": "^1.0.2",
"rimraf": "^2.4.3",
"rollup-plugin-babel": "^4.0.0-beta.0",
"rollup-plugin-node-resolve": "^3.0.2",
"rollup-stream": "^1.24.1",
"test262-stream": "^1.1.0",
"test262-stream": "^1.2.0",
"through2": "^2.0.0",
"uglify-js": "^2.4.16",
"vinyl-buffer": "^1.0.1",

View File

@@ -2,20 +2,18 @@
> Babel command line.
In addition, various entry point scripts live in the top-level package at `@babel/cli/bin`.
There is a shell-executable utility script, `babel-external-helpers.js`, and the main Babel cli script, `babel.js`.
See our website [@babel/cli](https://babeljs.io/docs/en/next/babel-cli.html) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20cli%22+is%3Aopen) associated with this package.
## Install
```sh
npm install --save-dev @babel/core @babel/cli
```
## Usage
Using npm:
```sh
babel script.js
npm install --save-dev @babel/cli
```
For more in depth documentation see: http://babeljs.io/docs/usage/cli/
or using yarn:
```sh
yarn add @babel/cli --dev
```

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/cli",
"version": "7.0.0-beta.48",
"version": "7.0.0-beta.55",
"description": "Babel command line.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -20,7 +20,8 @@
"convert-source-map": "^1.1.0",
"fs-readdir-recursive": "^1.0.0",
"glob": "^7.0.0",
"lodash": "^4.17.5",
"lodash": "^4.17.10",
"mkdirp": "^0.5.1",
"output-file-sync": "^2.0.0",
"slash": "^1.0.0",
"source-map": "^0.5.0"
@@ -29,11 +30,11 @@
"chokidar": "^2.0.3"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.48"
"@babel/core": ">=7.0.0-beta.50 <7.0.0-rc.0"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.48",
"@babel/helper-fixtures": "7.0.0-beta.48"
"@babel/core": "7.0.0-beta.55",
"@babel/helper-fixtures": "7.0.0-beta.55"
},
"bin": {
"babel": "./bin/babel.js",

View File

@@ -1,5 +1,6 @@
import defaults from "lodash/defaults";
import outputFileSync from "output-file-sync";
import { sync as mkdirpSync } from "mkdirp";
import slash from "slash";
import path from "path";
import fs from "fs";
@@ -71,13 +72,6 @@ export default async function({ cliOptions, babelOptions }) {
return path.join(cliOptions.outDir, filename);
}
function outputDestFolder(outDir) {
const outDirPath = path.resolve(outDir);
if (!fs.existsSync(outDirPath)) {
fs.mkdirSync(outDirPath);
}
}
async function handleFile(src, base) {
const written = await write(src, base);
@@ -122,7 +116,7 @@ export default async function({ cliOptions, babelOptions }) {
util.deleteDir(cliOptions.outDir);
}
outputDestFolder(cliOptions.outDir);
mkdirpSync(cliOptions.outDir);
let compiledFiles = 0;
for (const filename of cliOptions.filenames) {
@@ -130,7 +124,7 @@ export default async function({ cliOptions, babelOptions }) {
}
console.log(
`🎉 Successfully compiled ${compiledFiles} ${
`Successfully compiled ${compiledFiles} ${
compiledFiles !== 1 ? "files" : "file"
} with Babel.`,
);

View File

@@ -1,2 +1,2 @@
src/index.js -> lib/index.js
🎉 Successfully compiled 1 file with Babel.
Successfully compiled 1 file with Babel.

View File

@@ -1,3 +1,3 @@
src/foo/.foo.js -> lib/foo/.foo.js
src/foo/bar.js -> lib/foo/bar.js
🎉 Successfully compiled 2 files with Babel.
Successfully compiled 2 files with Babel.

View File

@@ -1,4 +1,4 @@
src/.foo.js -> lib/.foo.js
src/bar/index.js -> lib/bar/index.js
src/foo/foo.js -> lib/foo/foo.js
🎉 Successfully compiled 3 files with Babel.
Successfully compiled 3 files with Babel.

View File

@@ -1,2 +1,2 @@
src/index.js -> lib/index.js
🎉 Successfully compiled 1 file with Babel.
Successfully compiled 1 file with Babel.

View File

@@ -1,2 +1,2 @@
src/foo/bar.js -> lib/foo/bar.js
🎉 Successfully compiled 1 file with Babel.
Successfully compiled 1 file with Babel.

View File

@@ -1,3 +1,3 @@
src/bar/index.js -> lib/bar/index.js
src/foo/foo.js -> lib/foo/foo.js
🎉 Successfully compiled 2 files with Babel.
Successfully compiled 2 files with Babel.

View File

@@ -1,2 +1,2 @@
src/foobar/foo.js -> lib/foobar/foo.js
🎉 Successfully compiled 1 file with Babel.
Successfully compiled 1 file with Babel.

View File

@@ -2,4 +2,4 @@ src/a.js -> lib/a.js
src/b.js -> lib/b.js
src/baz/c.js -> lib/baz/c.js
src/foo.js -> lib/foo.js
🎉 Successfully compiled 4 files with Babel.
Successfully compiled 4 files with Babel.

View File

@@ -1,2 +1,2 @@
src/bar/index.js -> lib/bar/index.js
🎉 Successfully compiled 1 file with Babel.
Successfully compiled 1 file with Babel.

View File

@@ -1,3 +1,3 @@
src/a.foo.js -> lib/a.foo.js
src/baz/b.foo.js -> lib/baz/b.foo.js
🎉 Successfully compiled 2 files with Babel.
Successfully compiled 2 files with Babel.

View File

@@ -1,2 +1,2 @@
src/bar/index.js -> lib/bar/index.js
🎉 Successfully compiled 1 file with Babel.
Successfully compiled 1 file with Babel.

View File

@@ -1,2 +1,2 @@
src/foo.js -> lib/foo.js
🎉 Successfully compiled 1 file with Babel.
Successfully compiled 1 file with Babel.

View File

@@ -1,3 +1,3 @@
src/bar.mjs -> lib/bar.mjs
src/foo.js -> lib/foo.js
🎉 Successfully compiled 2 files with Babel.
Successfully compiled 2 files with Babel.

View File

@@ -1,3 +1 @@
class Test1 {
}
(() => 42)

View File

@@ -1,3 +1 @@
class Test2 {
}
(() => 42)

View File

@@ -1,9 +1,5 @@
"use strict";
function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Test1 = function Test1() {
_classCallCheck(this, Test1);
};
(function () {
return 42;
});

View File

@@ -1,9 +1,5 @@
"use strict";
function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Test2 = function Test2() {
_classCallCheck(this, Test2);
};
(function () {
return 42;
});

View File

@@ -2,4 +2,4 @@ package1/src/bar/bar1.js -> package1/lib/bar/bar1.js
package1/src/foo1.js -> package1/lib/foo1.js
package2/src/bar/bar2.js -> package2/lib/bar/bar2.js
package2/src/foo2.js -> package2/lib/foo2.js
🎉 Successfully compiled 4 files with Babel.
Successfully compiled 4 files with Babel.

View File

@@ -1,10 +1,6 @@
"use strict";
function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Test = function Test() {
_classCallCheck(this, Test);
};
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXIvYmFyLmpzIl0sIm5hbWVzIjpbIlRlc3QiXSwibWFwcGluZ3MiOiI7Ozs7OztJQUFNQSxJIiwic291cmNlc0NvbnRlbnQiOlsiY2xhc3MgVGVzdCB7XG5cbn0iXX0=
(function () {
return 42;
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXIvYmFyLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsQ0FBQztBQUFBLFNBQU0sRUFBTjtBQUFBLENBQUQiLCJzb3VyY2VzQ29udGVudCI6WyIoKCkgPT4gNDIpIl19

View File

@@ -3,4 +3,4 @@
arr.map(function (x) {
return x * MULTIPLIER;
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9mb28uanMiXSwibmFtZXMiOlsiYXJyIiwibWFwIiwieCIsIk1VTFRJUExJRVIiXSwibWFwcGluZ3MiOiI7O0FBQUFBLElBQUlDLEdBQUosQ0FBUTtBQUFBLFNBQUtDLElBQUlDLFVBQVQ7QUFBQSxDQUFSIiwic291cmNlc0NvbnRlbnQiOlsiYXJyLm1hcCh4ID0+IHggKiBNVUxUSVBMSUVSKTsiXX0=
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9mb28uanMiXSwibmFtZXMiOlsiYXJyIiwibWFwIiwieCIsIk1VTFRJUExJRVIiXSwibWFwcGluZ3MiOiI7O0FBQUFBLEdBQUcsQ0FBQ0MsR0FBSixDQUFRLFVBQUFDLENBQUM7QUFBQSxTQUFJQSxDQUFDLEdBQUdDLFVBQVI7QUFBQSxDQUFUIiwic291cmNlc0NvbnRlbnQiOlsiYXJyLm1hcCh4ID0+IHggKiBNVUxUSVBMSUVSKTsiXX0=

View File

@@ -1,3 +1,3 @@
src/bar/bar.js -> lib/bar/bar.js
src/foo.js -> lib/foo.js
🎉 Successfully compiled 2 files with Babel.
Successfully compiled 2 files with Babel.

View File

@@ -1,3 +1 @@
class Test {
}
(() => 42)

View File

@@ -1,10 +1,6 @@
"use strict";
function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Test = function Test() {
_classCallCheck(this, Test);
};
(function () {
return 42;
});
//# sourceMappingURL=bar.js.map

View File

@@ -1 +1 @@
{"version":3,"sources":["../../src/bar/bar.js"],"names":["Test"],"mappings":";;;;;;IAAMA,I","sourcesContent":["class Test {\n\n}"],"file":"bar.js"}
{"version":3,"sources":["../../src/bar/bar.js"],"names":[],"mappings":";;AAAA,CAAC;AAAA,SAAM,EAAN;AAAA,CAAD","sourcesContent":["(() => 42)"],"file":"bar.js"}

View File

@@ -1 +1 @@
{"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"}

View File

@@ -1,3 +1,3 @@
src/bar/bar.js -> lib/bar/bar.js
src/foo.js -> lib/foo.js
🎉 Successfully compiled 2 files with Babel.
Successfully compiled 2 files with Babel.

View File

@@ -1,3 +1 @@
class Test {
}
(() => 42)

View File

@@ -1,9 +1,5 @@
"use strict";
function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Test = function Test() {
_classCallCheck(this, Test);
};
(function () {
return 42;
});

View File

@@ -1,3 +1,3 @@
src/bar/bar.js -> lib/bar/bar.js
src/foo.js -> lib/foo.js
🎉 Successfully compiled 2 files with Babel.
Successfully compiled 2 files with Babel.

View File

@@ -1,3 +1 @@
class Test {
}
(() => 42)

View File

@@ -1,9 +1,5 @@
"use strict";
function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Test = function Test() {
_classCallCheck(this, Test);
};
(function () {
return 42;
});

View File

@@ -1 +1 @@
🎉 Successfully compiled 2 files with Babel.
Successfully compiled 2 files with Babel.

View File

@@ -1 +1 @@
🎉 Successfully compiled 0 files with Babel.
Successfully compiled 0 files with Babel.

View File

@@ -1,2 +1,2 @@
src/foo.js -> lib/foo.js
🎉 Successfully compiled 1 file with Babel.
Successfully compiled 1 file with Babel.

View File

@@ -1,2 +1,2 @@
src/foo.js -> lib/foo.js
🎉 Successfully compiled 1 file with Babel.
Successfully compiled 1 file with Babel.

View File

@@ -4,4 +4,4 @@ arr.map(function (x) {
return x * MULTIPLIER;
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLElBQUksR0FBSixDQUFRO0FBQUEsU0FBSyxJQUFJLFVBQVQ7QUFBQSxDQUFSIiwiZmlsZSI6InNjcmlwdDIuanMiLCJzb3VyY2VzQ29udGVudCI6WyJhcnIubWFwKHggPT4geCAqIE1VTFRJUExJRVIpOyJdfQ==
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLEdBQUcsQ0FBQyxHQUFKLENBQVEsVUFBQSxDQUFDO0FBQUEsU0FBSSxDQUFDLEdBQUcsVUFBUjtBQUFBLENBQVQiLCJmaWxlIjoic2NyaXB0Mi5qcyIsInNvdXJjZXNDb250ZW50IjpbImFyci5tYXAoeCA9PiB4ICogTVVMVElQTElFUik7Il19

View File

@@ -1,5 +1,3 @@
var foo = function () {
return 4;
};
arr.map(x => x * MULTIPLIER);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm9yaWdpbmFsLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLFVBQVUsWTtTQUFNLEM7Q0FBQyIsInNvdXJjZXNDb250ZW50IjpbInZhciBmb28gPSAoKSA9PiA0OyJdfQ==

View File

@@ -1,7 +1,7 @@
"use strict";
var foo = function foo() {
return 4;
};
arr.map(function (x) {
return x * MULTIPLIER;
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm9yaWdpbmFsLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsSUFBQSxNQUFVLFNBQVYsR0FBVSxHO1NBQU0sQztBQUFDLENBQWpCIiwiZmlsZSI6InNjcmlwdDIuanMiLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZm9vID0gKCkgPT4gNDsiXX0=
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm9yaWdpbmFsLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsR0FBQSxDQUFBLEdBQUEsQ0FBQSxVQUFBLENBQUE7QUFBQSxTQUFVLENBQUEsR0FBQSxVQUFWO0FBQUEsQ0FBQSIsImZpbGUiOiJzY3JpcHQyLmpzIiwic291cmNlc0NvbnRlbnQiOlsidmFyIGZvbyA9ICgpID0+IDQ7Il19

View File

@@ -1,16 +1,12 @@
"use strict";
function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Test = function Test() {
_classCallCheck(this, Test);
};
(function () {
return 42;
});
"use strict";
arr.map(function (x) {
return x * MULTIPLIER;
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyIsInNjcmlwdDIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0lBQU0sSTs7Ozs7QUNBTixJQUFJLEdBQUosQ0FBUTtBQUFBLFNBQUssSUFBSSxVQUFUO0FBQUEsQ0FBUiIsImZpbGUiOiJzY3JpcHQzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiY2xhc3MgVGVzdCB7XG5cbn0iLCJhcnIubWFwKHggPT4geCAqIE1VTFRJUExJRVIpOyJdfQ==
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyIsInNjcmlwdDIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxDQUFDO0FBQUEsU0FBTSxFQUFOO0FBQUEsQ0FBRDs7O0FDQUEsR0FBRyxDQUFDLEdBQUosQ0FBUSxVQUFBLENBQUM7QUFBQSxTQUFJLENBQUMsR0FBRyxVQUFSO0FBQUEsQ0FBVCIsImZpbGUiOiJzY3JpcHQzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiKCgpID0+IDQyKSIsImFyci5tYXAoeCA9PiB4ICogTVVMVElQTElFUik7Il19

View File

@@ -1,3 +1 @@
class Test {
}
(() => 42)

View File

@@ -1,12 +1,8 @@
"use strict";
function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Test = function Test() {
_classCallCheck(this, Test);
};
(function () {
return 42;
});
"use strict";
arr.map(function (x) {

View File

@@ -1 +1 @@
{"version":3,"sources":["script.js","script2.js"],"names":[],"mappings":";;;;;;IAAM,I;;;;;ACAN,IAAI,GAAJ,CAAQ;AAAA,SAAK,IAAI,UAAT;AAAA,CAAR","file":"script3.js","sourcesContent":["class Test {\n\n}","arr.map(x => x * MULTIPLIER);"]}
{"version":3,"sources":["script.js","script2.js"],"names":[],"mappings":";;AAAA,CAAC;AAAA,SAAM,EAAN;AAAA,CAAD;;;ACAA,GAAG,CAAC,GAAJ,CAAQ,UAAA,CAAC;AAAA,SAAI,CAAC,GAAG,UAAR;AAAA,CAAT","file":"script3.js","sourcesContent":["(() => 42)","arr.map(x => x * MULTIPLIER);"]}

View File

@@ -1,3 +1 @@
class Test {
}
(() => 42)

View File

@@ -1,12 +1,8 @@
"use strict";
function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Test = function Test() {
_classCallCheck(this, Test);
};
(function () {
return 42;
});
"use strict";
arr.map(function (x) {

View File

@@ -1 +1 @@
SyntaxError: test.js: Unexpected token, expected ";" (2:10)
SyntaxError: <CWD>/test.js: Unexpected token, expected ";" (2:10)

View File

@@ -14,12 +14,10 @@ const fileFilter = function(x) {
return x !== ".DS_Store";
};
const presetLocs = [
path.join(__dirname, "../../babel-preset-es2015"),
path.join(__dirname, "../../babel-preset-react"),
].join(",");
const presetLocs = [path.join(__dirname, "../../babel-preset-react")];
const pluginLocs = [
path.join(__dirname, "/../../babel-plugin-transform-arrow-functions"),
path.join(__dirname, "/../../babel-plugin-transform-strict-mode"),
path.join(__dirname, "/../../babel-plugin-transform-modules-commonjs"),
].join(",");
@@ -46,7 +44,20 @@ const saveInFiles = function(files) {
});
};
const assertTest = function(stdout, stderr, opts) {
const replacePaths = function(str, cwd) {
let prev;
do {
prev = str;
str = str.replace(cwd, "<CWD>");
} while (str !== prev);
return str;
};
const assertTest = function(stdout, stderr, opts, cwd) {
stdout = replacePaths(stdout, cwd);
stderr = replacePaths(stderr, cwd);
const expectStderr = opts.stderr.trim();
stderr = stderr.trim();
@@ -138,7 +149,7 @@ const buildTest = function(binName, testName, opts) {
let err;
try {
assertTest(stdout, stderr, opts);
assertTest(stdout, stderr, opts, tmpLoc);
} catch (e) {
err = e;
}

View File

@@ -2,141 +2,18 @@
> Generate errors that contain a code frame that point to source locations.
See our website [@babel/code-frame](https://babeljs.io/docs/en/next/babel-code-frame.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/code-frame
```
## Usage
or using yarn:
```js
import { codeFrameColumns } from '@babel/code-frame';
const rawLines = `class Foo {
constructor()
}`;
const location = { start: { line: 2, column: 16 } };
const result = codeFrameColumns(rawLines, location, { /* options */ });
console.log(result);
```
```
1 | class Foo {
> 2 | constructor()
| ^
3 | }
```
If the column number is not known, you may omit it.
You can also pass an `end` hash in `location`.
```js
import { codeFrameColumns } from '@babel/code-frame';
const rawLines = `class Foo {
constructor() {
console.log("hello");
}
}`;
const location = { start: { line: 2, column: 17 }, end: { line: 4, column: 3 } };
const result = codeFrameColumns(rawLines, location, { /* options */ });
console.log(result);
```
```
1 | class Foo {
> 2 | constructor() {
| ^
> 3 | console.log("hello");
| ^^^^^^^^^^^^^^^^^^^^^^^^^
> 4 | }
| ^^^
5 | };
```
## Options
### `highlightCode`
`boolean`, defaults to `false`.
Toggles syntax highlighting the code as JavaScript for terminals.
### `linesAbove`
`number`, defaults to `2`.
Adjust the number of lines to show above the error.
### `linesBelow`
`number`, defaults to `3`.
Adjust the number of lines to show below the error.
### `forceColor`
`boolean`, defaults to `false`.
Enable this to forcibly syntax highlight the code as JavaScript (for non-terminals); overrides `highlightCode`.
### `message`
`string`, otherwise nothing
Pass in a string to be displayed inline (if possible) next to the highlighted
location in the code. If it can't be positioned inline, it will be placed above
the code frame.
```
1 | class Foo {
> 2 | constructor()
| ^ Missing {
3 | };
```
## Upgrading from prior versions
Prior to version 7, the only API exposed by this module was for a single line and optional column pointer. The old API will now log a deprecation warning.
The new API takes a `location` object, similar to what is available in an AST.
This is an example of the deprecated (but still available) API:
```js
import codeFrame from '@babel/code-frame';
const rawLines = `class Foo {
constructor()
}`;
const lineNumber = 2;
const colNumber = 16;
const result = codeFrame(rawLines, lineNumber, colNumber, { /* options */ });
console.log(result);
```
To get the same highlighting using the new API:
```js
import { codeFrameColumns } from '@babel/code-frame';
const rawLines = `class Foo {
constructor() {
console.log("hello");
}
}`;
const location = { start: { line: 2, column: 16 } };
const result = codeFrameColumns(rawLines, location, { /* options */ });
console.log(result);
```sh
yarn add @babel/code-frame --dev
```

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/code-frame",
"version": "7.0.0-beta.48",
"version": "7.0.0-beta.55",
"description": "Generate errors that contain a code frame that point to source locations.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -8,7 +8,7 @@
"repository": "https://github.com/babel/babel/tree/master/packages/babel-code-frame",
"main": "lib/index.js",
"dependencies": {
"@babel/highlight": "7.0.0-beta.48"
"@babel/highlight": "7.0.0-beta.55"
},
"devDependencies": {
"chalk": "^2.0.0",

View File

@@ -2,249 +2,18 @@
> Babel compiler core.
See our website [@babel/core](https://babeljs.io/docs/en/next/babel-core.html) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20core%22+is%3Aopen) associated with this package.
```javascript
var babel = require("@babel/core");
import { transform } from "@babel/core";
import * as babel from "@babel/core";
## Install
Using npm:
```sh
npm install --save-dev @babel/core
```
All transformations will use your local configuration files (`.babelrc` or in `package.json`). See [options](#options) to disable it.
or using yarn:
## babel.transform(code: string, [options?](#options): Object, callback: Function)
Transforms the passed in `code`. Calling a callback with an object with the generated code,
source map, and AST.
```js
babel.transform(code, options, function(err, result) {
result; // => { code, map, ast }
});
```sh
yarn add @babel/core --dev
```
**Example**
```js
babel.transform("code();", options, function(err, result) {
result.code;
result.map;
result.ast;
});
```
### Compat Note:
In Babel 6, this method was synchronous and `transformSync` did not exist. For backward-compatibility,
this function will behave synchronously if no callback is given. If you're starting with Babel 7
and need synchronous behavior, please use `transformSync` since this backward-compat may be dropped in
future major versions of Babel.
## babel.transformSync(code: string, [options?](#options): Object)
Transforms the passed in `code`. Returning an object with the generated code,
source map, and AST.
```js
babel.transformSync(code, options) // => { code, map, ast }
```
**Example**
```js
var result = babel.transformSync("code();", options);
result.code;
result.map;
result.ast;
```
## babel.transformFile(filename: string, [options?](#options): Object, callback: Function)
Asynchronously transforms the entire contents of a file.
```js
babel.transformFile(filename, options, callback)
```
**Example**
```js
babel.transformFile("filename.js", options, function (err, result) {
result; // => { code, map, ast }
});
```
## babel.transformFileSync(filename: string, [options?](#options): Object)
Synchronous version of `babel.transformFile`. Returns the transformed contents of
the `filename`.
```js
babel.transformFileSync(filename, options) // => { code, map, ast }
```
**Example**
```js
babel.transformFileSync("filename.js", options).code;
```
## babel.transformFromAst(ast: Object, code?: string, [options?](#options): Object, callback: Function): FileNode | null
Given an [AST](https://astexplorer.net/), transform it.
```js
const sourceCode = "if (true) return;";
const parsedAst = babel.parse(sourceCode, { allowReturnOutsideFunction: true });
babel.transformFromAst(parsedAst, sourceCode, options, function(err, result) {
const { code, map, ast } = result;
});
```
### Compat Note:
In Babel 6, this method was synchronous and `transformFromAstSync` did not exist. For backward-compatibility,
this function will behave synchronously if no callback is given. If you're starting with Babel 7
and need synchronous behavior, please use `transformFromAstSync` since this backward-compat may be dropped in
future major versions of Babel.
## babel.transformFromAstSync(ast: Object, code?: string, [options?](#options): Object)
Given an [AST](https://astexplorer.net/), transform it.
```js
const sourceCode = "if (true) return;";
const parsedAst = babel.parse(sourceCode, { allowReturnOutsideFunction: true });
const { code, map, ast } = babel.transformFromAstSync(parsedAst, sourceCode, options);
```
## babel.parse(code: string, [options?](#options): Object)
Given some code, parse it using Babel's standard behavior. Referenced presets and
plugins will be loaded such that optional syntax plugins are automatically
enabled.
## Advanced APIs
Many systems that wrap Babel like to automatically inject plugins and presets,
or override options. To accomplish this goal, Babel exposes several functions
that aid in loading the configuration part-way without transforming.
### babel.loadOptions([options?](#options): Object)
Resolve Babel's options fully, resulting in an options object where:
* `opts.plugins` is a full list of `Plugin` instances.
* `opts.presets` is empty and all presets are flattened into `opts`.
* It can be safely passed back to Babel. Fields like `babelrc` have been set to
false so that later calls to Babel will not make a second attempt to load
config files.
`Plugin` instances aren't meant to be manipulated directly, but often
callers will serialize this `opts` to JSON to use it as a cache key representing
the options Babel has received. Caching on this isn't 100% guaranteed to
invalidate properly, but it is the best we have at the moment.
### babel.loadPartialConfig([options?](#options): Object): PartialConfig
To allow systems to easily manipulate and validate a user's config, this function
resolves the plugins and presets and proceeds no further. The expectation is
that callers will take the config's `.options`, manipulate it as then see fit
and pass it back to Babel again.
* `babelrc: string | void` - The path of the `.babelrc` file, if there was one.
* `babelignore: string | void` - The path of the `.babelignore` file, if there was one.
* `options: ValidatedOptions` - The partially resolved options, which can be manipulated and passed back to Babel again.
* `plugins: Array<ConfigItem>` - See below.
* `presets: Array<ConfigItem>` - See below.
* It can be safely passed back to Babel. Fields like `babelrc` have been set
to false so that later calls to Babel will not make a second attempt to
load config files.
* `hasFilesystemConfig(): boolean` - Check if the resolved config loaded any settings from the filesystem.
[`ConfigItem`](#configitem-type) instances expose properties to introspect the values, but each
item should be treated as immutable. If changes are desired, the item should be
removed from the list and replaced with either a normal Babel config value, or
with a replacement item created by `babel.createConfigItem`. See that
function for information about `ConfigItem` fields.
### babel.createConfigItem(value: string | {} | Function | [string | {} | Function, {} | void], { dirname?: string, type?: "preset" | "plugin" }): ConfigItem
Allows build tooling to create and cache config items up front. If this function
is called multiple times for a given plugin, Babel will call the plugin's function itself
multiple times. If you have a clear set of expected plugins and presets to
inject, pre-constructing the config items would be recommended.
### `ConfigItem` type
Each `ConfigItem` exposes all of the information Babel knows. The fields are:
* `value: {} | Function` - The resolved value of the plugin.
* `options: {} | void` - The options object passed to the plugin.
* `dirname: string` - The path that the options are relative to.
* `name: string | void` - The name that the user gave the plugin instance, e.g. `plugins: [ ['env', {}, 'my-env'] ]`
* `file: Object | void` - Information about the plugin's file, if Babel knows it.
* `request: string` - The file that the user requested, e.g. `"@babel/env"`
* `resolved: string` - The full path of the resolved file, e.g. `"/tmp/node_modules/@babel/preset-env/lib/index.js"`
## Options
<blockquote class="babel-callout babel-callout-info">
<h4>Babel CLI</h4>
<p>
You can pass these options from the Babel CLI like so:
</p>
<p>
<code>babel --option-name<span class="o">=</span>value</code>
</p>
</blockquote>
Following is a table of the options you can use:
| Option | Default | Description |
| ------------------------ | -------------------- | ------------------------------- |
| `ast` | `false` | Include the AST in the returned object |
| `auxiliaryCommentAfter` | `null` | Attach a comment after all non-user injected code |
| `auxiliaryCommentBefore` | `null` | Attach a comment before all non-user injected code |
| `root` | `"."` | Specify the "root" folder that defines the location to search for "babel.config.js", and the default folder to allow `.babelrc` files inside of.|
| `configFile` | `undefined` | The config file to load Babel's config from. Defaults to searching for "babel.config.js" inside the "root" folder. `false` will disable searching for config files.|
| `babelrc` | `true` | Specify whether or not to use .babelrc and .babelignore files. Not available when using the CLI, [use `--no-babelrc` instead](https://babeljs.io/docs/usage/cli/#babel-ignoring-babelrc) |
| `babelrcRoots` | `(root)` | Specify which packages should be search for .babelrc files when they are being compiled. `true` to _always_ search, or a path string or an array of paths to packages to search inside of. Defaults to only searching the "root" package. |
| `envName` | env vars | Defaults to environment variable `BABEL_ENV` if set, or else `NODE_ENV` if set, or else it defaults to `"development"` |
| `code` | `true` | Enable code generation |
| `comments` | `true` | Output comments in generated output |
| `compact` | `"auto"` | Do not include superfluous whitespace characters and line terminators. When set to `"auto"` compact is set to `true` on input sizes of >500KB |
| `env` | `{}` | This is an object of keys that represent different environments. For example, you may have: `{ env: { production: { /* specific options */ } } }` which will use those options when the `envName` is `production` |
| `extends` | `null` | A path to a `.babelrc` file to extend |
| `filename` | `"unknown"` | Filename for use in errors etc |
| `filenameRelative` | `(filename)` | Filename relative to `sourceRoot` |
| `generatorOpts` | `{}` | An object containing the options to be passed down to the babel code generator, @babel/generator |
| `getModuleId` | `null` | Specify a custom callback to generate a module id with. Called as `getModuleId(moduleName)`. If falsy value is returned then the generated module id is used |
| `highlightCode` | `true` | ANSI highlight syntax error code frames |
| `ignore` | `null` | Opposite to the `only` option. `ignore` is disregarded if `only` is specified |
| `inputSourceMap` | `null` | A source map object that the output source map will be based on |
| `minified` | `false` | Should the output be minified (not printing last semicolons in blocks, printing literal string values instead of escaped ones, stripping `()` from `new` when safe) |
| `moduleId` | `null` | Specify a custom name for module ids |
| `moduleIds` | `false` | If truthy, insert an explicit id for modules. By default, all modules are anonymous. (Not available for `common` modules) |
| `moduleRoot` | `(sourceRoot)` | Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions |
| `only` | `null` | A [glob](https://github.com/isaacs/minimatch), regex, or mixed array of both, matching paths to **only** compile. Can also be an array of arrays containing paths to explicitly match. When attempting to compile a non-matching file it's returned verbatim |
| `parserOpts` | `{}` | An object containing the options to be passed down to the babel parser, @babel/parser |
| `plugins` | `[]` | List of [plugins](https://babeljs.io/docs/plugins/) to load and use |
| `presets` | `[]` | List of [presets](https://babeljs.io/docs/plugins/#presets) (a set of plugins) to load and use |
| `retainLines` | `false` | Retain line numbers. This will lead to wacky code but is handy for scenarios where you can't use source maps. (**NOTE:** This will not retain the columns) |
| `shouldPrintComment` | `null` | An optional callback that controls whether a comment should be output or not. Called as `shouldPrintComment(commentContents)`. **NOTE:** This overrides the `comment` option when used |
| `sourceFileName` | `(filenameRelative)` | Set `sources[0]` on returned source map |
| `sourceMaps` | `false` | If truthy, adds a `map` property to returned output. If set to `"inline"`, a comment with a sourceMappingURL directive is added to the bottom of the returned code. If set to `"both"` then a `map` property is returned as well as a source map comment appended. **This does not emit sourcemap files by itself!** To have sourcemaps emitted using the CLI, you must pass it the `--source-maps` option |
| `sourceRoot` | `(moduleRoot)` | The root from which all sources are relative |
| `sourceType` | `"module"` | Indicate the mode the code should be parsed in. Can be one of "script", "module", or "unambiguous". `"unambiguous"` will make Babel attempt to _guess_, based on the presence of ES6 `import` or `export` statements. Files with ES6 `import`s and `export`s are considered `"module"` and are otherwise `"script"`. |
| `wrapPluginVisitorMethod`| `null` | An optional callback that can be used to wrap visitor methods. **NOTE:** This is useful for things like introspection, and not really needed for implementing anything. Called as `wrapPluginVisitorMethod(pluginAlias, visitorType, callback)`.

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/core",
"version": "7.0.0-beta.48",
"version": "7.0.0-beta.55",
"description": "Babel compiler core.",
"main": "lib/index.js",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
@@ -27,28 +27,26 @@
},
"browser": {
"./lib/config/files/index.js": "./lib/config/files/index-browser.js",
"./lib/transform-file.js": "./lib/transform-file-browser.js",
"./lib/transform-file-sync.js": "./lib/transform-file-sync-browser.js"
"./lib/transform-file.js": "./lib/transform-file-browser.js"
},
"dependencies": {
"@babel/code-frame": "7.0.0-beta.48",
"@babel/generator": "7.0.0-beta.48",
"@babel/helpers": "7.0.0-beta.48",
"@babel/parser": "7.0.0-beta.48",
"@babel/template": "7.0.0-beta.48",
"@babel/traverse": "7.0.0-beta.48",
"@babel/types": "7.0.0-beta.48",
"@babel/code-frame": "7.0.0-beta.55",
"@babel/generator": "7.0.0-beta.55",
"@babel/helpers": "7.0.0-beta.55",
"@babel/parser": "7.0.0-beta.55",
"@babel/template": "7.0.0-beta.55",
"@babel/traverse": "7.0.0-beta.55",
"@babel/types": "7.0.0-beta.55",
"convert-source-map": "^1.1.0",
"debug": "^3.1.0",
"json5": "^0.5.0",
"lodash": "^4.17.5",
"micromatch": "^2.3.11",
"lodash": "^4.17.10",
"resolve": "^1.3.2",
"semver": "^5.4.1",
"source-map": "^0.5.0"
},
"devDependencies": {
"@babel/helper-transform-fixture-test-runner": "7.0.0-beta.48",
"@babel/register": "7.0.0-beta.48"
"@babel/helper-transform-fixture-test-runner": "7.0.0-beta.55",
"@babel/register": "7.0.0-beta.55"
}
}

View File

@@ -1,7 +1,6 @@
// @flow
import path from "path";
import micromatch from "micromatch";
import buildDebug from "debug";
import {
validate,
@@ -10,6 +9,7 @@ import {
type ConfigApplicableTest,
type BabelrcSearch,
} from "./validation/options";
import pathPatternToRegex from "./pattern-to-regex";
const debug = buildDebug("babel:config:config-chain");
@@ -52,11 +52,6 @@ export type ConfigContext = {
envName: string,
};
type ConfigContextNamed = {
...ConfigContext,
filename: string,
};
/**
* Build a config chain for a given preset.
*/
@@ -217,7 +212,7 @@ function babelrcLoadEnabled(
const absoluteRoot = context.root;
// Fast path to avoid having to load micromatch if the babelrc is just
// Fast path to avoid having to match patterns if the babelrc is just
// loading in the standard root directory.
if (babelrcRoots === undefined) {
return pkgData.directories.indexOf(absoluteRoot) !== -1;
@@ -225,22 +220,32 @@ function babelrcLoadEnabled(
let babelrcPatterns = babelrcRoots;
if (!Array.isArray(babelrcPatterns)) babelrcPatterns = [babelrcPatterns];
babelrcPatterns = babelrcPatterns.map(pat => path.resolve(context.cwd, pat));
babelrcPatterns = babelrcPatterns.map(pat => {
return typeof pat === "string" ? path.resolve(context.cwd, pat) : pat;
});
// Fast path to avoid having to load micromatch if the babelrc is just
// Fast path to avoid having to match patterns if the babelrc is just
// loading in the standard root directory.
if (babelrcPatterns.length === 1 && babelrcPatterns[0] === absoluteRoot) {
return pkgData.directories.indexOf(absoluteRoot) !== -1;
}
return micromatch(pkgData.directories, babelrcPatterns).length > 0;
return babelrcPatterns.some(pat => {
if (typeof pat === "string") pat = pathPatternToRegex(pat, context.cwd);
return pkgData.directories.some(directory => {
return matchPattern(pat, context.cwd, directory);
});
});
}
const validateConfigFile = makeWeakCache((file: ConfigFile): ValidatedFile => ({
filepath: file.filepath,
dirname: file.dirname,
options: validate("configfile", file.options),
}));
const validateConfigFile = makeWeakCache(
(file: ConfigFile): ValidatedFile => ({
filepath: file.filepath,
dirname: file.dirname,
options: validate("configfile", file.options),
}),
);
const validateBabelrcFile = makeWeakCache(
(file: ConfigFile): ValidatedFile => ({
@@ -250,11 +255,13 @@ const validateBabelrcFile = makeWeakCache(
}),
);
const validateExtendFile = makeWeakCache((file: ConfigFile): ValidatedFile => ({
filepath: file.filepath,
dirname: file.dirname,
options: validate("extendsfile", file.options),
}));
const validateExtendFile = makeWeakCache(
(file: ConfigFile): ValidatedFile => ({
filepath: file.filepath,
dirname: file.dirname,
options: validate("extendsfile", file.options),
}),
);
/**
* Build a config chain for just the programmatic options passed into Babel.
@@ -496,11 +503,15 @@ function normalizeOptions(opts: ValidatedOptions): ValidatedOptions {
};
delete options.extends;
delete options.env;
delete options.overrides;
delete options.plugins;
delete options.presets;
delete options.passPerPreset;
delete options.ignore;
delete options.only;
delete options.test;
delete options.include;
delete options.exclude;
// "sourceMap" is just aliased to sourceMap, so copy it over as
// we merge the options together.
@@ -575,20 +586,9 @@ function configFieldIsApplicable(
test: ConfigApplicableTest,
dirname: string,
): boolean {
if (typeof context.filename !== "string") {
throw new Error(
`Configuration contains explicit test/include/exclude checks, but no filename was passed to Babel`,
);
}
// $FlowIgnore - Flow refinements aren't quite smart enough for this :(
const ctx: ConfigContextNamed = context;
const patterns = Array.isArray(test) ? test : [test];
// Disabling negation here because it's a bit buggy from
// https://github.com/babel/babel/issues/6907 and it's not clear that it is
// needed since users can use 'exclude' alongside 'test'/'include'.
return matchesPatterns(ctx, patterns, dirname, false /* allowNegation */);
return matchesPatterns(context, patterns, dirname);
}
/**
@@ -600,43 +600,24 @@ function shouldIgnore(
only: ?IgnoreList,
dirname: string,
): boolean {
if (ignore) {
if (typeof context.filename !== "string") {
throw new Error(
`Configuration contains ignore checks, but no filename was passed to Babel`,
);
}
// $FlowIgnore - Flow refinements aren't quite smart enough for this :(
const ctx: ConfigContextNamed = context;
if (matchesPatterns(ctx, ignore, dirname)) {
debug(
"Ignored %o because it matched one of %O from %o",
context.filename,
ignore,
dirname,
);
return true;
}
if (ignore && matchesPatterns(context, ignore, dirname)) {
debug(
"Ignored %o because it matched one of %O from %o",
context.filename,
ignore,
dirname,
);
return true;
}
if (only) {
if (typeof context.filename !== "string") {
throw new Error(
`Configuration contains ignore checks, but no filename was passed to Babel`,
);
}
// $FlowIgnore - Flow refinements aren't quite smart enough for this :(
const ctx: ConfigContextNamed = context;
if (!matchesPatterns(ctx, only, dirname)) {
debug(
"Ignored %o because it failed to match one of %O from %o",
context.filename,
only,
dirname,
);
return true;
}
if (only && !matchesPatterns(context, only, dirname)) {
debug(
"Ignored %o because it failed to match one of %O from %o",
context.filename,
only,
dirname,
);
return true;
}
return false;
@@ -647,64 +628,26 @@ function shouldIgnore(
* Otherwise returns result of matching pattern Regex with filename.
*/
function matchesPatterns(
context: ConfigContextNamed,
context: ConfigContext,
patterns: IgnoreList,
dirname: string,
allowNegation?: boolean = true,
): boolean {
const res = [];
const strings = [];
const fns = [];
patterns.forEach(pattern => {
if (typeof pattern === "string") strings.push(pattern);
else if (typeof pattern === "function") fns.push(pattern);
else res.push(pattern);
});
const filename = context.filename;
if (res.some(re => re.test(context.filename))) return true;
if (fns.some(fn => fn(filename))) return true;
if (strings.length > 0) {
const possibleDirs = getPossibleDirs(context);
const absolutePatterns = strings.map(pattern => {
// Preserve the "!" prefix so that micromatch can use it for negation.
const negate = pattern[0] === "!";
if (negate && !allowNegation) {
throw new Error(`Negation of file paths is not supported.`);
}
if (negate) pattern = pattern.slice(1);
return (negate ? "!" : "") + path.resolve(dirname, pattern);
});
if (
micromatch(possibleDirs, absolutePatterns, {
nocase: true,
nonegate: !allowNegation,
}).length > 0
) {
return true;
}
}
return false;
return patterns.some(pattern =>
matchPattern(pattern, dirname, context.filename),
);
}
const getPossibleDirs = makeWeakCache((context: ConfigContextNamed) => {
let current = context.filename;
if (typeof current !== "string") return [];
function matchPattern(pattern, dirname, pathToTest): boolean {
if (typeof pattern === "function") return !!pattern(pathToTest);
const possibleDirs = [current];
while (true) {
const previous = current;
current = path.dirname(current);
if (previous === current) break;
possibleDirs.push(current);
if (typeof pathToTest !== "string") {
throw new Error(
`Configuration contains string/RegExp pattern, but no filename was passed to Babel`,
);
}
return possibleDirs;
});
if (typeof pattern === "string") {
pattern = pathPatternToRegex(pattern, dirname);
}
return pattern.test(pathToTest);
}

View File

@@ -12,6 +12,7 @@ import {
} from "../caching";
import makeAPI from "../helpers/config-api";
import { makeStaticFileCache } from "./utils";
import pathPatternToRegex from "../pattern-to-regex";
import type { FilePackageData, RelativeConfig, ConfigFile } from "./types";
const debug = buildDebug("babel:config:loading:files:configuration");
@@ -198,8 +199,9 @@ const readConfigJS = makeStrongCache(
const packageToBabelConfig = makeWeakCache(
(file: ConfigFile): ConfigFile | null => {
if (typeof file.options.babel === "undefined") return null;
const babel = file.options.babel;
const babel = file.options[("babel": string)];
if (typeof babel === "undefined") return null;
if (typeof babel !== "object" || Array.isArray(babel) || babel === null) {
throw new Error(`${file.filepath}: .babel property must be an object`);
@@ -239,15 +241,24 @@ const readConfigJSON5 = makeStaticFileCache((filepath, content) => {
});
const readIgnoreConfig = makeStaticFileCache((filepath, content) => {
const ignore = content
const ignoreDir = path.dirname(filepath);
const ignorePatterns = content
.split("\n")
.map(line => line.replace(/#(.*?)$/, "").trim())
.filter(line => !!line);
for (const pattern of ignorePatterns) {
if (pattern[0] === "!") {
throw new Error(`Negation of file paths is not supported.`);
}
}
return {
filepath,
dirname: path.dirname(filepath),
ignore,
ignore: ignorePatterns.map(pattern =>
pathPatternToRegex(pattern, ignoreDir),
),
};
});

View File

@@ -19,14 +19,14 @@ export function findPackageData(filepath: string): FilePackageData {
}
export function findRelativeConfig(
pkgData: FilePackageData,
pkgData: FilePackageData, // eslint-disable-line no-unused-vars
envName: string, // eslint-disable-line no-unused-vars
): RelativeConfig {
return { pkg: null, config: null, ignore: null };
}
export function findRootConfig(
dirname: string,
dirname: string, // eslint-disable-line no-unused-vars
envName: string, // eslint-disable-line no-unused-vars
): ConfigFile | null {
return null;

View File

@@ -15,8 +15,9 @@ const BABEL_PLUGIN_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-plugin-)/;
const BABEL_PRESET_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-preset-)/;
const BABEL_PLUGIN_ORG_RE = /^(@babel\/)(?!plugin-|[^/]+\/)/;
const BABEL_PRESET_ORG_RE = /^(@babel\/)(?!preset-|[^/]+\/)/;
const OTHER_PLUGIN_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?!babel-plugin-|[^/]+\/)/;
const OTHER_PRESET_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?!babel-preset-|[^/]+\/)/;
const OTHER_PLUGIN_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?!babel-plugin(?:-|\/|$)|[^/]+\/)/;
const OTHER_PRESET_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?!babel-preset(?:-|\/|$)|[^/]+\/)/;
const OTHER_ORG_DEFAULT_RE = /^(@(?!babel$)[^/]+)$/;
export function resolvePlugin(name: string, dirname: string): string | null {
return resolveStandardizedName("plugin", name, dirname);
@@ -80,6 +81,8 @@ function standardizeName(type: "plugin" | "preset", name: string) {
isPreset ? OTHER_PRESET_ORG_RE : OTHER_PLUGIN_ORG_RE,
`$1babel-${type}-`,
)
// @foo -> @foo/babel-preset
.replace(OTHER_ORG_DEFAULT_RE, `$1/babel-${type}`)
// module:mypreset -> mypreset
.replace(EXACT_RE, "")
);

View File

@@ -9,7 +9,7 @@ export type ConfigFile = {
export type IgnoreFile = {
filepath: string,
dirname: string,
ignore: Array<string>,
ignore: Array<RegExp>,
};
export type RelativeConfig = {

View File

@@ -17,10 +17,3 @@ export function loadOptions(opts: {}): Object | null {
return config ? config.options : null;
}
// For easier backward-compatibility, provide an API like the one we exposed in Babel 6.
export class OptionManager {
init(opts: {}) {
return loadOptions(opts);
}
}

View File

@@ -60,9 +60,7 @@ export default function loadPrivatePartialConfig(
options.cwd = context.cwd;
options.root = context.root;
options.filename =
typeof context.filename === "string"
? path.relative(context.cwd, context.filename)
: undefined;
typeof context.filename === "string" ? context.filename : undefined;
options.plugins = configChain.plugins.map(descriptor =>
createItemFromDescriptor(descriptor),

View File

@@ -0,0 +1,51 @@
// @flow
import path from "path";
import escapeRegExp from "lodash/escapeRegExp";
const sep = `\\${path.sep}`;
const endSep = `(?:${sep}|$)`;
const substitution = `[^${sep}]+`;
const starPat = `(?:${substitution}${sep})`;
const starPatLast = `(?:${substitution}${endSep})`;
const starStarPat = `${starPat}*?`;
const starStarPatLast = `${starPat}*?${starPatLast}?`;
/**
* Implement basic pattern matching that will allow users to do the simple
* tests with * and **. If users want full complex pattern matching, then can
* always use regex matching, or function validation.
*/
export default function pathToPattern(
pattern: string,
dirname: string,
): RegExp {
const parts = path.resolve(dirname, pattern).split(path.sep);
return new RegExp(
[
"^",
...parts.map((part, i) => {
const last = i === parts.length - 1;
// ** matches 0 or more path parts.
if (part === "**") return last ? starStarPatLast : starStarPat;
// * matches 1 path part.
if (part === "*") return last ? starPatLast : starPat;
// *.ext matches a wildcard with an extension.
if (part.indexOf("*.") === 0) {
return (
substitution + escapeRegExp(part.slice(1)) + (last ? endSep : sep)
);
}
// Otherwise match the pattern text.
return escapeRegExp(part) + (last ? endSep : sep);
}),
].join(""),
);
}

View File

@@ -192,14 +192,14 @@ export function assertBabelrcSearch(
if (Array.isArray(value)) {
value.forEach((item, i) => {
if (typeof item !== "string") {
throw new Error(`.${key}[${i}] must be a string.`);
if (!checkValidTest(item)) {
throw new Error(`.${key}[${i}] must be a string/Function/RegExp.`);
}
});
} else if (typeof value !== "string") {
} else if (!checkValidTest(value)) {
throw new Error(
`.${key} must be a undefined, a boolean, a string, ` +
`or an array of strings, got ${JSON.stringify(value)}`,
`.${key} must be a undefined, a boolean, a string/Function/RegExp ` +
`or an array of those, got ${JSON.stringify(value)}`,
);
}
return (value: any);

View File

@@ -242,7 +242,7 @@ export type OverridesList = Array<ValidatedOptions>;
export type ConfigApplicableTest = IgnoreItem | Array<IgnoreItem>;
export type ConfigFileSearch = string | boolean;
export type BabelrcSearch = boolean | string | Array<string>;
export type BabelrcSearch = boolean | IgnoreItem | IgnoreList;
export type SourceMapsOption = boolean | "inline" | "both";
export type SourceTypeOption = "module" | "script" | "unambiguous";
export type CompactOption = boolean | "auto";

View File

@@ -13,26 +13,22 @@ export * as types from "@babel/types";
export { default as traverse } from "@babel/traverse";
export { default as template } from "@babel/template";
export { loadPartialConfig, loadOptions, OptionManager } from "./config";
export { createConfigItem } from "./config/item";
export function Plugin(alias: string) {
throw new Error(
`The (${alias}) Babel 5 plugin is being run with an unsupported Babel version.`,
);
}
export { loadPartialConfig, loadOptions } from "./config";
export { default as transform } from "./transform";
export { default as transformSync } from "./transform-sync";
export { default as transformFile } from "./transform-file";
export { default as transformFileSync } from "./transform-file-sync";
export { default as transformFromAst } from "./transform-ast";
export { default as transformFromAstSync } from "./transform-ast-sync";
export { default as parse } from "./parse";
export { transform, transformSync, transformAsync } from "./transform";
export {
transformFile,
transformFileSync,
transformFileAsync,
} from "./transform-file";
export {
transformFromAst,
transformFromAstSync,
transformFromAstAsync,
} from "./transform-ast";
export { parse, parseSync, parseAsync } from "./parse";
/**
* Recommended set of compilable extensions. Not used in @babel/core directly, but meant as
@@ -45,3 +41,17 @@ export const DEFAULT_EXTENSIONS = Object.freeze([
".es",
".mjs",
]);
// For easier backward-compatibility, provide an API like the one we exposed in Babel 6.
import { loadOptions } from "./config";
export class OptionManager {
init(opts: {}) {
return loadOptions(opts);
}
}
export function Plugin(alias: string) {
throw new Error(
`The (${alias}) Babel 5 plugin is being run with an unsupported Babel version.`,
);
}

View File

@@ -6,17 +6,79 @@ import normalizeOptions from "./transformation/normalize-opts";
type AstRoot = BabelNodeFile | BabelNodeProgram;
export default function parse(
code: string,
opts: InputOptions,
): AstRoot | null {
export type ParseResult = AstRoot;
export type FileParseCallback = {
(Error, null): any,
(null, ParseResult | null): any,
};
type Parse = {
(code: string, callback: FileParseCallback): void,
(code: string, opts: ?InputOptions, callback: FileParseCallback): void,
// Here for backward-compatibility. Ideally use ".parseSync" if you want
// a synchronous API.
(code: string, opts: ?InputOptions): ParseResult | null,
};
export const parse: Parse = (function parse(code, opts, callback) {
if (typeof opts === "function") {
callback = opts;
opts = undefined;
}
// For backward-compat with Babel 7's early betas, we allow sync parsing when
// no callback is given. Will be dropped in some future Babel major version.
if (callback === undefined) return parseSync(code, opts);
const config = loadConfig(opts);
if (config === null) {
return null;
}
const file = normalizeFile(config.passes, normalizeOptions(config), code);
// Reassign to keep Flowtype happy.
const cb = callback;
return file.ast;
// Just delaying the transform one tick for now to simulate async behavior
// but more async logic may land here eventually.
process.nextTick(() => {
let ast = null;
try {
const cfg = loadConfig(opts);
if (cfg === null) return cb(null, null);
ast = normalizeFile(cfg.passes, normalizeOptions(cfg), code).ast;
} catch (err) {
return cb(err);
}
cb(null, ast);
});
}: Function);
export function parseSync(
code: string,
opts?: InputOptions,
): ParseResult | null {
const config = loadConfig(opts);
if (config === null) {
return null;
}
return normalizeFile(config.passes, normalizeOptions(config), code).ast;
}
export function parseAsync(
code: string,
opts?: InputOptions,
): Promise<ParseResult | null> {
return new Promise((res, rej) => {
parse(code, opts, (err, result) => {
if (err == null) res(result);
else rej(err);
});
});
}

View File

@@ -1,18 +0,0 @@
// @flow
import loadConfig, { type InputOptions } from "./config";
import { runSync, type FileResult } from "./transformation";
type AstRoot = BabelNodeFile | BabelNodeProgram;
export default function transformFromAstSync(
ast: AstRoot,
code: string,
opts: ?InputOptions,
): FileResult | null {
const config = loadConfig(opts);
if (config === null) return null;
if (!ast) throw new Error("No AST given");
return runSync(config, code, ast);
}

View File

@@ -2,16 +2,15 @@
import loadConfig, { type InputOptions } from "./config";
import {
runSync,
runAsync,
type FileResult,
type FileResultCallback,
} from "./transformation";
import transformAstSync from "./transform-ast-sync";
type AstRoot = BabelNodeFile | BabelNodeProgram;
type TransformAst = {
type TransformFromAst = {
(ast: AstRoot, code: string, callback: FileResultCallback): void,
(
ast: AstRoot,
@@ -25,15 +24,20 @@ type TransformAst = {
(ast: AstRoot, code: string, opts: ?InputOptions): FileResult | null,
};
export default ((function transformFromAst(ast, code, opts, callback) {
export const transformFromAst: TransformFromAst = (function transformFromAst(
ast,
code,
opts,
callback,
) {
if (typeof opts === "function") {
opts = undefined;
callback = opts;
opts = undefined;
}
// For backward-compat with Babel 6, we allow sync transformation when
// no callback is given. Will be dropped in some future Babel major version.
if (callback === undefined) return transformAstSync(ast, code, opts);
if (callback === undefined) return transformFromAstSync(ast, code, opts);
// Reassign to keep Flowtype happy.
const cb = callback;
@@ -53,4 +57,30 @@ export default ((function transformFromAst(ast, code, opts, callback) {
runAsync(cfg, code, ast, cb);
});
}: Function): TransformAst);
}: Function);
export function transformFromAstSync(
ast: AstRoot,
code: string,
opts: ?InputOptions,
): FileResult | null {
const config = loadConfig(opts);
if (config === null) return null;
if (!ast) throw new Error("No AST given");
return runSync(config, code, ast);
}
export function transformFromAstAsync(
ast: AstRoot,
code: string,
opts: ?InputOptions,
): Promise<FileResult | null> {
return new Promise((res, rej) => {
transformFromAst(ast, code, opts, (err, result) => {
if (err == null) res(result);
else rej(err);
});
});
}

View File

@@ -1,25 +0,0 @@
// @flow
import fs from "fs";
import loadConfig, { type InputOptions } from "./config";
import { runSync, type FileResult } from "./transformation";
export default function transformFileSync(
filename: string,
opts: ?InputOptions,
): FileResult | null {
let options;
if (opts == null) {
options = { filename };
} else if (opts && typeof opts === "object") {
options = {
...opts,
filename,
};
}
const config = loadConfig(options);
if (config === null) return null;
return runSync(config, fs.readFileSync(filename, "utf8"));
}

View File

@@ -2,14 +2,23 @@
import fs from "fs";
import loadConfig, { type InputOptions } from "./config";
import { runAsync, type FileResultCallback } from "./transformation";
import {
runSync,
runAsync,
type FileResult,
type FileResultCallback,
} from "./transformation";
type TransformFile = {
(filename: string, callback: FileResultCallback): void,
(filename: string, opts: ?InputOptions, callback: FileResultCallback): void,
};
export default ((function transformFile(filename, opts, callback) {
export const transformFile: TransformFile = (function transformFile(
filename,
opts,
callback,
) {
let options;
if (typeof opts === "function") {
callback = opts;
@@ -43,4 +52,36 @@ export default ((function transformFile(filename, opts, callback) {
runAsync(config, code, null, callback);
});
});
}: Function): TransformFile);
}: Function);
export function transformFileSync(
filename: string,
opts: ?InputOptions,
): FileResult | null {
let options;
if (opts == null) {
options = { filename };
} else if (opts && typeof opts === "object") {
options = {
...opts,
filename,
};
}
const config = loadConfig(options);
if (config === null) return null;
return runSync(config, fs.readFileSync(filename, "utf8"));
}
export function transformFileAsync(
filename: string,
opts: ?InputOptions,
): Promise<FileResult | null> {
return new Promise((res, rej) => {
transformFile(filename, opts, (err, result) => {
if (err == null) res(result);
else rej(err);
});
});
}

View File

@@ -1,13 +0,0 @@
// @flow
import loadConfig, { type InputOptions } from "./config";
import { runSync, type FileResult } from "./transformation";
export default function transformSync(
code: string,
opts: ?InputOptions,
): FileResult | null {
const config = loadConfig(opts);
if (config === null) return null;
return runSync(config, code);
}

View File

@@ -1,13 +1,12 @@
// @flow
import loadConfig, { type InputOptions } from "./config";
import {
runSync,
runAsync,
type FileResult,
type FileResultCallback,
} from "./transformation";
import transformSync from "./transform-sync";
type Transform = {
(code: string, callback: FileResultCallback): void,
(code: string, opts: ?InputOptions, callback: FileResultCallback): void,
@@ -17,10 +16,10 @@ type Transform = {
(code: string, opts: ?InputOptions): FileResult | null,
};
export default ((function transform(code, opts, callback) {
export const transform: Transform = (function transform(code, opts, callback) {
if (typeof opts === "function") {
opts = undefined;
callback = opts;
opts = undefined;
}
// For backward-compat with Babel 6, we allow sync transformation when
@@ -43,4 +42,26 @@ export default ((function transform(code, opts, callback) {
runAsync(cfg, code, null, cb);
});
}: Function): Transform);
}: Function);
export function transformSync(
code: string,
opts: ?InputOptions,
): FileResult | null {
const config = loadConfig(opts);
if (config === null) return null;
return runSync(config, code);
}
export function transformAsync(
code: string,
opts: ?InputOptions,
): Promise<FileResult | null> {
return new Promise((res, rej) => {
transform(code, opts, (err, result) => {
if (err == null) res(result);
else rej(err);
});
});
}

View File

@@ -1,6 +1,8 @@
// @flow
import path from "path";
import buildDebug from "debug";
import cloneDeep from "lodash/cloneDeep";
import * as t from "@babel/types";
import type { PluginPasses } from "../config";
import convertSourceMap, { typeof Converter } from "convert-source-map";
@@ -27,32 +29,44 @@ export default function normalizeFile(
let inputMap = null;
if (options.inputSourceMap !== false) {
try {
inputMap = convertSourceMap.fromSource(code);
if (inputMap) {
code = convertSourceMap.removeComments(code);
}
} catch (err) {
debug("discarding unknown inline input sourcemap", err);
code = convertSourceMap.removeComments(code);
// If an explicit object is passed in, it overrides the processing of
// source maps that may be in the file itself.
if (typeof options.inputSourceMap === "object") {
inputMap = convertSourceMap.fromObject(options.inputSourceMap);
}
if (!inputMap) {
try {
inputMap = convertSourceMap.fromMapFileSource(code);
inputMap = convertSourceMap.fromSource(code);
if (inputMap) {
code = convertSourceMap.removeMapFileComments(code);
code = convertSourceMap.removeComments(code);
}
} catch (err) {
debug("discarding unknown file input sourcemap", err);
code = convertSourceMap.removeMapFileComments(code);
debug("discarding unknown inline input sourcemap", err);
code = convertSourceMap.removeComments(code);
}
}
if (!inputMap && typeof options.inputSourceMap === "object") {
inputMap = convertSourceMap.fromObject(options.inputSourceMap);
if (!inputMap) {
if (typeof options.filename === "string") {
try {
inputMap = convertSourceMap.fromMapFileSource(
code,
path.dirname(options.filename),
);
if (inputMap) {
code = convertSourceMap.removeMapFileComments(code);
}
} catch (err) {
debug("discarding unknown file input sourcemap", err);
code = convertSourceMap.removeMapFileComments(code);
}
} else {
debug("discarding un-loadable file input sourcemap");
code = convertSourceMap.removeMapFileComments(code);
}
}
}
@@ -62,6 +76,7 @@ export default function normalizeFile(
} else if (ast.type !== "File") {
throw new Error("AST root must be a Program or File node");
}
ast = cloneDeep(ast);
} else {
// The parser's AST types aren't fully compatible with the types generated
// by the logic in babel-types.

View File

@@ -8,10 +8,11 @@ export default class PluginPass {
file: File;
opts: Object;
// The working directory that Babel's options are loaded relative to.
// The working directory that Babel's programmatic options are loaded
// relative to.
cwd: string;
// The path of the file being compiled, relative to the working directory.
// The absolute path of the file being compiled.
filename: string | void;
constructor(file: File, key: ?string, options: ?Object) {

View File

@@ -5,11 +5,18 @@ import Plugin from "../lib/config/plugin";
import generator from "@babel/generator";
function assertIgnored(result) {
expect(result).toBeFalsy();
expect(result).toBeNull();
}
function assertNotIgnored(result) {
expect(result.ignored).toBeFalsy();
expect(result).not.toBeNull();
}
function parse(code, opts) {
return babel.parse(code, {
cwd: __dirname,
...opts,
});
}
function transform(code, opts) {
@@ -36,13 +43,18 @@ function transformFileSync(filename, opts) {
});
}
// shim
function transformAsync(code, opts) {
return {
then: function(resolve) {
resolve(transform(code, opts));
},
};
return babel.transformAsync(code, {
cwd: __dirname,
...opts,
});
}
function transformFromAst(ast, code, opts) {
return babel.transformFromAst(ast, code, {
cwd: __dirname,
...opts,
});
}
describe("parser and generator options", function() {
@@ -170,6 +182,30 @@ describe("api", function() {
expect(options).toEqual({ babelrc: false });
});
it("transformFromAst should not mutate the AST", function() {
const program = "const identifier = 1";
const node = parse(program);
const { code } = transformFromAst(node, program, {
plugins: [
function() {
return {
visitor: {
Identifier: function(path) {
path.node.name = "replaced";
},
},
};
},
],
});
expect(code).toBe("const replaced = 1;");
expect(node.program.body[0].declarations[0].id.name).toBe(
"identifier",
"original ast should not have been mutated",
);
});
it("options throw on falsy true", function() {
return expect(function() {
transform("", {
@@ -180,7 +216,7 @@ describe("api", function() {
it("options merge backwards", function() {
return transformAsync("", {
presets: [__dirname + "/../../babel-preset-es2015"],
presets: [__dirname + "/../../babel-preset-env"],
plugins: [__dirname + "/../../babel-plugin-syntax-jsx"],
}).then(function(result) {
expect(result.options.plugins[0].manipulateOptions.toString()).toEqual(
@@ -259,8 +295,8 @@ describe("api", function() {
};
},
// ES2015 preset
require(__dirname + "/../../babel-preset-es2015"),
// env preset
require(__dirname + "/../../babel-preset-env"),
// Third preset for Flow.
function() {

View File

@@ -899,6 +899,23 @@ describe("buildConfigChain", function() {
expect(opts.comments).toBe(true);
});
it("should remove the overrides and filtering fields from the options", () => {
const opts = loadOptions({
cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"),
babelrc: false,
overrides: [],
test: /^/,
include: /^/,
exclude: [],
});
expect(opts.overrides).toBeUndefined();
expect(opts.test).toBeUndefined();
expect(opts.include).toBeUndefined();
expect(opts.exclude).toBeUndefined();
});
});
describe("config files", () => {
@@ -936,7 +953,7 @@ describe("buildConfigChain", function() {
}),
).toEqual({
...getDefaults(),
filename: path.basename(filename),
filename: filename,
cwd: path.dirname(filename),
root: path.dirname(filename),
comments: true,
@@ -948,7 +965,7 @@ describe("buildConfigChain", function() {
expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({
...getDefaults(),
filename: path.basename(filename),
filename: filename,
cwd: path.dirname(filename),
root: path.dirname(filename),
comments: true,
@@ -960,7 +977,7 @@ describe("buildConfigChain", function() {
expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({
...getDefaults(),
filename: path.basename(filename),
filename: filename,
cwd: path.dirname(filename),
root: path.dirname(filename),
comments: true,
@@ -1002,7 +1019,7 @@ describe("buildConfigChain", function() {
expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({
...getDefaults(),
filename: path.basename(filename),
filename: filename,
cwd: path.dirname(filename),
root: path.dirname(filename),
comments: true,

View File

@@ -12,6 +12,11 @@ Object.defineProperty(exports, "__esModule", {
exports.default = function () {
return {
plugins: [require('../../../../../babel-plugin-syntax-decorators')]
plugins: [
[
require('../../../../../babel-plugin-syntax-decorators'),
{ legacy: true }
],
]
};
};

View File

@@ -9,6 +9,11 @@
exports.__esModule = true;
module.exports = function() {
return {
plugins: [require('../../../../../babel-plugin-syntax-decorators')]
plugins: [
[
require('../../../../../babel-plugin-syntax-decorators'),
{ legacy: true }
],
]
};
};

View File

@@ -1,7 +1,10 @@
module.exports = function () {
return {
plugins: [
require('../../../../../babel-plugin-syntax-decorators'),
[
require('../../../../../babel-plugin-syntax-decorators'),
{ legacy: true }
],
]
};
};

View File

@@ -1,7 +1,10 @@
module.exports = function() {
return {
plugins: [
require('../../../../../babel-plugin-syntax-decorators'),
[
require('../../../../../babel-plugin-syntax-decorators'),
{ legacy: true }
],
]
};
};

View File

@@ -1,5 +1,5 @@
{
"plugins": [
["@babel/syntax-decorators", { "legacy": true }]
]
"parserOpts": {
"plugins": ["decorators-legacy"]
}
}

View File

@@ -58,7 +58,7 @@
"column": 11
}
},
"callee": {
"expression": {
"type": "Identifier",
"start": 1,
"end": 11,

View File

@@ -0,0 +1,3 @@
module.exports = function() {
return {};
};

Some files were not shown because too many files have changed in this diff Show More