Awesome
@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/compiler
Usage
- 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.js
Where 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_EXTENSION
environment variable as follows:
RIOT_COMPONENTS_FILE_EXTENSION=.html node --import ./register-riot.js your-program.js