Skip to content

Some doubts about NWESM #8268

Open
Open
@ssnangua

Description

@ssnangua

OS: win32 x64 10.0.19045
NW: 0.99.1

Q1

What does the NWESM switch do? The new version of NW.js seems to be able to load ES modules in Node context without enabling NWESM:

package.json:

{
  "name": "nwesm-test",
  "main": "main.js"
}

main.js:

const testMJS = require("./test.mjs");
console.log(testMJS);

nw.Window.open("./index.html");

test.mjs:

export default {
  test: "test",
};

Q2

DevTools crashes when NWChainImportNode is enabled

package.json:

{
  "name": "nwesm-test",
  "main": "index.html",
  "chromium-args": "--enable-features=NWESM,NWChainImportNode"
}

Q3

Loading ES module via import in node-main will cause an error:

package.json:

{
  "name": "nwesm-test",
  "main": "index.html",
  "node-main": "node-main.js"
}

node-main.js:

import testMJS from "./test.mjs";
console.log(testMJS);

Q4

Why not add type="module" when loading main and bg-script, so that we can use import in these two scripts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions