Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atomic atomizer running before custom preprocessor #1411

Open
hmerritt opened this issue May 17, 2024 · 0 comments
Open

Atomic atomizer running before custom preprocessor #1411

hmerritt opened this issue May 17, 2024 · 0 comments
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler needs: complete repro 🖥️ Issue need to have complete repro provided

Comments

@hmerritt
Copy link
Contributor

Environment

{
  "dependencies": {
    "@linaria/atomic": "^6.2.0",
    "@linaria/core": "6.2.0",
    "@linaria/react": "6.2.1",
    
    "@wyw-in-js/babel-preset": "0.5.3",
    "@wyw-in-js/shared": "0.5.3",
    "@wyw-in-js/transform": "0.5.3",
    "@wyw-in-js/vite": "0.5.3"
  }
}
linaria({
	sourceMap: isDev,
	preprocessor: (selector, cssText) => {
		try {
			const result = sass.compileString(`${selector} {${cssText}}\n`);
			return result.css.toString();
		} catch (error) {
			console.error("Error processing SCSS:", error);
			return "";
		}
	}
})
  • Linaria version: 6.2.0
  • Bundler (+ version):
  • Node.js version: v20.8.0
  • OS: windows 11

Description

I am using a SCSS preprocessor (with great success), but getting errors when trying out the @linaria/atomic package.

I think, and created a small test which I believe confirms this, that the atomizer is running before the preprocessor (which naturally causes problems since all the SCSS needs to be compiled together, after which it can be safely atomized).

Simple example below showing the SCSS variable is not compiled when the atomizer is ran, resulting in color: $purple-900; being split out before SCSS can compile it alongside the variable declaration.

NB this example works just fine when using @linaria/core, the error is exclusive to @linaria/atomic

image

image

Reproducible Demo

Use the a custom preprocessor alongside @linaria/atomic.

@hmerritt hmerritt added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels May 17, 2024
@github-actions github-actions bot added bundler: webpack 📦 Issue is related to webpack bundler and removed needs: triage 🏷 Issue needs to be checked and prioritized labels May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler needs: complete repro 🖥️ Issue need to have complete repro provided
Projects
None yet
Development

No branches or pull requests

1 participant