Using TypeScript 2.9's resolveJsonModule feature has been successful when running the application with ts-node. However, upon transpiling the source files into the outdir, it also copies the JSON files into the outdir and includes a source map link to the type files within them, similar to this structure:
[
{
"scid": 59000000
},
{
"scid": 59000000
}
]
//# sourceMappingURL=roles.json.map
Upon running the transpiled javascript files, attempts to parse these JSON files result in SyntaxErrors due to an unexpected token pointing to the comment line:
internal/modules/cjs/loader.js:724
throw err;
^
SyntaxError: C:\Users\user\Documents\project\lib\assets\filename.json: Unexpected token / in JSON at position 22186
at JSON.parse (<anonymous>)
Post-transpilation project root structure:
- assets
- lib
- assets
- json-file.d.ts
- json-file.json
- src
- all transpiled js files and their d.ts files
- src
- all TypeScript source files tsconfig.json
Question:
Is there a way to utilize TypeScript 2.9's resolveJsonModule feature so that the transpiled JavaScript can successfully parse the JSON files (currently failing due to the comment line)?
Edit:
Attempts to exclude the assets folder from tsconfig.json's exclude property have proven ineffective. The full content of tsconfig.json can be found here: