Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoCo_Code_Op2
next.js
提交
06d53544
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,发现更多精彩内容 >>
未验证
提交
06d53544
编写于
4月 28, 2020
作者:
T
Tim Neutkens
提交者:
GitHub
4月 28, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove documentMiddleware experimental option (#12218)
上级
e6424fef
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
0 addition
and
102 deletion
+0
-102
packages/next/next-server/server/config.ts
packages/next/next-server/server/config.ts
+0
-1
packages/next/next-server/server/load-components.ts
packages/next/next-server/server/load-components.ts
+0
-4
packages/next/next-server/server/next-server.ts
packages/next/next-server/server/next-server.ts
+0
-3
packages/next/next-server/server/render.tsx
packages/next/next-server/server/render.tsx
+0
-7
test/integration/document-middleware/next.config.js
test/integration/document-middleware/next.config.js
+0
-3
test/integration/document-middleware/pages/_document.js
test/integration/document-middleware/pages/_document.js
+0
-32
test/integration/document-middleware/pages/another.js
test/integration/document-middleware/pages/another.js
+0
-3
test/integration/document-middleware/pages/index.js
test/integration/document-middleware/pages/index.js
+0
-3
test/integration/document-middleware/test/index.test.js
test/integration/document-middleware/test/index.test.js
+0
-46
未找到文件。
packages/next/next-server/server/config.ts
浏览文件 @
06d53544
...
@@ -41,7 +41,6 @@ const defaultConfig: { [key: string]: any } = {
...
@@ -41,7 +41,6 @@ const defaultConfig: { [key: string]: any } = {
(
Number
(
process
.
env
.
CIRCLE_NODE_TOTAL
)
||
(
Number
(
process
.
env
.
CIRCLE_NODE_TOTAL
)
||
(
os
.
cpus
()
||
{
length
:
1
}).
length
)
-
1
(
os
.
cpus
()
||
{
length
:
1
}).
length
)
-
1
),
),
documentMiddleware
:
false
,
granularChunks
:
true
,
granularChunks
:
true
,
modern
:
false
,
modern
:
false
,
plugins
:
false
,
plugins
:
false
,
...
...
packages/next/next-server/server/load-components.ts
浏览文件 @
06d53544
...
@@ -10,7 +10,6 @@ import { BuildManifest } from './get-page-files'
...
@@ -10,7 +10,6 @@ import { BuildManifest } from './get-page-files'
import
{
AppType
,
DocumentType
}
from
'
../lib/utils
'
import
{
AppType
,
DocumentType
}
from
'
../lib/utils
'
import
{
import
{
PageConfig
,
PageConfig
,
NextPageContext
,
GetStaticPaths
,
GetStaticPaths
,
GetServerSideProps
,
GetServerSideProps
,
GetStaticProps
,
GetStaticProps
,
...
@@ -35,7 +34,6 @@ export type LoadComponentsReturnType = {
...
@@ -35,7 +34,6 @@ export type LoadComponentsReturnType = {
buildManifest
:
BuildManifest
buildManifest
:
BuildManifest
reactLoadableManifest
:
ReactLoadableManifest
reactLoadableManifest
:
ReactLoadableManifest
Document
:
DocumentType
Document
:
DocumentType
DocumentMiddleware
?:
(
ctx
:
NextPageContext
)
=>
void
App
:
AppType
App
:
AppType
getStaticProps
?:
GetStaticProps
getStaticProps
?:
GetStaticProps
getStaticPaths
?:
GetStaticPaths
getStaticPaths
?:
GetStaticPaths
...
@@ -78,7 +76,6 @@ export async function loadComponents(
...
@@ -78,7 +76,6 @@ export async function loadComponents(
)
)
const
DocumentMod
=
require
(
documentPath
)
const
DocumentMod
=
require
(
documentPath
)
const
{
middleware
:
DocumentMiddleware
}
=
DocumentMod
const
AppMod
=
require
(
appPath
)
const
AppMod
=
require
(
appPath
)
...
@@ -105,7 +102,6 @@ export async function loadComponents(
...
@@ -105,7 +102,6 @@ export async function loadComponents(
Document
,
Document
,
Component
,
Component
,
buildManifest
,
buildManifest
,
DocumentMiddleware
,
reactLoadableManifest
,
reactLoadableManifest
,
pageConfig
:
ComponentMod
.
config
||
{},
pageConfig
:
ComponentMod
.
config
||
{},
getServerSideProps
,
getServerSideProps
,
...
...
packages/next/next-server/server/next-server.ts
浏览文件 @
06d53544
...
@@ -118,7 +118,6 @@ export default class Server {
...
@@ -118,7 +118,6 @@ export default class Server {
runtimeConfig
?:
{
[
key
:
string
]:
any
}
runtimeConfig
?:
{
[
key
:
string
]:
any
}
assetPrefix
?:
string
assetPrefix
?:
string
canonicalBase
:
string
canonicalBase
:
string
documentMiddlewareEnabled
:
boolean
dev
?:
boolean
dev
?:
boolean
previewProps
:
__ApiPreviewProps
previewProps
:
__ApiPreviewProps
customServer
?:
boolean
customServer
?:
boolean
...
@@ -171,8 +170,6 @@ export default class Server {
...
@@ -171,8 +170,6 @@ export default class Server {
this
.
renderOpts
=
{
this
.
renderOpts
=
{
poweredByHeader
:
this
.
nextConfig
.
poweredByHeader
,
poweredByHeader
:
this
.
nextConfig
.
poweredByHeader
,
canonicalBase
:
this
.
nextConfig
.
amp
.
canonicalBase
,
canonicalBase
:
this
.
nextConfig
.
amp
.
canonicalBase
,
documentMiddlewareEnabled
:
this
.
nextConfig
.
experimental
.
documentMiddleware
,
staticMarkup
,
staticMarkup
,
buildId
:
this
.
buildId
,
buildId
:
this
.
buildId
,
generateEtags
,
generateEtags
,
...
...
packages/next/next-server/server/render.tsx
浏览文件 @
06d53544
...
@@ -153,7 +153,6 @@ export type RenderOptsPartial = {
...
@@ -153,7 +153,6 @@ export type RenderOptsPartial = {
ampValidator
?:
(
html
:
string
,
pathname
:
string
)
=>
Promise
<
void
>
ampValidator
?:
(
html
:
string
,
pathname
:
string
)
=>
Promise
<
void
>
ampSkipValidation
?:
boolean
ampSkipValidation
?:
boolean
ampOptimizerConfig
?:
{
[
key
:
string
]:
any
}
ampOptimizerConfig
?:
{
[
key
:
string
]:
any
}
documentMiddlewareEnabled
?:
boolean
isDataReq
?:
boolean
isDataReq
?:
boolean
params
?:
ParsedUrlQuery
params
?:
ParsedUrlQuery
previewProps
:
__ApiPreviewProps
previewProps
:
__ApiPreviewProps
...
@@ -295,13 +294,11 @@ export async function renderToHTML(
...
@@ -295,13 +294,11 @@ export async function renderToHTML(
const
{
const
{
err
,
err
,
dev
=
false
,
dev
=
false
,
documentMiddlewareEnabled
=
false
,
staticMarkup
=
false
,
staticMarkup
=
false
,
ampPath
=
''
,
ampPath
=
''
,
App
,
App
,
Document
,
Document
,
pageConfig
=
{},
pageConfig
=
{},
DocumentMiddleware
,
Component
,
Component
,
buildManifest
,
buildManifest
,
reactLoadableManifest
,
reactLoadableManifest
,
...
@@ -483,10 +480,6 @@ export async function renderToHTML(
...
@@ -483,10 +480,6 @@ export async function renderToHTML(
}
}
let
props
:
any
let
props
:
any
if
(
documentMiddlewareEnabled
&&
typeof
DocumentMiddleware
===
'
function
'
)
{
await
DocumentMiddleware
(
ctx
)
}
const
ampState
=
{
const
ampState
=
{
ampFirst
:
pageConfig
.
amp
===
true
,
ampFirst
:
pageConfig
.
amp
===
true
,
hasQuery
:
Boolean
(
query
.
amp
),
hasQuery
:
Boolean
(
query
.
amp
),
...
...
test/integration/document-middleware/next.config.js
已删除
100644 → 0
浏览文件 @
e6424fef
module
.
exports
=
{
experimental
:
{
documentMiddleware
:
true
},
}
test/integration/document-middleware/pages/_document.js
已删除
100644 → 0
浏览文件 @
e6424fef
import
Document
,
{
Html
,
Head
,
Main
,
NextScript
}
from
'
next/document
'
export
async
function
middleware
({
req
,
res
})
{
if
(
req
.
url
===
'
/another
'
)
{
res
.
setHeader
(
'
next-middleware
'
,
'
hit another!
'
)
return
res
.
end
()
}
res
.
setHeader
(
'
next-middleware
'
,
'
hi from middleware
'
)
}
class
MyDocument
extends
Document
{
static
async
getInitialProps
(
ctx
)
{
const
initialProps
=
await
Document
.
getInitialProps
(
ctx
)
return
{
...
initialProps
}
}
render
()
{
return
(
<
Html
>
<
Head
>
<
style
>
{
`body { margin: 0 } /* custom! */`
}
<
/style
>
<
/Head
>
<
body
className
=
"
custom_class
"
>
<
Main
/>
<
NextScript
/>
<
/body
>
<
/Html
>
)
}
}
export
default
MyDocument
test/integration/document-middleware/pages/another.js
已删除
100644 → 0
浏览文件 @
e6424fef
const
Another
=
()
=>
<
p
>
Hi
again
👋
<
/p
>
Another
.
getInitialProps
=
()
=>
({})
export
default
Another
test/integration/document-middleware/pages/index.js
已删除
100644 → 0
浏览文件 @
e6424fef
const
Home
=
()
=>
<
p
>
Hi
there
👋
<
/p
>
Home
.
getInitialProps
=
()
=>
({})
export
default
Home
test/integration/document-middleware/test/index.test.js
已删除
100644 → 0
浏览文件 @
e6424fef
/* eslint-env jest */
/* global jasmine */
import
{
join
}
from
'
path
'
import
{
renderViaHTTP
,
fetchViaHTTP
,
findPort
,
launchApp
,
killApp
,
}
from
'
next-test-utils
'
jasmine
.
DEFAULT_TIMEOUT_INTERVAL
=
1000
*
60
*
2
let
app
let
appPort
describe
(
'
Document middleware
'
,
()
=>
{
beforeAll
(
async
()
=>
{
appPort
=
await
findPort
()
app
=
await
launchApp
(
join
(
__dirname
,
'
../
'
),
appPort
)
})
afterAll
(()
=>
killApp
(
app
))
it
(
'
should render a page without error
'
,
async
()
=>
{
const
html
=
await
renderViaHTTP
(
appPort
,
'
/
'
)
expect
(
html
).
toMatch
(
/hi there/i
)
})
it
(
'
should set header in middleware and still render
'
,
async
()
=>
{
const
res
=
await
fetchViaHTTP
(
appPort
,
'
/
'
)
const
html
=
await
res
.
text
()
const
header
=
res
.
headers
.
get
(
'
next-middleware
'
)
expect
(
html
).
toMatch
(
/hi there/i
)
expect
(
header
).
toBe
(
'
hi from middleware
'
)
})
it
(
'
should set header and abort render on res.end()
'
,
async
()
=>
{
const
res
=
await
fetchViaHTTP
(
appPort
,
'
/another
'
)
const
html
=
(
await
res
.
text
())
||
''
const
header
=
res
.
headers
.
get
(
'
next-middleware
'
)
expect
(
html
.
length
).
toBe
(
0
)
expect
(
header
).
toBe
(
'
hit another!
'
)
})
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录