Skip to content

fix: point @objectstack/metadata exports to compiled dist files#976

Merged
hotlong merged 2 commits intomainfrom
copilot/fix-module-not-found-error-again
Mar 23, 2026
Merged

fix: point @objectstack/metadata exports to compiled dist files#976
hotlong merged 2 commits intomainfrom
copilot/fix-module-not-found-error-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 23, 2026

@objectstack/metadata package.json had main, types, and all exports pointing to TypeScript source files (src/index.ts). Node.js can't import .ts at runtime, causing ERR_MODULE_NOT_FOUND on Vercel.

Changes

  • packages/metadata/package.json — Rewired all export paths to dist output, added files field, matching the established @objectstack/spec pattern:
    "exports": {
      ".": {
        "types": "./dist/index.d.ts",
        "import": "./dist/index.mjs",
        "require": "./dist/index.js"
      },
      "./node": {
        "types": "./dist/node.d.ts",
        "import": "./dist/node.mjs",
        "require": "./dist/node.js"
      }
    }
  • packages/metadata/tsup.config.ts (new) — Local tsup config with both entry points (src/index.ts, src/node.ts), since the root config only declares a single entry
  • CHANGELOG.md — Documented the fix
Original prompt

vercel studio error 2026-03-23 15:55:18.795 [error] Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/apps/studio/node_modules/@objectstack/metadata/src/index.ts' 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/metadata/src/index.ts'
}
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.


⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 23, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
spec Ignored Ignored Mar 23, 2026 4:05pm

Request Review

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 23, 2026

Deployment failed with the following error:

Environment Variable "TURSO_DATABASE_URL" references Secret "turso_database_url", which does not exist.

Learn More: https://vercel.com/docs/environment-variables

The package.json main, types, and exports fields were pointing to
TypeScript source files (src/index.ts, src/node.ts) instead of compiled
dist output. Node.js cannot import .ts files at runtime, causing
ERR_MODULE_NOT_FOUND on Vercel Studio deployment.

- Updated package.json exports to reference dist files (.js, .mjs, .d.ts)
- Added local tsup.config.ts with both entry points (index.ts, node.ts)
- Added files field to package.json for publishable assets

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Agent-Logs-Url: https://github.com/objectstack-ai/spec/sessions/e381b2da-4f5d-4848-8ffb-d11c8123a6c1
Copilot AI changed the title [WIP] Fix module not found error in Vercel Studio fix: point @objectstack/metadata exports to compiled dist files Mar 23, 2026
Copilot AI requested a review from hotlong March 23, 2026 16:07
@hotlong hotlong marked this pull request as ready for review March 23, 2026 16:29
Copilot AI review requested due to automatic review settings March 23, 2026 16:29
@hotlong hotlong merged commit 52d1cca into main Mar 23, 2026
4 of 5 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes @objectstack/metadata runtime import failures in Node/Vercel by ensuring the package’s main, types, and exports resolve to compiled dist/* artifacts rather than TypeScript source files.

Changes:

  • Repointed packages/metadata/package.json main/types/exports to dist outputs and restricted published contents via files.
  • Added a local packages/metadata/tsup.config.ts with both entry points (src/index.ts, src/node.ts) and updated the build script to use it.
  • Documented the fix in CHANGELOG.md.

Reviewed changes

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

File Description
packages/metadata/tsup.config.ts Adds a package-local tsup config to build both index and node entrypoints into dist/.
packages/metadata/package.json Updates runtime/type entrypoints and exports to compiled output; adds files and switches build script to local tsup config.
CHANGELOG.md Notes the Vercel ERR_MODULE_NOT_FOUND fix for @objectstack/metadata exports.

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