https://github.com/riot/register
Allow the .riot files importing in node
https://github.com/riot/register
Last synced: 11 months ago
JSON representation
Allow the .riot files importing in node
- Host: GitHub
- URL: https://github.com/riot/register
- Owner: riot
- License: mit
- Created: 2020-12-21T10:06:37.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-04-26T22:47:50.000Z (over 1 year ago)
- Last Synced: 2025-01-08T04:13:16.787Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 329 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @riotjs/register
Allow the import of `.riot` files importing in node.
**Note**: you can't import directly `.riot` files in [deno](https://github.com/denoland/deno/issues/1739) yet.
In that case you will need to compile your tags first
[![Build Status][ci-image]][ci-url]
[![NPM version][npm-version-image]][npm-url]
[![NPM downloads][npm-downloads-image]][npm-url]
[![MIT License][license-image]][license-url]
## Installation
```
npm i @riotjs/register @riotjs/compiler
```
## Usage
1. Create a module loader file as follows:
```js
import { pathToFileURL } from 'node:url'
import { register } from 'node:module'
register('@riotjs/register', pathToFileURL('./'))
```
2. Require the code above by running node as follows:
```shell
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`](https://nodejs.org/api/packages.html#packagejson-and-file-extensions) 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:
```shell
RIOT_COMPONENTS_FILE_EXTENSION=.html node --import ./register-riot.js your-program.js
```
[ci-image]: https://img.shields.io/github/actions/workflow/status/riot/register/test.yml?style=flat-square
[ci-url]: https://github.com/riot/register/actions
[license-image]: http://img.shields.io/badge/license-MIT-000000.svg?style=flat-square
[license-url]: LICENSE
[npm-version-image]: http://img.shields.io/npm/v/@riotjs/register.svg?style=flat-square
[npm-downloads-image]: http://img.shields.io/npm/dm/@riotjs/register.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@riotjs/register