Typescript issue
dcworldwide opened this issue · comments
Ran webpack --json | webpack-bundle-size-analyzer
Returns error
undefined:2
ts-loader: Using typescript@2.1.4 and /Users/projects/am/am-web/tsconfig.json
^
SyntaxError: Unexpected token t in JSON at position 1857
at JSON.parse (<anonymous>)
at printStats (/usr/local/lib/node_modules/webpack-bundle-size-analyzer/build/src/cli.js:6:28)
at Socket.<anonymous> (/usr/local/lib/node_modules/webpack-bundle-size-analyzer/build/src/cli.js:27:50)
at emitNone (events.js:91:20)
at Socket.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
I am experiencing the same issue here and also using typescript.
My issue is because my json output has debug info printed in the header ... I don't think it relates to the tool.
If webpack writes non-JSON output to stdout when run with the --json
argument that seems like a bug in Webpack or the loader rather than this tool.
However, I think webpack-bundle-size-analyzer could at least display a more helpful message if this happens.
Is anyone got it working with typescript?
@tedwong - Have a look at the documentation for the log options in ts-loader: https://github.com/TypeStrong/ts-loader/blob/f67ec463594b4eec68a070196fb8a38ca6f46c3b/README.md#loginfotostdout-boolean-defaultfalse
Specifically, make sure that ts-loader is not logging lines to stdout, as this will make the output of webpack --json
not valid JSON.
If you are doing a one-off examination of the bundle, you could just run webpack --json
and remove offending output before feeding the result into this tool.