jinge-compiler
raw JSON → 4.1.9 verified Fri May 01 auth: no javascript
A Rust-based template compiler for the jinge web framework, currently at version 4.1.9. It uses SWC under the hood to transform jinge templates into optimized JavaScript/TypeScript code. The compiler is distributed as an npm package and supports modern JavaScript features, TypeScript, and reactive template compilation. It is actively maintained with occasional releases as the jinge framework evolves. Key differentiators: written in Rust for performance, tightly integrated with the jinge reactive system, and provides compile-time optimizations like watch/listener generation for nested properties.
Common errors
error SyntaxError: Cannot use import statement outside a module ↓
cause Using ESM imports in a CommonJS file (e.g., .js with require or no type: module).
fix
Add "type": "module" to package.json, or rename file to .mjs, or use dynamic import() inside a CommonJS module.
error Error: Module "jinge-compiler" does not provide a named export "compile" ↓
cause Using require('jinge-compiler').compile when the package is ESM-only (v4+).
fix
Use import { compile } from 'jinge-compiler' or downgrade to v3.x.
error TypeError: compiler.default is not a function ↓
cause Assuming the default export is a function, but using import compiler from 'jinge-compiler' is correct for v2+ but not for v1.
fix
Check your jinge-compiler version. For v2+, use import compiler from 'jinge-compiler' (default is compile). For v1, use 'jinge-compiler/compiler'.
Warnings
breaking In v4.0, the package switched from CommonJS to ESM only. require() calls will fail. ↓
fix Use import syntax. If you must use require, downgrade to v3.x or use dynamic import().
breaking The default export changed from a compiler instance to the compile function in v2.0. ↓
fix For v1 usage, use: const compiler = require('jinge-compiler'); const result = compiler.compile(...); For v2+, use import { compile } from 'jinge-compiler'.
deprecated The `parse` function is deprecated as of v4.1.0; it will be removed in v5.0. Use `compile` with `output: 'ast'` instead. ↓
fix Replace import { parse } from 'jinge-compiler' with compile(input, { output: 'ast' }).
gotcha File paths in the `filename` option must use forward slashes on Windows, otherwise source maps may break. ↓
fix Always normalize paths with path.posix.join() or replace backslashes with forward slashes.
gotcha The compiler requires Node.js >= 14.0.0. Older Node versions will throw a syntax error on import. ↓
fix Upgrade Node to at least v14.0.0.
Install
npm install jinge-compiler yarn add jinge-compiler pnpm add jinge-compiler Imports
- compile wrong
const { compile } = require('jinge-compiler')correctimport { compile } from 'jinge-compiler' - parse wrong
import parse from 'jinge-compiler'correctimport { parse } from 'jinge-compiler' - default wrong
import { default as compiler } from 'jinge-compiler'correctimport compiler from 'jinge-compiler'
Quickstart
import { compile } from 'jinge-compiler';
const code = compile(`<div>{{ message }}</div>`, {
filename: 'App.js',
sourceMap: false,
mode: 'module'
});
console.log(code);