GSS Compiler

raw JSON →
0.8.2 verified Fri May 01 auth: no javascript abandoned

A compiler that parses GSS (Grid Style Sheets) rule strings into JSON AST format for execution by the GSS engine. Version 0.8.2 is the latest stable release; the project appears dormant with no recent releases or maintenance. GSS is a constraint-based layout system for the web, offering an alternative to CSS for complex layouts using constraint solving. The compiler outputs a JSON AST that the GSS engine uses to compute layout changes in the browser. This differentiates it from traditional CSS preprocessors by enabling real-time layout adjustments based on constraints.

error Cannot find module 'gss-compiler'
cause Package not installed or not in node_modules.
fix
Run npm install gss-compiler
error compile is not a function
cause Incorrect import: using default import when the module exports an object with compile property.
fix
Use const compile = require('gss-compiler').compile;
error Unexpected token: ... in GSS
cause GSS syntax error or unsupported feature.
fix
Check the GSS documentation for valid syntax. Ensure using a recent version of the compiler.
deprecated The GSS project is no longer actively maintained. The compiler may have bugs and missing features.
fix Consider using CSS Grid Layout or other modern layout solutions instead of GSS.
gotcha The package does not ship TypeScript type definitions. Usage in TypeScript projects requires custom type declarations.
fix Create a .d.ts file: declare module 'gss-compiler' { export function compile(gss: string): any; }
gotcha CommonJS require is the only supported module format; ES module import may fail depending on bundler.
fix Use require('gss-compiler').compile for compatibility.
npm install gss-compiler
yarn add gss-compiler
pnpm add gss-compiler

Demonstrates compiling a simple GSS rule string to JSON AST.

import { compile } from 'gss-compiler';

const gss = `
  #header {
    width: == 100%;
  }
  #sidebar {
    width: == 200px;
  }
  #content {
    width: == 100% - #sidebar[width];
  }
`;

const ast = compile(gss);
console.log(JSON.stringify(ast, null, 2));
// Outputs JSON AST that can be fed into GSS engine