Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable SWC Emotion importMap #41646

Closed
Zn4rK opened this issue Oct 22, 2022 · 0 comments · Fixed by #42750
Closed

Enable SWC Emotion importMap #41646

Zn4rK opened this issue Oct 22, 2022 · 0 comments · Fixed by #42750

Comments

@Zn4rK
Copy link
Contributor

Zn4rK commented Oct 22, 2022

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:

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).
@vercel vercel locked and limited conversation to collaborators Oct 24, 2022
@balazsorban44 balazsorban44 converted this issue into discussion #41732 Oct 24, 2022
kodiakhq bot pushed a commit that referenced this issue Nov 10, 2022
This PR aims to add support for the `importMap` option for `emotion`. It's already supported by `swc_emotion`.

Fixes #41646.

## Feature

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant