It is my understanding by the following documentation that the Browser Context should be able to import Node built-in modules via ESM according to: https://docs.nwjs.io/References/Command%20Line%20Options/#-enable-featuresnwesm
#7639 There is lengthy discussion with Roger Wang's resulting fix and instructions to use
"chromium-args": "--enable-features=NWESM,NWChainImportNode"
#8229 was closed after stating that NW.js does not support importing Node ESM modules. However, this was prior to the fix. The minimum script below illustrates the issue and I have tried it on linux, windows, with several versions from 0.102.1 to 0.108.0.
<script>
nw.Window.get().showDevTools();
const path = require('path');
console.log('path:', path);
</script>
<script type="module">
import path from "path"
//import path from "node:path"
console.log('path:', path);
</script>
Please let me know if you have insight or if you can adjust the provided minimum sample files to illustrate how to make it work. Importing only from node-main scripts is not an option for our project.
index.html
package.json
README.txt
Thanks!
It is my understanding by the following documentation that the Browser Context should be able to import Node built-in modules via ESM according to: https://docs.nwjs.io/References/Command%20Line%20Options/#-enable-featuresnwesm
#7639 There is lengthy discussion with Roger Wang's resulting fix and instructions to use
"chromium-args": "--enable-features=NWESM,NWChainImportNode"
#8229 was closed after stating that NW.js does not support importing Node ESM modules. However, this was prior to the fix. The minimum script below illustrates the issue and I have tried it on linux, windows, with several versions from 0.102.1 to 0.108.0.
<script> nw.Window.get().showDevTools(); const path = require('path'); console.log('path:', path); </script>Please let me know if you have insight or if you can adjust the provided minimum sample files to illustrate how to make it work. Importing only from node-main scripts is not an option for our project.
index.html
package.json
README.txt
Thanks!