Skip to content

(tsx issue): payload bin scripts are unable to import esm dependencies without explicit "type": "module" #15701

@italodr

Description

@italodr

Describe the Bug

This issue is a follow up from #15609

After upgrading from 3.73.0 to 3.74.0 or higher, the command pnpm generate:importmap and pnpm migrate:create fails with an ESM export error.

The exported name mentioned exists, but for some reason it fails starting with version 3.74.0.
The same setup works correctly in 3.73.0.

Image

Link to the code that reproduces this issue

https://github.com/italodr/payloadcms-turborepo-test

Reproduction Steps

Clone the repository

https://github.com/italodr/payloadcms-turborepo-test

I've created a simple project with Verdaccio and Docker for you to test. I've added a package to the storage directory, a simple function that logs "This is an example function" to the console, which you'll see if you run the development project.

You'll need to have two tabs open in your terminal. One for Verdaccio and another for the monorepo containing PayloadCMS

Terminal tab for Verdaccio

  1. cd verdaccio
  2. docker compose up
  3. You should be able to access http://0.0.0.0:4873/

Terminal tab for Monorepo (from the root)

  1. pnpm i
  2. pnpm build:packages (to simplify, the only existing package imports this private package and exports it)
  3. cd examples/with-payload (we import and run the example function of the package in payload.config.ts)
  4. pnpm dev (everything works correctly... you should be able to see the message mentioned above)
Image
  1. Cmd/Ctrl + C
  2. pnpm generate:importmap (error)
  3. pnpm migrate:create (error)
Image

Finally

You can change the Payload version to 3.73.0 in the root package.json file and in examples/with-payload, run the Monorepo process again. You'll see there's no error here. It only occurs from version 3.74.0 onwards.

Which area(s) are affected?

area: core

Environment Info

Binaries:
  Node: 24.13.0
  npm: 11.6.2
  Yarn: 1.22.22
  pnpm: 10.4.1
Relevant Packages:
  payload: 3.77.0
  next: 16.1.6
  @payloadcms/db-sqlite: 3.77.0
  @payloadcms/drizzle: 3.77.0
  @payloadcms/graphql: 3.77.0
  @payloadcms/next/utilities: 3.77.0
  @payloadcms/richtext-lexical: 3.77.0
  @payloadcms/translations: 3.77.0
  @payloadcms/ui/shared: 3.77.0
  react: 19.2.4
  react-dom: 19.2.4
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Wed Oct 15 21:12:05 PDT 2025; root:xnu-11417.140.69.703.14~1/RELEASE_ARM64_T6030
  Available memory (MB): 18432
  Available CPU cores: 11

Metadata

Metadata

Assignees

Labels

dependency-issueThe issue is in a dependency of payload - not payload itself

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions