When including Typescript, the generated source map for each file maps it the file to input.ts. This causes problems with breakpoints, as well as logging locations. Additionally, during loading in the Chrome debugger, you can sometimes see all Typescript files flash as input.ts.
$ npx create-vite-app
$ npm i
$ echo "console.log('test')" > test.ts
$ echo "import './test'" >> main.js
$ npm run dev
```sh
$ curl 'http://localhost:3000/test.ts'
console.log("test");
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiL2lucHV0LnRzIl0sCiAgInNvdXJjZXNDb250ZW50IjogWyJjb25zb2xlLmxvZygndGVzdCcpXG4iXSwKICAibWFwcGluZ3MiOiAiQUFBQSxRQUFRLElBQUk7IiwKICAibmFtZXMiOiBbXQp9Cg==
The sourcemap decodes to:
```json
{
"version": 3,
"sources": ["/input.ts"],
"sourcesContent": ["console.log('test')\n"],
"mappings": "AAAA,QAAQ,IAAI;",
"names": []
}
vite version: 0.14.4, 0.10.xvue version: 3.0.0-beta.10@vue/compiler-sfc version: 3.0.0-beta.10This is an issue with esbuild鈥檚 transform API. It currently doesn鈥檛 accept option to specify the file name for the source map.
I suspected that, seeing input.ts come back in a different issue, but I couldn't definitely relate it to this. Might be good to document that this is defunct for the time being.
The newest release of esbuild has an option for this called sourcefile. Please let me know if you have any trouble using it.
@evanw working nicely now! @Dykam thanks for the PR.
Most helpful comment
@evanw working nicely now! @Dykam thanks for the PR.