Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { cookies } from "next/headers";

async function MyComponent() {
function asyncFunction() {
callSomething(/* TODO: please manually await this call, if it's a server component, you can turn it to async function */
callSomething(/* Next.js Dynamic Async API Codemod: Manually await this call, if it's a Server Component */
cookies());
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cookies } from "next/headers";

function MyComponent() {
callSomething(/* TODO: please manually await this call, if it's a server component, you can turn it to async function */
callSomething(/* Next.js Dynamic Async API Codemod: Manually await this call, if it's a Server Component */
cookies());
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ function myFunc() {
nextHeaders.cookies()
}

const nextHeaders2 = /* The APIs under 'next/headers' are async now, need to be manually awaited. */ import('next/headers')
const nextHeaders2 = /* Next.js Dynamic Async API Codemod: The APIs under 'next/headers' are async now, need to be manually awaited. */ import('next/headers')
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const nextHeaders = /* The APIs under 'next/headers' are async now, need to be manually awaited. */
const nextHeaders = /* Next.js Dynamic Async API Codemod: The APIs under 'next/headers' are async now, need to be manually awaited. */
import('next/headers')

function myFunc() {
nextHeaders.cookies()
}

const nextHeaders2 = /* The APIs under 'next/headers' are async now, need to be manually awaited. */ import('next/headers')
const nextHeaders2 = /* Next.js Dynamic Async API Codemod: The APIs under 'next/headers' are async now, need to be manually awaited. */ import('next/headers')
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from 'next/headers'

export function MyDraftComponent() {
if (/* TODO: please manually await this call, if it's a server component, you can turn it to async function */
if (/* Next.js Dynamic Async API Codemod: Manually await this call, if it's a Server Component */
draftMode().isEnabled) {
return null
}
Expand All @@ -15,13 +15,13 @@ draftMode().isEnabled) {
}

export function MyCookiesComponent() {
const c = /* TODO: please manually await this call, if it's a server component, you can turn it to async function */
const c = /* Next.js Dynamic Async API Codemod: Manually await this call, if it's a Server Component */
cookies()
return c.get('name')
}

export function MyHeadersComponent() {
const h = /* TODO: please manually await this call, if it's a server component, you can turn it to async function */
const h = /* Next.js Dynamic Async API Codemod: Manually await this call, if it's a Server Component */
headers()
return (
<p>{h.get('x-foo')}</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export default function Page(props: any) {
callback(/* 'props' is passed as an argument. Any asynchronous properties of 'props' must be awaited when accessed. */
callback(/* Next.js Dynamic Async API Codemod: 'props' is passed as an argument. Any asynchronous properties of 'props' must be awaited when accessed. */
props, 1)
}

export function generateMetadata(props) {
callback2(/* 'props' is passed as an argument. Any asynchronous properties of 'props' must be awaited when accessed. */
callback2(/* Next.js Dynamic Async API Codemod: 'props' is passed as an argument. Any asynchronous properties of 'props' must be awaited when accessed. */
props)
}

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
insertCommentOnce,
} from './utils'

const DYNAMIC_IMPORT_WARN_COMMENT = ` The APIs under 'next/headers' are async now, need to be manually awaited. `
const DYNAMIC_IMPORT_WARN_COMMENT = ` Next.js Dynamic Async API Codemod: The APIs under 'next/headers' are async now, need to be manually awaited. `

function findDynamicImportsAndComment(root: Collection<any>, j: API['j']) {
let modified = false
Expand Down Expand Up @@ -187,7 +187,7 @@ export function transformDynamicAPI(
root,
filePath,
insertedTypes,
` TODO: please manually await this call, if it's a server component, you can turn it to async function `
` Next.js Dynamic Async API Codemod: Manually await this call, if it's a Server Component `
)
}
} else {
Expand All @@ -198,7 +198,7 @@ export function transformDynamicAPI(
root,
filePath,
insertedTypes,
' TODO: please manually await this call, codemod cannot transform due to undetermined async scope '
' Next.js Dynamic Async API Codemod: please manually await this call, codemod cannot transform due to undetermined async scope '
)
}
modified = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ export function transformDynamicProps(
const propPassedAsArg = args.find(
(arg) => j.Identifier.check(arg) && arg.name === argName
)
const comment = ` '${argName}' is passed as an argument. Any asynchronous properties of 'props' must be awaited when accessed. `
const comment = ` Next.js Dynamic Async API Codemod: '${argName}' is passed as an argument. Any asynchronous properties of 'props' must be awaited when accessed. `
insertCommentOnce(propPassedAsArg, j, comment)

modified = true
Expand Down
Loading