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.

Using imported values inside the create method breaks the Webpack build

See original GitHub issue

Using imported values within the styles object passed to Style9.create() seems to break the Webpack build when using the Style9 Webpack loader.

Steps to reproduce:

  1. Clone this minimal reproduction repo I created: https://github.com/nonAlgebraic/style9-import-bug
  2. Run yarn install
  3. Run yarn build

Expected result

The color value imported from colorValue.js (“blue”) is applied to the <body>.

Actual result

The Webpack build fails with an error:

SyntaxError: unknown: Could not evaluate value
  4 | const styles = style9.create({
  5 |   body: {
> 6 |     color: colorValue,
    |            ^^^^^^^^^^
  7 |   },
  8 | });

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
johanholmerincommented, Sep 8, 2020

Style values are evaluated using babel’s path.evaluate(), which operates on a single file. In the future this may be expanded, but at the moment this is per design.

0reactions
myamolanecommented, May 28, 2021

@rodrigojcmello could u merge style9’s updates and publish a version?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Code Splitting - webpack
The reason we need default is that since webpack 4, when importing a CommonJS module, the import will no longer resolve to the...
Read more >
Webpack and Dynamic Imports: Doing it Right
The problem is if you want to dynamically load a file, in this case, an image, Webpack by default generate a chunk for...
Read more >
How I solved and debugged my Webpack issue through ...
js ) and one of the source files contains an error, the stack trace will simply point to bundle.js . This isn't always...
Read more >
An in-depth perspective on webpack's bundling process
Conceptually, a module in webpack is associated with a file. So, in the diagram 'a.js' will result in a new module and so...
Read more >
Error: Cannot find module with dynamic import · Issue #6680
Webpack performs a static analyse at build time. It doesn't try to infer variables which that import(test) could be anything, hence the failure....
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