Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
15fe5db1
Unverified
Commit
15fe5db1
authored
Sep 22, 2024
by
Jiachi Liu
Committed by
GitHub
Sep 22, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: update SA tree-shaking test (#70327)
parent
607e383d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
223 additions
and
117 deletions
+223
-117
basic.test.ts
...oduction/app-dir/actions-tree-shaking/basic/basic.test.ts
+26
-23
mixed-module-actions.test.ts
...shaking/mixed-module-actions/mixed-module-actions.test.ts
+22
-19
reexport.test.ts
...on/app-dir/actions-tree-shaking/reexport/reexport.test.ts
+53
-49
shared-module-actions.test.ts
...aking/shared-module-actions/shared-module-actions.test.ts
+27
-24
use-effect-actions.test.ts
...ree-shaking/use-effect-actions/use-effect-actions.test.ts
+1
-2
turbopack-build-tests-manifest.json
test/turbopack-build-tests-manifest.json
+94
-0
No files found.
test/production/app-dir/actions-tree-shaking/basic/basic.test.ts
View file @
15fe5db1
...
@@ -5,30 +5,33 @@ import {
...
@@ -5,30 +5,33 @@ import {
}
from
'../_testing/utils'
}
from
'../_testing/utils'
// TODO: revisit when we have a better side-effect free transform approach for server action
// TODO: revisit when we have a better side-effect free transform approach for server action
describe
.
skip
(
'actions-tree-shaking - basic'
,
()
=>
{
;(
process
.
env
.
TURBOPACK
?
describe
:
describe
.
skip
)(
const
{
next
}
=
nextTestSetup
({
'actions-tree-shaking - basic'
,
files
:
__dirname
,
()
=>
{
})
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
})
if
(
process
.
env
.
TEST_EDGE
)
{
if
(
process
.
env
.
TEST_EDGE
)
{
markLayoutAsEdge
(
next
)
markLayoutAsEdge
(
next
)
}
}
it
(
'should not have the unused action in the manifest'
,
async
()
=>
{
it
(
'should not have the unused action in the manifest'
,
async
()
=>
{
const
actionsRoutesState
=
await
getActionsRoutesStateByRuntime
(
next
)
const
actionsRoutesState
=
await
getActionsRoutesStateByRuntime
(
next
)
expect
(
actionsRoutesState
).
toMatchObject
({
expect
(
actionsRoutesState
).
toMatchObject
({
// only one server layer action
// only one server layer action
'app/server/page'
:
{
'app/server/page'
:
{
rsc
:
1
,
rsc
:
1
,
},
},
// only one browser layer action
// only one browser layer action
'app/client/page'
:
{
'app/client/page'
:
{
'action-browser'
:
1
,
'action-browser'
:
1
,
},
},
'app/inline/page'
:
{
'app/inline/page'
:
{
rsc
:
1
,
rsc
:
1
,
},
},
})
})
})
}
)
}
}
)
)
test/production/app-dir/actions-tree-shaking/mixed-module-actions/mixed-module-actions.test.ts
View file @
15fe5db1
...
@@ -5,26 +5,29 @@ import {
...
@@ -5,26 +5,29 @@ import {
}
from
'../_testing/utils'
}
from
'../_testing/utils'
// TODO: revisit when we have a better side-effect free transform approach for server action
// TODO: revisit when we have a better side-effect free transform approach for server action
describe
.
skip
(
'actions-tree-shaking - mixed-module-actions'
,
()
=>
{
;(
process
.
env
.
TURBOPACK
?
describe
:
describe
.
skip
)(
const
{
next
}
=
nextTestSetup
({
'actions-tree-shaking - mixed-module-actions'
,
files
:
__dirname
,
()
=>
{
})
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
})
if
(
process
.
env
.
TEST_EDGE
)
{
if
(
process
.
env
.
TEST_EDGE
)
{
markLayoutAsEdge
(
next
)
markLayoutAsEdge
(
next
)
}
}
it
(
'should not do tree shake for cjs module when import server actions'
,
async
()
=>
{
it
(
'should not do tree shake for cjs module when import server actions'
,
async
()
=>
{
const
actionsRoutesState
=
await
getActionsRoutesStateByRuntime
(
next
)
const
actionsRoutesState
=
await
getActionsRoutesStateByRuntime
(
next
)
expect
(
actionsRoutesState
).
toMatchObject
({
expect
(
actionsRoutesState
).
toMatchObject
({
'app/mixed-module/esm/page'
:
{
'app/mixed-module/esm/page'
:
{
rsc
:
1
,
rsc
:
1
,
},
},
// CJS import is not able to tree shake, so it will include all actions
// CJS import is not able to tree shake, so it will include all actions
'app/mixed-module/cjs/page'
:
{
'app/mixed-module/cjs/page'
:
{
rsc
:
3
,
rsc
:
3
,
},
},
})
})
})
}
)
}
}
)
)
test/production/app-dir/actions-tree-shaking/reexport/reexport.test.ts
View file @
15fe5db1
...
@@ -6,63 +6,67 @@ import {
...
@@ -6,63 +6,67 @@ import {
import
{
retry
}
from
'next-test-utils'
import
{
retry
}
from
'next-test-utils'
// TODO: revisit when we have a better side-effect free transform approach for server action
// TODO: revisit when we have a better side-effect free transform approach for server action
describe
.
skip
(
'actions-tree-shaking - reexport'
,
()
=>
{
;(
process
.
env
.
TURBOPACK
?
describe
:
describe
.
skip
)(
const
{
next
}
=
nextTestSetup
({
'actions-tree-shaking - reexport'
,
files
:
__dirname
,
()
=>
{
skipDeployment
:
true
,
const
{
next
}
=
nextTestSetup
({
})
files
:
__dirname
,
skipDeployment
:
true
,
})
if
(
process
.
env
.
TEST_EDGE
)
{
if
(
process
.
env
.
TEST_EDGE
)
{
markLayoutAsEdge
(
next
)
markLayoutAsEdge
(
next
)
}
}
it
(
'should not tree-shake namespace exports the manifest'
,
async
()
=>
{
it
(
'should not tree-shake namespace exports the manifest'
,
async
()
=>
{
const
actionsRoutesState
=
await
getActionsRoutesStateByRuntime
(
next
)
const
actionsRoutesState
=
await
getActionsRoutesStateByRuntime
(
next
)
expect
(
actionsRoutesState
).
toMatchObject
({
expect
(
actionsRoutesState
).
toMatchObject
({
'app/namespace-reexport/server/page'
:
{
'app/namespace-reexport/server/page'
:
{
rsc
:
3
,
// Turbopack does not tree-shake server side chunks
},
rsc
:
process
.
env
.
TURBOPACK
?
3
:
1
,
'app/namespace-reexport/client/page'
:
{
},
'action-browser'
:
3
,
'app/namespace-reexport/client/page'
:
{
},
// Turbopack does not support tree-shaking export * as we don't have global information
'app/named-reexport/server/page'
:
{
'action-browser'
:
process
.
env
.
TURBOPACK
?
3
:
1
,
rsc
:
3
,
},
},
// We're not able to tree-shake these re-exports here in webpack mode
'app/namespace-reexport-2/client/page'
:
{
'app/named-reexport/server/page'
:
{
'action-browser'
:
3
,
// Turbopack supports tree-shaking these re-exports
},
rsc
:
process
.
env
.
TURBOPACK
?
1
:
3
,
'app/namespace-reexport-2/server/page'
:
{
},
rsc
:
3
,
'app/named-reexport/client/page'
:
{
},
'action-browser'
:
3
,
},
})
})
})
})
it
(
'should keep all the action exports for namespace export case on client layer'
,
async
()
=>
{
it
(
'should keep all the action exports for namespace export case on client layer'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/namespace-reexport-2/client'
)
const
browser
=
await
next
.
browser
(
'/namespace-reexport-2/client'
)
const
outputSize
=
next
.
cliOutput
.
length
const
outputSize
=
next
.
cliOutput
.
length
await
browser
.
elementByCss
(
'#test-1'
).
click
()
await
browser
.
elementByCss
(
'#test-1'
).
click
()
await
retry
(
async
()
=>
{
await
retry
(
async
()
=>
{
const
output
=
next
.
cliOutput
.
slice
(
outputSize
)
const
output
=
next
.
cliOutput
.
slice
(
outputSize
)
expect
(
output
).
toContain
(
'action: test-1'
)
expect
(
output
).
toContain
(
'action: test-1'
)
})
})
await
browser
.
elementByCss
(
'#test-2'
).
click
()
await
browser
.
elementByCss
(
'#test-2'
).
click
()
await
retry
(
async
()
=>
{
await
retry
(
async
()
=>
{
const
output
=
next
.
cliOutput
.
slice
(
outputSize
)
const
output
=
next
.
cliOutput
.
slice
(
outputSize
)
expect
(
output
).
toContain
(
'action: test-2'
)
expect
(
output
).
toContain
(
'action: test-2'
)
})
})
})
})
it
(
'should keep all the action exports for namespace export case on server layer'
,
async
()
=>
{
it
(
'should keep all the action exports for namespace export case on server layer'
,
async
()
=>
{
const
outputSize
=
next
.
cliOutput
.
length
const
outputSize
=
next
.
cliOutput
.
length
await
next
.
browser
(
'/namespace-reexport-2/server'
)
await
next
.
browser
(
'/namespace-reexport-2/server'
)
await
retry
(
async
()
=>
{
await
retry
(
async
()
=>
{
const
output
=
next
.
cliOutput
.
slice
(
outputSize
)
const
output
=
next
.
cliOutput
.
slice
(
outputSize
)
expect
(
output
).
toContain
(
'action: test-1'
)
expect
(
output
).
toContain
(
'action: test-1'
)
expect
(
output
).
toContain
(
'action: test-2'
)
expect
(
output
).
toContain
(
'action: test-2'
)
})
})
})
}
)
}
}
)
)
test/production/app-dir/actions-tree-shaking/shared-module-actions/shared-module-actions.test.ts
View file @
15fe5db1
...
@@ -5,31 +5,34 @@ import {
...
@@ -5,31 +5,34 @@ import {
}
from
'../_testing/utils'
}
from
'../_testing/utils'
// TODO: revisit when we have a better side-effect free transform approach for server action
// TODO: revisit when we have a better side-effect free transform approach for server action
describe
.
skip
(
'actions-tree-shaking - shared-module-actions'
,
()
=>
{
;(
process
.
env
.
TURBOPACK
?
describe
:
describe
.
skip
)(
const
{
next
}
=
nextTestSetup
({
'actions-tree-shaking - shared-module-actions'
,
files
:
__dirname
,
()
=>
{
})
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
})
if
(
process
.
env
.
TEST_EDGE
)
{
if
(
process
.
env
.
TEST_EDGE
)
{
markLayoutAsEdge
(
next
)
markLayoutAsEdge
(
next
)
}
}
it
(
'should not have the unused action in the manifest'
,
async
()
=>
{
it
(
'should not have the unused action in the manifest'
,
async
()
=>
{
const
actionsRoutesState
=
await
getActionsRoutesStateByRuntime
(
next
)
const
actionsRoutesState
=
await
getActionsRoutesStateByRuntime
(
next
)
expect
(
actionsRoutesState
).
toMatchObject
({
expect
(
actionsRoutesState
).
toMatchObject
({
'app/server/one/page'
:
{
'app/server/one/page'
:
{
rsc
:
1
,
rsc
:
1
,
},
},
'app/server/two/page'
:
{
'app/server/two/page'
:
{
rsc
:
1
,
rsc
:
1
,
},
},
'app/client/one/page'
:
{
'app/client/one/page'
:
{
'action-browser'
:
1
,
'action-browser'
:
1
,
},
},
'app/client/two/page'
:
{
'app/client/two/page'
:
{
'action-browser'
:
1
,
'action-browser'
:
1
,
},
},
})
})
})
}
)
}
}
)
)
test/production/app-dir/actions-tree-shaking/use-effect-actions/use-effect-actions.test.ts
View file @
15fe5db1
...
@@ -4,8 +4,7 @@ import {
...
@@ -4,8 +4,7 @@ import {
markLayoutAsEdge
,
markLayoutAsEdge
,
}
from
'../_testing/utils'
}
from
'../_testing/utils'
// TODO: revisit when we have a better side-effect free transform approach for server action
describe
(
'actions-tree-shaking - use-effect-actions'
,
()
=>
{
describe
.
skip
(
'actions-tree-shaking - use-effect-actions'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
files
:
__dirname
,
})
})
...
...
test/turbopack-build-tests-manifest.json
View file @
15fe5db1
...
@@ -15597,6 +15597,100 @@
...
@@ -15597,6 +15597,100 @@
"flakey"
:
[],
"flakey"
:
[],
"runtimeError"
:
false
"runtimeError"
:
false
},
},
"test/production/app-dir/actions-tree-shaking/basic/basic-edge.test.ts"
:
{
"passed"
:
[],
"failed"
:
[
"actions-tree-shaking - basic should not have the unused action in the manifest"
],
"pending"
:
[],
"flakey"
:
[],
"runtimeError"
:
false
},
"test/production/app-dir/actions-tree-shaking/basic/basic.test.ts"
:
{
"passed"
:
[
"actions-tree-shaking - basic should not have the unused action in the manifest"
],
"failed"
:
[],
"pending"
:
[],
"flakey"
:
[],
"runtimeError"
:
false
},
"test/production/app-dir/actions-tree-shaking/mixed-module-actions/mixed-module-actions-edge.test.ts"
:
{
"passed"
:
[
"actions-tree-shaking - mixed-module-actions should not do tree shake for cjs module when import server actions"
],
"failed"
:
[],
"pending"
:
[],
"flakey"
:
[],
"runtimeError"
:
false
},
"test/production/app-dir/actions-tree-shaking/mixed-module-actions/mixed-module-actions.test.ts"
:
{
"passed"
:
[
"actions-tree-shaking - mixed-module-actions should not do tree shake for cjs module when import server actions"
],
"failed"
:
[],
"pending"
:
[],
"flakey"
:
[],
"runtimeError"
:
false
},
"test/production/app-dir/actions-tree-shaking/reexport/reexport-edge.test.ts"
:
{
"passed"
:
[
"actions-tree-shaking - reexport should not have the unused action in the manifest"
],
"failed"
:
[
"actions-tree-shaking - reexport should keep all the action exports for namespace export case on client layer"
],
"pending"
:
[],
"flakey"
:
[],
"runtimeError"
:
false
},
"test/production/app-dir/actions-tree-shaking/reexport/reexport.test.ts"
:
{
"passed"
:
[
"actions-tree-shaking - reexport should not have the unused action in the manifest"
],
"failed"
:
[
"actions-tree-shaking - reexport should keep all the action exports for namespace export case on client layer"
],
"pending"
:
[],
"flakey"
:
[],
"runtimeError"
:
false
},
"test/production/app-dir/actions-tree-shaking/shared-module-actions/shared-module-actions-edge.test.ts"
:
{
"passed"
:
[
"actions-tree-shaking - shared-module-actions should not have the unused action in the manifest"
],
"failed"
:
[],
"pending"
:
[],
"flakey"
:
[],
"runtimeError"
:
false
},
"test/production/app-dir/actions-tree-shaking/shared-module-actions/shared-module-actions.test.ts"
:
{
"passed"
:
[
"actions-tree-shaking - shared-module-actions should not have the unused action in the manifest"
],
"failed"
:
[],
"pending"
:
[],
"flakey"
:
[],
"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/actions-tree-shaking/client-actions-tree-shaking/client-actions-tree-shaking.test.ts"
:
{
"test/production/app-dir/actions-tree-shaking/client-actions-tree-shaking/client-actions-tree-shaking.test.ts"
:
{
"passed"
:
[],
"passed"
:
[],
"failed"
:
[
"failed"
:
[
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment