bulma-css-vars icon indicating copy to clipboard operation
bulma-css-vars copied to clipboard

Swap out `css` package for more recent alternative?

Open prescience-data opened this issue 2 years ago • 3 comments

PNPM throws constant deprecation warnings about source-map-resolve which is due to the css dependency.

Looking at this source-map-resolve package it doesn't appear to have been updated in ~2 years, so potentially work looking into more current alternatives such as:

  • https://www.npmjs.com/package/css-what
  • https://www.npmjs.com/package/clean-css
  • https://www.npmjs.com/package/css-select
  • https://www.npmjs.com/package/css-tree

prescience-data avatar May 12 '22 00:05 prescience-data

Good point. Do you have any recommendations on any of the libraries?

The functionality we need is: Parse CSS to AST, traverse it to find declarations where CSS variable is used and manipulate the AST there

PRs are welcome!

wtho avatar May 13 '22 09:05 wtho

I would need to dig into the code to really work out a good fit - are there any main entrypoints in lib I should look at first?

I've used css-what a few times before and it seems quite fast but would hesitate to recommend it without more context / understanding of the codebase.

@stafyniaksacha do you have any thoughts given its part of your team's themes?

prescience-data avatar May 13 '22 10:05 prescience-data

It is all just in lib/src/css-post-processor.ts.

The code there is only used to create a css file with the default values in case a browser (IE basically) does not support CSS variables. When traversing the AST it looks for CSS variable declarations (declaration values that start with --var() and replaces them with the initial values set in the bulma css vars config file.

So I think we have two options:

  • remove the fallback (as we assume all used browsers can handle CSS variables)
  • replace css with some other, more up-to-date library (to me css-tree looks the best api-wise after a short glance)

wtho avatar May 13 '22 12:05 wtho