@@ -41,6 +41,7 @@ const SWC_SUPPORTED_CUSTOM_RULES = new Set([
4141 'transform-react-jsx' ,
4242 'transform-modules-commonjs' ,
4343 'proposal-export-default-from' ,
44+ 'transform-dynamic-import' ,
4445] ) ;
4546
4647function getTransformRuntimeConfig (
@@ -135,6 +136,22 @@ function getTransformExportDefaultFromConfig(
135136 } ;
136137}
137138
139+ function getTransformDynamicImportConfig (
140+ swcConfig : SwcLoaderOptions
141+ ) : SwcLoaderOptions {
142+ return {
143+ ...swcConfig ,
144+ jsc : {
145+ ...swcConfig . jsc ,
146+ parser : {
147+ ...swcConfig . jsc ?. parser ,
148+ syntax : swcConfig . jsc ?. parser ?. syntax ! ,
149+ dynamicImport : true ,
150+ } ,
151+ } ,
152+ } ;
153+ }
154+
138155function getTransformClassPropertiesConfig (
139156 swcConfig : SwcLoaderOptions ,
140157 ruleConfig : Record < string , any > = { loose : false }
@@ -244,6 +261,7 @@ const SWC_SUPPORTED_CUSTOM_RULES_MAP = {
244261 'transform-react-jsx-source' : getTransformReactDevelopmentConfig ,
245262 'transform-modules-commonjs' : getTransformModulesCommonjsConfig ,
246263 'proposal-export-default-from' : getTransformExportDefaultFromConfig ,
264+ 'transform-dynamic-import' : getTransformDynamicImportConfig ,
247265} ;
248266
249267export function getSupportedSwcNormalTransforms (
0 commit comments