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

Created on 18 Jan 2020  路  7Comments  路  Source: callstack/linaria

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

All 7 comments

cc @Anber

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

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

:no_entry_sign: 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 https://github.com/callstack/linaria/issues/537, but I've hard-removed the .linaria-cache folder a bunch of times to no avail.

:heavy_check_mark: 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.

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.

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

Probably, fixed in 1.4-beta.5.

Hey this solved it! Thanks so much @Anber 馃檱

Was this page helpful?
0 / 5 - 0 ratings