-
Notifications
You must be signed in to change notification settings - Fork 88
fix: ensure appDir routes with null dataRoutes are not added to edge manifest for rsc-data #2044
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a600d77
fix: ensure falsy dataRoutes are not included in the edge manifest
orinokai ab60685
test: add tests for falsy dataRoutes in the edge manifest
orinokai 1141f4f
chore: rename rsc data edge manifest function
orinokai b82d3d9
chore: update dataroute regex test description
orinokai 28d6bae
Merge branch 'main' into rs/fix-null-dataroutes
orinokai e080d16
Merge branch 'main' into rs/fix-null-dataroutes
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { generateRscDataEdgeManifest } from '../packages/runtime/src/helpers/edge' | ||
import type { PrerenderManifest } from 'next/dist/build' | ||
|
||
const basePrerenderManifest: PrerenderManifest = { | ||
version: 3, | ||
routes: {}, | ||
dynamicRoutes: {}, | ||
notFoundRoutes: [], | ||
preview: { | ||
previewModeId: '', | ||
previewModeSigningKey: '', | ||
previewModeEncryptionKey: '', | ||
}, | ||
} | ||
|
||
describe('generateRscDataEdgeManifest', () => { | ||
it('should return manifest entries for static appDir routes', async () => { | ||
const prerenderManifest: PrerenderManifest = { | ||
...basePrerenderManifest, | ||
routes: { | ||
'/': { | ||
initialRevalidateSeconds: false, | ||
srcRoute: '/', | ||
dataRoute: '/index.rsc', | ||
}, | ||
}, | ||
} | ||
const appPathRoutesManifest = { | ||
'/page': '/', | ||
} | ||
const edgeManifest = await generateRscDataEdgeManifest({ prerenderManifest, appPathRoutesManifest }) | ||
|
||
expect(edgeManifest).toEqual([ | ||
{ | ||
function: 'rsc-data', | ||
name: 'RSC data routing', | ||
path: '/', | ||
}, | ||
{ | ||
function: 'rsc-data', | ||
name: 'RSC data routing', | ||
path: '/index.rsc', | ||
}, | ||
]) | ||
}) | ||
|
||
it('should not return manifest entries for static appDir routes without dataRoutes', async () => { | ||
const prerenderManifest: PrerenderManifest = { | ||
...basePrerenderManifest, | ||
routes: { | ||
'/api/hello': { | ||
initialRevalidateSeconds: false, | ||
srcRoute: '/api/hello', | ||
dataRoute: null, | ||
}, | ||
}, | ||
} | ||
const appPathRoutesManifest = { | ||
'/api/hello/route': '/api/hello', | ||
} | ||
const edgeManifest = await generateRscDataEdgeManifest({ prerenderManifest, appPathRoutesManifest }) | ||
|
||
expect(edgeManifest).toEqual([]) | ||
}) | ||
|
||
it('should return manifest entries for dynamic appDir routes', async () => { | ||
const prerenderManifest: PrerenderManifest = { | ||
...basePrerenderManifest, | ||
dynamicRoutes: { | ||
'/blog/[author]': { | ||
routeRegex: '^/blog/([^/]+?)(?:/)?$', | ||
dataRoute: '/blog/[author].rsc', | ||
fallback: null, | ||
dataRouteRegex: '^/blog/([^/]+?)\\.rsc$', | ||
}, | ||
}, | ||
} | ||
|
||
const appPathRoutesManifest = { | ||
'/blog/[author]/page': '/blog/[author]', | ||
} | ||
const edgeManifest = await generateRscDataEdgeManifest({ prerenderManifest, appPathRoutesManifest }) | ||
|
||
expect(edgeManifest).toEqual([ | ||
{ | ||
function: 'rsc-data', | ||
name: 'RSC data routing', | ||
pattern: '^/blog/([^/]+?)(?:/)?$', | ||
}, | ||
{ | ||
function: 'rsc-data', | ||
name: 'RSC data routing', | ||
pattern: '^/blog/([^/]+?)\\.rsc$', | ||
}, | ||
]) | ||
}) | ||
|
||
it('should not return manifest entries for dynamic appDir routes without dataRouteRegex', async () => { | ||
const prerenderManifest: PrerenderManifest = { | ||
...basePrerenderManifest, | ||
dynamicRoutes: { | ||
'/api/[endpoint]': { | ||
routeRegex: '^/api/([^/]+?)(?:/)?$', | ||
dataRoute: '/api/[endpoint].rsc', | ||
fallback: null, | ||
dataRouteRegex: null, | ||
}, | ||
}, | ||
} | ||
|
||
const appPathRoutesManifest = { | ||
'/api/[endpoint]/route': '/api/[endpoint]', | ||
} | ||
const edgeManifest = await generateRscDataEdgeManifest({ prerenderManifest, appPathRoutesManifest }) | ||
|
||
expect(edgeManifest).toEqual([]) | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.