Skip to content

Fix missing dist directory in published npm package #1161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2025
Merged

Conversation

fainashalts
Copy link
Collaborator

Problem

Versions after 10.0.238 of @eth-optimism/tokenlist do not include a dist directory, resulting in the following error when attempting to import the package:

Module not found: Can't resolve '@eth-optimism/tokenlist'

Root Cause

The CircleCI publish workflow was missing a critical build step. While the workflow correctly:

  1. Generated the token list (pnpm generate:ci)
  2. Bumped the version and committed changes
  3. Published the package (pnpm publish)

It was not building the dist directory that contains the compiled JavaScript and TypeScript declaration files that consumers need to import the package.

The package.json correctly specifies:

  • "main": "dist/index.js"
  • "module": "dist/index.mjs"
  • "types": "dist/index.d.ts"
  • "files": ["dist"]

But without the build step, the dist directory didn't exist in the published package.

Solution

Added a build step in the CircleCI workflow before publishing:

- run:
    name: Build package
    command: |
      # build the dist directory for publishing
      pnpm tsup --dts

This ensures the dist directory is created with all necessary compiled files before the package is published to npm.

Verification

  • Ran npm pack --dry-run to confirm the dist directory and all its files are included in the package
  • Build process successfully creates all required files:
    • index.js, index.mjs (compiled JavaScript)
    • index.d.ts, optimism.tokenlist.d.ts (TypeScript declarations)
    • Source maps and other build artifacts

Impact

  • ✅ Fixes import errors for @eth-optimism/tokenlist package
  • ✅ Ensures future published versions include the required dist directory
  • ✅ No breaking changes - maintains existing API and file structure
  • ✅ Aligns CI workflow with the existing release script pattern

@fainashalts fainashalts requested review from wbnns and a team as code owners June 13, 2025 19:00
Copy link

@its-everdred its-everdred left a comment

Choose a reason for hiding this comment

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

great explanation!

@fainashalts fainashalts merged commit f2ebf00 into master Jun 13, 2025
8 checks passed
@fainashalts fainashalts deleted the fix-dist branch June 13, 2025 20:31
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.

3 participants