Skip to content

Commit

Permalink
feat: babel7 plugins use user options
Browse files Browse the repository at this point in the history
  • Loading branch information
furina-lu committed Oct 10, 2024
1 parent 8888701 commit bccb41e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 31 deletions.
3 changes: 2 additions & 1 deletion website/src/parsers/js/babylon7.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const parserSettingsConfiguration = {
}
],
};

export let parserOptions = []
export default {
...defaultParserInterface,

Expand Down Expand Up @@ -140,6 +140,7 @@ export default {
return plugin;
}
});
parserOptions = options.plugins
return babylon.parse(code, options);
},

Expand Down
34 changes: 4 additions & 30 deletions website/src/parsers/js/transformers/babel7/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import compileModule from '../../../utils/compileModule';
import pkg from 'babel7/package.json';

const ID = 'babelv7';

export default {
Expand All @@ -16,44 +15,19 @@ export default {
'../../../transpilers/babel',
'babel7',
'recast',
], (transpile, babel, recast) => callback({ transpile: transpile.default, babel, recast }));
'../../babylon7.js',
], (transpile, babel, recast, babylon7) => callback({ transpile: transpile.default, babel, recast, babylon7 }));
},

transform({ transpile, babel, recast }, transformCode, code) {
transform({ transpile, babel, recast, babylon7 }, transformCode, code) {
transformCode = transpile(transformCode);
let transform = compileModule( // eslint-disable-line no-shadow
transformCode,
);

return babel.transformAsync(code, {
parserOpts: {
parser: recast.parse,
plugins: [
'asyncGenerators',
'bigInt',
'classPrivateMethods',
'classPrivateProperties',
'classProperties',
['decorators', {decoratorsBeforeExport: false}],
'doExpressions',
'dynamicImport',
'exportDefaultFrom',
'exportNamespaceFrom',
'flow',
'flowComments',
'functionBind',
'functionSent',
'importMeta',
'jsx',
'logicalAssignment',
'nullishCoalescingOperator',
'numericSeparator',
'objectRestSpread',
'optionalCatchBinding',
'optionalChaining',
['pipelineOperator', {proposal: 'minimal'}],
'throwExpressions',
],
plugins: babylon7.parserOptions,
},
retainLines: false,
generatorOpts: {
Expand Down

0 comments on commit bccb41e

Please sign in to comment.