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
:
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.
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)