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
06d53544
Unverified
Commit
06d53544
authored
Apr 28, 2020
by
Tim Neutkens
Committed by
GitHub
Apr 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove documentMiddleware experimental option (#12218)
parent
e6424fef
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
0 additions
and
102 deletions
+0
-102
config.ts
packages/next/next-server/server/config.ts
+0
-1
load-components.ts
packages/next/next-server/server/load-components.ts
+0
-4
next-server.ts
packages/next/next-server/server/next-server.ts
+0
-3
render.tsx
packages/next/next-server/server/render.tsx
+0
-7
next.config.js
test/integration/document-middleware/next.config.js
+0
-3
_document.js
test/integration/document-middleware/pages/_document.js
+0
-32
another.js
test/integration/document-middleware/pages/another.js
+0
-3
index.js
test/integration/document-middleware/pages/index.js
+0
-3
index.test.js
test/integration/document-middleware/test/index.test.js
+0
-46
No files found.
packages/next/next-server/server/config.ts
View file @
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
View file @
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
View file @
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
View file @
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
deleted
100644 → 0
View file @
e6424fef
module
.
exports
=
{
experimental
:
{
documentMiddleware
:
true
},
}
test/integration/document-middleware/pages/_document.js
deleted
100644 → 0
View file @
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
deleted
100644 → 0
View file @
e6424fef
const
Another
=
()
=>
<
p
>
Hi
again
👋
<
/p
>
Another
.
getInitialProps
=
()
=>
({})
export
default
Another
test/integration/document-middleware/pages/index.js
deleted
100644 → 0
View file @
e6424fef
const
Home
=
()
=>
<
p
>
Hi
there
👋
<
/p
>
Home
.
getInitialProps
=
()
=>
({})
export
default
Home
test/integration/document-middleware/test/index.test.js
deleted
100644 → 0
View file @
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!'
)
})
})
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