C-Preprocessor
C-Preprocessor copied to clipboard
Add support for source maps
Would you consider adding support for source maps? This would allow build tools that include a c-preprocessor step to accurately map line numbers back to the original source files during downstream compilation and unit testing. Imagine this flow:
- Write some TypeScript code in several files.
- Run build: a) Strip some code with c-preprocessor. b) Compile post-processed code. c) Package everything into a single file.
- Run tests and errors occur on line X of package file.
- Apply source map generated during #1 to map the errors back to source code lines in #0.
But the stripping in 1a) altered the source code, so the source maps generated by b) and c) don't line up with the originals.
For my purposes, having c-preprocessor take an existing source map as an additional arg to the processing step, and then altering it accordingly as it processes the contents, would be ideal.