Remove rewriteUrlForNextExport from bundles when option is not enabled (#9946)
Co-authored-by: Joe Haddad <timer150@gmail.com>
This commit is contained in:
parent
72a0c5578e
commit
7e817cab04
2 changed files with 11 additions and 3 deletions
|
@ -3,7 +3,6 @@ declare const __NEXT_DATA__: any
|
|||
import { resolve, parse, UrlObject } from 'url'
|
||||
import React, { Component, Children } from 'react'
|
||||
import Router from './router'
|
||||
import { rewriteUrlForNextExport } from '../next-server/lib/router/rewrite-url-for-export'
|
||||
import {
|
||||
execOnce,
|
||||
formatWithValidation,
|
||||
|
@ -264,6 +263,8 @@ class Link extends Component<LinkProps> {
|
|||
// Add the ending slash to the paths. So, we can serve the
|
||||
// "<page>/index.html" directly.
|
||||
if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {
|
||||
const rewriteUrlForNextExport = require('../next-server/lib/router/rewrite-url-for-export')
|
||||
.rewriteUrlForNextExport
|
||||
if (
|
||||
props.href &&
|
||||
typeof __NEXT_DATA__ !== 'undefined' &&
|
||||
|
|
|
@ -13,7 +13,6 @@ import {
|
|||
NextPageContext,
|
||||
SUPPORTS_PERFORMANCE_USER_TIMING,
|
||||
} from '../utils'
|
||||
import { rewriteUrlForNextExport } from './rewrite-url-for-export'
|
||||
import { isDynamicRoute } from './utils/is-dynamic'
|
||||
import { getRouteMatcher } from './utils/route-matcher'
|
||||
import { getRouteRegex } from './utils/route-regex'
|
||||
|
@ -154,7 +153,13 @@ export default class Router implements BaseRouter {
|
|||
|
||||
// @deprecated backwards compatibility even though it's a private method.
|
||||
static _rewriteUrlForNextExport(url: string): string {
|
||||
return rewriteUrlForNextExport(url)
|
||||
if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {
|
||||
const rewriteUrlForNextExport = require('./rewrite-url-for-export')
|
||||
.rewriteUrlForNextExport
|
||||
return rewriteUrlForNextExport(url)
|
||||
} else {
|
||||
return url
|
||||
}
|
||||
}
|
||||
|
||||
onPopState = (e: PopStateEvent): void => {
|
||||
|
@ -275,6 +280,8 @@ export default class Router implements BaseRouter {
|
|||
// Add the ending slash to the paths. So, we can serve the
|
||||
// "<page>/index.html" directly for the SSR page.
|
||||
if (process.env.__NEXT_EXPORT_TRAILING_SLASH) {
|
||||
const rewriteUrlForNextExport = require('./rewrite-url-for-export')
|
||||
.rewriteUrlForNextExport
|
||||
// @ts-ignore this is temporarily global (attached to window)
|
||||
if (__NEXT_DATA__.nextExport) {
|
||||
as = rewriteUrlForNextExport(as)
|
||||
|
|
Loading…
Reference in a new issue