C-Preprocessor icon indicating copy to clipboard operation
C-Preprocessor copied to clipboard

Add support for source maps

Open paulmedynski opened this issue 6 years ago • 0 comments

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:

  1. Write some TypeScript code in several files.
  2. Run build: a) Strip some code with c-preprocessor. b) Compile post-processed code. c) Package everything into a single file.
  3. Run tests and errors occur on line X of package file.
  4. 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.

paulmedynski avatar Feb 08 '19 00:02 paulmedynski