Unverified Commit aa0ba3c3 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Ensure server components entries are not part of the pages buildmanifest (#38416)

Co-authored-by: 's avatarJiachi Liu <inbox@huozhi.im>
Co-authored-by: 's avatarkodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
parent 93cb635e
......@@ -4,6 +4,20 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch app-dir development",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "yarn",
"runtimeArgs": ["run", "debug", "dev", "test/e2e/app-dir/app"],
"skipFiles": ["<node_internals>/**"],
"outFiles": ["${workspaceFolder}/packages/next/dist/**/*"],
"port": 9229,
"env": {
"NEXT_PRIVATE_LOCAL_WEBPACK5": "1"
}
},
{
"name": "Launch app development",
"type": "node",
......
......@@ -120,7 +120,7 @@ export class ClientEntryPlugin {
name,
})}!`
const bundlePath = 'pages' + normalizePagePath(routeInfo.page)
const bundlePath = 'app' + normalizePagePath(routeInfo.page)
// Inject the entry to the client compiler.
if (this.dev) {
......
import Runtime from '../utils/runtime'
import Time from '../utils/time'
import Runtime from '../../utils/runtime'
import Time from '../../utils/time'
export default function Page() {
return (
......
import Runtime from '../utils/runtime'
import Time from '../utils/time'
import Runtime from '../../utils/runtime'
import Time from '../../utils/time'
export default function Page({ type }) {
return (
......
import Runtime from '../utils/runtime'
import Time from '../utils/time'
import Runtime from '../../utils/runtime'
import Time from '../../utils/time'
export default function Page({ type }) {
return (
......
import Runtime from '../utils/runtime'
import Time from '../utils/time'
import Runtime from '../../utils/runtime'
import Time from '../../utils/time'
export default function Page({ type }) {
return (
......
import Runtime from '../utils/runtime'
import Time from '../utils/time'
import Runtime from '../../utils/runtime'
import Time from '../../utils/time'
export default function Page() {
return (
......
This diff is collapsed.
module.exports = {
reactStrictMode: true,
experimental: {
appDir: true,
serverComponents: true,
// runtime: 'experimental-edge',
},
}
export default function App({ Component, pageProps }) {
return (
<div className="app-client-root" data-title={Component.title || ''}>
<div className="app-client-root">
<Component {...pageProps} />
</div>
)
......
......@@ -2,41 +2,12 @@
import fs from 'fs-extra'
import { join } from 'path'
import {
File,
nextBuild,
runDevSuite,
runProdSuite,
fetchViaHTTP,
} from 'next-test-utils'
import { File, nextBuild } from 'next-test-utils'
const appDir = __dirname
const nodeArgs = ['-r', join(appDir, '../../lib/react-channel-require-hook.js')]
const reactDomPackagePah = join(appDir, 'node_modules/react-dom')
const nextConfig = new File(join(appDir, 'next.config.js'))
const documentPage = new File(join(appDir, 'pages/_document.js'))
const indexPage = join(appDir, 'pages/index.js')
const indexServerPage = join(appDir, 'pages/index.server.js')
const documentWithGip = `
import { Html, Head, Main, NextScript } from 'next/document'
export default function Document() {
return (
<Html>
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
Document.getInitialProps = (ctx) => {
return ctx.defaultGetInitialProps(ctx)
}
`
function writeNextConfig(config) {
const content = `
......@@ -91,36 +62,3 @@ describe('React 17 with React 18 config', () => {
expect(code).toBe(1)
})
})
const documentSuite = {
runTests: (context, env) => {
if (env === 'dev') {
it('should error when custom _document has getInitialProps method', async () => {
const res = await fetchViaHTTP(context.appPort, '/')
expect(res.status).toBe(500)
})
} else {
it('should failed building', async () => {
expect(context.code).toBe(1)
})
}
},
beforeAll: async () => {
writeNextConfig({
serverComponents: true,
})
documentPage.write(documentWithGip)
await fs.rename(indexPage, indexServerPage)
},
afterAll: async () => {
documentPage.delete()
nextConfig.restore()
await fs.rename(indexServerPage, indexPage)
},
env: {
__NEXT_REACT_CHANNEL: 'exp',
},
}
runDevSuite('Invalid custom document with gip', appDir, documentSuite)
runProdSuite('Invalid custom document with gip', appDir, documentSuite)
{
"private": true,
"scripts": {
"dev": "yarn next dev",
"build": "yarn next build",
"start": "yarn next start"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment