-
Notifications
You must be signed in to change notification settings - Fork 27.3k
Commit
Follow up for #40415 Remove internal next client api determination, fully relying on `'client'` directive. Change `.client.js` extension to `.js ` in tests, remove legacy / unused test files
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,12 @@ | ||
import { RSC_MODULE_TYPES } from '../../../shared/lib/constants' | ||
|
||
const nextClientComponents = [ | ||
'dist/client/link', | ||
'dist/client/image', | ||
'dist/client/future/image', | ||
'dist/shared/lib/head', | ||
'dist/client/script', | ||
'dist/shared/lib/dynamic', | ||
] | ||
|
||
const imageExtensions = ['jpg', 'jpeg', 'png', 'webp', 'avif'] | ||
const imageRegex = new RegExp(`\\.(${imageExtensions.join('|')})$`) | ||
|
||
const NEXT_API_CLIENT_RSC_REGEX = new RegExp( | ||
`next[\\\\/](${nextClientComponents.join('|')})(\\.js)?` | ||
) | ||
|
||
// Cover resource paths like `next/dist/client/*` | ||
export function isNextBuiltInClientComponent(resource: string) { | ||
return NEXT_API_CLIENT_RSC_REGEX.test(resource) | ||
} | ||
|
||
export function isClientComponentModule(mod: { | ||
resource: string | ||
buildInfo: any | ||
}) { | ||
const hasClientDirective = mod.buildInfo.rsc?.type === RSC_MODULE_TYPES.client | ||
return ( | ||
isNextBuiltInClientComponent(mod.resource) || | ||
hasClientDirective || | ||
imageRegex.test(mod.resource) | ||
) | ||
return hasClientDirective || imageRegex.test(mod.resource) | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import Foo from './foo.client' | ||
import Foo from './foo' | ||
|
||
export default function Bar() { | ||
return ( | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export default function bar() { | ||
return 'bar.client' | ||
return 'bar' | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export default function foo() { | ||
return 'foo.client' | ||
return 'foo' | ||
} | ||
|
||
export const config = 'this is not page config' |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.