You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1073 lines
37 KiB

4 years ago
  1. # Changelog
  2. > **Tags:**
  3. > - :boom: [Breaking Change]
  4. > - :eyeglasses: [Spec Compliance]
  5. > - :rocket: [New Feature]
  6. > - :bug: [Bug Fix]
  7. > - :memo: [Documentation]
  8. > - :house: [Internal]
  9. > - :nail_care: [Polish]
  10. > Semver Policy: https://github.com/babel/babel/tree/master/packages/babel-parser#semver
  11. _Note: Gaps between patch versions are faulty, broken or test releases._
  12. See the [Babel Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.md) for the pre-6.8.0 version Changelog.
  13. ## 6.17.1 (2017-05-10)
  14. ### :bug: Bug Fix
  15. * Fix typo in flow spread operator error (Brian Ng)
  16. * Fixed invalid number literal parsing ([#473](https://github.com/babel/babylon/pull/473)) (Alex Kuzmenko)
  17. * Fix number parser ([#433](https://github.com/babel/babylon/pull/433)) (Alex Kuzmenko)
  18. * Ensure non pattern shorthand props are checked for reserved words ([#479](https://github.com/babel/babylon/pull/479)) (Brian Ng)
  19. * Remove jsx context when parsing arrow functions ([#475](https://github.com/babel/babylon/pull/475)) (Brian Ng)
  20. * Allow super in class properties ([#499](https://github.com/babel/babylon/pull/499)) (Brian Ng)
  21. * Allow flow class field to be named constructor ([#510](https://github.com/babel/babylon/pull/510)) (Brian Ng)
  22. ## 6.17.0 (2017-04-20)
  23. ### :bug: Bug Fix
  24. * Cherry-pick #418 to 6.x ([#476](https://github.com/babel/babylon/pull/476)) (Sebastian McKenzie)
  25. * Add support for invalid escapes in tagged templates ([#274](https://github.com/babel/babylon/pull/274)) (Kevin Gibbons)
  26. * Throw error if new.target is used outside of a function ([#402](https://github.com/babel/babylon/pull/402)) (Brian Ng)
  27. * Fix parsing of class properties ([#351](https://github.com/babel/babylon/pull/351)) (Kevin Gibbons)
  28. * Fix parsing yield with dynamicImport ([#383](https://github.com/babel/babylon/pull/383)) (Brian Ng)
  29. * Ensure consistent start args for parseParenItem ([#386](https://github.com/babel/babylon/pull/386)) (Brian Ng)
  30. ## 7.0.0-beta.8 (2017-04-04)
  31. ### New Feature
  32. * Add support for flow type spread (#418) (Conrad Buck)
  33. * Allow statics in flow interfaces (#427) (Brian Ng)
  34. ### Bug Fix
  35. * Fix predicate attachment to match flow parser (#428) (Brian Ng)
  36. * Add extra.raw back to JSXText and JSXAttribute (#344) (Alex Rattray)
  37. * Fix rest parameters with array and objects (#424) (Brian Ng)
  38. * Fix number parser (#433) (Alex Kuzmenko)
  39. ### Docs
  40. * Fix CONTRIBUTING.md [skip ci] (#432) (Alex Kuzmenko)
  41. ### Internal
  42. * Use babel-register script when running babel smoke tests (#442) (Brian Ng)
  43. ## 7.0.0-beta.7 (2017-03-22)
  44. ### Spec Compliance
  45. * Remove babylon plugin for template revision since it's stage-4 (#426) (Henry Zhu)
  46. ### Bug Fix
  47. * Fix push-pop logic in flow (#405) (Daniel Tschinder)
  48. ## 7.0.0-beta.6 (2017-03-21)
  49. ### New Feature
  50. * Add support for invalid escapes in tagged templates (#274) (Kevin Gibbons)
  51. ### Polish
  52. * Improves error message when super is called outside of constructor (#408) (Arshabh Kumar Agarwal)
  53. ### Docs
  54. * [7.0] Moved value field in spec from ObjectMember to ObjectProperty as ObjectMethod's don't have it (#415) [skip ci] (James Browning)
  55. ## 7.0.0-beta.5 (2017-03-21)
  56. ### Bug Fix
  57. * Throw error if new.target is used outside of a function (#402) (Brian Ng)
  58. * Fix parsing of class properties (#351) (Kevin Gibbons)
  59. ### Other
  60. * Test runner: Detect extra property in 'actual' but not in 'expected'. (#407) (Andy)
  61. * Optimize travis builds (#419) (Daniel Tschinder)
  62. * Update codecov to 2.0 (#412) (Daniel Tschinder)
  63. * Fix spec for ClassMethod: It doesn't have a function, it *is* a function. (#406) [skip ci] (Andy)
  64. * Changed Non-existent RestPattern to RestElement which is what is actually parsed (#409) [skip ci] (James Browning)
  65. * Upgrade flow to 0.41 (Daniel Tschinder)
  66. * Fix watch command (#403) (Brian Ng)
  67. * Update yarn lock (Daniel Tschinder)
  68. * Fix watch command (#403) (Brian Ng)
  69. * chore(package): update flow-bin to version 0.41.0 (#395) (greenkeeper[bot])
  70. * Add estree test for correct order of directives (Daniel Tschinder)
  71. * Add DoExpression to spec (#364) (Alex Kuzmenko)
  72. * Mention cloning of repository in CONTRIBUTING.md (#391) [skip ci] (Sumedh Nimkarde)
  73. * Explain how to run only one test (#389) [skip ci] (Aaron Ang)
  74. ## 7.0.0-beta.4 (2017-03-01)
  75. * Don't consume async when checking for async func decl (#377) (Brian Ng)
  76. * add `ranges` option [skip ci] (Henry Zhu)
  77. * Don't parse class properties without initializers when classProperties is disabled and Flow is enabled (#300) (Andrew Levine)
  78. ## 7.0.0-beta.3 (2017-02-28)
  79. - [7.0] Change RestProperty/SpreadProperty to RestElement/SpreadElement (#384)
  80. - Merge changes from 6.x
  81. ## 7.0.0-beta.2 (2017-02-20)
  82. - estree: correctly change literals in all cases (#368) (Daniel Tschinder)
  83. ## 7.0.0-beta.1 (2017-02-20)
  84. - Fix negative number literal typeannotations (#366) (Daniel Tschinder)
  85. - Update contributing with more test info [skip ci] (#355) (Brian Ng)
  86. ## 7.0.0-beta.0 (2017-02-15)
  87. - Reintroduce Variance node (#333) (Daniel Tschinder)
  88. - Rename NumericLiteralTypeAnnotation to NumberLiteralTypeAnnotation (#332) (Charles Pick)
  89. - [7.0] Remove ForAwaitStatement, add await flag to ForOfStatement (#349) (Brandon Dail)
  90. - chore(package): update ava to version 0.18.0 (#345) (greenkeeper[bot])
  91. - chore(package): update babel-plugin-istanbul to version 4.0.0 (#350) (greenkeeper[bot])
  92. - Change location of ObjectTypeIndexer to match flow (#228) (Daniel Tschinder)
  93. - Rename flow AST Type ExistentialTypeParam to ExistsTypeAnnotation (#322) (Toru Kobayashi)
  94. - Revert "Temporary rollback for erroring on trailing comma with spread (#154)" (#290) (Daniel Tschinder)
  95. - Remove classConstructorCall plugin (#291) (Brian Ng)
  96. - Update yarn.lock (Daniel Tschinder)
  97. - Update cross-env to 3.x (Daniel Tschinder)
  98. - [7.0] Remove node 0.10, 0.12 and 5 from Travis (#284) (Sergey Rubanov)
  99. - Remove `String.fromCodePoint` shim (#279) (Mathias Bynens)
  100. ## 6.16.1 (2017-02-23)
  101. ### :bug: Regression
  102. - Revert "Fix export default async function to be FunctionDeclaration" ([#375](https://github.com/babel/babylon/pull/375))
  103. Need to modify Babel for this AST node change, so moving to 7.0.
  104. - Revert "Don't parse class properties without initializers when classProperties plugin is disabled, and Flow is enabled" ([#376](https://github.com/babel/babylon/pull/376))
  105. [react-native](https://github.com/facebook/react-native/issues/12542) broke with this so we reverted.
  106. ## 6.16.0 (2017-02-23)
  107. ### :rocket: New Feature
  108. ***ESTree*** compatibility as plugin ([#277](https://github.com/babel/babylon/pull/277)) (Daniel Tschinder)
  109. We finally introduce a new compatibility layer for ESTree. To put babylon into ESTree-compatible mode the new plugin `estree` can be enabled. In this mode the parser will output an AST that is compliant to the specs of [ESTree](https://github.com/estree/estree/)
  110. We highly recommend everyone who uses babylon outside of babel to use this plugin. This will make it much easier for users to switch between different ESTree-compatible parsers. We so far tested several projects with different parsers and exchanged their parser to babylon and in nearly all cases it worked out of the box. Some other estree-compatible parsers include `acorn`, `esprima`, `espree`, `flow-parser`, etc.
  111. To enable `estree` mode simply add the plugin in the config:
  112. ```json
  113. {
  114. "plugins": [ "estree" ]
  115. }
  116. ```
  117. If you want to migrate your project from non-ESTree mode to ESTree, have a look at our [Readme](https://github.com/babel/babylon/#output), where all deviations are mentioned.
  118. Add a parseExpression public method ([#213](https://github.com/babel/babylon/pull/213)) (jeromew)
  119. Babylon exports a new function to parse a single expression
  120. ```js
  121. import { parseExpression } from 'babylon';
  122. const ast = parseExpression('x || y && z', options);
  123. ```
  124. The returned AST will only consist of the expression. The options are the same as for `parse()`
  125. Add startLine option ([#346](https://github.com/babel/babylon/pull/346)) (Raphael Mu)
  126. A new option was added to babylon allowing to change the initial linenumber for the first line which is usually `1`.
  127. Changing this for example to `100` will make line `1` of the input source to be marked as line `100`, line `2` as `101`, line `3` as `102`, ...
  128. Function predicate declaration ([#103](https://github.com/babel/babylon/pull/103)) (Panagiotis Vekris)
  129. Added support for function predicates which flow introduced in version 0.33.0
  130. ```js
  131. declare function is_number(x: mixed): boolean %checks(typeof x === "number");
  132. ```
  133. Allow imports in declare module ([#315](https://github.com/babel/babylon/pull/315)) (Daniel Tschinder)
  134. Added support for imports within module declarations which flow introduced in version 0.37.0
  135. ```js
  136. declare module "C" {
  137. import type { DT } from "D";
  138. declare export type CT = { D: DT };
  139. }
  140. ```
  141. ### :eyeglasses: Spec Compliance
  142. Forbid semicolons after decorators in classes ([#352](https://github.com/babel/babylon/pull/352)) (Kevin Gibbons)
  143. This example now correctly throws an error when there is a semicolon after the decorator:
  144. ```js
  145. class A {
  146. @a;
  147. foo(){}
  148. }
  149. ```
  150. Keywords are not allowed as local specifier ([#307](https://github.com/babel/babylon/pull/307)) (Daniel Tschinder)
  151. Using keywords in imports is not allowed anymore:
  152. ```js
  153. import { default } from "foo";
  154. import { a as debugger } from "foo";
  155. ```
  156. Do not allow overwritting of primitive types ([#314](https://github.com/babel/babylon/pull/314)) (Daniel Tschinder)
  157. In flow it is now forbidden to overwrite the primitive types `"any"`, `"mixed"`, `"empty"`, `"bool"`, `"boolean"`, `"number"`, `"string"`, `"void"` and `"null"` with your own type declaration.
  158. Disallow import type { type a } from … ([#305](https://github.com/babel/babylon/pull/305)) (Daniel Tschinder)
  159. The following code now correctly throws an error
  160. ```js
  161. import type { type a } from "foo";
  162. ```
  163. Don't parse class properties without initializers when classProperties is disabled and Flow is enabled ([#300](https://github.com/babel/babylon/pull/300)) (Andrew Levine)
  164. Ensure that you enable the `classProperties` plugin in order to enable correct parsing of class properties. Prior to this version it was possible to parse them by enabling the `flow` plugin but this was not intended the behaviour.
  165. If you enable the flow plugin you can only define the type of the class properties, but not initialize them.
  166. Fix export default async function to be FunctionDeclaration ([#324](https://github.com/babel/babylon/pull/324)) (Daniel Tschinder)
  167. Parsing the following code now returns a `FunctionDeclaration` AST node instead of `FunctionExpression`.
  168. ```js
  169. export default async function bar() {};
  170. ```
  171. ### :nail_care: Polish
  172. Improve error message on attempt to destructure named import ([#288](https://github.com/babel/babylon/pull/288)) (Brian Ng)
  173. ### :bug: Bug Fix
  174. Fix negative number literal typeannotations ([#366](https://github.com/babel/babylon/pull/366)) (Daniel Tschinder)
  175. Ensure takeDecorators is called on exported class ([#358](https://github.com/babel/babylon/pull/358)) (Brian Ng)
  176. ESTree: correctly change literals in all cases ([#368](https://github.com/babel/babylon/pull/368)) (Daniel Tschinder)
  177. Correctly convert RestProperty to Assignable ([#339](https://github.com/babel/babylon/pull/339)) (Daniel Tschinder)
  178. Fix #321 by allowing question marks in type params ([#338](https://github.com/babel/babylon/pull/338)) (Daniel Tschinder)
  179. Fix #336 by correctly setting arrow-param ([#337](https://github.com/babel/babylon/pull/337)) (Daniel Tschinder)
  180. Fix parse error when destructuring `set` with default value ([#317](https://github.com/babel/babylon/pull/317)) (Brian Ng)
  181. Fix ObjectTypeCallProperty static ([#298](https://github.com/babel/babylon/pull/298)) (Dan Harper)
  182. ### :house: Internal
  183. Fix generator-method-with-computed-name spec ([#360](https://github.com/babel/babylon/pull/360)) (Alex Rattray)
  184. Fix flow type-parameter-declaration test with unintended semantic ([#361](https://github.com/babel/babylon/pull/361)) (Alex Rattray)
  185. Cleanup and splitup parser functions ([#295](https://github.com/babel/babylon/pull/295)) (Daniel Tschinder)
  186. chore(package): update flow-bin to version 0.38.0 ([#313](https://github.com/babel/babylon/pull/313)) (greenkeeper[bot])
  187. Call inner function instead of 1:1 copy to plugin ([#294](https://github.com/babel/babylon/pull/294)) (Daniel Tschinder)
  188. Update eslint-config-babel to the latest version 🚀 ([#299](https://github.com/babel/babylon/pull/299)) (greenkeeper[bot])
  189. Update eslint-config-babel to the latest version 🚀 ([#293](https://github.com/babel/babylon/pull/293)) (greenkeeper[bot])
  190. devDeps: remove eslint-plugin-babel ([#292](https://github.com/babel/babylon/pull/292)) (Kai Cataldo)
  191. Correct indent eslint rule config ([#276](https://github.com/babel/babylon/pull/276)) (Daniel Tschinder)
  192. Fail tests that have expected.json and throws-option ([#285](https://github.com/babel/babylon/pull/285)) (Daniel Tschinder)
  193. ### :memo: Documentation
  194. Update contributing with more test info [skip ci] ([#355](https://github.com/babel/babylon/pull/355)) (Brian Ng)
  195. Update API documentation ([#330](https://github.com/babel/babylon/pull/330)) (Timothy Gu)
  196. Added keywords to package.json ([#323](https://github.com/babel/babylon/pull/323)) (Dmytro)
  197. AST spec: fix casing of `RegExpLiteral` ([#318](https://github.com/babel/babylon/pull/318)) (Mathias Bynens)
  198. ## 6.15.0 (2017-01-10)
  199. ### :eyeglasses: Spec Compliance
  200. Add support for Flow shorthand import type ([#267](https://github.com/babel/babylon/pull/267)) (Jeff Morrison)
  201. This change implements flows new shorthand import syntax
  202. and where previously you had to write this code:
  203. ```js
  204. import {someValue} from "blah";
  205. import type {someType} from "blah";
  206. import typeof {someOtherValue} from "blah";
  207. ```
  208. you can now write it like this:
  209. ```js
  210. import {
  211. someValue,
  212. type someType,
  213. typeof someOtherValue,
  214. } from "blah";
  215. ```
  216. For more information look at [this](https://github.com/facebook/flow/pull/2890) pull request.
  217. flow: allow leading pipes in all positions ([#256](https://github.com/babel/babylon/pull/256)) (Vladimir Kurchatkin)
  218. This change now allows a leading pipe everywhere types can be used:
  219. ```js
  220. var f = (x): | 1 | 2 => 1;
  221. ```
  222. Throw error when exporting non-declaration ([#241](https://github.com/babel/babylon/pull/241)) (Kai Cataldo)
  223. Previously babylon parsed the following exports, although they are not valid:
  224. ```js
  225. export typeof foo;
  226. export new Foo();
  227. export function() {};
  228. export for (;;);
  229. export while(foo);
  230. ```
  231. ### :bug: Bug Fix
  232. Don't set inType flag when parsing property names ([#266](https://github.com/babel/babylon/pull/266)) (Vladimir Kurchatkin)
  233. This fixes parsing of this case:
  234. ```js
  235. const map = {
  236. [age <= 17] : 'Too young'
  237. };
  238. ```
  239. Fix source location for JSXEmptyExpression nodes (fixes #248) ([#249](https://github.com/babel/babylon/pull/249)) (James Long)
  240. The following case produced an invalid AST
  241. ```js
  242. <div>{/* foo */}</div>
  243. ```
  244. Use fromCodePoint to convert high value unicode entities ([#243](https://github.com/babel/babylon/pull/243)) (Ryan Duffy)
  245. When high value unicode entities (e.g. 💩) were used in the input source code they are now correctly encoded in the resulting AST.
  246. Rename folder to avoid Windows-illegal characters ([#281](https://github.com/babel/babylon/pull/281)) (Ryan Plant)
  247. Allow this.state.clone() when parsing decorators ([#262](https://github.com/babel/babylon/pull/262)) (Alex Rattray)
  248. ### :house: Internal
  249. User external-helpers ([#254](https://github.com/babel/babylon/pull/254)) (Daniel Tschinder)
  250. Add watch script for dev ([#234](https://github.com/babel/babylon/pull/234)) (Kai Cataldo)
  251. Freeze current plugins list for "*" option, and remove from README.md ([#245](https://github.com/babel/babylon/pull/245)) (Andrew Levine)
  252. Prepare tests for multiple fixture runners. ([#240](https://github.com/babel/babylon/pull/240)) (Daniel Tschinder)
  253. Add some test coverage for decorators stage-0 plugin ([#250](https://github.com/babel/babylon/pull/250)) (Andrew Levine)
  254. Refactor tokenizer types file ([#263](https://github.com/babel/babylon/pull/263)) (Sven SAULEAU)
  255. Update eslint-config-babel to the latest version 🚀 ([#273](https://github.com/babel/babylon/pull/273)) (greenkeeper[bot])
  256. chore(package): update rollup to version 0.41.0 ([#272](https://github.com/babel/babylon/pull/272)) (greenkeeper[bot])
  257. chore(package): update flow-bin to version 0.37.0 ([#255](https://github.com/babel/babylon/pull/255)) (greenkeeper[bot])
  258. ## 6.14.1 (2016-11-17)
  259. ### :bug: Bug Fix
  260. Allow `"plugins": ["*"]` ([#229](https://github.com/babel/babylon/pull/229)) (Daniel Tschinder)
  261. ```js
  262. {
  263. "plugins": ["*"]
  264. }
  265. ```
  266. Will include all parser plugins instead of specifying each one individually. Useful for tools like babel-eslint, jscodeshift, and ast-explorer.
  267. ## 6.14.0 (2016-11-16)
  268. ### :eyeglasses: Spec Compliance
  269. Throw error for reserved words `enum` and `await` ([#195](https://github.com/babel/babylon/pull/195)) (Kai Cataldo)
  270. [11.6.2.2 Future Reserved Words](http://www.ecma-international.org/ecma-262/6.0/#sec-future-reserved-words)
  271. Babylon will throw for more reserved words such as `enum` or `await` (in strict mode).
  272. ```
  273. class enum {} // throws
  274. class await {} // throws in strict mode (module)
  275. ```
  276. Optional names for function types and object type indexers ([#197](https://github.com/babel/babylon/pull/197)) (Gabe Levi)
  277. So where you used to have to write
  278. ```js
  279. type A = (x: string, y: boolean) => number;
  280. type B = (z: string) => number;
  281. type C = { [key: string]: number };
  282. ```
  283. you can now write (with flow 0.34.0)
  284. ```js
  285. type A = (string, boolean) => number;
  286. type B = string => number;
  287. type C = { [string]: number };
  288. ```
  289. Parse flow nested array type annotations like `number[][]` ([#219](https://github.com/babel/babylon/pull/219)) (Bernhard Häussner)
  290. Supports these form now of specifying array types:
  291. ```js
  292. var a: number[][][][];
  293. var b: string[][];
  294. ```
  295. ### :bug: Bug Fix
  296. Correctly eat semicolon at the end of `DelcareModuleExports` ([#223](https://github.com/babel/babylon/pull/223)) (Daniel Tschinder)
  297. ```
  298. declare module "foo" { declare module.exports: number }
  299. declare module "foo" { declare module.exports: number; } // also allowed now
  300. ```
  301. ### :house: Internal
  302. * Count Babel tests towards Babylon code coverage ([#182](https://github.com/babel/babylon/pull/182)) (Moti Zilberman)
  303. * Fix strange line endings ([#214](https://github.com/babel/babylon/pull/214)) (Thomas Grainger)
  304. * Add node 7 (Daniel Tschinder)
  305. * chore(package): update flow-bin to version 0.34.0 ([#204](https://github.com/babel/babylon/pull/204)) (Greenkeeper)
  306. ## v6.13.1 (2016-10-26)
  307. ### :nail_care: Polish
  308. - Use rollup for bundling to speed up startup time ([#190](https://github.com/babel/babylon/pull/190)) ([@drewml](https://github.com/DrewML))
  309. ```js
  310. const babylon = require('babylon');
  311. const ast = babylon.parse('var foo = "lol";');
  312. ```
  313. With that test case, there was a ~95ms savings by removing the need for node to build/traverse the dependency graph.
  314. **Without bundling**
  315. ![image](https://cloud.githubusercontent.com/assets/5233399/19420264/3133497e-93ad-11e6-9a6a-2da59c4f5c13.png)
  316. **With bundling**
  317. ![image](https://cloud.githubusercontent.com/assets/5233399/19420267/388f556e-93ad-11e6-813e-7c5c396be322.png)
  318. - add clean command [skip ci] ([#201](https://github.com/babel/babylon/pull/201)) (Henry Zhu)
  319. - add ForAwaitStatement (async generator already added) [skip ci] ([#196](https://github.com/babel/babylon/pull/196)) (Henry Zhu)
  320. ## v6.13.0 (2016-10-21)
  321. ### :eyeglasses: Spec Compliance
  322. Property variance type annotations for Flow plugin ([#161](https://github.com/babel/babylon/pull/161)) (Sam Goldman)
  323. > See https://flowtype.org/docs/variance.html for more information
  324. ```js
  325. type T = { +p: T };
  326. interface T { -p: T };
  327. declare class T { +[k:K]: V };
  328. class T { -[k:K]: V };
  329. class C2 { +p: T = e };
  330. ```
  331. Raise error on duplicate definition of __proto__ ([#183](https://github.com/babel/babylon/pull/183)) (Moti Zilberman)
  332. ```js
  333. ({ __proto__: 1, __proto__: 2 }) // Throws an error now
  334. ```
  335. ### :bug: Bug Fix
  336. Flow: Allow class properties to be named `static` ([#184](https://github.com/babel/babylon/pull/184)) (Moti Zilberman)
  337. ```js
  338. declare class A {
  339. static: T;
  340. }
  341. ```
  342. Allow "async" as identifier for object literal property shorthand ([#187](https://github.com/babel/babylon/pull/187)) (Andrew Levine)
  343. ```js
  344. var foo = { async, bar };
  345. ```
  346. ### :nail_care: Polish
  347. Fix flowtype and add inType to state ([#189](https://github.com/babel/babylon/pull/189)) (Daniel Tschinder)
  348. > This improves the performance slightly (because of hidden classes)
  349. ### :house: Internal
  350. Fix .gitattributes line ending setting ([#191](https://github.com/babel/babylon/pull/191)) (Moti Zilberman)
  351. Increase test coverage ([#175](https://github.com/babel/babylon/pull/175) (Moti Zilberman)
  352. Readd missin .eslinignore for IDEs (Daniel Tschinder)
  353. Error on missing expected.json fixture in CI ([#188](https://github.com/babel/babylon/pull/188)) (Moti Zilberman)
  354. Add .gitattributes and .editorconfig for LF line endings ([#179](https://github.com/babel/babylon/pull/179)) (Moti Zilberman)
  355. Fixes two tests that are failing after the merge of #172 ([#177](https://github.com/babel/babylon/pull/177)) (Moti Zilberman)
  356. ## v6.12.0 (2016-10-14)
  357. ### :eyeglasses: Spec Compliance
  358. Implement import() syntax ([#163](https://github.com/babel/babylon/pull/163)) (Jordan Gensler)
  359. #### Dynamic Import
  360. - Proposal Repo: https://github.com/domenic/proposal-dynamic-import
  361. - Championed by [@domenic](https://github.com/domenic)
  362. - stage-2
  363. - [sept-28 tc39 notes](https://github.com/rwaldron/tc39-notes/blob/master/es7/2016-09/sept-28.md#113a-import)
  364. > This repository contains a proposal for adding a "function-like" import() module loading syntactic form to JavaScript
  365. ```js
  366. import(`./section-modules/${link.dataset.entryModule}.js`)
  367. .then(module => {
  368. module.loadPageInto(main);
  369. })
  370. ```
  371. Add EmptyTypeAnnotation ([#171](https://github.com/babel/babylon/pull/171)) (Sam Goldman)
  372. #### EmptyTypeAnnotation
  373. Just wasn't covered before.
  374. ```js
  375. type T = empty;
  376. ```
  377. ### :bug: Bug Fix
  378. Fix crash when exporting with destructuring and sparse array ([#170](https://github.com/babel/babylon/pull/170)) (Jeroen Engels)
  379. ```js
  380. // was failing due to sparse array
  381. export const { foo: [ ,, qux7 ] } = bar;
  382. ```
  383. Allow keyword in Flow object declaration property names with type parameters ([#146](https://github.com/babel/babylon/pull/146)) (Dan Harper)
  384. ```js
  385. declare class X {
  386. foobar<T>(): void;
  387. static foobar<T>(): void;
  388. }
  389. ```
  390. Allow keyword in object/class property names with Flow type parameters ([#145](https://github.com/babel/babylon/pull/145)) (Dan Harper)
  391. ```js
  392. class Foo {
  393. delete<T>(item: T): T {
  394. return item;
  395. }
  396. }
  397. ```
  398. Allow typeAnnotations for yield expressions ([#174](https://github.com/babel/babylon/pull/174))) (Daniel Tschinder)
  399. ```js
  400. function *foo() {
  401. const x = (yield 5: any);
  402. }
  403. ```
  404. ### :nail_care: Polish
  405. Annotate more errors with expected token ([#172](https://github.com/babel/babylon/pull/172))) (Moti Zilberman)
  406. ```js
  407. // Unexpected token, expected ; (1:6)
  408. { set 1 }
  409. ```
  410. ### :house: Internal
  411. Remove kcheck ([#173](https://github.com/babel/babylon/pull/173))) (Daniel Tschinder)
  412. Also run flow, linting, babel tests on separate instances (add back node 0.10)
  413. ## v6.11.6 (2016-10-12)
  414. ### :bug: Bug Fix/Regression
  415. Fix crash when exporting with destructuring and sparse array ([#170](https://github.com/babel/babylon/pull/170)) (Jeroen Engels)
  416. ```js
  417. // was failing with `Cannot read property 'type' of null` because of null identifiers
  418. export const { foo: [ ,, qux7 ] } = bar;
  419. ```
  420. ## v6.11.5 (2016-10-12)
  421. ### :eyeglasses: Spec Compliance
  422. Fix: Check for duplicate named exports in exported destructuring assignments ([#144](https://github.com/babel/babylon/pull/144)) (Kai Cataldo)
  423. ```js
  424. // `foo` has already been exported. Exported identifiers must be unique. (2:20)
  425. export function foo() {};
  426. export const { a: [{foo}] } = bar;
  427. ```
  428. Fix: Check for duplicate named exports in exported rest elements/properties ([#164](https://github.com/babel/babylon/pull/164)) (Kai Cataldo)
  429. ```js
  430. // `foo` has already been exported. Exported identifiers must be unique. (2:22)
  431. export const foo = 1;
  432. export const [bar, ...foo] = baz;
  433. ```
  434. ### :bug: Bug Fix
  435. Fix: Allow identifier `async` for default param in arrow expression ([#165](https://github.com/babel/babylon/pull/165)) (Kai Cataldo)
  436. ```js
  437. // this is ok now
  438. const test = ({async = true}) => {};
  439. ```
  440. ### :nail_care: Polish
  441. Babylon will now print out the token it's expecting if there's a `SyntaxError` ([#150](https://github.com/babel/babylon/pull/150)) (Daniel Tschinder)
  442. ```bash
  443. # So in the case of a missing ending curly (`}`)
  444. Module build failed: SyntaxError: Unexpected token, expected } (30:0)
  445. 28 | }
  446. 29 |
  447. > 30 |
  448. | ^
  449. ```
  450. ## v6.11.4 (2016-10-03)
  451. Temporary rollback for erroring on trailing comma with spread (#154) (Henry Zhu)
  452. ## v6.11.3 (2016-10-01)
  453. ### :eyeglasses: Spec Compliance
  454. Add static errors for object rest (#149) ([@danez](https://github.com/danez))
  455. > https://github.com/sebmarkbage/ecmascript-rest-spread
  456. Object rest copies the *rest* of properties from the right hand side `obj` starting from the left to right.
  457. ```js
  458. let { x, y, ...z } = { x: 1, y: 2, z: 3 };
  459. // x = 1
  460. // y = 2
  461. // z = { z: 3 }
  462. ```
  463. #### New Syntax Errors:
  464. **SyntaxError**: The rest element has to be the last element when destructuring (1:10)
  465. ```bash
  466. > 1 | let { ...x, y, z } = { x: 1, y: 2, z: 3};
  467. | ^
  468. # Previous behavior:
  469. # x = { x: 1, y: 2, z: 3 }
  470. # y = 2
  471. # z = 3
  472. ```
  473. Before, this was just a more verbose way of shallow copying `obj` since it doesn't actually do what you think.
  474. **SyntaxError**: Cannot have multiple rest elements when destructuring (1:13)
  475. ```bash
  476. > 1 | let { x, ...y, ...z } = { x: 1, y: 2, z: 3};
  477. | ^
  478. # Previous behavior:
  479. # x = 1
  480. # y = { y: 2, z: 3 }
  481. # z = { y: 2, z: 3 }
  482. ```
  483. Before y and z would just be the same value anyway so there is no reason to need to have both.
  484. **SyntaxError**: A trailing comma is not permitted after the rest element (1:16)
  485. ```js
  486. let { x, y, ...z, } = obj;
  487. ```
  488. The rationale for this is that the use case for trailing comma is that you can add something at the end without affecting the line above. Since a RestProperty always has to be the last property it doesn't make sense.
  489. ---
  490. get / set are valid property names in default assignment (#142) ([@jezell](https://github.com/jezell))
  491. ```js
  492. // valid
  493. function something({ set = null, get = null }) {}
  494. ```
  495. ## v6.11.2 (2016-09-23)
  496. ### Bug Fix
  497. - [#139](https://github.com/babel/babylon/issues/139) Don't do the duplicate check if not an identifier (#140) @hzoo
  498. ```js
  499. // regression with duplicate export check
  500. SyntaxError: ./typography.js: `undefined` has already been exported. Exported identifiers must be unique. (22:13)
  501. 20 |
  502. 21 | export const { rhythm } = typography;
  503. > 22 | export const { TypographyStyle } = typography
  504. ```
  505. Bail out for now, and make a change to account for destructuring in the next release.
  506. ## 6.11.1 (2016-09-22)
  507. ### Bug Fix
  508. - [#137](https://github.com/babel/babylon/pull/137) - Fix a regression with duplicate exports - it was erroring on all keys in `Object.prototype`. @danez
  509. ```javascript
  510. export toString from './toString';
  511. ```
  512. ```bash
  513. `toString` has already been exported. Exported identifiers must be unique. (1:7)
  514. > 1 | export toString from './toString';
  515. | ^
  516. 2 |
  517. ```
  518. ## 6.11.0 (2016-09-22)
  519. ### Spec Compliance (will break CI)
  520. - Disallow duplicate named exports ([#107](https://github.com/babel/babylon/pull/107)) @kaicataldo
  521. ```js
  522. // Only one default export allowed per module. (2:9)
  523. export default function() {};
  524. export { foo as default };
  525. // Only one default export allowed per module. (2:0)
  526. export default {};
  527. export default function() {};
  528. // `Foo` has already been exported. Exported identifiers must be unique. (2:0)
  529. export { Foo };
  530. export class Foo {};
  531. ```
  532. ### New Feature (Syntax)
  533. - Add support for computed class property names ([#121](https://github.com/babel/babylon/pull/121)) @motiz88
  534. ```js
  535. // AST
  536. interface ClassProperty <: Node {
  537. type: "ClassProperty";
  538. key: Identifier;
  539. value: Expression;
  540. computed: boolean; // added
  541. }
  542. ```
  543. ```js
  544. // with "plugins": ["classProperties"]
  545. class Foo {
  546. [x]
  547. ['y']
  548. }
  549. class Bar {
  550. [p]
  551. [m] () {}
  552. }
  553. ```
  554. ### Bug Fix
  555. - Fix `static` property falling through in the declare class Flow AST ([#135](https://github.com/babel/babylon/pull/135)) @danharper
  556. ```js
  557. declare class X {
  558. a: number;
  559. static b: number; // static
  560. c: number; // this was being marked as static in the AST as well
  561. }
  562. ```
  563. ### Polish
  564. - Rephrase "assigning/binding to rvalue" errors to include context ([#119](https://github.com/babel/babylon/pull/119)) @motiz88
  565. ```js
  566. // Used to error with:
  567. // SyntaxError: Assigning to rvalue (1:0)
  568. // Now:
  569. // Invalid left-hand side in assignment expression (1:0)
  570. 3 = 4
  571. // Invalid left-hand side in for-in statement (1:5)
  572. for (+i in {});
  573. ```
  574. ### Internal
  575. - Fix call to `this.parseMaybeAssign` with correct arguments ([#133](https://github.com/babel/babylon/pull/133)) @danez
  576. - Add semver note to changelog ([#131](https://github.com/babel/babylon/pull/131)) @hzoo
  577. ## 6.10.0 (2016-09-19)
  578. > We plan to include some spec compliance bugs in patch versions. An example was the multiple default exports issue.
  579. ### Spec Compliance
  580. * Implement ES2016 check for simple parameter list in strict mode ([#106](https://github.com/babel/babylon/pull/106)) (Timothy Gu)
  581. > It is a Syntax Error if ContainsUseStrict of FunctionBody is true and IsSimpleParameterList of FormalParameters is false. https://tc39.github.io/ecma262/2016/#sec-function-definitions-static-semantics-early-errors
  582. More Context: [tc39-notes](https://github.com/rwaldron/tc39-notes/blob/master/es7/2015-07/july-29.md#611-the-scope-of-use-strict-with-respect-to-destructuring-in-parameter-lists)
  583. For example:
  584. ```js
  585. // this errors because it uses destructuring and default parameters
  586. // in a function with a "use strict" directive
  587. function a([ option1, option2 ] = []) {
  588. "use strict";
  589. }
  590. ```
  591. The solution would be to use a top level "use strict" or to remove the destructuring or default parameters when using a function + "use strict" or to.
  592. ### New Feature
  593. * Exact object type annotations for Flow plugin ([#104](https://github.com/babel/babylon/pull/104)) (Basil Hosmer)
  594. Added to flow in https://github.com/facebook/flow/commit/c710c40aa2a115435098d6c0dfeaadb023cd39b8
  595. Looks like:
  596. ```js
  597. var a : {| x: number, y: string |} = { x: 0, y: 'foo' };
  598. ```
  599. ### Bug Fixes
  600. * Include `typeParameter` location in `ArrowFunctionExpression` ([#126](https://github.com/babel/babylon/pull/126)) (Daniel Tschinder)
  601. * Error on invalid flow type annotation with default assignment ([#122](https://github.com/babel/babylon/pull/122)) (Dan Harper)
  602. * Fix Flow return types on arrow functions ([#124](https://github.com/babel/babylon/pull/124)) (Dan Harper)
  603. ### Misc
  604. * Add tests for export extensions ([#127](https://github.com/babel/babylon/pull/127)) (Daniel Tschinder)
  605. * Fix Contributing guidelines [skip ci] (Daniel Tschinder)
  606. ## 6.9.2 (2016-09-09)
  607. The only change is to remove the `babel-runtime` dependency by compiling with Babel's ES2015 loose mode. So using babylon standalone should be smaller.
  608. ## 6.9.1 (2016-08-23)
  609. This release contains mainly small bugfixes but also updates babylons default mode to es2017. The features for `exponentiationOperator`, `asyncFunctions` and `trailingFunctionCommas` which previously needed to be activated via plugin are now enabled by default and the plugins are now no-ops.
  610. ### Bug Fixes
  611. - Fix issues with default object params in async functions ([#96](https://github.com/babel/babylon/pull/96)) @danez
  612. - Fix issues with flow-types and async function ([#95](https://github.com/babel/babylon/pull/95)) @danez
  613. - Fix arrow functions with destructuring, types & default value ([#94](https://github.com/babel/babylon/pull/94)) @danharper
  614. - Fix declare class with qualified type identifier ([#97](https://github.com/babel/babylon/pull/97)) @danez
  615. - Remove exponentiationOperator, asyncFunctions, trailingFunctionCommas plugins and enable them by default ([#98](https://github.com/babel/babylon/pull/98)) @danez
  616. ## 6.9.0 (2016-08-16)
  617. ### New syntax support
  618. - Add JSX spread children ([#42](https://github.com/babel/babylon/pull/42)) @calebmer
  619. (Be aware that React is not going to support this syntax)
  620. ```js
  621. <div>
  622. {...todos.map(todo => <Todo key={todo.id} todo={todo}/>)}
  623. </div>
  624. ```
  625. - Add support for declare module.exports ([#72](https://github.com/babel/babylon/pull/72)) @danez
  626. ```js
  627. declare module "foo" {
  628. declare module.exports: {}
  629. }
  630. ```
  631. ### New Features
  632. - If supplied, attach filename property to comment node loc. ([#80](https://github.com/babel/babylon/pull/80)) @divmain
  633. - Add identifier name to node loc field ([#90](https://github.com/babel/babylon/pull/90)) @kittens
  634. ### Bug Fixes
  635. - Fix exponential operator to behave according to spec ([#75](https://github.com/babel/babylon/pull/75)) @danez
  636. - Fix lookahead to not add comments to arrays which are not cloned ([#76](https://github.com/babel/babylon/pull/76)) @danez
  637. - Fix accidental fall-through in Flow type parsing. ([#82](https://github.com/babel/babylon/pull/82)) @xiemaisi
  638. - Only allow declares inside declare module ([#73](https://github.com/babel/babylon/pull/73)) @danez
  639. - Small fix for parsing type parameter declarations ([#83](https://github.com/babel/babylon/pull/83)) @gabelevi
  640. - Fix arrow param locations with flow types ([#57](https://github.com/babel/babylon/pull/57)) @danez
  641. - Fixes SyntaxError position with flow optional type ([#65](https://github.com/babel/babylon/pull/65)) @danez
  642. ### Internal
  643. - Add codecoverage to tests @danez
  644. - Fix tests to not save expected output if we expect the test to fail @danez
  645. - Make a shallow clone of babel for testing @danez
  646. - chore(package): update cross-env to version 2.0.0 ([#77](https://github.com/babel/babylon/pull/77)) @greenkeeperio-bot
  647. - chore(package): update ava to version 0.16.0 ([#86](https://github.com/babel/babylon/pull/86)) @greenkeeperio-bot
  648. - chore(package): update babel-plugin-istanbul to version 2.0.0 ([#89](https://github.com/babel/babylon/pull/89)) @greenkeeperio-bot
  649. - chore(package): update nyc to version 8.0.0 ([#88](https://github.com/babel/babylon/pull/88)) @greenkeeperio-bot
  650. ## 6.8.4 (2016-07-06)
  651. ### Bug Fixes
  652. - Fix the location of params, when flow and default value used ([#68](https://github.com/babel/babylon/pull/68)) @danez
  653. ## 6.8.3 (2016-07-02)
  654. ### Bug Fixes
  655. - Fix performance regression introduced in 6.8.2 with conditionals ([#63](https://github.com/babel/babylon/pull/63)) @danez
  656. ## 6.8.2 (2016-06-24)
  657. ### Bug Fixes
  658. - Fix parse error with yielding jsx elements in generators `function* it() { yield <a></a>; }` ([#31](https://github.com/babel/babylon/pull/31)) @eldereal
  659. - When cloning nodes do not clone its comments ([#24](https://github.com/babel/babylon/pull/24)) @danez
  660. - Fix parse errors when using arrow functions with an spread element and return type `(...props): void => {}` ([#10](https://github.com/babel/babylon/pull/10)) @danez
  661. - Fix leading comments added from previous node ([#23](https://github.com/babel/babylon/pull/23)) @danez
  662. - Fix parse errors with flow's optional arguments `(arg?) => {}` ([#19](https://github.com/babel/babylon/pull/19)) @danez
  663. - Support negative numeric type literals @kittens
  664. - Remove line terminator restriction after await keyword @kittens
  665. - Remove grouped type arrow restriction as it seems flow no longer has it @kittens
  666. - Fix parse error with generic methods that have the name `get` or `set` `class foo { get() {} }` ([#55](https://github.com/babel/babylon/pull/55)) @vkurchatkin
  667. - Fix parse error with arrow functions that have flow type parameter declarations `<T>(x: T): T => x;` ([#54](https://github.com/babel/babylon/pull/54)) @gabelevi
  668. ### Documentation
  669. - Document AST differences from ESTree ([#41](https://github.com/babel/babylon/pull/41)) @nene
  670. - Move ast spec from babel/babel ([#46](https://github.com/babel/babylon/pull/46)) @hzoo
  671. ### Internal
  672. - Enable skipped tests ([#16](https://github.com/babel/babylon/pull/16)) @danez
  673. - Add script to test latest version of babylon with babel ([#21](https://github.com/babel/babylon/pull/21)) @danez
  674. - Upgrade test runner ava @kittens
  675. - Add missing generate-identifier-regex script @kittens
  676. - Rename parser context types @kittens
  677. - Add node v6 to travis testing @hzoo
  678. - Update to Unicode v9 ([#45](https://github.com/babel/babylon/pull/45)) @mathiasbynens
  679. ## 6.8.1 (2016-06-06)
  680. ### New Feature
  681. - Parse type parameter declarations with defaults like `type Foo<T = string> = T`
  682. ### Bug Fixes
  683. - Type parameter declarations need 1 or more type parameters.
  684. - The existential type `*` is not a valid type parameter.
  685. - The existential type `*` is a primary type
  686. ### Spec Compliance
  687. - The param list for type parameter declarations now consists of `TypeParameter` nodes
  688. - New `TypeParameter` AST Node (replaces using the `Identifier` node before)
  689. ```
  690. interface TypeParameter <: Node {
  691. bound: TypeAnnotation;
  692. default: TypeAnnotation;
  693. name: string;
  694. variance: "plus" | "minus";
  695. }
  696. ```
  697. ## 6.8.0 (2016-05-02)
  698. #### New Feature
  699. ##### Parse Method Parameter Decorators ([#12](https://github.com/babel/babylon/pull/12))
  700. > [Method Parameter Decorators](https://goo.gl/8MmCMG) is now a TC39 [stage 0 proposal](https://github.com/tc39/ecma262/blob/master/stage0.md).
  701. Examples:
  702. ```js
  703. class Foo {
  704. constructor(@foo() x, @bar({ a: 123 }) @baz() y) {}
  705. }
  706. export default function func(@foo() x, @bar({ a: 123 }) @baz() y) {}
  707. var obj = {
  708. method(@foo() x, @bar({ a: 123 }) @baz() y) {}
  709. };
  710. ```
  711. ##### Parse for-await statements (w/ `asyncGenerators` plugin) ([#17](https://github.com/babel/babylon/pull/17))
  712. There is also a new node type, `ForAwaitStatement`.
  713. > [Async generators and for-await](https://github.com/tc39/proposal-async-iteration) are now a [stage 2 proposal](https://github.com/tc39/ecma262#current-proposals).
  714. Example:
  715. ```js
  716. async function f() {
  717. for await (let x of y);
  718. }
  719. ```