Registry / serialization / lightningcss-freebsd-x64

lightningcss-freebsd-x64

JSON →
library1.32.0jsnpmunverified

LightningCSS is an exceptionally fast CSS parser, transformer, bundler, and minifier, leveraging the performance benefits of Rust. Currently stable at version 1.32.0, it maintains an active and frequent release cadence, often issuing minor or patch updates every few weeks. Key differentiators include its speed, boasting over 100x faster processing than JavaScript-based alternatives and capable of minifying millions of lines of code per second. It utilizes a browser-grade parser based on Mozilla's `cssparser` and processes typed property values, ensuring accuracy and consistency. The library offers extensive minification optimizations, including combining shorthands, merging adjacent rules, reducing `calc()` expressions, and converting colors to shorter formats. It also provides vendor prefixing, syntax lowering for older browsers, support for CSS Modules, and robust source map generation. Crucially, LightningCSS guarantees that its output CSS behaves identically to the input, avoiding unsafe optimizations that might alter styling for file size reductions.

npm install lightningcss-freebsd-x64
INSTALL
IMPORT
SIG · LIGHTNINGCSS-FREEB
L
lightningcss-freebsd-x64
serializationjavascriptv1.32.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

transform
import { transform } from 'lightningcss';
const { transform } = require('lightningcss');
The core `lightningcss` library is primarily an ESM module. While Node.js supports `require()` for ESM, `import` is the recommended and cleaner syntax. This `lightningcss-freebsd-x64` package is a native binding and not typically imported directly.
bundle
import { bundle } from 'lightningcss';
import bundle from 'lightningcss';
Used for bundling multiple CSS files and resolving `@import` statements. The `bundleAsync` variant supports custom resolvers. Requires `filename` option to read directly from the filesystem.
browserslistToTargets, Features
import { transform, browserslistToTargets, Features } from 'lightningcss';
import { browserslistToTargets } from 'lightningcss/node';
`browserslistToTargets` converts a Browserslist query into a target object for transpilation, and `Features` enum allows fine-grained control over transpilation features (e.g., `Features.Colors | Features.Nesting`).

This example demonstrates how to use the `transform` function from `lightningcss` to parse, minify, transpile modern CSS features for specified browser targets, and generate a source map. It includes setting up browser targets using `browserslist`.

import { transform, browserslistToTargets } from 'lightningcss'; import browserslist from 'browserslist'; import { readFileSync } from 'fs'; // Create a dummy CSS file for demonstration const cssInput = ` @import url('other.css'); .container { display: flex; gap: 10px; color: oklab(59.686% 0.1009 0.1192); /* A modern CSS feature that will be lowered */ background: linear-gradient(to right, red, blue); } @media (min-width: 768px) { .container { flex-direction: column; } } `; const otherCss = `.other { padding: 5px; }`; // In a real application, you'd write these to files or use a bundler. // For quickstart, we'll simulate file content. // Normally, `bundle` would read from actual files. async function processCss() { // Define browser targets using browserslist const targets = browserslistToTargets(browserslist('>= 0.25%, not dead')); // Using transform for a single file (no @import resolution via `code` option) const { code: transformedCode, map: transformedMap } = transform({ filename: 'style.css', code: Buffer.from(cssInput), minify: true, targets: targets, sourceMap: true, drafts: { nesting: true } // Enable draft features if needed }); console.log('--- Transformed & Minified CSS ---\n', transformedCode.toString()); console.log('\n--- Source Map (partial) ---\n', transformedMap ? transformedMap.toString().substring(0, 200) + '...' : 'No source map generated'); // To demonstrate @import bundling, you would typically use `bundle` // which requires actual filesystem access. // For example, if 'style.css' contained '@import "./other.css";' /* // You would need to ensure 'style.css' and 'other.css' exist on disk // For this quickstart, demonstrating with Buffer for `transform` is more direct. import { bundle } from 'lightningcss'; // ... (write cssInput and otherCss to 'style.css' and 'other.css') const { code: bundledCode } = bundle({ filename: 'style.css', minify: true, targets: targets }); console.log('\n--- Bundled CSS (if files existed) ---\n', bundledCode.toString()); */ } processCss().catch(console.error);
Debug
Known issues
breakingThe v1.30.0 release introduced a breaking change in relative color parsing to align with the latest CSS specification. Code using relative color calculations on percentages may need to be updated to use numbers instead.
fix
Review CSS code involving relative color calculations. If percentages were used where numbers are now expected by the spec, convert them to their numerical equivalents. Refer to the official v1.30.0 release notes for specific details.
affects: >=1.30.0
gotchaLightningCSS is a native module primarily designed for ESM environments. Using `require()` for CommonJS modules can lead to issues or require specific configurations, especially in older Node.js setups.
fix
Prefer ES Module `import` syntax (`import { symbol } from 'lightningcss';`) in your Node.js projects. Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`). If CommonJS is unavoidable, investigate dynamic `import()` or specific transpilation configurations.
affects: >=1.0.0
gotchaThis package (`lightningcss-freebsd-x64`) is a platform-specific native binding. Incorrect installation or resolution of the native module (e.g., due to Docker environment mismatch, incorrect `npm install --force`) can lead to runtime errors like 'Cannot find module'.
fix
Ensure `npm` can correctly identify and install the appropriate native module for your runtime environment. For Docker, build images on the target architecture or ensure multi-arch builds are correctly configured. Avoid `npm install --force` unless absolutely necessary and understand its implications. If errors occur, try deleting `node_modules` and `package-lock.json` and reinstalling.
affects: >=1.0.0
gotchaBy default, LightningCSS is strict and will throw an error when parsing invalid CSS rules or declarations. This can halt builds if third-party CSS contains non-standard or malformed syntax.
fix
For cases where invalid third-party CSS cannot be fixed, enable the `errorRecovery` option in the API (`transform({ errorRecovery: true })`) or use the `--error-recovery` CLI flag. This will skip invalid rules and declarations, emitting warnings instead of errors.
affects: >=1.0.0
gotchaWhen using the bundling API, `@import` rules must strictly appear before all other rules in a stylesheet, except for `@charset` and `@layer` statements. Violating this order will result in an error.
fix
Always place `@import` statements at the very top of your CSS files, after any `@charset` or `@layer` rules, but before any other `@rule` or style declarations.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module '../lightningcss.<platform>.node'
The native binding for the current platform (e.g., `lightningcss-freebsd-x64`) could not be found or loaded, often due to an architecture mismatch or corrupted `node_modules`.
fix
Clear your `node_modules` directory and `package-lock.json` (or `yarn.lock`), then reinstall dependencies. For Docker environments, ensure the build process correctly identifies and installs the native module for the container's architecture or use multi-arch builds.
CSS parse error: Unexpected token <token>
LightningCSS encountered syntactically invalid CSS code or an unexpected token, as it strictly adheres to the CSS specification by default.
fix
Review the CSS code around the indicated token for syntax errors. If the error originates from third-party CSS that cannot be directly fixed, consider using the `errorRecovery: true` option in the `transform` or `bundle` API call to skip invalid constructs.
Error: `@import` rules must appear before all other rules.
An `@import` rule was found after a non-`@charset` or non-`@layer` rule within a CSS stylesheet when using the `bundle` API.
fix
Rearrange your CSS to ensure all `@import` rules are declared at the very beginning of the stylesheet, following only `@charset` or `@layer` rules if present.
Upgrade
Version history
1.32.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources