Skip to content

Commit cef8ff6

Browse files
authored
fix: enable additional lightningcss syntax lowering (#166)
1 parent 4513fe3 commit cef8ff6

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/__tests__/compiler/@prop.test.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { render, screen } from "@testing-library/react-native";
22
import { compile } from "react-native-css/compiler";
33
import { View } from "react-native-css/components";
4-
import { registerCSS, testID } from "react-native-css/jest";
4+
import {
5+
compileWithAutoDebug,
6+
registerCSS,
7+
testID,
8+
} from "react-native-css/jest";
59

610
test("@prop target (nested @media)", () => {
711
const compiled = registerCSS(`
@@ -222,10 +226,10 @@ test("@prop value: wildcard nested target", () => {
222226
});
223227

224228
test("@prop multiple", () => {
225-
const compiled = compile(`
229+
const compiled = compileWithAutoDebug(`
226230
.test {
227231
color: red;
228-
background-color: blue;
232+
background-color: oklab(40.1% 0.1143 0.045);
229233
@prop {
230234
background-color: *.myBackgroundColor;
231235
color: *.myColor;
@@ -241,7 +245,7 @@ test("@prop multiple", () => {
241245
{
242246
d: [
243247
{
244-
myBackgroundColor: "#00f",
248+
myBackgroundColor: "#7d2429",
245249
myColor: "#f00",
246250
},
247251
],

src/compiler/compiler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { inspect } from "node:util";
33

44
import { debug } from "debug";
55
import {
6+
Features,
67
transform as lightningcss,
78
type ContainerRule,
89
type MediaQuery as CSSMediaQuery,
@@ -65,6 +66,8 @@ export function compile(code: Buffer | string, options: CompilerOptions = {}) {
6566
*/
6667
const { code: firstPass } = lightningcss({
6768
code: typeof code === "string" ? new TextEncoder().encode(code) : code,
69+
include: Features.DoublePositionGradients | Features.ColorFunction,
70+
exclude: Features.VendorPrefixes,
6871
visitor: {
6972
Length(length) {
7073
if (length.unit !== "rem" || options.inlineRem === false) {
@@ -84,7 +87,7 @@ export function compile(code: Buffer | string, options: CompilerOptions = {}) {
8487
if (isLoggerEnabled) {
8588
const MAX_LOG_SIZE = 100 * 1024; // 100KB
8689
if (firstPass.length <= MAX_LOG_SIZE) {
87-
logger(firstPass.toString());
90+
console.log(firstPass.toString());
8891
} else {
8992
logger(
9093
`firstPass buffer too large to log in full (${firstPass.length} bytes). Preview: ` +

0 commit comments

Comments
 (0)