@@ -148,6 +148,33 @@ export default ({ types: t }) => {
148
148
}
149
149
}
150
150
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
+
151
178
return {
152
179
manipulateOptions ( babelOptions ) {
153
180
const findPluginOptions = babelOptions . plugins . find ( plugin => plugin [ 0 ] === this ) [ 1 ] ;
@@ -188,6 +215,7 @@ export default ({ types: t }) => {
188
215
189
216
transformRequireCall ( nodePath , state , this . moduleResolverCWD ) ;
190
217
transformJestCalls ( nodePath , state , this . moduleResolverCWD ) ;
218
+ transformSystemImportCall ( nodePath , state , this . moduleResolverCWD ) ;
191
219
192
220
// eslint-disable-next-line no-param-reassign
193
221
nodePath . node . seen = true ;
0 commit comments