Skip to content

Comments

fix: ensure dist folder is built before npm publish#39

Merged
zanussbaum merged 1 commit intomainfrom
fix/npm-publish-missing-dist
May 24, 2025
Merged

fix: ensure dist folder is built before npm publish#39
zanussbaum merged 1 commit intomainfrom
fix/npm-publish-missing-dist

Conversation

@zanussbaum
Copy link
Owner

Problem

The latest npm release (v1.0.12) is missing the dist folder, making the package unusable since the main entry point is dist/index.js. This happened because:

  1. The dist folder is in .gitignore (correctly)
  2. The release workflow publishes to npm without building the project first
  3. The package.json specifies "files": ["dist"] but the folder doesn't exist during publish

Solution

This PR adds two layers of protection:

  1. Build step in release workflow: Added npm run build step before publishing in .github/workflows/release-please.yml
  2. prepublishOnly script: Added "prepublishOnly": "npm run build" to package.json as a safety net

Testing

Tested with npm publish --dry-run which now correctly:

  • Runs the prepublishOnly script
  • Builds the dist folder
  • Includes all 66 files (82.2 kB unpacked) in the package

Impact

  • Fixes the broken v1.0.12 npm package
  • Prevents future releases from missing the dist folder
  • No breaking changes to existing functionality

- Add build step to release workflow before publishing
- Add prepublishOnly script as safety net to ensure build runs before any publish
- Fixes missing dist folder in npm package v1.0.12
@zanussbaum zanussbaum marked this pull request as ready for review May 24, 2025 01:32
@zanussbaum zanussbaum merged commit 2d18d4c into main May 24, 2025
2 checks passed
@zanussbaum zanussbaum deleted the fix/npm-publish-missing-dist branch May 24, 2025 01:33
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