Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All Typescript sourcemaps resolve to input.ts when running live #137

Closed
Dykam opened this issue May 14, 2020 · 4 comments · Fixed by #141
Closed

All Typescript sourcemaps resolve to input.ts when running live #137

Dykam opened this issue May 14, 2020 · 4 comments · Fixed by #141

Comments

@Dykam
Copy link
Contributor

Dykam commented May 14, 2020

Describe the bug

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.

Reproduction

$ npx create-vite-app
$ npm i
$ echo "console.log('test')" > test.ts
$ echo "import './test'" >> main.js
$ npm run dev
$ curl 'http://localhost:3000/test.ts'
> console.log("test");
> 
> 
> //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiL2lucHV0LnRzIl0sCiAgInNvdXJjZXNDb250ZW50IjogWyJjb25zb2xlLmxvZygndGVzdCcpXG4iXSwKICAibWFwcGluZ3MiOiAiQUFBQSxRQUFRLElBQUk7IiwKICAibmFtZXMiOiBbXQp9Cg==

The sourcemap decodes to:

{
  "version": 3,
  "sources": ["/input.ts"],
  "sourcesContent": ["console.log('test')\n"],
  "mappings": "AAAA,QAAQ,IAAI;",
  "names": []
}

System Info

  • required vite version: 0.14.4, 0.10.x
  • required Operating System: Ubuntu, Windows, WSL
  • required Node version: 12.11.1, 12.13.1
  • Optional:
    • npm/yarn version: 6.11.3, 6.14.5
    • Installed vue version: 3.0.0-beta.10
    • Installed @vue/compiler-sfc version: 3.0.0-beta.10
@Dykam Dykam added the bug label May 14, 2020
@yyx990803
Copy link
Member

yyx990803 commented May 14, 2020

This is an issue with esbuild’s transform API. It currently doesn’t accept option to specify the file name for the source map.

@Dykam
Copy link
Contributor Author

Dykam commented May 14, 2020

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.

@evanw
Copy link

evanw commented May 14, 2020

The newest release of esbuild has an option for this called sourcefile. Please let me know if you have any trouble using it.

@yyx990803
Copy link
Member

@evanw working nicely now! @Dykam thanks for the PR.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants