Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoCo_Code_Op2
next.js
提交
abd69ec4
N
next.js
项目概览
CoCo_Code_Op2
/
next.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
next.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
abd69ec4
编写于
1月 27, 2020
作者:
J
Joe Haddad
提交者:
GitHub
1月 27, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix Experimental Modern Mode with CSS (#10289)
上级
ac6a7f96
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
242 addition
and
1 deletion
+242
-1
packages/next/build/webpack/plugins/build-manifest-plugin.ts
packages/next/build/webpack/plugins/build-manifest-plugin.ts
+3
-1
test/integration/css-client-nav/test/index.test.js
test/integration/css-client-nav/test/index.test.js
+156
-0
test/integration/css-fixtures/multi-module-modern/next.config.js
...tegration/css-fixtures/multi-module-modern/next.config.js
+9
-0
test/integration/css-fixtures/multi-module-modern/pages/blue.js
...ntegration/css-fixtures/multi-module-modern/pages/blue.js
+20
-0
test/integration/css-fixtures/multi-module-modern/pages/blue.module.css
...on/css-fixtures/multi-module-modern/pages/blue.module.css
+3
-0
test/integration/css-fixtures/multi-module-modern/pages/none.js
...ntegration/css-fixtures/multi-module-modern/pages/none.js
+19
-0
test/integration/css-fixtures/multi-module-modern/pages/red.js
...integration/css-fixtures/multi-module-modern/pages/red.js
+20
-0
test/integration/css-fixtures/multi-module-modern/pages/red.module.css
...ion/css-fixtures/multi-module-modern/pages/red.module.css
+3
-0
test/integration/css-fixtures/multi-module/next.config.js
test/integration/css-fixtures/multi-module/next.config.js
+9
-0
未找到文件。
packages/next/build/webpack/plugins/build-manifest-plugin.ts
浏览文件 @
abd69ec4
...
...
@@ -33,7 +33,9 @@ const generateClientManifest = (
// Filter out dependencies in the _app entry, because those will have already
// been loaded by the client prior to a navigation event
const
filteredDeps
=
dependencies
.
filter
(
dep
=>
!
appDependencies
.
has
(
dep
)
&&
/
\.
module
\.
js$/
.
test
(
dep
)
===
isModern
dep
=>
!
appDependencies
.
has
(
dep
)
&&
(
!
dep
.
endsWith
(
'
.js
'
)
||
dep
.
endsWith
(
'
.module.js
'
)
===
isModern
)
)
// The manifest can omit the page if it has no requirements
...
...
test/integration/css-client-nav/test/index.test.js
浏览文件 @
abd69ec4
...
...
@@ -171,3 +171,159 @@ describe('CSS Module client-side navigation in Production', () => {
}
})
})
describe
(
'
CSS Module client-side navigation in Production (Modern)
'
,
()
=>
{
const
appDir
=
join
(
fixturesDir
,
'
multi-module-modern
'
)
beforeAll
(
async
()
=>
{
await
remove
(
join
(
appDir
,
'
.next
'
))
})
let
appPort
let
app
beforeAll
(
async
()
=>
{
await
nextBuild
(
appDir
)
appPort
=
await
findPort
()
app
=
await
nextStart
(
appDir
,
appPort
)
})
afterAll
(
async
()
=>
{
await
killApp
(
app
)
})
it
(
'
should be able to client-side navigate from red to blue
'
,
async
()
=>
{
let
browser
try
{
browser
=
await
webdriver
(
appPort
,
'
/red
'
)
await
browser
.
eval
(
`window.__did_not_ssr = 'make sure this is set'`
)
const
redColor
=
await
browser
.
eval
(
`window.getComputedStyle(document.querySelector('#verify-red')).color`
)
expect
(
redColor
).
toMatchInlineSnapshot
(
`"rgb(255, 0, 0)"`
)
await
browser
.
elementByCss
(
'
#link-blue
'
).
click
()
await
browser
.
waitForElementByCss
(
'
#verify-blue
'
)
const
blueColor
=
await
browser
.
eval
(
`window.getComputedStyle(document.querySelector('#verify-blue')).color`
)
expect
(
blueColor
).
toMatchInlineSnapshot
(
`"rgb(0, 0, 255)"`
)
expect
(
await
browser
.
eval
(
`window.__did_not_ssr`
)).
toMatchInlineSnapshot
(
`"make sure this is set"`
)
}
finally
{
if
(
browser
)
{
await
browser
.
close
()
}
}
})
it
(
'
should be able to client-side navigate from blue to red
'
,
async
()
=>
{
const
content
=
await
renderViaHTTP
(
appPort
,
'
/blue
'
)
const
$
=
cheerio
.
load
(
content
)
// Ensure only `/blue` page's CSS is preloaded
const
serverCssPreloads
=
$
(
'
link[rel="preload"][as="style"]
'
)
expect
(
serverCssPreloads
.
length
).
toBe
(
1
)
const
serverCssPrefetches
=
$
(
'
link[rel="prefetch"][as="style"]
'
)
expect
(
serverCssPrefetches
.
length
).
toBe
(
0
)
let
browser
try
{
browser
=
await
webdriver
(
appPort
,
'
/blue
'
)
await
browser
.
eval
(
`window.__did_not_ssr = 'make sure this is set'`
)
const
redColor
=
await
browser
.
eval
(
`window.getComputedStyle(document.querySelector('#verify-blue')).color`
)
expect
(
redColor
).
toMatchInlineSnapshot
(
`"rgb(0, 0, 255)"`
)
// Check that Red was preloaded
const
result
=
await
browser
.
eval
(
`[].slice.call(document.querySelectorAll('link[rel="prefetch"][as="style"]')).map(e=>({href:e.href})).sort()`
)
expect
(
result
.
length
).
toBe
(
1
)
// Check that CSS was not loaded as script
const
cssPreloads
=
await
browser
.
eval
(
`[].slice.call(document.querySelectorAll('link[rel=preload][href*=".css"]')).map(e=>e.as)`
)
expect
(
cssPreloads
.
every
(
e
=>
e
===
'
style
'
)).
toBe
(
true
)
const
cssPreloads2
=
await
browser
.
eval
(
`[].slice.call(document.querySelectorAll('link[rel=prefetch][href*=".css"]')).map(e=>e.as)`
)
expect
(
cssPreloads2
.
every
(
e
=>
e
===
'
style
'
)).
toBe
(
true
)
await
browser
.
elementByCss
(
'
#link-red
'
).
click
()
await
browser
.
waitForElementByCss
(
'
#verify-red
'
)
const
blueColor
=
await
browser
.
eval
(
`window.getComputedStyle(document.querySelector('#verify-red')).color`
)
expect
(
blueColor
).
toMatchInlineSnapshot
(
`"rgb(255, 0, 0)"`
)
expect
(
await
browser
.
eval
(
`window.__did_not_ssr`
)).
toMatchInlineSnapshot
(
`"make sure this is set"`
)
}
finally
{
if
(
browser
)
{
await
browser
.
close
()
}
}
})
it
(
'
should be able to client-side navigate from none to red
'
,
async
()
=>
{
let
browser
try
{
browser
=
await
webdriver
(
appPort
,
'
/none
'
)
await
browser
.
eval
(
`window.__did_not_ssr = 'make sure this is set'`
)
await
browser
.
elementByCss
(
'
#link-red
'
).
click
()
await
browser
.
waitForElementByCss
(
'
#verify-red
'
)
const
blueColor
=
await
browser
.
eval
(
`window.getComputedStyle(document.querySelector('#verify-red')).color`
)
expect
(
blueColor
).
toMatchInlineSnapshot
(
`"rgb(255, 0, 0)"`
)
expect
(
await
browser
.
eval
(
`window.__did_not_ssr`
)).
toMatchInlineSnapshot
(
`"make sure this is set"`
)
}
finally
{
if
(
browser
)
{
await
browser
.
close
()
}
}
})
it
(
'
should be able to client-side navigate from none to blue
'
,
async
()
=>
{
let
browser
try
{
browser
=
await
webdriver
(
appPort
,
'
/none
'
)
await
browser
.
eval
(
`window.__did_not_ssr = 'make sure this is set'`
)
await
browser
.
elementByCss
(
'
#link-blue
'
).
click
()
await
browser
.
waitForElementByCss
(
'
#verify-blue
'
)
const
blueColor
=
await
browser
.
eval
(
`window.getComputedStyle(document.querySelector('#verify-blue')).color`
)
expect
(
blueColor
).
toMatchInlineSnapshot
(
`"rgb(0, 0, 255)"`
)
expect
(
await
browser
.
eval
(
`window.__did_not_ssr`
)).
toMatchInlineSnapshot
(
`"make sure this is set"`
)
}
finally
{
if
(
browser
)
{
await
browser
.
close
()
}
}
})
})
test/integration/css-fixtures/multi-module-modern/next.config.js
0 → 100644
浏览文件 @
abd69ec4
const
parent
=
require
(
'
../next.config
'
)
module
.
exports
=
{
...
parent
,
experimental
:
{
...
parent
.
experimental
,
modern
:
true
,
},
}
test/integration/css-fixtures/multi-module-modern/pages/blue.js
0 → 100644
浏览文件 @
abd69ec4
import
Link
from
'
next/link
'
import
{
blueText
}
from
'
./blue.module.css
'
export
default
function
Blue
()
{
return
(
<>
<
div
id
=
"
verify-blue
"
className
=
{
blueText
}
>
This
text
should
be
blue
.
<
/div
>
<
br
/>
<
Link
href
=
"
/red
"
prefetch
>
<
a
id
=
"
link-red
"
>
Red
<
/a
>
<
/Link
>
<
br
/>
<
Link
href
=
"
/none
"
prefetch
=
{
false
}
>
<
a
id
=
"
link-none
"
>
None
<
/a
>
<
/Link
>
<
/
>
)
}
test/integration/css-fixtures/multi-module-modern/pages/blue.module.css
0 → 100644
浏览文件 @
abd69ec4
.blueText
{
color
:
blue
;
}
test/integration/css-fixtures/multi-module-modern/pages/none.js
0 → 100644
浏览文件 @
abd69ec4
import
Link
from
'
next/link
'
export
default
function
None
()
{
return
(
<>
<
div
id
=
"
verify-black
"
style
=
{{
color
:
'
black
'
}}
>
This
text
should
be
black
.
<
/div
>
<
br
/>
<
Link
href
=
"
/red
"
prefetch
=
{
false
}
>
<
a
id
=
"
link-red
"
>
Red
<
/a
>
<
/Link
>
<
br
/>
<
Link
href
=
"
/blue
"
prefetch
=
{
false
}
>
<
a
id
=
"
link-blue
"
>
Blue
<
/a
>
<
/Link
>
<
/
>
)
}
test/integration/css-fixtures/multi-module-modern/pages/red.js
0 → 100644
浏览文件 @
abd69ec4
import
Link
from
'
next/link
'
import
{
redText
}
from
'
./red.module.css
'
export
default
function
Red
()
{
return
(
<>
<
div
id
=
"
verify-red
"
className
=
{
redText
}
>
This
text
should
be
red
.
<
/div
>
<
br
/>
<
Link
href
=
"
/blue
"
prefetch
=
{
false
}
>
<
a
id
=
"
link-blue
"
>
Blue
<
/a
>
<
/Link
>
<
br
/>
<
Link
href
=
"
/none
"
prefetch
=
{
false
}
>
<
a
id
=
"
link-none
"
>
None
<
/a
>
<
/Link
>
<
/
>
)
}
test/integration/css-fixtures/multi-module-modern/pages/red.module.css
0 → 100644
浏览文件 @
abd69ec4
.redText
{
color
:
red
;
}
test/integration/css-fixtures/multi-module/next.config.js
0 → 100644
浏览文件 @
abd69ec4
const
parent
=
require
(
'
../next.config
'
)
module
.
exports
=
{
...
parent
,
experimental
:
{
...
parent
.
experimental
,
modern
:
false
,
},
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录