Draft: fix inconsistent bits/flags between emsdk and nodejs
This fixes #23777 by getting constants from the C compiler and converting the bit flag in stat.st_mode
to the emsdk values before returning it to Haskell.
TODO: Review the code that accesses these constants, in particular from Haskell. Special treatment for the JS backend may not be necessary.
TODO: Check for other places that use constants in JS files in this way.