parcoursup/node_modules/@riotjs/register/register.js

42 lines
847 B
JavaScript
Raw Normal View History

2023-03-05 13:23:23 +01:00
'use strict';
var pirates = require('pirates');
var compiler = require('@riotjs/compiler');
var core = require('@babel/core');
function compile(source, filename) {
const { code } = compiler.compile(source, { file: filename });
return core.transform(code, {
presets: [
[
'@babel/preset-env',
{
modules: 'cjs',
targets: {
node: process.versions.node
}
}
]
]
}).code
}
// returns the teardown function
function register(options) {
return pirates.addHook(compile,
{
exts: ['.riot'],
ignoreNodeModules: false,
...options
}
)
}
// autoregister the .riot file import if this file gets required without any explicit require call
if (typeof module !== 'undefined' && !module.parent) {
register();
}
module.exports = register;