-
Notifications
You must be signed in to change notification settings - Fork 0
/
bin.js
43 lines (37 loc) · 847 Bytes
/
bin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env node
// @ts-check
'use strict';
const { transformSync } = require('@swc/core');
const { sync: findUp } = require('find-up');
const debug = require('debug')('foobar');
const { dirname, join, relative } = require('path');
const { addHook } = require('pirates');
const { install } = require('source-map-support');
const rootDir = dirname(findUp('yarn.lock'));
install({
environment: 'node',
hookRequire: true,
});
addHook(
(source, filename) => {
if (debug.enabled) {
debug('transpiling %s', relative(rootDir, filename));
}
return transformSync(source, {
filename,
jsc: {
parser: {
syntax: 'typescript',
},
},
module: {
type: 'commonjs',
},
sourceMaps: 'inline',
}).code;
},
{
exts: ['.ts'],
}
);
require('./src/index');