-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable experimental.optimizeServer by default (#69788)
- Loading branch information
Showing
11 changed files
with
146 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
test/production/app-dir/actions-tree-shaking/shared-module-actions/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"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"] | ||
} |
7 changes: 7 additions & 0 deletions
7
test/production/app-dir/actions-tree-shaking/use-effect-actions/app/layout.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Layout({ children }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
11 changes: 11 additions & 0 deletions
11
test/production/app-dir/actions-tree-shaking/use-effect-actions/app/mixed/actions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use server' | ||
|
||
export async function action1() { | ||
return { hello: 'world' } | ||
} | ||
export async function action2() { | ||
return { hello: 'action2' } | ||
} | ||
export async function action3() { | ||
return { hello: 'action3' } | ||
} |
9 changes: 9 additions & 0 deletions
9
test/production/app-dir/actions-tree-shaking/use-effect-actions/app/mixed/my-component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
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> | ||
} |
23 changes: 23 additions & 0 deletions
23
test/production/app-dir/actions-tree-shaking/use-effect-actions/app/mixed/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'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 /> | ||
} |
24 changes: 24 additions & 0 deletions
24
test/production/app-dir/actions-tree-shaking/use-effect-actions/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"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"] | ||
} |
3 changes: 3 additions & 0 deletions
3
...roduction/app-dir/actions-tree-shaking/use-effect-actions/use-effect-actions-edge.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
process.env.TEST_EDGE = '1' | ||
|
||
require('./use-effect-actions.test') |
25 changes: 25 additions & 0 deletions
25
test/production/app-dir/actions-tree-shaking/use-effect-actions/use-effect-actions.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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, | ||
}, | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters