@@ -110,21 +110,21 @@ module.exports = (env, argv) => {
110110 {
111111 test : / \. ( t s | j s ) x ? $ / ,
112112 include : ( f ) => {
113+ // our own source needs babel-ing
114+ if ( f . startsWith ( path . resolve ( __dirname , 'src' ) ) ) return true ;
115+
113116 // we use the original source files of react-sdk and js-sdk, so we need to
114- // run them through babel.
115- if ( f . startsWith ( path . resolve ( __dirname , 'node_modules' , 'matrix-js-sdk' , 'src' ) ) ) return true ;
116- if ( f . startsWith ( path . resolve ( __dirname , 'node_modules' , 'matrix-react-sdk' , 'src' ) ) ) return true ;
117+ // run them through babel. Because the path tested is the resolved, absolute
118+ // path, these could be anywhere thanks to yarn link. We must also not
119+ // include node modules inside these modules, so we add 'src'.
120+ if ( f . includes ( path . join ( 'matrix-js-sdk' , 'src' ) ) ) return true ;
121+ if ( f . includes ( path . join ( 'matrix-react-sdk' , 'src' ) ) ) return true ;
122+
117123 // but we can't run all of our dependencies through babel (many of them still
118124 // use module.exports which breaks if babel injects an 'include' for its
119125 // polyfills: probably fixable but babeling all our dependencies is probably
120- // not necessary anyway).
121- if ( f . startsWith ( path . resolve ( __dirname , 'node_modules' ) ) ) return false ;
122- // anything else gets babeled (our own source files, and also modules that
123- // are yarn linked from somewhere else because this tests the absolute,
124- // resolved path, so react-sdk and js-sdk fall under this case in a standard
125- // dev setup. This will presumably start running any other module through
126- // babel if yarn linked... caveat emptor.
127- return true ;
126+ // not necessary anyway). So, for anything else, don't babel.
127+ return false ;
128128 } ,
129129 loader : 'babel-loader' ,
130130 options : {
0 commit comments