Unverified Commit 3a770fd1 authored by Shu Ding's avatar Shu Ding Committed by GitHub

Fix app routes are not correctly matched when src directory is used (#43234)

When creating the client entries, the `src/` prefix shouldn't be included in the entrypoint's name. Closes #42874.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent ef7a6e12
...@@ -203,7 +203,9 @@ export class FlightClientEntryPlugin { ...@@ -203,7 +203,9 @@ export class FlightClientEntryPlugin {
: entryRequest : entryRequest
// Replace file suffix as `.js` will be added. // Replace file suffix as `.js` will be added.
const bundlePath = relativeRequest.replace(/\.(js|ts)x?$/, '') const bundlePath = relativeRequest
.replace(/\.(js|ts)x?$/, '')
.replace(/^src[\\/]/, '')
promises.push( promises.push(
this.injectClientEntryAndSSRModules({ this.injectClientEntryAndSSRModules({
......
...@@ -3,6 +3,7 @@ import { NextInstance } from 'test/lib/next-modes/base' ...@@ -3,6 +3,7 @@ import { NextInstance } from 'test/lib/next-modes/base'
import { renderViaHTTP } from 'next-test-utils' import { renderViaHTTP } from 'next-test-utils'
import webdriver from 'next-webdriver' import webdriver from 'next-webdriver'
import path from 'path' import path from 'path'
import { readJSON } from 'fs-extra'
describe('app-dir alias handling', () => { describe('app-dir alias handling', () => {
if ((global as any).isNextDeploy) { if ((global as any).isNextDeploy) {
...@@ -41,4 +42,15 @@ describe('app-dir alias handling', () => { ...@@ -41,4 +42,15 @@ describe('app-dir alias handling', () => {
.getComputedCss('font-size') .getComputedCss('font-size')
expect(fontSize).toBe('50px') expect(fontSize).toBe('50px')
}) })
if (!(global as any).isNextDev) {
it('should generate app-build-manifest correctly', async () => {
// Remove other page CSS files:
const manifest = await readJSON(
path.join(next.testDir, '.next', 'app-build-manifest.json')
)
expect(manifest.pages).not.toBeEmptyObject()
})
}
}) })
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