rsnext/test/e2e/app-dir/app-external/app/cjs
Jiachi Liu 4aa5e9cad2
Fix next/server api alias for ESM pkg (#61721)
### What & Why

We have a modularize imports config for `next/server` before, which will
transform the `next/server` imports to directly import from the actual
file, for instance: `import { NextRequest } from 'next/server'` will
become `import { NextRequest } from
'next/dist/server/web/exports/next-request'`, where the NextRequest is
exported as default export. This is fine in most case until you're using
a ESM pkg, then it will be resolved as `{ default: NextRequest }`
according to the spec. Since it's a ESM import to a CJS module in
`next/dist`.

Since we already have the ESM alias introduced in #59852 , this can
handle the case more properly.

### How

Remove the modularize imports config for `next/server`, use the ESM api
alias instead.

Migrate the cjs optimizer tests from middleware to a separate endpoint
`/cjs/server`. As now ESM imports for next/server are not going to get
tree-shaken in dev, but since we don't have image response there it's
still fine.

Closes NEXT-2376
Closes NEXT-2374
2024-02-06 16:59:24 +00:00
..
client Fix react-refresh for transpiled packages (#60563) 2024-01-12 21:44:41 +01:00
server Fix next/server api alias for ESM pkg (#61721) 2024-02-06 16:59:24 +00:00