Is your enhancement related to a problem? Please describe
The published npm package @eclipse-che/license-tool ships the entire src/ directory alongside dist/, inflating the tarball unnecessarily.
The root cause: the webpack build uses transpileOnly: true in ts-loader, so no .d.ts declaration files are emitted into dist/. The "types": "dist/index.d.ts" field in package.json points to a file that does not exist. Including src/ in the files array is a workaround to give TypeScript consumers access to type information via source files.
Current state:
package.json declares "types": "dist/index.d.ts" — this file does not exist
package.json "files" includes "src" — ships raw TypeScript source to compensate
- TypeScript consumers cannot get proper type-checking from
dist/
Describe the solution you'd like
Generate .d.ts declaration files during the build and remove src/ from the published package.
Implementation
- Add a
postbuild step to emit declarations:
"postbuild": "tsc --emitDeclarationOnly --outDir dist && chmod +x dist/cli.js"
- Remove
src from the files array:
- Verify that
dist/index.d.ts is generated after npm run build.
Expected result
dist/index.d.ts exists and provides correct type information for library consumers
src/ is no longer shipped in the npm tarball
- Package size is reduced
"types": "dist/index.d.ts" in package.json resolves correctly
Describe alternatives you've considered
- Keep shipping
src/ — works but inflates the tarball and is non-standard
- Use
tsc instead of webpack — would generate declarations natively, but loses webpack bundling benefits (tree-shaking, single-file output, banner plugin for CLI shebang)
Additional context
Found during CHE-23756 PR review.
Is your enhancement related to a problem? Please describe
The published npm package
@eclipse-che/license-toolships the entiresrc/directory alongsidedist/, inflating the tarball unnecessarily.The root cause: the webpack build uses
transpileOnly: trueints-loader, so no.d.tsdeclaration files are emitted intodist/. The"types": "dist/index.d.ts"field inpackage.jsonpoints to a file that does not exist. Includingsrc/in thefilesarray is a workaround to give TypeScript consumers access to type information via source files.Current state:
package.jsondeclares"types": "dist/index.d.ts"— this file does not existpackage.json"files"includes"src"— ships raw TypeScript source to compensatedist/Describe the solution you'd like
Generate
.d.tsdeclaration files during the build and removesrc/from the published package.Implementation
postbuildstep to emit declarations:srcfrom thefilesarray:dist/index.d.tsis generated afternpm run build.Expected result
dist/index.d.tsexists and provides correct type information for library consumerssrc/is no longer shipped in the npm tarball"types": "dist/index.d.ts"inpackage.jsonresolves correctlyDescribe alternatives you've considered
src/— works but inflates the tarball and is non-standardtscinstead of webpack — would generate declarations natively, but loses webpack bundling benefits (tree-shaking, single-file output, banner plugin for CLI shebang)Additional context
Found during CHE-23756 PR review.