callstack / linaria

Zero-runtime CSS in JS library
https://linaria.dev
MIT License
11.49k stars 414 forks source link

Make @linaria/atomic depend on css-tree or CSSOM rather than postcss #901

Open jpnelson opened 2 years ago

jpnelson commented 2 years ago

Describe the enhancement

I've run into some issues using @linaria/extractor with @linaria/atomic, where when evaluating dependencies, it tries to evaluate @linaria/atomic which includes calls to fs (which we don't allow). It does this so that it can read source maps from disk.

This creates an error like:

Cannot destructure property 'existsSync' of 'require(...)' as it is null

Motivation

This would fix it by changing the dependency and refactoring to use a smaller library with no fs calls in it.

Possible implementations

I'd consider making @linaria/atomic use https://github.com/csstree/csstree, or https://www.npmjs.com/package/cssom to avoid this issue. This would also help as we only need to be able to parse and reformat the CSS to atomize it, and postcss is a large dependency.

Nitsan-Baleli-lmnd commented 1 year ago

@jpnelson have you managed to fix it? Im facing the same issue