emscripten-core/emscripten

Faulty assertion in node on .mjs files

Open

#17,465 建立於 2022年7月18日

在 GitHub 查看
 (4 留言) (0 反應) (0 負責人)C++ (3,519 fork)batch import
JavaScriptgood first bughelp wanted

倉庫指標

Star
 (27,361 star)
PR 合併指標
 (平均合併 19天 10小時) (30 天內合併 147 個 PR)

描述

It turns out that node will disable the global require function on foo.mjs - that is just not defined there, unlike for foo.js. I guess mjs files are modules and require is not supposed to be used there. This ends up a problem for us since we have an assertion on it:

https://github.com/emscripten-core/emscripten/blob/a3d8979b38d2f655f59b040bfd32f562ebc92d03/src/shell.js#L196-L198

Removing that assertion is necessary to run an .mjs file in node with -sASSERTIONS.

We should probably just remove it?

This happens on binaryen CI which will manually builds an .mjs file by concatenating the emcc output with some extra code.

貢獻者指南