Skip to content

Create a publish pipeline for @uncefact/untp-ri-services #403

@ashleythedeveloper

Description

@ashleythedeveloper

Problem

The services package (@uncefact/untp-ri-services) is published to npm manually. The exports field in package.json currently uses flat types/default conditions because the CJS build artefacts (.cjs, .d.cts) only exist during the manual publish process, not in the workspace.

The Next.js standalone output tracer (@vercel/nft) fails when exports reference non-existent files. This means we cannot use nested import/require conditions in the workspace package.json, as the .cjs and .d.cts files are only generated at publish time via esbuild.

Current Behaviour

Publishing requires manually modifying package.json (adding import/require conditions, adjusting version), running esbuild to generate CJS bundles, copying .d.ts.d.cts, publishing, then reverting.

Expected Behaviour

A CI pipeline that:

  1. Builds the ESM output (tsc)
  2. Generates CJS bundles via esbuild (build/index.cjs, build/server.cjs, build/encryption/index.cjs, build/key-provider/index.cjs)
  3. Copies .d.ts files to .d.cts for CJS type resolution
  4. Rewrites the exports field to include nested import/require conditions
  5. Removes digitallink_toolkit_server from dependencies (workspace-only, see Remove digitallink_toolkit_server local dependency #401)
  6. Publishes to npm with --access public
  7. Does NOT commit the publish-time changes back to the repository

Context

  • Package uses subpath exports (./server, ./encryption, ./key-provider) to avoid pulling in digitallink_toolkit_server via the main entry (see Remove digitallink_toolkit_server local dependency #401)
  • typesVersions field is already configured for backwards-compatible type resolution
  • Dual CJS/ESM build uses esbuild: npx esbuild --bundle --format=cjs --platform=node --out-extension:.js=.cjs with all dependencies marked as external
  • The publish pipeline should also consider the files field (currently ["build"]) to ensure only build output is included in the tarball

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions