forked from esmbly/esmbly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesmbly.config.js
34 lines (32 loc) · 887 Bytes
/
esmbly.config.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
const path = require('path');
const t = require('@babel/types');
const Flow = require('@esmbly/transformer-flow');
const Wasm = require('@esmbly/transformer-wasm');
const DefaultReturnTypeToNumber = (warnings) => ({
FunctionDeclaration(path) {
if (!path.node.returnType) {
warnings.push({
info: `Found function without return type, using number as default`,
loc: path.container.loc,
});
path.node.returnType = t.typeAnnotation(t.numberTypeAnnotation());
}
}
});
module.exports = {
input: ['./src/**/*.js'],
transformers: [
Flow.createTransformer({ customRules: { DefaultReturnTypeToNumber }}),
Wasm.createTransformer(),
],
output: [
{
format: '.ts',
outFile: path.join(__dirname, 'dist', 'add.ts'),
},
{
format: '.wasm',
outFile: path.join(__dirname, 'dist', 'add.wasm'),
},
],
};