22
33const crypto = require ( 'crypto' ) ;
44const path = require ( 'path' ) ;
5- const defaultOptions = require ( '../static/babelrc.json' ) ;
5+ const defaultOptions = require ( './babel.config.js' ) ;
6+ const configFile = path . join ( __dirname , './babel.config.js' ) ;
67
78let babel = null ;
89let babelVersionDirectory = null ;
@@ -31,7 +32,7 @@ exports.shouldCompile = function(sourceCode) {
3132
3233exports . getCachePath = function ( sourceCode ) {
3334 if ( babelVersionDirectory == null ) {
34- const babelVersion = require ( 'babel- core/package.json' ) . version ;
35+ const babelVersion = require ( '@ babel/ core/package.json' ) . version ;
3536 babelVersionDirectory = path . join (
3637 'js' ,
3738 'babel' ,
@@ -50,28 +51,22 @@ exports.getCachePath = function(sourceCode) {
5051
5152exports . compile = function ( sourceCode , filePath ) {
5253 if ( ! babel ) {
53- babel = require ( 'babel-core' ) ;
54- const Logger = require ( 'babel-core/lib/transformation/file/logger' ) ;
55- const noop = function ( ) { } ;
56- Logger . prototype . debug = noop ;
57- Logger . prototype . verbose = noop ;
54+ babel = require ( '@babel/core' ) ;
5855 }
59-
6056 if ( process . platform === 'win32' ) {
6157 filePath = 'file:///' + path . resolve ( filePath ) . replace ( / \\ / g, '/' ) ;
6258 }
6359
64- const options = { filename : filePath } ;
65- for ( const key in defaultOptions ) {
66- options [ key ] = defaultOptions [ key ] ;
67- }
68- return babel . transform ( sourceCode , options ) . code ;
60+ return babel . transformSync ( sourceCode , {
61+ filename : filePath ,
62+ configFile
63+ } ) . code ;
6964} ;
7065
7166function createVersionAndOptionsDigest ( version , options ) {
7267 return crypto
7368 . createHash ( 'sha1' )
74- . update ( 'babel- core' , 'utf8' )
69+ . update ( '@ babel/ core' , 'utf8' )
7570 . update ( '\0' , 'utf8' )
7671 . update ( version , 'utf8' )
7772 . update ( '\0' , 'utf8' )
0 commit comments