Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alias nextjs api entry to esm version for app router #59852

Merged
merged 5 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update alias
  • Loading branch information
huozhi committed Dec 21, 2023
commit c3889ea24c6ffa356cf591b0d0643b08a7339ef3
9 changes: 4 additions & 5 deletions packages/next/src/build/create-compiler-aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ import {
} from '../lib/constants'
import type { NextConfigComplete } from '../server/config-shared'
import { defaultOverrides } from '../server/require-hook'
import {
NEXT_PROJECT_ROOT,
NEXT_PROJECT_ROOT_DIST,
hasExternalOtelApiPackage,
} from './webpack-config'
import { NEXT_PROJECT_ROOT, hasExternalOtelApiPackage } from './webpack-config'
import { WEBPACK_LAYERS } from '../lib/constants'

interface CompilerAliases {
Expand Down Expand Up @@ -96,12 +92,15 @@ export function createWebpackAliases({
// let this alias hit before `next` alias.
...(isEdgeServer
? {
'next/dist/api': 'next/dist/esm/api',
'next/dist/build': 'next/dist/esm/build',
'next/dist/client': 'next/dist/esm/client',
'next/dist/shared': 'next/dist/esm/shared',
'next/dist/pages': 'next/dist/esm/pages',
'next/dist/lib': 'next/dist/esm/lib',
'next/dist/server': 'next/dist/esm/server',

...createNextApiEsmAliases(),
}
: undefined),

Expand Down
1 change: 1 addition & 0 deletions packages/next/taskfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2482,6 +2482,7 @@ export async function api_esm(task, opts) {
.source('src/api/**/*.+(js|mts|ts|tsx)')
.swc('server', { dev: opts.dev, esm: true })
.target('dist/api')
.target('dist/esm/api')
}

export async function nextbuild(task, opts) {
Expand Down
Loading