Skip to content

Commit

Permalink
Fix app routes are not correctly matched when src directory is used (v…
Browse files Browse the repository at this point in the history
…ercel#43234)

When creating the client entries, the `src/` prefix shouldn't be included in the entrypoint's name. Closes vercel#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)
  • Loading branch information
shuding authored and jankaifer committed Nov 23, 2022
1 parent dbb42df commit 712d45f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Expand Up @@ -203,7 +203,9 @@ export class FlightClientEntryPlugin {
: entryRequest

// 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(
this.injectClientEntryAndSSRModules({
Expand Down
12 changes: 12 additions & 0 deletions test/e2e/app-dir/app-alias.test.ts
Expand Up @@ -3,6 +3,7 @@ import { NextInstance } from 'test/lib/next-modes/base'
import { renderViaHTTP } from 'next-test-utils'
import webdriver from 'next-webdriver'
import path from 'path'
import { readJSON } from 'fs-extra'

describe('app-dir alias handling', () => {
if ((global as any).isNextDeploy) {
Expand Down Expand Up @@ -41,4 +42,15 @@ describe('app-dir alias handling', () => {
.getComputedCss('font-size')
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()
})
}
})

0 comments on commit 712d45f

Please sign in to comment.