Skip to content

evalNWBinModule ERR_FILE_NOT_FOUND after import #8344

@Joe-Kerr

Description

@Joe-Kerr

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions