I noticed some TypeScript node modules (e.g loopback-next/packages) publish their source files with the node module. Is there a particular reason for this or is it just unnecessarily increasing the size of the module?
To start with a credible source: TypeScript Publishing guide only considers bundling of declaration files with the compiled .js
files, no inclusion of .ts
files.
Being no contributor, I could imagine two reasons for package @loopback/authentication
:
- Source Maps and debugging support (most likely)
- usage as some kind of source package 1
1. Source Maps and debugging support
The package authors might include source maps for debugging support, which reference/map to original .ts
files in src
. That way, those original sources need to be also distributed. E.g. authentication.component.js.map
:
"sources": ["../src/authentication.component.ts"],
Side note: The sourcemap "spec" would also provide a sourcesContent
field to support self contained source maps.
2. Source package
As an alternative to precompiled files, the package offers to be not opinionated concerning the build target. So a client app project can make use of its bundler and transpile the library in a specific target format itself. For example, if you support a) Electron and b) a wide variety of browsers, you don't need extra polyfills and transformations for the Electron renderer build.
1 RFC: Source Packages #4092 ; see also 2, 3 (React biased)
© 2022 - 2024 — McMap. All rights reserved.
package.json
file. For example here. This can be verified by installing the module or by runningnpm pack
in the directory to see what will be published. – Musaloopback-next
package where they are not included. For@loopback/authentication
you indeed find asrc
folder with .ts files. – Orthogenic