Unverified Commit 78ef1391 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Fix un-transpiled client file with rewrites (#16453)

This fixes a client-side file not being transpiled correctly when rewrites are used. The cross browser tests have been updated to make sure there are rewrites so the related code is included and not dead-code eliminated'

Closes: https://github.com/vercel/next.js/issues/16440
parent 7c7ecaa6
...@@ -149,7 +149,7 @@ const nextServerlessLoader: loader.Loader = function () { ...@@ -149,7 +149,7 @@ const nextServerlessLoader: loader.Loader = function () {
const rewriteImports = ` const rewriteImports = `
const { rewrites } = require('${routesManifest}') const { rewrites } = require('${routesManifest}')
const { pathToRegexp, default: pathMatch } = require('next/dist/next-server/server/lib/path-match') const { pathToRegexp, default: pathMatch } = require('next/dist/next-server/lib/router/utils/path-match')
` `
const handleRewrites = ` const handleRewrites = `
......
import { ParsedUrlQuery } from 'querystring' import { ParsedUrlQuery } from 'querystring'
import pathMatch from '../../../server/lib/path-match' import pathMatch from './path-match'
import prepareDestination from './prepare-destination' import prepareDestination from './prepare-destination'
import { Rewrite } from '../../../../lib/load-custom-routes' import { Rewrite } from '../../../../lib/load-custom-routes'
......
...@@ -38,7 +38,7 @@ import * as envConfig from '../lib/runtime-config' ...@@ -38,7 +38,7 @@ import * as envConfig from '../lib/runtime-config'
import { isResSent, NextApiRequest, NextApiResponse } from '../lib/utils' import { isResSent, NextApiRequest, NextApiResponse } from '../lib/utils'
import { apiResolver, tryGetPreviewData, __ApiPreviewProps } from './api-utils' import { apiResolver, tryGetPreviewData, __ApiPreviewProps } from './api-utils'
import loadConfig, { isTargetLikeServerless } from './config' import loadConfig, { isTargetLikeServerless } from './config'
import pathMatch from './lib/path-match' import pathMatch from '../lib/router/utils/path-match'
import { recursiveReadDirSync } from './lib/recursive-readdir-sync' import { recursiveReadDirSync } from './lib/recursive-readdir-sync'
import { loadComponents, LoadComponentsReturnType } from './load-components' import { loadComponents, LoadComponentsReturnType } from './load-components'
import { normalizePagePath } from './normalize-page-path' import { normalizePagePath } from './normalize-page-path'
......
import { IncomingMessage, ServerResponse } from 'http' import { IncomingMessage, ServerResponse } from 'http'
import { UrlWithParsedQuery } from 'url' import { UrlWithParsedQuery } from 'url'
import pathMatch from './lib/path-match' import pathMatch from '../lib/router/utils/path-match'
import { removePathTrailingSlash } from '../../client/normalize-trailing-slash' import { removePathTrailingSlash } from '../../client/normalize-trailing-slash'
export const route = pathMatch() export const route = pathMatch()
......
module.exports = {
rewrites() {
// add a rewrite so the code isn't dead-code eliminated
return [
{
source: '/some-rewrite',
destination: '/',
},
]
},
}
...@@ -3,6 +3,15 @@ module.exports = { ...@@ -3,6 +3,15 @@ module.exports = {
// Make sure entries are not getting disposed. // Make sure entries are not getting disposed.
maxInactiveAge: 1000 * 60 * 60, maxInactiveAge: 1000 * 60 * 60,
}, },
rewrites() {
// add a rewrite so the code isn't dead-code eliminated
return [
{
source: '/some-rewrite',
destination: '/',
},
]
},
redirects() { redirects() {
return [ return [
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment