I have been trying to load a minimal module. According to the docs:
Load and execute the compiled binary for Modules in the frame. The binary should be compiled with nwjc --nw-module. The following code will load lib.bin as module and other modules can refer to it with something like import * from './lib.js':
But loading the module bin file fails (see below). Using a non-module file works.
//package.json
{
"name": "helloworld",
"main": "./game/index.html"
}
// nwjc ./game/file_in.js ./game/file_mod.bin --nw-module
export default function test() {
alert("Pass");
}
//---------------------------
// nwjc ./game/file_in_no_mod.js ./game/file.bin
alert("Pass");
<!-- index.html -->
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<script type="module">
//nw.Window.get().evalNWBin(null, './game/file.bin'); //works
nw.Window.get().evalNWBinModule(null, './game/file_mod.bin', 'lib.js'); //no errors
//nw.Window.get().evalNWBinModule(null, './game/file_mod.bin', './lib.js'); //no errors
import testFn from './lib.js'; //Failed to load resource: net::ERR_FILE_NOT_FOUND lib.js:1
testFn();
</script>
</head>
<body>
</body>
</html>
I have been trying to load a minimal module. According to the docs:
But loading the module bin file fails (see below). Using a non-module file works.