Skip to content

Commit bccb41e

Browse files
author
furina-lu
committed
feat: babel7 plugins use user options
1 parent 8888701 commit bccb41e

File tree

2 files changed

+6
-31
lines changed

2 files changed

+6
-31
lines changed

website/src/parsers/js/babylon7.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export const parserSettingsConfiguration = {
106106
}
107107
],
108108
};
109-
109+
export let parserOptions = []
110110
export default {
111111
...defaultParserInterface,
112112

@@ -140,6 +140,7 @@ export default {
140140
return plugin;
141141
}
142142
});
143+
parserOptions = options.plugins
143144
return babylon.parse(code, options);
144145
},
145146

website/src/parsers/js/transformers/babel7/index.js

+4-30
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import compileModule from '../../../utils/compileModule';
22
import pkg from 'babel7/package.json';
3-
43
const ID = 'babelv7';
54

65
export default {
@@ -16,44 +15,19 @@ export default {
1615
'../../../transpilers/babel',
1716
'babel7',
1817
'recast',
19-
], (transpile, babel, recast) => callback({ transpile: transpile.default, babel, recast }));
18+
'../../babylon7.js',
19+
], (transpile, babel, recast, babylon7) => callback({ transpile: transpile.default, babel, recast, babylon7 }));
2020
},
2121

22-
transform({ transpile, babel, recast }, transformCode, code) {
22+
transform({ transpile, babel, recast, babylon7 }, transformCode, code) {
2323
transformCode = transpile(transformCode);
2424
let transform = compileModule( // eslint-disable-line no-shadow
2525
transformCode,
2626
);
27-
2827
return babel.transformAsync(code, {
2928
parserOpts: {
3029
parser: recast.parse,
31-
plugins: [
32-
'asyncGenerators',
33-
'bigInt',
34-
'classPrivateMethods',
35-
'classPrivateProperties',
36-
'classProperties',
37-
['decorators', {decoratorsBeforeExport: false}],
38-
'doExpressions',
39-
'dynamicImport',
40-
'exportDefaultFrom',
41-
'exportNamespaceFrom',
42-
'flow',
43-
'flowComments',
44-
'functionBind',
45-
'functionSent',
46-
'importMeta',
47-
'jsx',
48-
'logicalAssignment',
49-
'nullishCoalescingOperator',
50-
'numericSeparator',
51-
'objectRestSpread',
52-
'optionalCatchBinding',
53-
'optionalChaining',
54-
['pipelineOperator', {proposal: 'minimal'}],
55-
'throwExpressions',
56-
],
30+
plugins: babylon7.parserOptions,
5731
},
5832
retainLines: false,
5933
generatorOpts: {

0 commit comments

Comments
 (0)