@@ -5,6 +5,35 @@ const concat = require('concat-stream');
5
5
const moduleFilters = require ( '../module_filters' ) ;
6
6
const smartGlob = require ( '../smart_glob.js' ) ;
7
7
8
+ const STANDARD_BABEL_CONFIG = {
9
+ sourceMaps : false ,
10
+ compact : false ,
11
+ cwd : path . resolve ( __dirname , '../../' ) ,
12
+ presets : [ '@babel/preset-react' , '@babel/preset-env' , '@babel/preset-flow' ] ,
13
+ plugins : [
14
+ // Stage 0
15
+ '@babel/plugin-proposal-function-bind' ,
16
+ // Stage 1
17
+ '@babel/plugin-proposal-export-default-from' ,
18
+ '@babel/plugin-proposal-logical-assignment-operators' ,
19
+ '@babel/plugin-proposal-optional-chaining' ,
20
+ [ '@babel/plugin-proposal-pipeline-operator' , { proposal : 'minimal' } ] ,
21
+ [ '@babel/plugin-proposal-nullish-coalescing-operator' , { loose : false } ] ,
22
+ '@babel/plugin-proposal-do-expressions' ,
23
+ // Stage 2
24
+ [ '@babel/plugin-proposal-decorators' , { legacy : true } ] ,
25
+ '@babel/plugin-proposal-function-sent' ,
26
+ '@babel/plugin-proposal-export-namespace-from' ,
27
+ '@babel/plugin-proposal-numeric-separator' ,
28
+ '@babel/plugin-proposal-throw-expressions' ,
29
+ // Stage 3
30
+ '@babel/plugin-syntax-dynamic-import' ,
31
+ '@babel/plugin-syntax-import-meta' ,
32
+ [ '@babel/plugin-proposal-class-properties' , { loose : false } ] ,
33
+ '@babel/plugin-proposal-json-strings'
34
+ ]
35
+ } ;
36
+
8
37
/**
9
38
* Returns a readable stream of dependencies, given an array of entry
10
39
* points and an object of options to provide to module-deps.
@@ -17,6 +46,9 @@ const smartGlob = require('../smart_glob.js');
17
46
* @returns results
18
47
*/
19
48
function dependencyStream ( indexes , config ) {
49
+ const babelConfig = config . babel
50
+ ? { configFile : path . resolve ( __dirname , '../../../../' , config . babel ) }
51
+ : STANDARD_BABEL_CONFIG ;
20
52
const md = mdeps ( {
21
53
/**
22
54
* Determine whether a module should be included in documentation
@@ -28,43 +60,7 @@ function dependencyStream(indexes, config) {
28
60
. concat ( config . requireExtension || [ ] )
29
61
. map ( ext => '.' + ext . replace ( / ^ \. / , '' ) )
30
62
. concat ( [ '.mjs' , '.js' , '.json' , '.es6' , '.jsx' ] ) ,
31
- transform : [
32
- babelify . configure ( {
33
- sourceMaps : false ,
34
- compact : false ,
35
- cwd : path . resolve ( __dirname , '../../' ) ,
36
- presets : [
37
- '@babel/preset-react' ,
38
- '@babel/preset-env' ,
39
- '@babel/preset-flow'
40
- ] ,
41
- plugins : [
42
- // Stage 0
43
- '@babel/plugin-proposal-function-bind' ,
44
- // Stage 1
45
- '@babel/plugin-proposal-export-default-from' ,
46
- '@babel/plugin-proposal-logical-assignment-operators' ,
47
- '@babel/plugin-proposal-optional-chaining' ,
48
- [ '@babel/plugin-proposal-pipeline-operator' , { proposal : 'minimal' } ] ,
49
- [
50
- '@babel/plugin-proposal-nullish-coalescing-operator' ,
51
- { loose : false }
52
- ] ,
53
- '@babel/plugin-proposal-do-expressions' ,
54
- // Stage 2
55
- [ '@babel/plugin-proposal-decorators' , { legacy : true } ] ,
56
- '@babel/plugin-proposal-function-sent' ,
57
- '@babel/plugin-proposal-export-namespace-from' ,
58
- '@babel/plugin-proposal-numeric-separator' ,
59
- '@babel/plugin-proposal-throw-expressions' ,
60
- // Stage 3
61
- '@babel/plugin-syntax-dynamic-import' ,
62
- '@babel/plugin-syntax-import-meta' ,
63
- [ '@babel/plugin-proposal-class-properties' , { loose : false } ] ,
64
- '@babel/plugin-proposal-json-strings'
65
- ]
66
- } )
67
- ] ,
63
+ transform : [ babelify . configure ( babelConfig ) ] ,
68
64
postFilter : moduleFilters . externals ( indexes , config ) ,
69
65
resolve :
70
66
config . resolve === 'node' &&
0 commit comments