Skip to content

Ship compiled dist/ so @thingweb/code-gen is consumable#80

Merged
egekorkan merged 1 commit into
eclipse-thingweb:mainfrom
bobur-khay:fix/code-gen-broken-npm-publish
Jul 7, 2026
Merged

Ship compiled dist/ so @thingweb/code-gen is consumable#80
egekorkan merged 1 commit into
eclipse-thingweb:mainfrom
bobur-khay:fix/code-gen-broken-npm-publish

Conversation

@bobur-khay

Copy link
Copy Markdown
Contributor

Problem

@thingweb/code-gen@1.0.0 (the only version on npm) is broken. Its package.json
declares "main": "dist/index.js", but the published tarball shipped only the
src/*.ts TypeScript sources — no compiled dist/. Consumers (bundlers like
webpack, or node/import) fail to resolve the package:

Module not found: Error: Can't resolve '@thingweb/code-gen'
node_modules/@thingweb/code-gen doesn't exist (main -> dist/index.js missing)

Root cause: published without a build step and without a files allow-list /
prepack hook to guarantee dist/ is compiled and included.

Changes

  • package.json
    • Added "prepack": "npm run build" so dist/ is always built before pack/publish.
    • Added "files": ["dist", "README.md", "LICENSE"] allow-list (overrides the
      .gitignore dist exclusion for the tarball; keeps src//tests out).
    • Added "types": "dist/index.d.ts" and a modern exports map (types + import).
    • Changed build to tsc -p tsconfig.build.json.
    • Added a bin entry (code-gendist/cli.js), kept out of the library exports.
    • Bumped version 1.0.01.0.1.
  • tsconfig.build.json (new): extends tsconfig.json and excludes src/tests/**
    so vitest test files are never compiled/shipped.
  • src/cli.ts: added #!/usr/bin/env node shebang so the bin is executable.

Release note

Publish 1.0.1 after merge to replace the broken 1.0.0 on npm.

@egekorkan egekorkan merged commit 651835c into eclipse-thingweb:main Jul 7, 2026
4 checks passed
@egekorkan

Copy link
Copy Markdown
Member

published 1.0.1 . Good catch...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants