{"id":25787,"library":"jinge-compiler","title":"jinge-compiler","description":"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.","status":"active","version":"4.1.9","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","jinge","compiler","swc","typescript"],"install":[{"cmd":"npm install jinge-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add jinge-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add jinge-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"core runtime required for compiled output","package":"jinge","optional":false},{"reason":"used for JavaScript/TypeScript parsing and code generation","package":"@swc/core","optional":false}],"imports":[{"note":"ESM-only; CJS require will cause runtime error. Since v4, ESM is the only supported module format.","wrong":"const { compile } = require('jinge-compiler')","symbol":"compile","correct":"import { compile } from 'jinge-compiler'"},{"note":"parse is a named export, not default. This has been consistent across versions.","wrong":"import parse from 'jinge-compiler'","symbol":"parse","correct":"import { parse } from 'jinge-compiler'"},{"note":"Default export is a function that compiles a single template. Do not use named default.","wrong":"import { default as compiler } from 'jinge-compiler'","symbol":"default","correct":"import compiler from 'jinge-compiler'"}],"quickstart":{"code":"import { compile } from 'jinge-compiler';\n\nconst code = compile(`<div>{{ message }}</div>`, {\n  filename: 'App.js',\n  sourceMap: false,\n  mode: 'module'\n});\nconsole.log(code);","lang":"typescript","description":"Demonstrates basic usage of the compile function with an inline template string, specifying filename and module mode."},"warnings":[{"fix":"Use import syntax. If you must use require, downgrade to v3.x or use dynamic import().","message":"In v4.0, the package switched from CommonJS to ESM only. require() calls will fail.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"For v1 usage, use: const compiler = require('jinge-compiler'); const result = compiler.compile(...); For v2+, use import { compile } from 'jinge-compiler'.","message":"The default export changed from a compiler instance to the compile function in v2.0.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Replace import { parse } from 'jinge-compiler' with compile(input, { output: 'ast' }).","message":"The `parse` function is deprecated as of v4.1.0; it will be removed in v5.0. Use `compile` with `output: 'ast'` instead.","severity":"deprecated","affected_versions":">=4.1.0 <5.0.0"},{"fix":"Always normalize paths with path.posix.join() or replace backslashes with forward slashes.","message":"File paths in the `filename` option must use forward slashes on Windows, otherwise source maps may break.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Upgrade Node to at least v14.0.0.","message":"The compiler requires Node.js >= 14.0.0. Older Node versions will throw a syntax error on import.","severity":"gotcha","affected_versions":">=4.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Add \"type\": \"module\" to package.json, or rename file to .mjs, or use dynamic import() inside a CommonJS module.","cause":"Using ESM imports in a CommonJS file (e.g., .js with require or no type: module).","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"Use import { compile } from 'jinge-compiler' or downgrade to v3.x.","cause":"Using require('jinge-compiler').compile when the package is ESM-only (v4+).","error":"Error: Module \"jinge-compiler\" does not provide a named export \"compile\""},{"fix":"Check your jinge-compiler version. For v2+, use import compiler from 'jinge-compiler' (default is compile). For v1, use 'jinge-compiler/compiler'.","cause":"Assuming the default export is a function, but using import compiler from 'jinge-compiler' is correct for v2+ but not for v1.","error":"TypeError: compiler.default is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}