cloudflare / cloudflare/vinext

App Router client modules: package `type: "commonjs"`/`"module"` overrides ignored

Open
#1,504 0 comments 0 reactions 0 assignees View on GitHub
adapter-api-e2e help wanted
Dominant language
TypeScript
Stars
8.8k
Forks
406
Avg merge
2d 6h
Merged PRs (30d)
120

Description

> *This issue was created by an agent analysing CI failures from the [Next.js Deploy Suite](https://github.com/cloudflare/vinext/actions/runs/26282973805) (vinext `main` vs Next.js `v16.2.6`, 2026-05-22).*

## Problem

When a `"use client"` module imports a package whose `package.json` sets `"type": "commonjs"` (or `"module"`) without an `exports` map, Next.js honors the type field. vinext always resolves the ESM build, so the rendered text mixes up `cjs` and `esm` markers.

```
Package with `type: "commonjs"` still resolved as ESM
```

## Estimated Impact

~2 test failures across the deploy suite.

## Affected Test Suites

- `test/e2e/app-dir/client-module-with-package-type/index.test.ts` (2 failures)

## Recommendation

1. **Reproduce first in vinext's own test suite.** Add fixtures importing two packages: one with `type: 'commonjs'` and one with `type: 'module'`, both without `exports`. Assert each resolves correctly.

2. **Respect `type` field in the resolver.** When there is no `exports` map, fall back to `type` for choosing between `main` (CJS) and `module` (ESM) entry.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue in vinext's own suite, using the affected test at test/e2e/app-dir/client-module-with-package-type/index.test.ts as the reference. Trace the package resolver for packages without an exports map, then verify fixtures for both type: 'commonjs' and type: 'module'. Done means each package resolves to the expected entry and the affected test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.