Commit bf484488 authored by Jiachi Liu's avatar Jiachi Liu

Disable experimental.optimizeServer by default (#69788)

parent 86547db9
...@@ -939,7 +939,7 @@ export const defaultConfig: NextConfig = { ...@@ -939,7 +939,7 @@ export const defaultConfig: NextConfig = {
: false, : false,
webpackBuildWorker: undefined, webpackBuildWorker: undefined,
missingSuspenseWithCSRBailout: true, missingSuspenseWithCSRBailout: true,
optimizeServerReact: true, optimizeServerReact: false,
useEarlyImport: false, useEarlyImport: false,
staleTimes: { staleTimes: {
dynamic: 30, dynamic: 30,
......
// @ts-ignore avoid ts errors during manual testing
import { type NextInstance } from 'e2e-utils' import { type NextInstance } from 'e2e-utils'
async function getActionsMappingByRuntime( async function getActionsMappingByRuntime(
......
{
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"noEmit": true,
"incremental": true,
"module": "esnext",
"esModuleInterop": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"plugins": [
{
"name": "next"
}
]
},
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
export default function Layout({ children }) {
return (
<html>
<body>{children}</body>
</html>
)
}
'use server'
export async function action1() {
return { hello: 'world' }
}
export async function action2() {
return { hello: 'action2' }
}
export async function action3() {
return { hello: 'action3' }
}
import { action3 } from './actions'
export default function MyComponent() {
// to prevent tree-shaking
if (globalThis.DO_NOT_TREE_SHAKE) {
console.log('MyComponent imported action3', action3)
}
return <span>i'm MyComponent</span>
}
'use client'
import React, { useEffect } from 'react'
import { action1, action2 } from './actions'
import MyComponent from './my-component'
export default function Page() {
// to prevent tree-shaking
if (globalThis.DO_NOT_TREE_SHAKE) {
console.log('Page imported action2', action2)
}
// calling action1 fails!!
useEffect(() => {
if (globalThis.DO_NOT_TREE_SHAKE) {
action1().then((obj) => {
console.log('action1 returned:', obj)
})
}
}, [])
return <MyComponent />
}
{
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"noEmit": true,
"incremental": true,
"module": "esnext",
"esModuleInterop": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"plugins": [
{
"name": "next"
}
]
},
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
import { nextTestSetup } from 'e2e-utils'
import {
getActionsRoutesStateByRuntime,
markLayoutAsEdge,
} from '../_testing/utils'
describe('actions-tree-shaking - use-effect-actions', () => {
const { next } = nextTestSetup({
files: __dirname,
})
if (process.env.TEST_EDGE) {
markLayoutAsEdge(next)
}
it('should not tree shake the used action under useEffect', async () => {
const actionsRoutesState = await getActionsRoutesStateByRuntime(next)
expect(actionsRoutesState).toMatchObject({
'app/mixed/page': {
'action-browser': 3,
},
})
})
})
...@@ -15600,6 +15600,24 @@ ...@@ -15600,6 +15600,24 @@
"pending": [], "pending": [],
"flakey": [], "flakey": [],
"runtimeError": false "runtimeError": false
},
"test/production/app-dir/actions-tree-shaking/use-effect-actions/use-effect-actions-edge.test.ts": {
"passed": [],
"failed": [
"actions-tree-shaking - use-effect-actions should not tree shake the used action under useEffect"
],
"pending": [],
"flakey": [],
"runtimeError": false
},
"test/production/app-dir/actions-tree-shaking/use-effect-actions/use-effect-actions.test.ts": {
"passed": [],
"failed": [
"actions-tree-shaking - use-effect-actions should not tree shake the used action under useEffect"
],
"pending": [],
"flakey": [],
"runtimeError": false
} }
}, },
"rules": { "rules": {
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