Skip to content

Commit 6033727

Browse files
committed
use fallback path and remove querystring usage
1 parent 3da1442 commit 6033727

File tree

8 files changed

+23
-7
lines changed

8 files changed

+23
-7
lines changed

packages/next/lib/constants.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { join } from 'path'
1+
import path from '../shared/lib/fallback/path'
2+
3+
const { join } = path
4+
25
export const NEXT_PROJECT_ROOT = join(__dirname, '..', '..')
36
export const NEXT_PROJECT_ROOT_DIST = join(NEXT_PROJECT_ROOT, 'dist')
47
export const NEXT_PROJECT_ROOT_NODE_MODULES = join(

packages/next/server/incremental-cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { CacheFs } from '../shared/lib/utils'
22

33
import LRUCache from 'next/dist/compiled/lru-cache'
4-
import path from 'path'
4+
import path from '../shared/lib/fallback/path'
55
import { PrerenderManifest } from '../build'
66
import { normalizePagePath } from './normalize-page-path'
77
import { IncrementalCacheValue, IncrementalCacheEntry } from './response-cache'

packages/next/server/normalize-page-path.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { posix } from 'path'
1+
import path from '../shared/lib/fallback/path'
22
import { isDynamicRoute } from '../shared/lib/router/utils'
33

4+
const { posix } = path
5+
46
export { normalizePathSep, denormalizePagePath } from './denormalize-page-path'
57

68
export function normalizePagePath(page: string): string {

packages/next/server/render.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import type { GetServerSideProps, GetStaticProps, PreviewData } from '../types'
2121
import type { UnwrapPromise } from '../lib/coalesced-function'
2222

2323
import React from 'react'
24-
import { stringify as stringifyQuery } from 'querystring'
2524
import { createFromReadableStream } from 'next/dist/compiled/react-server-dom-webpack'
2625
import { renderToReadableStream } from 'next/dist/compiled/react-server-dom-webpack/writer.browser.server'
2726
import { StyleRegistry, createStyleRegistry } from 'styled-jsx'
@@ -79,6 +78,7 @@ import {
7978
import { ImageConfigContext } from '../shared/lib/image-config-context'
8079
import { FlushEffectsContext } from '../shared/lib/flush-effects'
8180
import { interopDefault } from '../lib/interop-default'
81+
import { urlQueryToSearchParams } from '../shared/lib/router/utils/querystring'
8282

8383
let optimizeAmp: typeof import('./optimize-amp').default
8484
let getFontDefinitionFromManifest: typeof import('./font-utils').getFontDefinitionFromManifest
@@ -518,7 +518,7 @@ export async function renderToHTML(
518518

519519
if (isServerComponent) {
520520
serverComponentsInlinedTransformStream = new TransformStream()
521-
const search = stringifyQuery(query)
521+
const search = urlQueryToSearchParams(query).toString()
522522
Component = createServerComponentRenderer(AppMod, ComponentMod, {
523523
cachePrefix: pathname + (search ? `?${search}` : ''),
524524
inlinedTransformStream: serverComponentsInlinedTransformStream,

packages/next/server/web-server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import type { NextParsedUrlQuery } from './request-meta'
55
import type { Params } from './router'
66
import type { PayloadOptions } from './send-payload'
77
import type { LoadComponentsReturnType } from './load-components'
8+
import type { Options } from './base-server'
89

9-
import BaseServer, { Options } from './base-server'
10+
import BaseServer from './base-server'
1011
import { renderToHTML } from './render'
1112
import { byteLength, generateETag } from './api-utils/web'
1213

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const path = process.browser
2+
? require('next/dist/compiled/path-browserify')
3+
: require('path')
4+
5+
export default path

packages/next/shared/lib/router/utils/querystring.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ParsedUrlQuery } from 'querystring'
1+
import type { ParsedUrlQuery } from 'querystring'
22

33
export function searchParamsToUrlQuery(
44
searchParams: URLSearchParams

packages/next/types/misc.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,11 @@ declare module 'next/dist/compiled/process' {
340340
export = m
341341
}
342342

343+
declare module 'next/dist/compiled/path-browserify' {
344+
import m from 'path'
345+
export = m
346+
}
347+
343348
declare module 'pnp-webpack-plugin' {
344349
import webpack from 'webpack4'
345350

0 commit comments

Comments
 (0)