question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modifying values outside of a module doesn't update the component styles

See original GitHub issue

Describe the bug

When developing (using Parcel) in a component and modifying some properties outside of the module that are imported - don’t end up recompiling the component - thus they don’t get updated.

// colors.tsx
export const heroBackground = 'linear-gradient(120deg,blue 0%, #8fd3f4 100%)';

// hero.tsx
import React from 'react';
import '@compiled/core';
import { heroBackground } from '../utils/colors';

export const Hero = ({ children }: { children: React.ReactNode }) => {
  return (
    <div
      css={{
        background: heroBackground,
      }}>
      {children}
    </div>
  );
};

What’s worse - sometimes you get into a state where it just won’t update. In this case is it our caching behaviour, or is it the bundler? Both?

To Reproduce Steps to reproduce the behavior:

  1. Use code above
  2. Run with your favourite bundler
  3. Update hero background
  4. Notice that the component doesn’t have the updated color
  5. Now modify hero component
  6. Notice that is now is updated as expected

Expected behavior

It should update the component color without needing the modify the component file.

Additional context

Not sure what we can do here. Is it possible to fix this if we create a bundler plugin to make sure any depending module gets re-transformed if something changes?

Questions

  • Does this also affect Webpack
  • How can we force a bundler to recompile a consuming module (so it runs the Babel plugin over it, again)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
itsdougescommented, Feb 12, 2021

Hi all the webpack loader for Compiled is nearing completion, see: https://github.com/atlassian-labs/compiled/pull/530

If I cut a nightly would anyone want to have a play? Or alternatively grab the branch and play locally?

0reactions
itsdougescommented, Jan 18, 2021

Confirmed addIncludedFile is what we’re interested in https://github.com/parcel-bundler/parcel/discussions/5677

Read more comments on GitHub >

github_iconTop Results From Across the Web

function change $scope variable , but do not update the value ...
I have a little problem here, ng-click function change the scope value inside the function but does not update the scope value outside...
Read more >
CSS Module styles do not update upon saving file in ... - GitHub
When changing and saving CSS Module file the style change does not get reflected to current open page in development.
Read more >
Solving the React Error: Not Picking Up CSS Style | Pluralsight
In this guide, you will learn about the errors that can occur while importing a CSS file into your React file.
Read more >
Component styles - Angular
Sometimes it's useful to apply styles to elements within a component's template based on some condition in an element that is an ancestor...
Read more >
Chapter 4, Understanding and Using Angular Components
The selector takes a string value, which is the CSS selector Angular will use to identify the element. The recommended practice when we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found