Registry / web-framework / riot-compiler

riot-compiler

JSON →
library3.6.0jsnpmunverified

Compiler for Riot.js .tag files, transforming custom tag syntax (HTML + JavaScript) into standard JavaScript modules. Current stable version is 10.0.1 (2024), with major breaking changes in v10.0.0: dropped Node <22, switched from `assert` to `with` for JSON imports, and changed boolean attribute handling on root nodes. v9.x series is in maintenance. Key differentiator: tightly coupled to Riot.js library, designed specifically for Riot's tag-based component model. Release cadence: irregular, with major versions tied to Riot.js updates.

npm install riot-compiler
INSTALL
IMPORT
SIG · RIOT-COMPILER
R
riot-compiler
web-frameworkjavascriptv3.6.0
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 'riot-compiler'
const compile = require('riot-compiler').compile
ESM-only since v10.0.0; CommonJS not supported.
registerPreprocessor
import { registerPreprocessor } from 'riot-compiler'
import registerPreprocessor from 'riot-compiler'
Named export, not default.
RiotCompiler
import { RiotCompiler } from 'riot-compiler'
const RiotCompiler = require('riot-compiler')
Class export for programmatic use; ESM only since v10.

Compile a basic Riot.js .tag file with an ES module script tag.

import { compile } from 'riot-compiler'; const code = compile(`<my-tag>\n <p>{ message }</p>\n <script>\n export default {\n message: 'Hello'\n }\n </script>\n</my-tag>`); console.log(code);
riot --version
Debug
Known issues
breakingv10.0.0 drops support for Node.js <22 and removes CommonJS support.
fix
Update Node.js version to >=22; ensure imports use ESM syntax.
affects: >=10.0.0
breakingv10.0.0 changes boolean attribute handling on root nodes: attributes are no longer automatically set as properties.
fix
Review component templates: use explicit attribute bindings or update Riot.js to latest.
affects: >=10.0.0
breakingv10.0.0 switches JSON imports from 'assert' to 'with' syntax.
fix
Update JSON import statements: replace `assert { type: 'json' }` with `with { type: 'json' }`.
affects: >=10.0.0
deprecatedv9.x is no longer actively maintained; security patches only.
fix
Upgrade to v10.x for ongoing support.
affects: >=9.0.0 <10.0.0
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Trying to use ESM import in a CommonJS module without 'type': 'module' in package.json.
fix
Add "type": "module" to your package.json or rename file to .mjs.
Error: The 'assert' option is deprecated. Please use 'with' instead.
Using old JSON import syntax with 'assert' in Node >=22.
fix
Replace `assert { type: 'json' }` with `with { type: 'json' }`.
Upgrade
Version history
3.6.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
riot-compiler — npm install riot-compiler · libregistry