@riotjs/register
v10.0.0
Published
Allow .riot file importing in node
Downloads
291
Readme
@riotjs/register
Allow the import of .riot files importing in node.
Note: you can't import directly .riot files in deno yet.
In that case you will need to compile your tags first
Installation
npm i @riotjs/register @riotjs/compilerUsage
- Create a module loader file as follows:
import { pathToFileURL } from 'node:url'
import { register } from 'node:module'
register('@riotjs/register', pathToFileURL('./'))- Require the code above by running node as follows:
node --import ./register-riot.js your-program.jsWhere register-riot.js is the file where you have pasted the module loader example described above.
This loader supports only type=module projects.
Custom file extensions
To use custom file extensions (instead of .riot) for your Riot.js components
you need to set the RIOT_COMPONENTS_FILE_EXTENSIONenvironment variable as follows:
RIOT_COMPONENTS_FILE_EXTENSION=.html node --import ./register-riot.js your-program.js