I have encountered some challenges with transforming imports in Next.js using the SWC compiler.
My goal is to utilize swc-plugin-transform-import instead of babel-plugin-transform-imports to simplify Material UI imports.
Despite following the documented instructions, I am facing an issue with the settings. It displays an experimental warning and does not apply the plugin at all.
// next.config.js
module.exports = {
experimental: {
swcPlugins: [
[
'swc-plugin-transform-import',
{
"@mui/material": {
transform: "@mui/material/${member}",
preventFullImport: true
},
"@mui/icons-material": {
transform: "@mui/icons-material/${member}",
preventFullImport: true
},
"@mui/styles": {
transform: "@mui/styles/${member}",
preventFullImport: true
},
"@mui/lab": {
transform: "@mui/lab/${member}",
preventFullImport: true
}
}
]
]
}
}
Does anyone have insights on how to activate and configure swc-plugin-transform-import
for Next.js effectively? Your help is appreciated!