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
7e817cab
Commit
7e817cab
authored
Jan 04, 2020
by
Tim Neutkens
Committed by
Joe Haddad
Jan 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove rewriteUrlForNextExport from bundles when option is not enabled (#9946)
Co-authored-by:
Joe Haddad
<
timer150@gmail.com
>
parent
72a0c557
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
link.tsx
packages/next/client/link.tsx
+2
-1
router.ts
packages/next/next-server/lib/router/router.ts
+9
-2
No files found.
packages/next/client/link.tsx
View file @
7e817cab
...
@@ -3,7 +3,6 @@ declare const __NEXT_DATA__: any
...
@@ -3,7 +3,6 @@ declare const __NEXT_DATA__: any
import
{
resolve
,
parse
,
UrlObject
}
from
'url'
import
{
resolve
,
parse
,
UrlObject
}
from
'url'
import
React
,
{
Component
,
Children
}
from
'react'
import
React
,
{
Component
,
Children
}
from
'react'
import
Router
from
'./router'
import
Router
from
'./router'
import
{
rewriteUrlForNextExport
}
from
'../next-server/lib/router/rewrite-url-for-export'
import
{
import
{
execOnce
,
execOnce
,
formatWithValidation
,
formatWithValidation
,
...
@@ -264,6 +263,8 @@ class Link extends Component<LinkProps> {
...
@@ -264,6 +263,8 @@ class Link extends Component<LinkProps> {
// Add the ending slash to the paths. So, we can serve the
// Add the ending slash to the paths. So, we can serve the
// "<page>/index.html" directly.
// "<page>/index.html" directly.
if
(
process
.
env
.
__NEXT_EXPORT_TRAILING_SLASH
)
{
if
(
process
.
env
.
__NEXT_EXPORT_TRAILING_SLASH
)
{
const
rewriteUrlForNextExport
=
require
(
'../next-server/lib/router/rewrite-url-for-export'
)
.
rewriteUrlForNextExport
if
(
if
(
props
.
href
&&
props
.
href
&&
typeof
__NEXT_DATA__
!==
'undefined'
&&
typeof
__NEXT_DATA__
!==
'undefined'
&&
...
...
packages/next/next-server/lib/router/router.ts
View file @
7e817cab
...
@@ -13,7 +13,6 @@ import {
...
@@ -13,7 +13,6 @@ import {
NextPageContext
,
NextPageContext
,
SUPPORTS_PERFORMANCE_USER_TIMING
,
SUPPORTS_PERFORMANCE_USER_TIMING
,
}
from
'../utils'
}
from
'../utils'
import
{
rewriteUrlForNextExport
}
from
'./rewrite-url-for-export'
import
{
isDynamicRoute
}
from
'./utils/is-dynamic'
import
{
isDynamicRoute
}
from
'./utils/is-dynamic'
import
{
getRouteMatcher
}
from
'./utils/route-matcher'
import
{
getRouteMatcher
}
from
'./utils/route-matcher'
import
{
getRouteRegex
}
from
'./utils/route-regex'
import
{
getRouteRegex
}
from
'./utils/route-regex'
...
@@ -154,7 +153,13 @@ export default class Router implements BaseRouter {
...
@@ -154,7 +153,13 @@ export default class Router implements BaseRouter {
// @deprecated backwards compatibility even though it's a private method.
// @deprecated backwards compatibility even though it's a private method.
static
_rewriteUrlForNextExport
(
url
:
string
):
string
{
static
_rewriteUrlForNextExport
(
url
:
string
):
string
{
if
(
process
.
env
.
__NEXT_EXPORT_TRAILING_SLASH
)
{
const
rewriteUrlForNextExport
=
require
(
'./rewrite-url-for-export'
)
.
rewriteUrlForNextExport
return
rewriteUrlForNextExport
(
url
)
return
rewriteUrlForNextExport
(
url
)
}
else
{
return
url
}
}
}
onPopState
=
(
e
:
PopStateEvent
):
void
=>
{
onPopState
=
(
e
:
PopStateEvent
):
void
=>
{
...
@@ -275,6 +280,8 @@ export default class Router implements BaseRouter {
...
@@ -275,6 +280,8 @@ export default class Router implements BaseRouter {
// Add the ending slash to the paths. So, we can serve the
// Add the ending slash to the paths. So, we can serve the
// "<page>/index.html" directly for the SSR page.
// "<page>/index.html" directly for the SSR page.
if
(
process
.
env
.
__NEXT_EXPORT_TRAILING_SLASH
)
{
if
(
process
.
env
.
__NEXT_EXPORT_TRAILING_SLASH
)
{
const
rewriteUrlForNextExport
=
require
(
'./rewrite-url-for-export'
)
.
rewriteUrlForNextExport
// @ts-ignore this is temporarily global (attached to window)
// @ts-ignore this is temporarily global (attached to window)
if
(
__NEXT_DATA__
.
nextExport
)
{
if
(
__NEXT_DATA__
.
nextExport
)
{
as
=
rewriteUrlForNextExport
(
as
)
as
=
rewriteUrlForNextExport
(
as
)
...
...
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