Skip to content

chore: add prepublishOnly hook so dist/ is always built before publish - #96

Open
Shawnchee wants to merge 1 commit into
jup-ag:mainfrom
Shawnchee:fix/prevent-empty-publish
Open

chore: add prepublishOnly hook so dist/ is always built before publish#96
Shawnchee wants to merge 1 commit into
jup-ag:mainfrom
Shawnchee:fix/prevent-empty-publish

Conversation

@Shawnchee

Copy link
Copy Markdown

Problem

The published package is entirely dist/main, module, and typings all resolve there and files is ["dist"]. But dist/ is gitignored and only produced by a manual npm run build (a step in PUBLISH.md). Nothing enforces that build, so a publish from a clean checkout / one where the build step is skipped / ships a package with no code

Change

"build": "npm run openapi-gen && npm run bundle",
"bundle": "tsup src/index.ts --dts --format esm,cjs",
"prepublishOnly": "npm run bundle",

prepublishOnly runs automatically before npm publish/pnpm publish, so dist/ is always built and packed

Design notes

  • prepublishOnly, not prepareprepare also runs on every npm install, pushing the build toolchain onto consumers/contributors; prepublishOnly runs only at publish time
  • The hook runs bundle (tsup), not the full buildgenerated/ is committed, so dist/ builds without invoking openapi-gen (which needs Java) and without regenerating tracked sources at publish time. bundle is factored out of build so the tsup command isn't duplicated
  • No change for consumers or npm install; build behaves exactly as before

dist/ is gitignored and built manually, so a forgotten build before npm publish would ship an empty package. Build it automatically via a
Java-free bundle step on publish

@Trustinbtc999-hue Trustinbtc999-hue left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add

@Trustinbtc999-hue Trustinbtc999-hue left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add

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