Accessing sources from npm package
See original GitHub issueHello!
I have a project in which I use typedi through npm. The npm-package includes source-map files for all .js files. However, those source maps reference original files like this: ../../src/Container.ts, so this path leads outside of node_modules directory and points to non-existent source files.
I’m using source-map-support module to make stack traces more readable, but the source maps of typedi make reported paths weird. It tries to resolve them to files in my project. This complicates debugging.
Actually, I would love those stack traces to be resolved back to original TypeScript files, but sadly the npm-package doesn’t contain source files at all. If source files were present it would allow to much easier trace and resolve errors in projects and even to use debugger to dive into internals of typedi when used with the real project (this really helps with integration).
So, I think there could be two courses of action:
1). Add source .ts files to the npm-package.
2). Remove source maps from npm package because they point to inexistent files.
Does it makes sense?
Thank you.
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (8 by maintainers)

Top Related StackOverflow Question
Why don’t you want to treat TypeScript files as a first class citizens? We are developing a TypeScript modules are we not? The generated
.jsfiles should be actually treated like secondary ones and only for the sake of users who don’t want to compile them themselves.I totally agree with you, but I’ve never proposed to ship them instead of
.js, I’m proposing to ship them as a main code and ship generated.jsadditionally to.tsfor better compatibility with native (vanilla) JavaScript projects. So thepackage = TS [+ JS].It’s really nice to have source files inside
node_modules, because when error happens, or when you debugging things interactively with IDE you can just click on a stack trace and navigate around the call stack. This is invaluable when integrating project with third-party dependencies. And I truly believe that this must be an integral part of great developer experience. For examplereflect-metadatamodule contains source files and it makes working with this module very convenient.It’s very helpful to see method or class implementation when you navigate around classes, but instead you have to see blunt typings. So in order to study internals of the
typediortypeormI have to open them in a separate window as a separate IDE project and to copy-paste class names or paths to files. This makes no sense at all.Could you elaborate on this please? What are the actual drawbacks?
How do you propose to fix them? The source maps only contain a reference to the original source file, which allows to resolve the actual place in it. If there is no source files in the package, then there is no sense for keeping the source maps, because it breaks the IDE (source-maps just point nowhere). It would be even better without source maps at all — at least you will be able to see the error in generated
.jsfiles instead of broken references.This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.