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

Nested Styled components breaks react-refresh with '$RefreshReg$ is not defined' #848

Closed
ntucker opened this issue Sep 29, 2021 · 4 comments
Assignees
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler

Comments

@ntucker
Copy link

ntucker commented Sep 29, 2021

Environment

  • Linaria version: 3-beta.13
  • Bundler (+ version): webpack
  • @pmmmwh/react-refresh-webpack-plugin: 0.5.1
  • react-refresh: 0.10.0
  • Node.js version: 12.22.1
  • OS: Ubuntu 20.04

Description

When using linaria and @pmmmwh/react-refresh-webpack-plugin, referring to a react styled component triggers the following error:

home/ntucker/src/anansi/examples/linaria/src/MenuItem.tsx: An unexpected runtime error occurred during dependencies evaluation: 
/home/ntucker/src/anansi/examples/linaria/src/MenuItem.tsx:37
$RefreshReg$(_c, "MenuItemContainer");
^

ReferenceError: $RefreshReg$ is not defined

Note this used to work in beta-4. I haven't traced down which version it first starts having trouble with yet.

Have isolated this to @linaria/shaker. Just setting that package version to beta.4 fixes this

Reproducible Demo

const MenuItemContainer = styled.div`
  width: 32px;
`

const IconContainer = styled.div`
  ${MenuItemContainer}:hover & {
    background-color: #f2f4f7;
  }
`

export default ({ children }) => {
  return (
    <MenuItemContainer>
      <IconContainer>{children}</IconContainer>
    </MenuItemContainer>
  )
}

For full runnable configuration:

@ntucker ntucker added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels Sep 29, 2021
@github-actions github-actions bot added bundler: webpack 📦 Issue is related to webpack bundler and removed needs: triage 🏷 Issue needs to be checked and prioritized labels Sep 29, 2021
@ntucker
Copy link
Author

ntucker commented Sep 29, 2021

Confirmed @linaria/shake@3.0.0-beta.4 is last working version. beta.5 breaks. This suggests 6907e22 is related? (from release notes)

@ntucker
Copy link
Author

ntucker commented Sep 29, 2021

How do I remove complete repro label? I provided one

@Anber Anber removed the needs: complete repro 🖥️ Issue need to have complete repro provided label Oct 7, 2021
@Anber Anber self-assigned this Oct 7, 2021
@Anber Anber closed this as completed in 8f1d7cb Oct 8, 2021
@Anber
Copy link
Collaborator

Anber commented Oct 8, 2021

Hi @ntucker
Thank you for the report!

This suggests 6907e22 is related?

It is related. I've reverted changes and added another way to support enums.

@ntucker
Copy link
Author

ntucker commented Oct 12, 2021

Planning on releasing a new version? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler
Projects
None yet
Development

No branches or pull requests

2 participants