+const fs = require('fs');
const wrt = require('../../browser/wrt');
+async function compileWasmForCaching(file_path) {
+ console.log(`Requesting WASM compilation for building a cache, file_path:(${file_path})`);
+ try {
+ let source = fs.readFileSync(file_path);
+ let file = new Uint8Array(source);
+ await WebAssembly.compile(file);
+ } catch (e) {
+ console.error(`An error occurred while compiling a wasm module. error:(${e})`);
+ }
+}
+
function run(app_id) {
- console.log('wasm_builder.js start');
- // sample
- /*
- let files = wrt.tv.enumerateWasmFiles(app_id);
+ console.log(`wasm_builder.js starts, app_id:(${app_id})`);
+ wrt.tv.setDiskCache(app_id);
+ let files = wrt.tv.getWasmFiles(app_id);
+ console.log(files);
files.forEach((file_path) => {
- console.log(`file_path: ${file_path}`);
- require(`${file_path}`);
+ compileWasmForCaching(file_path);
});
- */
}
module.exports = {
- run
-}
\ No newline at end of file
+ run
+}