Registry / web-framework / jinge-compiler

jinge-compiler

JSON →
library4.1.9jsnpmunverified

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.

npm install jinge-compiler
INSTALL
IMPORT
SIG · JINGE-COMPILER
J
jinge-compiler
web-frameworkjavascriptv4.1.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

compile
import { compile } from 'jinge-compiler'
const { compile } = require('jinge-compiler')
ESM-only; CJS require will cause runtime error. Since v4, ESM is the only supported module format.
parse
import { parse } from 'jinge-compiler'
import parse from 'jinge-compiler'
parse is a named export, not default. This has been consistent across versions.
default
import compiler from 'jinge-compiler'
import { default as compiler } from 'jinge-compiler'
Default export is a function that compiles a single template. Do not use named default.

Demonstrates basic usage of the compile function with an inline template string, specifying filename and module mode.

import { compile } from 'jinge-compiler'; const code = compile(`<div>{{ message }}</div>`, { filename: 'App.js', sourceMap: false, mode: 'module' }); console.log(code);
Debug
Known issues
breakingIn 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().
affects: >=4.0.0
breakingThe 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'.
affects: >=2.0.0
deprecatedThe `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' }).
affects: >=4.1.0 <5.0.0
gotchaFile 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.
affects: >=4.0.0
gotchaThe 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.
affects: >=4.0.0
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
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: Module "jinge-compiler" does not provide a named export "compile"
Using require('jinge-compiler').compile when the package is ESM-only (v4+).
fix
Use import { compile } from 'jinge-compiler' or downgrade to v3.x.
TypeError: compiler.default is not a function
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'.
Upgrade
Version history
4.1.9latest on npm
Audit
Dependencies
jingerequiredcore runtime required for compiled output
@swc/corerequiredused for JavaScript/TypeScript parsing and code generation
Agent activity
2 hits · last 30 days
node
2
Resources
jinge-compiler — npm install jinge-compiler · libregistry