Unverified Commit 5c4d0bde authored by Tommaso De Rossi's avatar Tommaso De Rossi Committed by GitHub

Resolve to real path before checking for path inequality (#17279)

Co-authored-by: 's avatarLuis Alvarez D <luis@vercel.com>
Co-authored-by: 's avatarTim Neutkens <tim@timneutkens.nl>
parent fad07cc0
...@@ -98,6 +98,7 @@ ...@@ -98,6 +98,7 @@
"npm-run-all": "4.1.5", "npm-run-all": "4.1.5",
"nprogress": "0.2.0", "nprogress": "0.2.0",
"pixrem": "5.0.0", "pixrem": "5.0.0",
"pnpm": "5.8.0",
"postcss-nested": "4.2.1", "postcss-nested": "4.2.1",
"postcss-pseudoelements": "5.0.0", "postcss-pseudoelements": "5.0.0",
"postcss-short-size": "4.0.0", "postcss-short-size": "4.0.0",
......
import { codeFrameColumns } from '@babel/code-frame' import { codeFrameColumns } from '@babel/code-frame'
import ReactRefreshWebpackPlugin from '@next/react-refresh-utils/ReactRefreshWebpackPlugin' import ReactRefreshWebpackPlugin from '@next/react-refresh-utils/ReactRefreshWebpackPlugin'
import crypto from 'crypto' import crypto from 'crypto'
import { readFileSync } from 'fs' import { readFileSync, realpathSync } from 'fs'
import chalk from 'next/dist/compiled/chalk' import chalk from 'next/dist/compiled/chalk'
import semver from 'next/dist/compiled/semver' import semver from 'next/dist/compiled/semver'
import TerserPlugin from 'next/dist/compiled/terser-webpack-plugin' import TerserPlugin from 'next/dist/compiled/terser-webpack-plugin'
...@@ -685,7 +685,12 @@ export default async function getBaseWebpackConfig( ...@@ -685,7 +685,12 @@ export default async function getBaseWebpackConfig(
// Same as above: if the package, when required from the root, // Same as above: if the package, when required from the root,
// would be different from what the real resolution would use, we // would be different from what the real resolution would use, we
// cannot externalize it. // cannot externalize it.
if (baseRes !== res) { if (
!baseRes ||
(baseRes !== res &&
// if res and baseRes are symlinks they could point to the the same file
realpathSync(baseRes) !== realpathSync(res))
) {
return callback() return callback()
} }
} }
......
export default function About() {
return <div>About us</div>
}
export default function About2() {
return <div>About 2</div>
}
export default function Day() {
return <div>Hello Day</div>
}
import Link from 'next/link'
export default function Home() {
return (
<div>
Hello World.{' '}
<Link href="/about">
<a>About</a>
</Link>
</div>
)
}
/* eslint-env jest */
import { execSync } from 'child_process'
import fs from 'fs-extra'
import path from 'path'
jest.setTimeout(100 * 1000)
beforeAll(async () => {
await clean()
})
afterAll(async () => {
await clean()
})
test('pnpm installs', async () => {
const pnpm = getStdout('yarn bin pnpm')
exec(pnpm + ' init -y')
exec(pnpm + ' add next react react-dom')
await useLocalNextjs()
// exec('pnpm install')
})
test('nextjs builds with pnpm', () => {
const pnpx = getStdout(`yarn bin pnpx`)
exec(pnpx + ' next build')
})
const exec = (cmd) => {
return execSync(cmd, {
env: process.env,
shell: true,
stdio: 'inherit',
cwd: path.resolve(__dirname, '..'),
})
}
const getStdout = (cmd) => {
return execSync(cmd, {
env: process.env,
shell: true,
stdio: 'pipe',
})
.toString()
.trim()
}
async function useLocalNextjs() {
// installed nextjs
const nextPath = path.dirname(require.resolve('next/package.json'))
// repository root
const root = path.dirname(
require.resolve(path.resolve(process.cwd(), 'package.json'))
)
// local nextjs
const currentNextPath = path.resolve(root, 'packages/next')
// copy local nextjs to node_modules
await fs.copy(
path.resolve(currentNextPath, 'dist'),
path.resolve(nextPath, 'dist')
)
console.log('copied local nextjs to node_modules')
}
async function clean() {
// jest test cannot be found if a package.json exists in test directory
await fs.remove(path.resolve(__dirname, '../package.json'))
await fs.remove(path.resolve(__dirname, '../node_modules'))
await fs.remove(path.resolve(__dirname, '../pnpm-lock.yaml'))
}
...@@ -12587,6 +12587,11 @@ pnp-webpack-plugin@1.6.4: ...@@ -12587,6 +12587,11 @@ pnp-webpack-plugin@1.6.4:
dependencies: dependencies:
ts-pnp "^1.1.6" ts-pnp "^1.1.6"
pnpm@5.8.0:
version "5.8.0"
resolved "https://registry.yarnpkg.com/pnpm/-/pnpm-5.8.0.tgz#a933d6c756efe8795b12004bbff1b82c622e771b"
integrity sha512-J2rAxEXnohwcDkR4KNI6UsYhDs9hJ/tje/BahHpXawi406pmxd6caJUXfRxZPbKvKdyVqfBRKhlX1vyhYbM8lQ==
posix-character-classes@^0.1.0: posix-character-classes@^0.1.0:
version "0.1.1" version "0.1.1"
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
......
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