aurelia: Webpack typescript setup doesn't generate correct souremap
๐ Bug Report
The source map for .ts file is not against original user source file, but a modified source file done by @aurelia/webpack-loader.
๐ค Expected Behavior
It should display original source in debugger.
๐ฏ Current Behavior
Our webpack-loader did generate the initial source map https://github.com/aurelia/aurelia/blob/1bdb122cd1af090b298c934325d917b9bd494949/packages/webpack-loader/src/index.ts#L34, but the ts-loader ignored incoming source map. This is a well known issue in ts-loader since 2017. https://github.com/TypeStrong/ts-loader/issues/552
๐ Possible Solution
Not sure what can be done, as ts-loader assumes itโs the first loader in the chain.
For reference, ts-loader only reads file contents but not the existing source map. https://github.com/TypeStrong/ts-loader/blob/172ebeb10cc8d15b91eca0828943bf7b962b4366/src/index.ts#L35
๐ฆ Context
In our webpack-loader, the incoming sourcemap is ignored but thatโs fine, because our loader is the first to be run in the loader chain. The problem is that ts-loader assumes itโs the first loader too. In comparison, webpack+babel does give you correct source map.
๐ป Code Sample
๐ Your Environment
| Software | Version(s) |
|---|---|
| Aurelia | |
| Language | |
| Browser | |
| Bundler | |
| Operating System | |
| NPM/Node/Yarn |
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (16 by maintainers)
Commits related to this issue
- fix(webpack): better dev mode source map Thx @josundt, related to aurelia/aurelia#1052 — committed to aurelia/new by 3cp 6 years ago
I packed a
ts-loaderwith support for source map mapping. If you want to try:npm install --save-dev @bojanv55/ts-loaderand then in webpack config:
I had this problem myself after testing out a TypeScript/Webpack project created using today with latest version of
npx makes aurelia. All breakpoints were gray (not effective) in VSCode when debugging using โDebugger for Chromeโ extension.After setting the
sourceMapproperty in the scaffolded tsconfig.json:โฆI was able to set breakpoints that were active (red), but the breakpoints positions act weird - I guess that indicates that lines and character positions are off in the source maps.
I then changed the
devtoolproperty in webpack.config.js frominline-source-maptoeval-cheap-source-map. Now everything works as expected.I guess these things should be updated in the code scaffolding for
makeswith WebPack/TypeScript