Unverified Commit 87e91d5b authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Disable experimental.optimizeServer by default (#69788)

parent d463bde6
...@@ -1066,7 +1066,7 @@ export const defaultConfig: NextConfig = { ...@@ -1066,7 +1066,7 @@ export const defaultConfig: NextConfig = {
), ),
webpackBuildWorker: undefined, webpackBuildWorker: undefined,
webpackMemoryOptimizations: false, webpackMemoryOptimizations: false,
optimizeServerReact: true, optimizeServerReact: false,
useEarlyImport: false, useEarlyImport: false,
staleTimes: { staleTimes: {
dynamic: 0, dynamic: 0,
......
// @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,
},
})
})
})
...@@ -15674,6 +15674,24 @@ ...@@ -15674,6 +15674,24 @@
"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
},
"test/production/app-dir/app-edge-middleware/app-edge-middleware.test.ts": { "test/production/app-dir/app-edge-middleware/app-edge-middleware.test.ts": {
"passed": [ "passed": [
"app edge middleware without node.js modules should not have any errors about using Node.js modules if not present in middleware" "app edge middleware without node.js modules should not have any errors about using Node.js modules if not present in middleware"
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