livescript-compiler
raw JSON → 0.1.1 verified Fri May 01 auth: no javascript deprecated
Pluggable LiveScript compiler that extends the original compiler with plugin support for code transformation and AST manipulation. It is part of the livescript-system ecosystem and requires the master branch of livescript (not the npm version). Version 0.1.1 is a work-in-progress, with constant development and a messy codebase; not recommended for production use. It provides plugins for ES modules, implicit async, and Object.create-based cloning. Released under BSD-3-Clause.
Common errors
error Error: Cannot find module 'livescript' ↓
cause livescript not installed from GitHub master branch
fix
npm install 'https://github.com/gkz/LiveScript'
error SyntaxError: Cannot use import statement outside a module ↓
cause Trying to use ESM import in a CommonJS file
fix
Add 'type': 'module' to package.json or use a .mjs extension.
error TypeError: compiler.compile is not a function ↓
cause Incorrect import of default export as named export
fix
Use: import compiler from 'livescript-compiler'; then compiler.compile(...).
Warnings
deprecated Package is work-in-progress and not stable. Not recommended for production use. ↓
fix Use official livescript package instead.
breaking Requires livescript from GitHub master branch; npm version is incompatible. ↓
fix Install livescript from GitHub: npm install 'https://github.com/gkz/LiveScript'
gotcha Package is ESM-only; does not export CommonJS. ↓
fix Use import syntax or dynamic import(). Do not use require().
Install
npm install livescript-compiler yarn add livescript-compiler pnpm add livescript-compiler Imports
- compile wrong
const { compile } = require('livescript-compiler')correctimport { compile } from 'livescript-compiler' - SourceNode wrong
import SourceNode from 'livescript-compiler'correctimport { SourceNode } from 'livescript-compiler' - default (compiler instance) wrong
import { compiler } from 'livescript-compiler'correctimport compiler from 'livescript-compiler'
Quickstart
import compiler, { compile, SourceNode } from 'livescript-compiler';
import livescript from 'livescript'; // must be from GitHub master
const code = 'x = 1\ny = 2\nx + y';
const result = compile(code, { bare: true });
console.log(result.js); // compiled JavaScript
const node = new SourceNode(null, null, null, 'generated code');
console.log(node.toStringWithSourceMap());