-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Description
Describe the feature you'd like to request
I recently tried to move from babel to SWC in one of my project, but noticed that I couldn't due to the fact that the SWC plugin for emotion does not have importMap support. In the current setup I have, emotion
is re-exported and then used under the new export across the project.
importMap makes that possible:
https://github.com/emotion-js/emotion/tree/main/packages/babel-plugin#importmap
Describe the solution you'd like
It looks like importMap support is already in the emotion plugin:
https://github.com/vercel/next.js/blob/canary/packages/next-swc/crates/emotion/src/import_map.rs
https://github.com/vercel/next.js/blob/canary/packages/next-swc/crates/emotion/tests/testImportMap.json
(Edit: These moved to here and here after #41613 was merged. Probably should've used a permalink, but w/e).
But the options are gated in the config:
next.js/packages/next/build/swc/options.js
Line 156 in 99d88f2
function getEmotionOptions(nextConfig, development) { |
Is this an oversight or is there a specific reason for the importMap not being accepted as options to the emotion compiler settings?
Describe alternatives you've considered
- Continue using babel.
- Using a patch to manually edit
node_modules/next/dist/build/swc/options.js
and set the importMap (which seems to work).