Skip to content

fix: correct ESM/CJS export paths for "type": "module" service packages#973

Merged
hotlong merged 2 commits into
mainfrom
copilot/fix-vercel-module-not-found-error
Mar 23, 2026
Merged

fix: correct ESM/CJS export paths for "type": "module" service packages#973
hotlong merged 2 commits into
mainfrom
copilot/fix-vercel-module-not-found-error

Conversation

Copilot AI commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Vercel deploys fail with ERR_MODULE_NOT_FOUND for @objectstack/service-feed/dist/index.mjs because the file doesn't exist.

When tsup builds a "type": "module" package, it emits dist/index.js (ESM) and dist/index.cjs (CJS). Eight service packages had their exports pointing to .mjs/.js — the convention for packages without "type": "module":

// Before (wrong — these files don't exist for "type": "module")
"import": "./dist/index.mjs",
"require": "./dist/index.js"

// After (matches actual tsup output)
"import": "./dist/index.js",
"require": "./dist/index.cjs"

Packages like core, runtime, rest, and service-i18n already had the correct paths — this aligns the remaining eight:

  • service-feed ← the specific Vercel failure
  • service-automation
  • service-cache
  • service-realtime
  • service-job
  • service-queue
  • service-storage
  • service-analytics
Original prompt

This section details on the original issue you should resolve

<issue_title>vercel 报错</issue_title>
<issue_description>Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/apps/studio/node_modules/@objectstack/service-feed/dist/index.mjs' imported from /var/task/apps/studio/api/index.js
at finalizeResolution (node:internal/modules/esm/resolve:280:11)
at moduleResolve (node:internal/modules/esm/resolve:870:10)
at moduleResolveWithNodePath (node:internal/modules/esm/resolve:996:14)
at defaultResolve (node:internal/modules/esm/resolve:1039:79)
at #cachedDefaultResolve (node:internal/modules/esm/loader:718:20)
at #resolveAndMaybeBlockOnLoaderThread (node:internal/modules/esm/loader:735:38)
at ModuleLoader.resolveSync (node:internal/modules/esm/loader:764:52)
at #resolve (node:internal/modules/esm/loader:700:17)
at ModuleLoader.getOrCreateModuleJob (node:internal/modules/esm/loader:620:35)
at ModuleJob.syncLink (node:internal/modules/esm/module_job:143:33) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///var/task/apps/studio/node_modules/@objectstack/service-feed/dist/index.mjs'
}
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.</issue_description>

Comments on the Issue (you are @copilot in this section)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

@vercel

vercel Bot commented Mar 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectstack-play Ready Ready Preview, Comment Mar 23, 2026 11:30am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
spec Ignored Ignored Mar 23, 2026 11:30am

Request Review

When tsup builds a package with "type": "module", it outputs:
- ESM → dist/index.js (not .mjs)
- CJS → dist/index.cjs (not .js)

All 8 service packages had the wrong export paths (using .mjs/.js
convention intended for packages WITHOUT "type": "module"), causing
ERR_MODULE_NOT_FOUND on Vercel when importing @objectstack/service-feed.

Fixes: service-feed, service-automation, service-cache, service-realtime,
service-job, service-queue, service-storage, service-analytics.

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Agent-Logs-Url: https://github.com/objectstack-ai/spec/sessions/584d6e41-6f6f-493b-8c7b-7634aadaa08f
Copilot AI changed the title [WIP] Fix Vercel module not found error in service-feed import fix: correct ESM/CJS export paths for "type": "module" service packages Mar 23, 2026
Copilot AI requested a review from hotlong March 23, 2026 11:29
@hotlong
hotlong marked this pull request as ready for review March 23, 2026 13:19
Copilot AI review requested due to automatic review settings March 23, 2026 13:19
@hotlong
hotlong merged commit a0beeea into main Mar 23, 2026
5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes Vercel ERR_MODULE_NOT_FOUND failures caused by incorrect package.json exports paths in "type": "module" service packages, aligning them with tsup’s actual ESM/CJS output filenames.

Changes:

  • Updated exports maps in eight service packages to use import: ./dist/index.js and require: ./dist/index.cjs.
  • Added a changelog entry documenting the Vercel deployment fix and listing affected packages.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/services/service-storage/package.json Fix exports to match tsup output for "type": "module" (ESM .js, CJS .cjs).
packages/services/service-realtime/package.json Fix exports to match tsup output for "type": "module" (ESM .js, CJS .cjs).
packages/services/service-queue/package.json Fix exports to match tsup output for "type": "module" (ESM .js, CJS .cjs).
packages/services/service-job/package.json Fix exports to match tsup output for "type": "module" (ESM .js, CJS .cjs).
packages/services/service-feed/package.json Fix exports to resolve Vercel dist/index.mjs import failure.
packages/services/service-cache/package.json Fix exports to match tsup output for "type": "module" (ESM .js, CJS .cjs).
packages/services/service-automation/package.json Fix exports to match tsup output for "type": "module" (ESM .js, CJS .cjs).
packages/services/service-analytics/package.json Fix exports to match tsup output for "type": "module" (ESM .js, CJS .cjs).
CHANGELOG.md Document the Vercel ERR_MODULE_NOT_FOUND fix and affected packages.

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.

vercel 报错

3 participants