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.

Issue with Colorjs.io that seems to lead back to Vanilla Extract

See original GitHub issue

Describe the bug

I have an issue where the Colorjs.io library toString() method outputs a wrong color format when used inside *.css.ts files.

I filed this issue originally here and there’s some further information, but given the method seems to otherwise work well in pure node, it may be related to how VE builds the *.css.ts files. Any ideas what could be happening?

Reproduction

https://github.com/mystrdat/colorjs-vanilla-test

System Info

System:
    OS: Linux 6.0 Fedora Linux 37.20221101.n.0 (Silverblue)
    CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
    Memory: 24.92 GB / 31.28 GB
    Container: Yes
    Shell: 3.5.0 - /usr/bin/fish
  Binaries:
    Node: 16.17.1 - ~/.local/share/nvm/v16.17.1/bin/node
    npm: 8.15.0 - ~/.local/share/nvm/v16.17.1/bin/npm
  npmPackages:
    @vanilla-extract/css: ^1.9.1 => 1.9.1 
    @vanilla-extract/vite-plugin: ^3.6.1 => 3.6.1 
    vite: ^3.2.0 => 3.2.2

Used Package Manager

npm

Logs

No response

Validations

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
rothsandrocommented, Nov 3, 2022

Just debugged a bit in both the browser and node (with no knowledge of how VE works internally). The difference between browser and node is in ColorSpace.getFormat when calling processFormat() (ref):

getFormat (format) {
  // ...
  if (ret) {
    ret = this.#processFormat(ret); // We end up here
    return ret;
  }
}

In node with VE the compiled code looks like this:

ret = __privateMethod(this, _processFormat, __create).call(this, ret);

In the browser the processFormat() is called as expected. In node there is a strange behavior. The third argument __create is the function that gets called (returned by __privateMethod). Now the funny thing is that __create is declared and initialized twice in the same file, once for the processFormat function and once for the getPath function - and we end up in the latter one instead of processFormat (which then returns something different which than later breaks everything). The file looks like this:

var _processFormat, __create, _path, _getPath, __create; 

// ...

__create = function(format) {
  // Code of processFormat()
}

// ...

__create = function() {
 // Code of getPath()
}

Assuming that the file was transformed by esbuild (as Vite uses esbuild, but I don’t know if there is any other magic going on): this was actually a bug in esbuild that was fixed over one year ago https://github.com/evanw/esbuild/issues/1424


That’s all I’ve found out so far. It’s time to call it a day 😴

1reaction
mystrdatcommented, Nov 4, 2022

That makes sense given the bug only manifests in *.css.ts files and not otherwise in the Vite stack. @markdalgleish would it be possible to update esbuild in the integration package to squash this? Many thanks again for debugging this @rothsandro ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · vanilla-extract-css/vanilla-extract - GitHub
Contribute to vanilla-extract-css/vanilla-extract development by creating an ... Issue with Colorjs.io that seems to lead back to Vanilla Extract pending ...
Read more >
Color.js: Let's get serious about color
Let's get serious about color · Fully color space aware · Doesn't gloss over color science · Up to date with CSS Color...
Read more >
What's the Best Vanilla Extract? The Vanilla Queen Tells All
The best quality vanilla extracts come with a price. The simple answer for what is the best vanilla extract often boils down to...
Read more >
Tutorial 6: Transformers and Multi-Head Attention
For each element, we perform an attention layer where based on its query, we check the similarity of the all sequence elements' keys,...
Read more >
I want candy! Introduction to Vanilla Extract library | TSH.io
The Vanilla Extract library is not like any other CSS-in-JS solution. ... The battle of frontend world domination between frameworks seems ...
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