@@ -148,6 +148,33 @@ export default ({ types: t }) => {
148148 }
149149 }
150150
151+ function transformSystemImportCall ( nodePath , state , cwd ) {
152+ const calleePath = nodePath . get ( 'callee' ) ;
153+
154+ if ( ! (
155+ t . isMemberExpression ( calleePath . node ) &&
156+ t . isIdentifier ( calleePath . node . object , { name : 'System' } ) &&
157+ t . isIdentifier ( calleePath . node . property , { name : 'import' } )
158+ ) ) {
159+ return ;
160+ }
161+
162+ const args = nodePath . get ( 'arguments' ) ;
163+ if ( ! args . length ) {
164+ return ;
165+ }
166+
167+ const moduleArg = args [ 0 ] ;
168+ if ( moduleArg . node . type === 'StringLiteral' ) {
169+ const modulePath = mapModule ( moduleArg . node . value , state . file . opts . filename , state . opts , cwd ) ;
170+ if ( modulePath ) {
171+ nodePath . replaceWith ( t . callExpression (
172+ calleePath . node , [ t . stringLiteral ( modulePath ) ] ,
173+ ) ) ;
174+ }
175+ }
176+ }
177+
151178 return {
152179 manipulateOptions ( babelOptions ) {
153180 const findPluginOptions = babelOptions . plugins . find ( plugin => plugin [ 0 ] === this ) [ 1 ] ;
@@ -188,6 +215,7 @@ export default ({ types: t }) => {
188215
189216 transformRequireCall ( nodePath , state , this . moduleResolverCWD ) ;
190217 transformJestCalls ( nodePath , state , this . moduleResolverCWD ) ;
218+ transformSystemImportCall ( nodePath , state , this . moduleResolverCWD ) ;
191219
192220 // eslint-disable-next-line no-param-reassign
193221 nodePath . node . seen = true ;
0 commit comments