Skip to content

Latest commit

 

History

History
56 lines (38 loc) · 1.77 KB

README.md

File metadata and controls

56 lines (38 loc) · 1.77 KB

@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

Build Status

NPM version NPM downloads MIT License

Installation

npm i @riotjs/register @riotjs/compiler

Usage

  1. Create a module loader file as follows:
import { pathToFileURL } from 'node:url'
import { register } from 'node:module'

register('@riotjs/register', pathToFileURL('./'))
  1. 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_EXTENSIONenvironment variable as follows:

RIOT_COMPONENTS_FILE_EXTENSION=.html node --import ./register-riot.js your-program.js