Skip to content

pnpm build fails on a fresh clone: core's copy-css plugin copies into dist/ before it exists #183

Open

Description

@Laptopmini

Description

On a fresh clone, the first pnpm build fails in @bprogress/core, and turbo skips every package that depends on it:

@bprogress/core:build: ERROR: [plugin: copy-css] ENOENT: no such file or directory, copyfile './src/index.css' -> './dist/index.css'
 Tasks:    0 successful, 5 total
Failed:    @bprogress/core#build

Running pnpm build a second time works (6 successful, 6 total), because by then the first run has created dist/. The husky pre-push hook runs pnpm build, so a contributor's first push from a new clone fails the same way.

Cause: packages/core/tsup.config.ts copies the CSS in an esbuild onEnd callback. tsup runs esbuild with write: false and writes the output files (creating dist/) after esbuild returns, so onEnd runs before dist/ exists. I checked this in tsup 8.4.0, the version in the lockfile.

Steps (pnpm 9.12.3, Node 24.14.1, macOS 26.4.1, main at f3c776a):

  1. git clone https://github.com/imskyleen/bprogress.git && cd bprogress
  2. pnpm install --frozen-lockfile
  3. pnpm build → fails as above
  4. pnpm build → passes

The published @bprogress/[email protected] tarball does include dist/index.css, so npm users aren't affected.

Two fixes I tried, each passing from an empty dist/ (2 of 2 runs, all 6 output files, index.css identical to the source):

  • Create the directory first: mkdirSync("./dist", { recursive: true }) before copyFileSync (and import mkdirSync).

  • Or drop the esbuild plugin and copy in tsup's onSuccess, which runs after the files are written:

    onSuccess: async () => {
      copyFileSync("./src/index.css", "./dist/index.css");
    },

Code example

// packages/core/tsup.config.ts (current)
esbuildPlugins: [
  {
    name: "copy-css",
    setup(build) {
      build.onEnd(() => {
        copyFileSync("./src/index.css", "./dist/index.css");
      });
    },
  },
],

Package used (or docs)

@bprogress/core (repo main f3c776a; 1.3.4 on npm is not affected)

Additional context

tsup 8.4.0 and esbuild 0.25.0 (from the lockfile).

Activity

  1. added
    bug
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions