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

Source maps broken under Windows since 8.10.0 (ESM support) #1037

Closed
shunf4 opened this issue May 12, 2020 · 3 comments · Fixed by #1038 or SalesforceCommerceCloud/raml-toolkit#144
Closed
Labels

Comments

@shunf4
Copy link

shunf4 commented May 12, 2020

Expected Behavior

Source maps work under Windows 10 in 8.10.0 and later versions.

Actual Behavior

Source maps are broken under Windows 10 since 8.10.0 (ESM support). Under GNU/Linux it works well.

Steps to reproduce the problem

test.ts:

function main() {






  throw new Error("aaa")
  console.log(1)
  console.log(1)
  console.log(1)
  console.log(1)
  console.log(1)
  console.log(1)
}

main()

Running ts-node test.ts should always give output like this:

  throw new Error("aaa")
        ^
Error: aaa
    at main (C:\Users\User\Desktop\test.ts:8:9)
    at Object.<anonymous> (C:\Users\User\Desktop\test.ts:17:1)
    at Module._compile (internal/modules/cjs/loader.js:1176:30)
    at Module.m._compile (C:\Users\User\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:839:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
    at Object.require.extensions.<computed> [as .ts] (C:\Users\User\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:842:12)
    at Module.load (internal/modules/cjs/loader.js:1040:32)
    at Function.Module._load (internal/modules/cjs/loader.js:929:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at main (C:\Users\User\AppData\Roaming\npm\node_modules\ts-node\src\bin.ts:227:14)

When running under Windows 10, ts-node 8.10.0 and later give:

Error: aaa
    at main (C:\Users\User\Desktop\test.ts:2:11)
    at Object.<anonymous> (C:\Users\User\Desktop\test.ts:10:1)
    at Module._compile (internal/modules/cjs/loader.js:1176:30)
    at Module.m._compile (C:\Users\User\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:858:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
    at Object.require.extensions.<computed> [as .ts] (C:\Users\User\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:861:12)
    at Module.load (internal/modules/cjs/loader.js:1040:32)
    at Function.Module._load (internal/modules/cjs/loader.js:929:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at main (C:\Users\User\AppData\Roaming\npm\node_modules\ts-node\src\bin.ts:227:14)

The line number do not correspond to the .ts file. The source map is broken.

Minimal reproduction

See "Steps to reproduce the problem".

Specifications

  • ts-node version: v8.10.0 and later
  • node version: v12.13.0 and v14.2.0
  • TypeScript version: v3.8.3
  • tsconfig.json, if you're using one: None
  • Operating system and version: Windows 10 Version 1909 (OS Build 18363.752)
  • If Windows, are you using WSL or WSL2?: No
@cspotcode
Copy link
Collaborator

Thanks for the detailed report. I'm able to reproduce this and confirm it broke on ts-node 8.10. 8.9.1 still works.

@cspotcode
Copy link
Collaborator

Found the bug. We started normalizing to / path separators internally, but we are not doing that when looking up items in outputCache.

@cspotcode
Copy link
Collaborator

@shunf4 once the fix passes code review, I'll publish a new release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants