Unverified Commit e9b423b3 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

polish isomorphic path module (#36521)

List all exports for internal path module to avoid import destruction is breaking with typescript.

#### Prev
```js
import pathMod from '../isomorphic/path'

const { join, resolve } = pathMod
```

#### Now
```js
import { join, resolve } from '../isomorphic/path'
```
parent 2fc27c1e
import path from '../shared/lib/isomorphic/path'
const { join } = path
import { join } from '../shared/lib/isomorphic/path'
export const NEXT_PROJECT_ROOT = join(__dirname, '..', '..')
export const NEXT_PROJECT_ROOT_DIST = join(NEXT_PROJECT_ROOT, 'dist')
......
......@@ -17,7 +17,7 @@ import type { PagesManifest } from '../build/webpack/plugins/pages-manifest-plug
import type { BaseNextRequest, BaseNextResponse } from './base-http'
import type { PayloadOptions } from './send-payload'
import pathMod from '../shared/lib/isomorphic/path'
import { join, resolve } from '../shared/lib/isomorphic/path'
import { parse as parseQs } from 'querystring'
import { format as formatUrl, parse as parseUrl } from 'url'
import { getRedirectStatus } from '../lib/load-custom-routes'
......@@ -66,8 +66,6 @@ import { PrerenderManifest } from '../build'
import { ImageConfigComplete } from '../shared/lib/image-config'
import { replaceBasePath } from './router-utils'
const { join, resolve } = pathMod
export type FindComponentsResult = {
components: LoadComponentsReturnType
query: NextParsedUrlQuery
......
import path from '../shared/lib/isomorphic/path'
import { posix } from '../shared/lib/isomorphic/path'
import { isDynamicRoute } from '../shared/lib/router/utils'
const { posix } = path
export { normalizePathSep, denormalizePagePath } from './denormalize-page-path'
export function normalizePagePath(page: string): string {
......
/**
* This module is for next.js server internal usage of path module.
* It will use native path module for nodejs runtime.
* It will use path-browserify polyfill for edge runtime.
*/
const path =
process.env.NEXT_RUNTIME === 'edge'
? require('next/dist/compiled/path-browserify')
: require('path')
export default path
module.exports = path
......@@ -340,11 +340,6 @@ declare module 'next/dist/compiled/process' {
export = m
}
declare module 'next/dist/compiled/path-browserify' {
import m from 'path'
export = m
}
declare module 'pnp-webpack-plugin' {
import webpack from 'webpack4'
......
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