Skip to content
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

Emotion SWC Plugin - Spaces between expressions are being stripped #35609

Closed
1 task done
JohnDaly opened this issue Mar 26, 2022 · 1 comment · Fixed by #35613
Closed
1 task done

Emotion SWC Plugin - Spaces between expressions are being stripped #35609

JohnDaly opened this issue Mar 26, 2022 · 1 comment · Fixed by #35613
Labels
bug Issue was opened via the bug report template.

Comments

@JohnDaly
Copy link
Contributor

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 21.4.0: Mon Feb 21 20:34:37 PST 2022; root:xnu-8020.101.4~2/RELEASE_X86_64
Binaries:
  Node: 14.17.0
  npm: 6.14.13
  Yarn: 1.19.1
  pnpm: N/A
Relevant packages:
  next: 12.1.1
  react: 17.0.2
  react-dom: 17.0.2

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

When using Emotion with SWC, spaces between template strings expressions are being stripped. This can cause invalid CSS to be generated.

Expected Behavior

There should be spaces preserved between expressions, to ensure that valid CSS is generated

To Reproduce

Input

const unitNormal = '1rem';
const unitLarge = '2rem';

const Example = styled.div`
  margin: ${unitNormal} ${unitLarge};
`;

Output

var unitNormal = '1rem';
var unitLarge = '2rem';
var Example = /*#__PURE__*/ (0,_emotion_styled__WEBPACK_IMPORTED_MODULE_0__["default"])("div", {
    target: "e1s94g990",
    label: "Example"
})("margin:", unitNormal, unitLarge, ";");

This results in the following CSS:

.next-19a10xq-Example {
    margin: 1rem2rem;
}
@JohnDaly JohnDaly added the bug Issue was opened via the bug report template. label Mar 26, 2022
@kodiakhq kodiakhq bot closed this as completed in #35613 Mar 26, 2022
kodiakhq bot pushed a commit that referenced this issue Mar 26, 2022
fixes #35609

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

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

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`


Co-authored-by: John Daly <[email protected]>
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 25, 2022
pavleadev pushed a commit to pavleadev/next.js that referenced this issue Mar 29, 2023
fixes vercel/next.js#35609

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

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

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`


Co-authored-by: John Daly <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
1 participant