mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 18:20:51 +00:00
This is a roundabout way to say that this addresses the last comment on #23, namely if you only use the `console` submodule from `web_sys` it doesn't actually link correctly! The problem here has to do with codegen units and the compiler. The compiler will create a codegen unit for each `mod` in the source code. If a codegen unit isn't actually used, then the codegen unit is removed from the final link step. This causes problems for web-sys where the JSON description of our program was part of the main CGU but not in each submodule, so when submodules were only used the descriptor program in the main CGU was not included. The fix in this commit is to instead generate a descriptor program in the submodule itself instead of leaving it in the main CGU. By removing the `Module` node in the AST this naturally happens as the descriptor is only generated in the same module as all other associated items.