fix: next dev with edge runtime on windows (#56502)
- Reverts https://github.com/vercel/next.js/pull/44616 - Regression introduced in https://github.com/vercel/next.js/pull/51651 - Fixes https://github.com/vercel/next.js/issues/55013
This commit is contained in:
parent
5d2c503eac
commit
35f507242c
6 changed files with 118 additions and 76 deletions
|
@ -127,9 +127,6 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
|
|||
)
|
||||
.catch(console.error)
|
||||
|
||||
console.log(await exec(`ls ${path.join(__dirname, '../native')}`))
|
||||
console.log(await exec(`cd ${dir} && ls ${dir}/packages/next-swc/native`))
|
||||
|
||||
logger(`Linking packages in ${dir}`)
|
||||
const isMainRepo = dir === mainRepoDir
|
||||
const pkgPaths = await linkPackages({
|
||||
|
|
|
@ -111,76 +111,76 @@ stages:
|
|||
env:
|
||||
NEXT_TEST_MODE: 'dev'
|
||||
|
||||
# - job: test_e2e_dev
|
||||
# pool:
|
||||
# vmImage: 'windows-2019'
|
||||
# steps:
|
||||
# - task: NodeTool@0
|
||||
# inputs:
|
||||
# versionSpec: $(node_16_version)
|
||||
# displayName: 'Install Node.js'
|
||||
- job: test_e2e_dev
|
||||
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'
|
||||
- bash: |
|
||||
node scripts/run-for-change.js --not --type docs --exec echo "##vso[task.setvariable variable=isDocsOnly]No"
|
||||
displayName: 'Check Docs Only Change'
|
||||
|
||||
# - script: corepack enable
|
||||
# condition: eq(variables['isDocsOnly'], 'No')
|
||||
# displayName: 'Enable Corepack'
|
||||
- script: corepack enable
|
||||
condition: eq(variables['isDocsOnly'], 'No')
|
||||
displayName: 'Enable Corepack'
|
||||
|
||||
# - script: pnpm config set store-dir $(PNPM_CACHE_FOLDER)
|
||||
# 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 store path
|
||||
condition: eq(variables['isDocsOnly'], 'No')
|
||||
|
||||
# - script: pnpm install && pnpm run build
|
||||
# condition: eq(variables['isDocsOnly'], 'No')
|
||||
# displayName: 'Install and build'
|
||||
- script: pnpm install && pnpm run build
|
||||
condition: eq(variables['isDocsOnly'], 'No')
|
||||
displayName: 'Install and build'
|
||||
|
||||
# - script: npx playwright@1.35.1 install chromium
|
||||
# condition: eq(variables['isDocsOnly'], 'No')
|
||||
- script: npx playwright@1.35.1 install chromium
|
||||
condition: eq(variables['isDocsOnly'], 'No')
|
||||
|
||||
# - script: |
|
||||
# node run-tests.js -c 1 --debug test/e2e/app-dir/app/index.test.ts
|
||||
# condition: eq(variables['isDocsOnly'], 'No')
|
||||
# displayName: 'Run tests (E2E Development)'
|
||||
# env:
|
||||
# NEXT_TEST_MODE: 'dev'
|
||||
- script: |
|
||||
node run-tests.js -c 1 --debug test/e2e/app-dir/app/index.test.ts test/e2e/app-dir/app-edge/app-edge.test.ts
|
||||
condition: eq(variables['isDocsOnly'], 'No')
|
||||
displayName: 'Run tests (E2E Development)'
|
||||
env:
|
||||
NEXT_TEST_MODE: 'dev'
|
||||
|
||||
# - job: test_e2e_prod
|
||||
# pool:
|
||||
# vmImage: 'windows-2019'
|
||||
# steps:
|
||||
# - task: NodeTool@0
|
||||
# inputs:
|
||||
# versionSpec: $(node_16_version)
|
||||
# displayName: 'Install Node.js'
|
||||
- job: test_e2e_prod
|
||||
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'
|
||||
- bash: |
|
||||
node scripts/run-for-change.js --not --type docs --exec echo "##vso[task.setvariable variable=isDocsOnly]No"
|
||||
displayName: 'Check Docs Only Change'
|
||||
|
||||
# - script: corepack enable
|
||||
# condition: eq(variables['isDocsOnly'], 'No')
|
||||
# displayName: 'Enable Corepack'
|
||||
- script: corepack enable
|
||||
condition: eq(variables['isDocsOnly'], 'No')
|
||||
displayName: 'Enable Corepack'
|
||||
|
||||
# - script: pnpm config set store-dir $(PNPM_CACHE_FOLDER)
|
||||
# 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 store path
|
||||
condition: eq(variables['isDocsOnly'], 'No')
|
||||
|
||||
# - script: pnpm install && pnpm run build
|
||||
# condition: eq(variables['isDocsOnly'], 'No')
|
||||
# displayName: 'Install and build'
|
||||
- script: pnpm install && pnpm run build
|
||||
condition: eq(variables['isDocsOnly'], 'No')
|
||||
displayName: 'Install and build'
|
||||
|
||||
# - script: npx playwright@1.35.1 install chromium
|
||||
# condition: eq(variables['isDocsOnly'], 'No')
|
||||
- script: npx playwright@1.35.1 install chromium
|
||||
condition: eq(variables['isDocsOnly'], 'No')
|
||||
|
||||
# - script: |
|
||||
# node run-tests.js -c 1 --debug test/e2e/app-dir/app/index.test.ts
|
||||
# condition: eq(variables['isDocsOnly'], 'No')
|
||||
# displayName: 'Run tests (E2E Production)'
|
||||
# env:
|
||||
# NEXT_TEST_MODE: 'start'
|
||||
- script: |
|
||||
node run-tests.js -c 1 --debug test/e2e/app-dir/app/index.test.ts test/e2e/app-dir/app-edge/app-edge.test.ts
|
||||
condition: eq(variables['isDocsOnly'], 'No')
|
||||
displayName: 'Run tests (E2E Production)'
|
||||
env:
|
||||
NEXT_TEST_MODE: 'start'
|
||||
|
|
|
@ -822,28 +822,41 @@ export default async function getBaseWebpackConfig(
|
|||
'next/dist/server': 'next/dist/esm/server',
|
||||
|
||||
// Alias the usage of next public APIs
|
||||
[`${NEXT_PROJECT_ROOT}/server`]:
|
||||
[path.join(NEXT_PROJECT_ROOT, 'server')]:
|
||||
'next/dist/esm/server/web/exports/index',
|
||||
[`${NEXT_PROJECT_ROOT}/dist/client/link`]:
|
||||
[path.join(NEXT_PROJECT_ROOT_DIST, 'client', 'link')]:
|
||||
'next/dist/esm/client/link',
|
||||
[`${NEXT_PROJECT_ROOT}/dist/shared/lib/image-external`]:
|
||||
'next/dist/esm/shared/lib/image-external',
|
||||
[`${NEXT_PROJECT_ROOT}/dist/client/script`]:
|
||||
[path.join(
|
||||
NEXT_PROJECT_ROOT,
|
||||
'dist',
|
||||
'shared',
|
||||
'lib',
|
||||
'image-external'
|
||||
)]: 'next/dist/esm/shared/lib/image-external',
|
||||
[path.join(NEXT_PROJECT_ROOT_DIST, 'client', 'script')]:
|
||||
'next/dist/esm/client/script',
|
||||
[`${NEXT_PROJECT_ROOT}/dist/client/router`]:
|
||||
[path.join(NEXT_PROJECT_ROOT_DIST, 'client', 'router')]:
|
||||
'next/dist/esm/client/router',
|
||||
[`${NEXT_PROJECT_ROOT}/dist/shared/lib/head`]:
|
||||
[path.join(NEXT_PROJECT_ROOT_DIST, 'shared', 'lib', 'head')]:
|
||||
'next/dist/esm/shared/lib/head',
|
||||
[`${NEXT_PROJECT_ROOT}/dist/shared/lib/dynamic`]:
|
||||
[path.join(NEXT_PROJECT_ROOT_DIST, 'shared', 'lib', 'dynamic')]:
|
||||
'next/dist/esm/shared/lib/dynamic',
|
||||
[`${NEXT_PROJECT_ROOT}/dist/pages/_document`]:
|
||||
[path.join(NEXT_PROJECT_ROOT_DIST, 'pages', '_document')]:
|
||||
'next/dist/esm/pages/_document',
|
||||
[`${NEXT_PROJECT_ROOT}/dist/pages/_app`]:
|
||||
[path.join(NEXT_PROJECT_ROOT_DIST, 'pages', '_app')]:
|
||||
'next/dist/esm/pages/_app',
|
||||
[`${NEXT_PROJECT_ROOT}/dist/client/components/navigation`]:
|
||||
'next/dist/esm/client/components/navigation',
|
||||
[`${NEXT_PROJECT_ROOT}/dist/client/components/headers`]:
|
||||
'next/dist/esm/client/components/headers',
|
||||
[path.join(
|
||||
NEXT_PROJECT_ROOT_DIST,
|
||||
'client',
|
||||
'components',
|
||||
'navigation'
|
||||
)]: 'next/dist/esm/client/components/navigation',
|
||||
[path.join(
|
||||
NEXT_PROJECT_ROOT_DIST,
|
||||
'client',
|
||||
'components',
|
||||
'headers'
|
||||
)]: 'next/dist/esm/client/components/headers',
|
||||
}
|
||||
: undefined),
|
||||
|
||||
|
|
|
@ -55,12 +55,22 @@ createNextDescribe(
|
|||
next.on('stderr', (log) => {
|
||||
logs.push(log)
|
||||
})
|
||||
await next.render('app-edge')
|
||||
await next.render('/app-edge')
|
||||
expect(
|
||||
logs.some((log) => log.includes(`Attempted import error:`))
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
it('should resolve client component without error', async () => {
|
||||
const logs = []
|
||||
next.on('stderr', (log) => {
|
||||
logs.push(log)
|
||||
})
|
||||
const html = await next.render('/with-client')
|
||||
expect(html).toContain('My Button')
|
||||
expect(logs).toEqual([])
|
||||
})
|
||||
|
||||
it('should handle edge rsc hmr', async () => {
|
||||
const pageFile = 'app/edge/basic/page.tsx'
|
||||
const content = await next.readFile(pageFile)
|
||||
|
|
13
test/e2e/app-dir/app-edge/app/with-client/page.tsx
Normal file
13
test/e2e/app-dir/app-edge/app/with-client/page.tsx
Normal file
|
@ -0,0 +1,13 @@
|
|||
import Button from '../../components/button'
|
||||
import React from 'react'
|
||||
|
||||
export const runtime = 'edge'
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<>
|
||||
<h1>Import a client component</h1>
|
||||
<Button />
|
||||
</>
|
||||
)
|
||||
}
|
9
test/e2e/app-dir/app-edge/components/button.tsx
Normal file
9
test/e2e/app-dir/app-edge/components/button.tsx
Normal file
|
@ -0,0 +1,9 @@
|
|||
'use client'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import React from 'react'
|
||||
|
||||
export default function Button() {
|
||||
const router = useRouter()
|
||||
const onClick = () => router.push('/')
|
||||
return <button onClick={onClick}>My Button</button>
|
||||
}
|
Loading…
Reference in a new issue