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

[1.4.0-beta.1] Changes to exported variables are not picked up when using webpack hmr #528

Closed
bartels opened this issue Jan 17, 2020 · 7 comments
Assignees

Comments

@bartels
Copy link

bartels commented Jan 17, 2020

Environment

1.4.0-beta.1

Description

When using webpack hmr (or webpack --watch flag), changes to variables exported from an external module are not picked up by linaria.

For example, defining color values in a colors.js module and importing those variables in a linaria styled component, the css output by linaria is not updated when that module is changed. Only after killing the webpack build/devServer and restarting will linaria pick up the style changes.

I checked in .linaria-cache folder and noticed the styles are not updated there.

Reproducible Demo

Here's a github repo to demo the problem: https://github.com/bartels/linaria-1.4.0-beta.1-hmr-bug

@thymikee
Copy link
Member

cc @Anber

@Anber
Copy link
Collaborator

Anber commented Jan 18, 2020

@bartels thank you for the report and sample repo! I'll take a look in a couple of days.

@Anber Anber self-assigned this Jan 18, 2020
@resolritter
Copy link

resolritter commented Feb 8, 2020

I found that if you link the linaria package instead of installing it through npm/yarn, it works.

🚫 Bug reproduction:

  1. git clone https://github.com/bartels/linaria-1.4.0-beta.1-hmr-bug
  2. npm install
  3. npm run start

Through the Firefox DevTools, I could see the DOM tree flashing briefly; it seemed like some update had been executed, although it had no effect on the style.

I thought it had relation a with #537, but I've hard-removed the .linaria-cache folder a bunch of times to no avail.

✔️ Workaround

  1. git clone https://github.com/callstack/linaria and enter the cloned path
  2. yarn bootstrap && yarn link
  3. git clone https://github.com/bartels/linaria-1.4.0-beta.1-hmr-bug and enter the cloned path
  4. yarn && yarn link linaria
  5. yarn start

Changes I made to src/colors.js were hot-reloaded; their usage in pseudo-classes worked as well.

@adamseckel
Copy link

Hey @Anber, any progress on this one by any chance? 😊 I've been getting a lot of reports from my team that this is happening regularly.

@Anber
Copy link
Collaborator

Anber commented Mar 20, 2020

@Hemlok Unfortunately, not really, but it's time to change it.

Anber added a commit that referenced this issue Mar 27, 2020
@Anber
Copy link
Collaborator

Anber commented Mar 27, 2020

Probably, fixed in 1.4-beta.5.

@Anber Anber closed this as completed Mar 27, 2020
@adamseckel
Copy link

Hey this solved it! Thanks so much @Anber 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants