-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Embed source files in source map file #22189
Description
I want to generate a source map when compiling my C code that includes all the source files in the source map file itself instead of having to serve all the source code files alongside the source map file. This can be done by adding a sourcesContent key to the source map file. Otherwise I would have to upload 93 C files to npm with my JavaScript library.
wasm-sourcemap.py includes support for doing this already with the --sources argument
emscripten/tools/wasm-sourcemap.py
Line 37 in b3c2567
| parser.add_argument('-s', '--sources', action='store_true', help='read and embed source files from file system into source map') |
but there's no way to pass that argument from the emcc command
Lines 1107 to 1111 in b3c2567
| sourcemap_cmd = [sys.executable, '-E', path_from_root('tools/wasm-sourcemap.py'), | |
| wasm_file, | |
| '--dwarfdump=' + LLVM_DWARFDUMP, | |
| '-o', map_file, | |
| '--basepath=' + base_path] |
This could be a -ginline-source-map option or -gsource-map -s INLINE_SOURCE_MAP, which would match TypeScript's --inlineSourceMap. Though I expected this to be the default behavior. Serving C files over HTTP is weird.
My use case is that I have an npm package compiled with Emscripten and my source map requires files from ../../../../../../../opt/homebrew/Cellar/emscripten/3.1.61/libexec/system/lib/ and I have no idea how I could put that path in my npm module tree-sitter/tree-sitter#3381