Skip to content

Commit

Permalink
Fix app client entry key for windows (#44011)
Browse files Browse the repository at this point in the history
## Bug

The app client entry key was in win32 slashes like `app\blog`, and when
we add the new layer checking logic in #43197, `name.startsWith('app/')`
doesn't work.

Fixes #43854
Fixes #43902

<img width="862" alt="image"
src="https://user-images.githubusercontent.com/4800338/207641886-08ffc159-0516-4609-9a1f-8c8693586122.png">


- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
  • Loading branch information
huozhi authored Dec 14, 2022
1 parent d5fd2d7 commit 6aae39c
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 12 deletions.
41 changes: 38 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ variables:
PNPM_CACHE_FOLDER: $(Pipeline.Workspace)/.pnpm-store
PNPM_VERSION: 7.3.0
NEXT_TELEMETRY_DISABLED: '1'
node_version: ^14.19.0
node_14_version: ^14.19.0
node_16_version: ^16.8.0

stages:
- stage: Test
Expand All @@ -46,7 +47,7 @@ stages:
steps:
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
versionSpec: $(node_14_version)
displayName: 'Install Node.js'

- bash: |
Expand Down Expand Up @@ -84,7 +85,7 @@ stages:
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
versionSpec: $(node_14_version)
displayName: 'Install Node.js'

- bash: |
Expand All @@ -107,3 +108,37 @@ stages:
- script: node run-tests.js --type unit
condition: eq(variables['isDocsOnly'], 'No')
displayName: 'Run tests'

- job: test_integration_app_dir
pool:
vmImage: 'windows-2019'
steps:
- task: NodeTool@0
inputs:
versionSpec: $(node_16_version)
displayName: 'Install Node.js'

- bash: |
node scripts/run-for-change.js --not --type docs --exec echo "##vso[task.setvariable variable=isDocsOnly]No"
displayName: 'Check Docs Only Change'
- script: npm i -g pnpm@$(PNPM_VERSION)
condition: eq(variables['isDocsOnly'], 'No')

- script: pnpm config set store-dir $(PNPM_CACHE_FOLDER)
condition: eq(variables['isDocsOnly'], 'No')

- script: pnpm store path
condition: eq(variables['isDocsOnly'], 'No')

- script: pnpm install && pnpm run build
condition: eq(variables['isDocsOnly'], 'No')
displayName: 'Install and build'

- script: npx playwright install chromium
condition: eq(variables['isDocsOnly'], 'No')

- script: |
node run-tests.js -c 1 test/integration/app-dir-basic/test/index.test.js
condition: eq(variables['isDocsOnly'], 'No')
displayName: 'Run tests'
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
"release": "6.3.1",
"request-promise-core": "1.1.2",
"resolve-from": "5.0.0",
"rimraf": "3.0.2",
"sass": "1.54.0",
"seedrandom": "3.0.5",
"selenium-webdriver": "4.0.0-beta.4",
Expand Down
1 change: 0 additions & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"cross-spawn": "6.0.5",
"got": "10.7.0",
"prompts": "2.1.0",
"rimraf": "3.0.2",
"tar": "4.4.10",
"update-check": "1.5.4",
"validate-npm-package-name": "3.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/font/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"license": "MIT",
"scripts": {
"build": "rm -rf dist && pnpm ncc-fontkit && tsc -d -p tsconfig.json",
"build": "rimraf dist && pnpm ncc-fontkit && tsc -d -p tsconfig.json",
"prepublishOnly": "cd ../../ && turbo run build",
"dev": "pnpm ncc-fontkit && tsc -d -w -p tsconfig.json",
"typescript": "tsec --noEmit -p tsconfig.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,10 @@ export class FlightClientEntryPlugin {
// Add for the client compilation
// Inject the entry to the client compiler.
if (this.dev) {
const pageKey = COMPILER_NAMES.client + bundlePath
const pageKey = (COMPILER_NAMES.client + bundlePath).replace(
/\\/g,
path.posix.sep
)
if (!entries[pageKey]) {
entries[pageKey] = {
type: EntryTypes.CHILD_ENTRY,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dev-overlay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"author": "Joe Haddad <timer@vercel.com>",
"license": "MIT",
"scripts": {
"build": "rm -rf dist && tsc -d -p tsconfig.json",
"build": "rimraf dist && tsc -d -p tsconfig.json",
"prepublishOnly": "cd ../../ && turbo run build",
"dev": "tsc -d -w -p tsconfig.json",
"typescript": "tsec --noEmit -p tsconfig.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-refresh-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"author": "Joe Haddad <timer@vercel.com>",
"license": "MIT",
"scripts": {
"build": "rm -rf dist && tsc -d -p tsconfig.json",
"build": "rimraf dist && tsc -d -p tsconfig.json",
"prepublishOnly": "cd ../../ && turbo run build",
"dev": "tsc -d -w -p tsconfig.json"
},
Expand Down
9 changes: 5 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/integration/app-dir-basic/app/blog/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function page() {
return <>blog</>
}
8 changes: 8 additions & 0 deletions test/integration/app-dir-basic/app/layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function RootLayout({ children }) {
return (
<html>
<head></head>
<body>{children}</body>
</html>
)
}
3 changes: 3 additions & 0 deletions test/integration/app-dir-basic/app/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function page() {
return <>page</>
}
5 changes: 5 additions & 0 deletions test/integration/app-dir-basic/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
experimental: {
appDir: true,
},
}
33 changes: 33 additions & 0 deletions test/integration/app-dir-basic/test/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* eslint-env jest */

import { join } from 'path'
import { runDevSuite, runProdSuite, renderViaHTTP } from 'next-test-utils'

import webdriver from 'next-webdriver'
const appDir = join(__dirname, '..')

function runTests(context, env) {
describe('App Dir Basic', () => {
it('should render html properly', async () => {
const indexHtml = await renderViaHTTP(context.appPort, '/')
const blogHtml = await renderViaHTTP(context.appPort, '/blog')

expect(indexHtml).toContain('page')
expect(blogHtml).toContain('blog')
})

it('should hydrate pages properly', async () => {
const browser = await webdriver(context.appPort, '/')
const indexHtml = await browser.waitForElementByCss('body').text()
const url = await browser.url()
await browser.loadPage(url + 'blog')
const blogHtml = await browser.waitForElementByCss('body').text()

expect(indexHtml).toContain('page')
expect(blogHtml).toContain('blog')
})
})
}

runDevSuite('App Dir Basic', appDir, { runTests })
runProdSuite('App Dir Basic', appDir, { runTests })

0 comments on commit 6aae39c

Please sign in to comment.