@@ -42,6 +42,7 @@ const SWC_SUPPORTED_CUSTOM_RULES = new Set([
4242 'transform-modules-commonjs' ,
4343 'proposal-export-default-from' ,
4444 'transform-typescript' ,
45+ 'transform-dynamic-import' ,
4546] ) ;
4647
4748function getTransformRuntimeConfig (
@@ -136,6 +137,22 @@ function getTransformExportDefaultFromConfig(
136137 } ;
137138}
138139
140+ function getTransformDynamicImportConfig (
141+ swcConfig : SwcLoaderOptions
142+ ) : SwcLoaderOptions {
143+ return {
144+ ...swcConfig ,
145+ jsc : {
146+ ...swcConfig . jsc ,
147+ parser : {
148+ ...swcConfig . jsc ?. parser ,
149+ syntax : swcConfig . jsc ?. parser ?. syntax ! ,
150+ dynamicImport : true ,
151+ } ,
152+ } ,
153+ } ;
154+ }
155+
139156function getTransformClassPropertiesConfig (
140157 swcConfig : SwcLoaderOptions ,
141158 ruleConfig : Record < string , any > = { loose : false }
@@ -253,6 +270,7 @@ const SWC_SUPPORTED_CUSTOM_RULES_MAP = {
253270 'transform-modules-commonjs' : getTransformModulesCommonjsConfig ,
254271 'proposal-export-default-from' : getTransformExportDefaultFromConfig ,
255272 'transform-typescript' : getTransformTypescriptConfig ,
273+ 'transform-dynamic-import' : getTransformDynamicImportConfig ,
256274} ;
257275
258276export function getSupportedSwcNormalTransforms (
0 commit comments