-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (19 loc) · 674 Bytes
/
index.js
File metadata and controls
27 lines (19 loc) · 674 Bytes
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
const fs = require('fs');
const execSync = require('child_process').execSync;
module.exports = function(content) {
this.cacheable && this.cacheable();
this.value = content;
const options = this.query;
const source = this.resourcePath;
const destination = this.resourcePath + '.wasm';
let compillerOptions;
if (options && options.compiller) {
compillerOptions = options.compiller;
} else {
compillerOptions = '-Os -s WASM=1 -s SIDE_MODULE=1';
}
const command = 'emcc ' + source + ' ' + compillerOptions + ' -o ' + destination;
const execEndCode = execSync(command);
return fs.readFileSync(destination);
}
module.exports.seperable = true;