Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to latest watchpack with dynamic route rename fix #10351

Merged
merged 8 commits into from Feb 19, 2020
2 changes: 1 addition & 1 deletion packages/next/package.json
Expand Up @@ -142,7 +142,7 @@
"url": "0.11.0",
"url-polyfill": "1.1.7",
"use-subscription": "1.1.1",
"watchpack": "2.0.0-beta.5",
"watchpack": "2.0.0-beta.13",
"webpack": "4.41.2",
"webpack-dev-middleware": "3.7.0",
"webpack-hot-middleware": "2.25.0",
Expand Down
1 change: 1 addition & 0 deletions test/integration/dynamic-route-rename/pages/[pid].js
@@ -0,0 +1 @@
export default () => 'hi'
53 changes: 53 additions & 0 deletions test/integration/dynamic-route-rename/test/index.test.js
@@ -0,0 +1,53 @@
/* eslint-env jest */
/* global jasmine */
import fs from 'fs-extra'
import { join } from 'path'
import {
renderViaHTTP,
launchApp,
findPort,
killApp,
waitFor,
} from 'next-test-utils'

jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 30 * 2

let app
let appPort
let stderr = ''

const appDir = join(__dirname, '../')
const pageFile = join(appDir, 'pages/[pid].js')
const pageFileAlt = join(appDir, 'pages/[PiD].js')

describe('Dynamic route rename casing', () => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort, {
onStderr(msg) {
stderr += msg || ''
},
})
})
afterAll(() => killApp(app))

it('should not throw error when changing casing of dynamic route file', async () => {
// make sure route is loaded in webpack
const html = await renderViaHTTP(appPort, '/abc')
expect(html).toContain('hi')

await fs.rename(pageFile, pageFileAlt)
await waitFor(2000)

expect(stderr).not.toContain(
`You cannot use different slug names for the same dynamic path`
)

await fs.rename(pageFileAlt, pageFile)
await waitFor(2000)

expect(stderr).not.toContain(
`You cannot use different slug names for the same dynamic path`
)
})
})
9 changes: 4 additions & 5 deletions yarn.lock
Expand Up @@ -16736,14 +16736,13 @@ walker@^1.0.7, walker@~1.0.5:
dependencies:
makeerror "1.0.x"

watchpack@2.0.0-beta.5:
version "2.0.0-beta.5"
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.0.0-beta.5.tgz#c005db39570d81d9d34334870abc0f548901b880"
integrity sha512-HGqh9e9QZFhow8JYX+1+E+kIYK0uTTsk6rCOkI0ff0f9kMO0wX783yW8saQC9WDx7qHpVGPXsRnld9nY7iwzQA==
watchpack@2.0.0-beta.13:
version "2.0.0-beta.13"
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.0.0-beta.13.tgz#9d9b0c094b8402139333e04eb6194643c8384f55"
integrity sha512-ZEFq2mx/k5qgQwgi6NOm+2ImICb8ngAkA/rZ6oyXZ7SgPn3pncf+nfhYTCrs3lmHwOxnPtGLTOuFLfpSMh1VMA==
dependencies:
glob-to-regexp "^0.4.1"
graceful-fs "^4.1.2"
neo-async "^2.5.0"

watchpack@^1.6.0:
version "1.6.0"
Expand Down