11/*
2- * Copyright (c) 2015, Facebook, Inc.
3- * All rights reserved.
2+ * Copyright (c) 2015, Facebook, Inc.
3+ * All rights reserved.
44 *
5- * This source code is licensed under the BSD-style license found in the
6- * LICENSE file in the root directory of this source tree. An additional grant
7- * of patent rights can be found in the PATENTS file in the same directory.
5+ * This source code is licensed under the BSD-style license found in the
6+ * LICENSE file in the root directory of this source tree. An additional grant
7+ * of patent rights can be found in the PATENTS file in the same directory.
88 *
9- */
10-
11- /**
129 * @flow
10+ *
1311 */
14- "use strict" ;
1512
16- var Documentation = require ( './Documentation' ) ;
13+ import Documentation from './Documentation' ;
1714
18- var recast = require ( 'recast' ) ;
15+ import babylon from './babylon' ;
16+ import recast from 'recast' ;
1917
20- var ERROR_MISSING_DEFINITION = 'No suitable component definition found.' ;
18+ const ERROR_MISSING_DEFINITION = 'No suitable component definition found.' ;
2119
2220function executeHandlers ( handlers , componentDefinitions ) {
2321 return componentDefinitions . map ( componentDefinition => {
@@ -47,12 +45,12 @@ function executeHandlers(handlers, componentDefinitions) {
4745 * an array of documentation objects. If `resolver` returns a single node
4846 * instead, `parse` will return a documentation object.
4947 */
50- function parse (
48+ export default function parse (
5149 src : string ,
5250 resolver : Resolver ,
5351 handlers : Array < Handler >
54- ) : ( Array < Object > | Object ) {
55- var ast = recast . parse ( src ) ;
52+ ) : Array < Object > | Object {
53+ var ast = recast . parse ( src , { esprima : babylon } ) ;
5654 var componentDefinitions = resolver ( ast . program , recast ) ;
5755 var isArray = Array . isArray ( componentDefinitions ) ;
5856
@@ -65,5 +63,4 @@ function parse(
6563 executeHandlers ( handlers , [ componentDefinitions ] ) [ 0 ] ;
6664}
6765
68- module . exports = parse ;
69- exports . ERROR_MISSING_DEFINITION = ERROR_MISSING_DEFINITION ;
66+ export { ERROR_MISSING_DEFINITION } ;
0 commit comments