Skip to content

[license-tool] Generate .d.ts declaration files and remove src/ from published package #23809

@olexii4

Description

@olexii4

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

  1. Add a postbuild step to emit declarations:
"postbuild": "tsc --emitDeclarationOnly --outDir dist && chmod +x dist/cli.js"
  1. Remove src from the files array:
"files": [
  "dist"
],
  1. 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.

Metadata

Metadata

Assignees

Labels

area/dashboardkind/bugOutline of a bug - must adhere to the bug report template.kind/technical-debtTechnical debt issueseverity/P2Has a minor but important impact to the usage or development of the system.

Type

No type

Projects

Status

📋 Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions