Skip to content

chore: packaging for release#11

Merged
davideast merged 5 commits into
mainfrom
chore/pkging
Apr 21, 2026
Merged

chore: packaging for release#11
davideast merged 5 commits into
mainfrom
chore/pkging

Conversation

@davideast

Copy link
Copy Markdown
Collaborator

Harden @google/design.md for npm publish.

  • Remove production debug logging. loadSpecConfig() wrote to stdout/stderr, corrupting JSON output for agent consumers.
  • Lazy-load config singleton. getSpecConfig() replaces the module-level loadSpecConfig() call that crashed on import if the YAML was missing.
  • engines field. node >= 22.
  • prepublishOnly script. Enforces bun run build before every publish.
  • Node.js smoke test in CI. Runs node dist/index.js lint after build.
  • Remove unused TUI deps. react, ink, @json-render/core, @json-render/ink removed from dependencies.
  • Dynamic version. New src/version.ts reads ../package.json via import.meta.url. Stable across source, bundle, npm install, and npx contexts.
  • Simplify spec.md resolution. 5 shotgun candidate paths → 2 deterministic strategies (bundle + dev), plus an explicit specPath override.
  • designmd bin alias. Windows cmd.exe confuses .md extension with file associations.
  • Move 9 build-only deps to devDependencies (keep zod for type compat). Bundle has zero runtime require() calls to npm packages.
  • Add ./package.json to exports map (prevents ERR_PACKAGE_PATH_NOT_EXPORTED).
  • Remove stale @types/react.
  • Add tarball smoke test to CI: pack → install in /tmp → run CLI + programmatic import.

Test coverage

9 new tests across 3 files.

File Tests added
spec-config.test.ts no-stdout-pollution, lazy-load validity, cache identity
version.test.ts matches package.json, valid semver, not fallback
spec-helpers.test.ts consistency, content length, explicit path contract

Tarball

309 kB packed / 1.5 MB unpacked / 47 files

- Remove console.log/console.error from loadSpecConfig() that corrupted
  stdout JSON output for CLI and programmatic consumers
- Introduce getSpecConfig() lazy singleton to cache YAML file reads
- Add 3 new tests: no-stdout-pollution, lazy-load validity, cache identity

Fixes Critical Blockers #1 and #2 from pre-publish analysis.
- Add engines field to package.json (node >= 18)
- Add prepublishOnly script to enforce build before publish
- Add Node.js smoke test to CI workflow
- Clean up unused SPEC_VERSION import in test
Version:
- Create src/version.ts that reads ../package.json using import.meta.url
- Path is stable across source, bundle, installed, and npx contexts
  because npm always includes package.json in the published tarball
- Replace hardcoded '0.1.0' in index.ts with dynamic VERSION import
- Add 3 tests: matches package.json, valid semver, not fallback

spec.md path resolution:
- Reduce 5 shotgun candidate paths to 2 deterministic strategies:
  1. Bundle path: ./spec.md (build copies it alongside entry points)
  2. Dev path: ../../../../../docs/spec.md (relative to source)
- Add explicit specPath parameter for callers who know the path
- Update build script to copy spec.md to both dist/ and dist/linter/
- Add 3 tests: consistency, content length, explicit path contract
1. Move build-only deps to devDependencies (keep zod for type compat)
   - citty, mdast, remark-*, unified, unist-util-visit, yaml all bundled
   - Zero runtime require() calls to any npm dependency
2. Add 'designmd' bin alias for Windows shell compatibility
   - cmd.exe confuses .md extension with file association
3. Add ./package.json to exports map
   - Prevents ERR_PACKAGE_PATH_NOT_EXPORTED in strict ESM bundlers
4. Remove stale @types/react from devDependencies
5. Add tarball smoke test to CI workflow
   - Packs, installs in clean dir, runs CLI + programmatic import
   - Catches 'works in monorepo, breaks when installed' bugs
@davideast davideast merged commit 7eec9e0 into main Apr 21, 2026
7 checks passed
@davideast davideast deleted the chore/pkging branch April 21, 2026 15:52
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.

1 participant