diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts
index 19ab7857164b7..2fb05f53c014f 100644
--- a/packages/next/build/webpack-config.ts
+++ b/packages/next/build/webpack-config.ts
@@ -1483,7 +1483,7 @@ export default async function getBaseWebpackConfig(
include: [
dir,
// To let the internal client components passing through flight loader
- /next[\\/]dist[\\/]client[\\/]/,
+ /next[\\/]dist/,
],
issuerLayer: WEBPACK_LAYERS.server,
use: {
diff --git a/packages/next/build/webpack/loaders/next-flight-loader/index.ts b/packages/next/build/webpack/loaders/next-flight-loader/index.ts
index 2b44a52d3f0ae..c05e8ea4b43e6 100644
--- a/packages/next/build/webpack/loaders/next-flight-loader/index.ts
+++ b/packages/next/build/webpack/loaders/next-flight-loader/index.ts
@@ -44,7 +44,6 @@ export default async function transformSource(
})
const rscType = getRSCModuleType(source)
- const isModule = swcAST.type === 'Module'
const createError = (name: string) =>
new Error(
`${name} is not supported in client components.\nFrom: ${this.resourcePath}`
@@ -74,6 +73,7 @@ export default async function transformSource(
return callback(null, source, sourceMap)
}
+ const isModule = swcAST.type === 'Module'
const code = transformServer(source, isModule)
return callback(null, code, sourceMap)
}
diff --git a/packages/next/build/webpack/loaders/utils.ts b/packages/next/build/webpack/loaders/utils.ts
index e2cec1a021250..6bbcacc2268a6 100644
--- a/packages/next/build/webpack/loaders/utils.ts
+++ b/packages/next/build/webpack/loaders/utils.ts
@@ -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)
}
diff --git a/test/e2e/app-dir/rsc-basic.test.ts b/test/e2e/app-dir/rsc-basic.test.ts
index fb4a6fefdb26e..4d5196ffcad32 100644
--- a/test/e2e/app-dir/rsc-basic.test.ts
+++ b/test/e2e/app-dir/rsc-basic.test.ts
@@ -150,17 +150,6 @@ describe('app dir - react server components', () => {
expect(sharedServerModule[0][1]).toBe(sharedServerModule[1][1])
expect(sharedClientModule[0][1]).toBe(sharedClientModule[1][1])
expect(sharedServerModule[0][1]).not.toBe(sharedClientModule[0][1])
-
- // Note: This is currently unsupported because packages from another layer
- // will not be re-initialized by webpack.
- // Should import 2 module instances for node_modules too.
- // const modFromClient = main.match(
- // /node_modules instance from \.client\.js:(\d+)/
- // )
- // const modFromServer = main.match(
- // /node_modules instance from \.server\.js:(\d+)/
- // )
- // expect(modFromClient[1]).not.toBe(modFromServer[1])
})
it('should be able to navigate between rsc routes', async () => {
diff --git a/test/e2e/app-dir/rsc-basic/app/css-in-js/page.js b/test/e2e/app-dir/rsc-basic/app/css-in-js/page.js
index 82dec40e278e9..6a69632037f02 100644
--- a/test/e2e/app-dir/rsc-basic/app/css-in-js/page.js
+++ b/test/e2e/app-dir/rsc-basic/app/css-in-js/page.js
@@ -1,5 +1,5 @@
-import Comp from './styled-jsx.client'
-import StyledComp from './styled-components.client'
+import Comp from './styled-jsx'
+import StyledComp from './styled-components'
export default function Page() {
return (
diff --git a/test/e2e/app-dir/rsc-basic/app/css-in-js/styled-components.client.js b/test/e2e/app-dir/rsc-basic/app/css-in-js/styled-components.js
similarity index 100%
rename from test/e2e/app-dir/rsc-basic/app/css-in-js/styled-components.client.js
rename to test/e2e/app-dir/rsc-basic/app/css-in-js/styled-components.js
diff --git a/test/e2e/app-dir/rsc-basic/app/css-in-js/styled-jsx.client.js b/test/e2e/app-dir/rsc-basic/app/css-in-js/styled-jsx.js
similarity index 100%
rename from test/e2e/app-dir/rsc-basic/app/css-in-js/styled-jsx.client.js
rename to test/e2e/app-dir/rsc-basic/app/css-in-js/styled-jsx.js
diff --git a/test/e2e/app-dir/rsc-basic/app/css-modules/page.js b/test/e2e/app-dir/rsc-basic/app/css-modules/page.js
index 9fcdad027d780..0e8dda27cfd67 100644
--- a/test/e2e/app-dir/rsc-basic/app/css-modules/page.js
+++ b/test/e2e/app-dir/rsc-basic/app/css-modules/page.js
@@ -1,5 +1,5 @@
// CSS modules can only be imported inside client components for now.
-import RedText from '../../components/red/index.client'
+import RedText from '../../components/red/index'
export default function CSSM() {
return (
diff --git a/test/e2e/app-dir/rsc-basic/app/layout.js b/test/e2e/app-dir/rsc-basic/app/layout.js
index d168e4e717853..4a732e89c2c8f 100644
--- a/test/e2e/app-dir/rsc-basic/app/layout.js
+++ b/test/e2e/app-dir/rsc-basic/app/layout.js
@@ -1,5 +1,5 @@
import React from 'react'
-import RootStyleRegistry from './root-style-registry.client'
+import RootStyleRegistry from './root-style-registry'
export default function AppLayout({ children }) {
return (
diff --git a/test/e2e/app-dir/rsc-basic/app/native-module/page.js b/test/e2e/app-dir/rsc-basic/app/native-module/page.js
index c74dcf3163b75..67dffb1a5259f 100644
--- a/test/e2e/app-dir/rsc-basic/app/native-module/page.js
+++ b/test/e2e/app-dir/rsc-basic/app/native-module/page.js
@@ -1,6 +1,6 @@
import fs from 'fs'
-import Foo from '../../components/foo.client'
+import Foo from '../../components/foo'
export default function Page() {
return (
diff --git a/test/e2e/app-dir/rsc-basic/app/partial-hydration/page.js b/test/e2e/app-dir/rsc-basic/app/partial-hydration/page.js
index b551f10f04909..f656e0b80b121 100644
--- a/test/e2e/app-dir/rsc-basic/app/partial-hydration/page.js
+++ b/test/e2e/app-dir/rsc-basic/app/partial-hydration/page.js
@@ -1,6 +1,6 @@
import { Suspense } from 'react'
-import Counter from '../../components/partial-hydration-counter.client'
+import Counter from '../../components/partial-hydration-counter'
let result
let promise
diff --git a/test/e2e/app-dir/rsc-basic/app/root-style-registry.client.js b/test/e2e/app-dir/rsc-basic/app/root-style-registry.js
similarity index 100%
rename from test/e2e/app-dir/rsc-basic/app/root-style-registry.client.js
rename to test/e2e/app-dir/rsc-basic/app/root-style-registry.js
diff --git a/test/e2e/app-dir/rsc-basic/app/routes/[dynamic]/page.js.bak b/test/e2e/app-dir/rsc-basic/app/routes/[dynamic]/page.js.bak
deleted file mode 100644
index 97d7c734596e8..0000000000000
--- a/test/e2e/app-dir/rsc-basic/app/routes/[dynamic]/page.js.bak
+++ /dev/null
@@ -1,21 +0,0 @@
-import { parse } from 'url'
-import RouterPath from '../../../components/router-path.client'
-
-export default function Pid({ text, pathname }) {
- return (
- <>
-
{`query: ${text}`}
-
{`pathname: ${pathname}`}
-
- >
- )
-}
-
-export function getServerSideProps({ params, req }) {
- return {
- props: {
- pathname: parse(req.url).pathname,
- text: params.dynamic,
- },
- }
-}
diff --git a/test/e2e/app-dir/rsc-basic/app/shared/page.js b/test/e2e/app-dir/rsc-basic/app/shared/page.js
index 4fefb0d1963f4..761727eca2e7d 100644
--- a/test/e2e/app-dir/rsc-basic/app/shared/page.js
+++ b/test/e2e/app-dir/rsc-basic/app/shared/page.js
@@ -1,11 +1,9 @@
-import ClientFromDirect from '../../components/client.client'
+import ClientFromDirect from '../../components/client'
import ClientFromShared from '../../components/shared'
-import SharedFromClient from '../../components/shared.client'
-import Random from '../../components/random-module-instance.client'
+import SharedFromClient from '../../components/shared-client'
+import Random from '../../components/random-module-instance'
import Bar from '../../components/bar'
-// import { random } from 'random-module-instance'
-
export default function Page() {
// All three client components should be rendered correctly, but only
// shared component is a server component, and another is a client component.
@@ -16,7 +14,6 @@ export default function Page() {
- {/* {`node_modules instance from .server.js:` + random} */}
diff --git a/test/e2e/app-dir/rsc-basic/app/various-exports/page.js b/test/e2e/app-dir/rsc-basic/app/various-exports/page.js
index 865d7904362c8..603ba8b5e9e78 100644
--- a/test/e2e/app-dir/rsc-basic/app/various-exports/page.js
+++ b/test/e2e/app-dir/rsc-basic/app/various-exports/page.js
@@ -3,12 +3,13 @@ import { a, b, c, d, e } from '../../components/shared-exports'
// client default, named exports
import DefaultArrow, {
Named as ClientNamed,
-} from '../../components/client-exports.client'
+} from '../../components/client-exports'
-import { Cjs as CjsShared } from '../../components/cjs'
-import { Cjs as CjsClient } from '../../components/cjs.client'
+import { Cjs as CjsShared } from '../../components/cjs-server'
+import { Cjs as CjsClient } from '../../components/cjs-client'
-import { One, Two, TwoAliased } from '../../components/export-all/index.client'
+// client exports all
+import { One, Two, TwoAliased } from '../../components/export-all'
export default function Page() {
return (
diff --git a/test/e2e/app-dir/rsc-basic/components/bar.client.js b/test/e2e/app-dir/rsc-basic/components/bar-client.js
similarity index 100%
rename from test/e2e/app-dir/rsc-basic/components/bar.client.js
rename to test/e2e/app-dir/rsc-basic/components/bar-client.js
diff --git a/test/e2e/app-dir/rsc-basic/components/bar.js b/test/e2e/app-dir/rsc-basic/components/bar.js
index 9b5c231fccc38..dd460ddda586d 100644
--- a/test/e2e/app-dir/rsc-basic/components/bar.js
+++ b/test/e2e/app-dir/rsc-basic/components/bar.js
@@ -1,4 +1,4 @@
-import Foo from './foo.client'
+import Foo from './foo'
export default function Bar() {
return (
diff --git a/test/e2e/app-dir/rsc-basic/components/cjs.client.js b/test/e2e/app-dir/rsc-basic/components/cjs-client.js
similarity index 100%
rename from test/e2e/app-dir/rsc-basic/components/cjs.client.js
rename to test/e2e/app-dir/rsc-basic/components/cjs-client.js
diff --git a/test/e2e/app-dir/rsc-basic/components/cjs.js b/test/e2e/app-dir/rsc-basic/components/cjs-server.js
similarity index 100%
rename from test/e2e/app-dir/rsc-basic/components/cjs.js
rename to test/e2e/app-dir/rsc-basic/components/cjs-server.js
diff --git a/test/e2e/app-dir/rsc-basic/components/client-exports.client.js b/test/e2e/app-dir/rsc-basic/components/client-exports.js
similarity index 100%
rename from test/e2e/app-dir/rsc-basic/components/client-exports.client.js
rename to test/e2e/app-dir/rsc-basic/components/client-exports.js
diff --git a/test/e2e/app-dir/rsc-basic/components/client.client.js b/test/e2e/app-dir/rsc-basic/components/client.js
similarity index 100%
rename from test/e2e/app-dir/rsc-basic/components/client.client.js
rename to test/e2e/app-dir/rsc-basic/components/client.js
diff --git a/test/e2e/app-dir/rsc-basic/components/export-all/index.client.js b/test/e2e/app-dir/rsc-basic/components/export-all/index.js
similarity index 100%
rename from test/e2e/app-dir/rsc-basic/components/export-all/index.client.js
rename to test/e2e/app-dir/rsc-basic/components/export-all/index.js
diff --git a/test/e2e/app-dir/rsc-basic/components/foo.client.js b/test/e2e/app-dir/rsc-basic/components/foo.js
similarity index 100%
rename from test/e2e/app-dir/rsc-basic/components/foo.client.js
rename to test/e2e/app-dir/rsc-basic/components/foo.js
diff --git a/test/e2e/app-dir/rsc-basic/components/partial-hydration-counter.client.js b/test/e2e/app-dir/rsc-basic/components/partial-hydration-counter.js
similarity index 100%
rename from test/e2e/app-dir/rsc-basic/components/partial-hydration-counter.client.js
rename to test/e2e/app-dir/rsc-basic/components/partial-hydration-counter.js
diff --git a/test/e2e/app-dir/rsc-basic/components/random-module-instance.client.js b/test/e2e/app-dir/rsc-basic/components/random-module-instance.js
similarity index 59%
rename from test/e2e/app-dir/rsc-basic/components/random-module-instance.client.js
rename to test/e2e/app-dir/rsc-basic/components/random-module-instance.js
index 6b3e418e27a39..d3badf9b35ef0 100644
--- a/test/e2e/app-dir/rsc-basic/components/random-module-instance.client.js
+++ b/test/e2e/app-dir/rsc-basic/components/random-module-instance.js
@@ -3,5 +3,5 @@
import { random } from 'random-module-instance'
export default function () {
- return `node_modules instance from .client.js:${random}`
+ return `node_modules instance from client module ${random}`
}
diff --git a/test/e2e/app-dir/rsc-basic/components/red/index.client.js b/test/e2e/app-dir/rsc-basic/components/red/index.js
similarity index 100%
rename from test/e2e/app-dir/rsc-basic/components/red/index.client.js
rename to test/e2e/app-dir/rsc-basic/components/red/index.js
diff --git a/test/e2e/app-dir/rsc-basic/components/router-path.client.js b/test/e2e/app-dir/rsc-basic/components/router-path.client.js
deleted file mode 100644
index 40d08dd3c7e57..0000000000000
--- a/test/e2e/app-dir/rsc-basic/components/router-path.client.js
+++ /dev/null
@@ -1,8 +0,0 @@
-'client'
-
-import { useRouter } from 'next/router'
-
-export default () => {
- const { pathname } = useRouter()
- return
{`router pathname: ${pathname}`}
-}
diff --git a/test/e2e/app-dir/rsc-basic/components/shared.client.js b/test/e2e/app-dir/rsc-basic/components/shared-client.js
similarity index 100%
rename from test/e2e/app-dir/rsc-basic/components/shared.client.js
rename to test/e2e/app-dir/rsc-basic/components/shared-client.js
diff --git a/test/e2e/app-dir/rsc-basic/components/shared.js b/test/e2e/app-dir/rsc-basic/components/shared.js
index 8cb90b9a87c59..f1a59405238b6 100644
--- a/test/e2e/app-dir/rsc-basic/components/shared.js
+++ b/test/e2e/app-dir/rsc-basic/components/shared.js
@@ -1,5 +1,5 @@
import React from 'react'
-import Client from './client.client'
+import Client from './client'
const random = ~~(Math.random() * 10000)
diff --git a/test/integration/react-streaming/app/components/bar.client.js b/test/integration/react-streaming/app/components/bar.js
similarity index 60%
rename from test/integration/react-streaming/app/components/bar.client.js
rename to test/integration/react-streaming/app/components/bar.js
index b58488a9c3b5c..97cd1c985e192 100644
--- a/test/integration/react-streaming/app/components/bar.client.js
+++ b/test/integration/react-streaming/app/components/bar.js
@@ -1,3 +1,3 @@
export default function bar() {
- return 'bar.client'
+ return 'bar'
}
diff --git a/test/integration/react-streaming/app/components/bar.server.js b/test/integration/react-streaming/app/components/bar.server.js
deleted file mode 100644
index e8b54be31993b..0000000000000
--- a/test/integration/react-streaming/app/components/bar.server.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import Foo from './foo.client'
-
-export default function Bar() {
- return (
-
- bar.server.js:
-
- )
-}
diff --git a/test/integration/react-streaming/app/components/cjs.client.js b/test/integration/react-streaming/app/components/cjs.client.js
deleted file mode 100644
index d3c078184ab64..0000000000000
--- a/test/integration/react-streaming/app/components/cjs.client.js
+++ /dev/null
@@ -1,3 +0,0 @@
-exports.Cjs = function Cjs() {
- return 'cjs-client'
-}
diff --git a/test/integration/react-streaming/app/components/cjs.js b/test/integration/react-streaming/app/components/cjs.js
deleted file mode 100644
index 444f1229a2272..0000000000000
--- a/test/integration/react-streaming/app/components/cjs.js
+++ /dev/null
@@ -1,3 +0,0 @@
-exports.Cjs = function Cjs() {
- return 'cjs-shared'
-}
diff --git a/test/integration/react-streaming/app/components/client-exports.client.js b/test/integration/react-streaming/app/components/client-exports.client.js
deleted file mode 100644
index eca931680a232..0000000000000
--- a/test/integration/react-streaming/app/components/client-exports.client.js
+++ /dev/null
@@ -1,5 +0,0 @@
-export function Named() {
- return 'named.client'
-}
-
-export default () => 'default-export-arrow.client'
diff --git a/test/integration/react-streaming/app/components/client.client.js b/test/integration/react-streaming/app/components/client.client.js
deleted file mode 100644
index 7b20e208abd7c..0000000000000
--- a/test/integration/react-streaming/app/components/client.client.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import { useState } from 'react'
-
-export default function Client() {
- // To ensure that this component is rendered as a client component, we use a
- // state here.
- return useState('client_component')[0]
-}
diff --git a/test/integration/react-streaming/app/components/container.server.js b/test/integration/react-streaming/app/components/container.server.js
deleted file mode 100644
index ab63ebb0d37f0..0000000000000
--- a/test/integration/react-streaming/app/components/container.server.js
+++ /dev/null
@@ -1,3 +0,0 @@
-export default function Container({ children }) {
- return
{children}
-}
diff --git a/test/integration/react-streaming/app/components/export-all/index.client.js b/test/integration/react-streaming/app/components/export-all/index.client.js
deleted file mode 100644
index 1087c98723264..0000000000000
--- a/test/integration/react-streaming/app/components/export-all/index.client.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from './one'
diff --git a/test/integration/react-streaming/app/components/export-all/one.js b/test/integration/react-streaming/app/components/export-all/one.js
deleted file mode 100644
index c06971f1cbd5d..0000000000000
--- a/test/integration/react-streaming/app/components/export-all/one.js
+++ /dev/null
@@ -1,6 +0,0 @@
-export function One() {
- return 'one'
-}
-
-export * from './two'
-export { Two as TwoAliased } from './two'
diff --git a/test/integration/react-streaming/app/components/export-all/two.js b/test/integration/react-streaming/app/components/export-all/two.js
deleted file mode 100644
index efcee31004001..0000000000000
--- a/test/integration/react-streaming/app/components/export-all/two.js
+++ /dev/null
@@ -1,3 +0,0 @@
-export function Two() {
- return 'two'
-}
diff --git a/test/integration/react-streaming/app/components/foo.client.js b/test/integration/react-streaming/app/components/foo.js
similarity index 79%
rename from test/integration/react-streaming/app/components/foo.client.js
rename to test/integration/react-streaming/app/components/foo.js
index 30d3854497926..66d4ff2dabfa4 100644
--- a/test/integration/react-streaming/app/components/foo.client.js
+++ b/test/integration/react-streaming/app/components/foo.js
@@ -1,5 +1,5 @@
export default function foo() {
- return 'foo.client'
+ return 'foo'
}
export const config = 'this is not page config'
diff --git a/test/integration/react-streaming/app/components/nav.js b/test/integration/react-streaming/app/components/nav.js
deleted file mode 100644
index 23fb83d933a36..0000000000000
--- a/test/integration/react-streaming/app/components/nav.js
+++ /dev/null
@@ -1,23 +0,0 @@
-import Link from 'next/link'
-
-export default function Nav() {
- return (
- <>
-