Unverified Commit 2fcc1e2c authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Remove resolved `app` directory todos (#43672)

All of these todos have been handled right before Next.js conf / shortly after, this PR is cleaning them up.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/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`
- [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) 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`](https://github.com/vercel/next.js/blob/canary/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 93297437
...@@ -561,7 +561,6 @@ export class FlightClientEntryPlugin { ...@@ -561,7 +561,6 @@ export class FlightClientEntryPlugin {
return shouldInvalidate return shouldInvalidate
} }
// TODO-APP: make sure dependsOn is added for layouts/pages
addEntry( addEntry(
compilation: any, compilation: any,
context: string, context: string,
......
...@@ -95,7 +95,6 @@ export async function fetchServerResponse( ...@@ -95,7 +95,6 @@ export async function fetchServerResponse(
} }
// Ensure the initialParallelRoutes are not combined because of double-rendering in the browser with Strict Mode. // Ensure the initialParallelRoutes are not combined because of double-rendering in the browser with Strict Mode.
// TODO-APP: move this back into AppRouter
let initialParallelRoutes: CacheNode['parallelRoutes'] = let initialParallelRoutes: CacheNode['parallelRoutes'] =
typeof window === 'undefined' ? null! : new Map() typeof window === 'undefined' ? null! : new Map()
...@@ -254,7 +253,6 @@ function Router({ ...@@ -254,7 +253,6 @@ function Router({
const routerInstance: AppRouterInstance = { const routerInstance: AppRouterInstance = {
back: () => window.history.back(), back: () => window.history.back(),
forward: () => window.history.forward(), forward: () => window.history.forward(),
// TODO-APP: implement prefetching of flight
prefetch: async (href) => { prefetch: async (href) => {
// If prefetch has already been triggered, don't trigger it again. // If prefetch has already been triggered, don't trigger it again.
if (prefetched.has(href)) { if (prefetched.has(href)) {
...@@ -264,7 +262,6 @@ function Router({ ...@@ -264,7 +262,6 @@ function Router({
const url = new URL(href, location.origin) const url = new URL(href, location.origin)
try { try {
const routerTree = window.history.state?.tree || initialTree const routerTree = window.history.state?.tree || initialTree
// TODO-APP: handle case where history.state is not the new router history entry
const serverResponse = await fetchServerResponse( const serverResponse = await fetchServerResponse(
url, url,
// initialTree is used when history.state.tree is missing because the history state is set in `useEffect` below, it being missing means this is the hydration case. // initialTree is used when history.state.tree is missing because the history state is set in `useEffect` below, it being missing means this is the hydration case.
...@@ -301,8 +298,6 @@ function Router({ ...@@ -301,8 +298,6 @@ function Router({
React.startTransition(() => { React.startTransition(() => {
dispatch({ dispatch({
type: ACTION_REFRESH, type: ACTION_REFRESH,
// TODO-APP: revisit if this needs to be passed.
cache: { cache: {
status: CacheStates.LAZY_INITIALIZED, status: CacheStates.LAZY_INITIALIZED,
data: null, data: null,
...@@ -363,8 +358,7 @@ function Router({ ...@@ -363,8 +358,7 @@ function Router({
return return
} }
// TODO-APP: this case happens when pushState/replaceState was called outside of Next.js or when the history entry was pushed by the old router. // This case happens when when the history entry was pushed by the `pages` router.
// It reloads the page in this case but we might have to revisit this as the old router ignores it.
if (!state.__NA) { if (!state.__NA) {
window.location.reload() window.location.reload()
return return
......
...@@ -209,7 +209,6 @@ export function InnerLayoutRouter({ ...@@ -209,7 +209,6 @@ export function InnerLayoutRouter({
// If cache node has a data request we have to unwrap response by `use` and update the cache. // If cache node has a data request we have to unwrap response by `use` and update the cache.
if (childNode.data) { if (childNode.data) {
// TODO-APP: error case
/** /**
* Flight response data * Flight response data
*/ */
...@@ -229,7 +228,6 @@ export function InnerLayoutRouter({ ...@@ -229,7 +228,6 @@ export function InnerLayoutRouter({
setTimeout(() => { setTimeout(() => {
// @ts-ignore startTransition exists // @ts-ignore startTransition exists
React.startTransition(() => { React.startTransition(() => {
// TODO-APP: handle redirect
changeByServerResponse(fullTree, flightData, overrideCanonicalUrl) changeByServerResponse(fullTree, flightData, overrideCanonicalUrl)
}) })
}) })
......
...@@ -109,7 +109,6 @@ export { ...@@ -109,7 +109,6 @@ export {
useServerInsertedHTML, useServerInsertedHTML,
} from '../../shared/lib/server-inserted-html' } from '../../shared/lib/server-inserted-html'
// TODO-APP: Move the other router context over to this one
/** /**
* Get the router methods. For example router.push('/dashboard') * Get the router methods. For example router.push('/dashboard')
*/ */
......
...@@ -214,7 +214,6 @@ function getArgumentsForLineNumber( ...@@ -214,7 +214,6 @@ function getArgumentsForLineNumber(
function guessEditor(): string[] { function guessEditor(): string[] {
// Explicit config always wins // Explicit config always wins
if (process.env.REACT_EDITOR) { if (process.env.REACT_EDITOR) {
// TODO-APP: fix this type
return shellQuote.parse(process.env.REACT_EDITOR) as any return shellQuote.parse(process.env.REACT_EDITOR) as any
} }
......
...@@ -55,7 +55,6 @@ export function useWebsocketPing( ...@@ -55,7 +55,6 @@ export function useWebsocketPing(
sendMessage( sendMessage(
JSON.stringify({ JSON.stringify({
event: 'ping', event: 'ping',
// TODO-APP: fix case for dynamic parameters, this will be resolved wrong currently.
tree, tree,
appDirRoute: true, appDirRoute: true,
}) })
......
...@@ -54,7 +54,6 @@ export function createHrefFromUrl( ...@@ -54,7 +54,6 @@ export function createHrefFromUrl(
/** /**
* Invalidate cache one level down from the router state. * Invalidate cache one level down from the router state.
*/ */
// TODO-APP: Verify if this needs to be recursive.
function invalidateCacheByRouterState( function invalidateCacheByRouterState(
newCache: CacheNode, newCache: CacheNode,
existingCache: CacheNode, existingCache: CacheNode,
...@@ -472,12 +471,6 @@ function createOptimisticTree( ...@@ -472,12 +471,6 @@ function createOptimisticTree(
result[3] = 'refetch' result[3] = 'refetch'
} }
// TODO-APP: Revisit
// Add url into the tree
// if (isFirstSegment) {
// result[2] = href
// }
return result return result
} }
...@@ -495,10 +488,6 @@ function applyRouterStatePatchToTree( ...@@ -495,10 +488,6 @@ function applyRouterStatePatchToTree(
if (flightSegmentPath.length === 1) { if (flightSegmentPath.length === 1) {
const tree: FlightRouterState = [...treePatch] const tree: FlightRouterState = [...treePatch]
// TODO-APP: revisit
// if (url) {
// tree[2] = url
// }
return tree return tree
} }
...@@ -539,11 +528,6 @@ function applyRouterStatePatchToTree( ...@@ -539,11 +528,6 @@ function applyRouterStatePatchToTree(
tree[4] = true tree[4] = true
} }
// TODO-APP: Revisit
// if (url) {
// tree[2] = url
// }
return tree return tree
} }
...@@ -812,7 +796,6 @@ function clientReducer( ...@@ -812,7 +796,6 @@ function clientReducer(
canonicalUrl: mutable.canonicalUrlOverride canonicalUrl: mutable.canonicalUrlOverride
? mutable.canonicalUrlOverride ? mutable.canonicalUrlOverride
: href, : href,
// TODO-APP: verify mpaNavigation not being set is correct here.
pushRef: { pushRef: {
pendingPush, pendingPush,
mpaNavigation: mutable.mpaNavigation, mpaNavigation: mutable.mpaNavigation,
...@@ -834,7 +817,6 @@ function clientReducer( ...@@ -834,7 +817,6 @@ function clientReducer(
canonicalUrl: mutable.canonicalUrlOverride canonicalUrl: mutable.canonicalUrlOverride
? mutable.canonicalUrlOverride ? mutable.canonicalUrlOverride
: href, : href,
// TODO-APP: verify mpaNavigation not being set is correct here.
pushRef: { pushRef: {
pendingPush, pendingPush,
mpaNavigation: false, mpaNavigation: false,
...@@ -877,7 +859,6 @@ function clientReducer( ...@@ -877,7 +859,6 @@ function clientReducer(
) )
if (hardNavigate) { if (hardNavigate) {
// TODO-APP: segments.slice(1) strips '', we can get rid of '' altogether.
// Copy subTreeData for the root node of the cache. // Copy subTreeData for the root node of the cache.
cache.subTreeData = state.cache.subTreeData cache.subTreeData = state.cache.subTreeData
...@@ -1333,7 +1314,6 @@ function clientReducer( ...@@ -1333,7 +1314,6 @@ function clientReducer(
const { url, serverResponse } = action const { url, serverResponse } = action
const [flightData, canonicalUrlOverride] = serverResponse const [flightData, canonicalUrlOverride] = serverResponse
// TODO-APP: Implement prefetch for hard navigation
if (typeof flightData === 'string') { if (typeof flightData === 'string') {
return state return state
} }
......
...@@ -1586,7 +1586,6 @@ export async function renderToHTMLOrFlight( ...@@ -1586,7 +1586,6 @@ export async function renderToHTMLOrFlight(
// Flight data that is going to be passed to the browser. // Flight data that is going to be passed to the browser.
// Currently a single item array but in the future multiple patches might be combined in a single request. // Currently a single item array but in the future multiple patches might be combined in a single request.
const flightData: FlightData = [ const flightData: FlightData = [
// TODO-APP: change walk to output without ''
( (
await walkTreeWithFlightRouterState({ await walkTreeWithFlightRouterState({
createSegmentPath: (child) => child, createSegmentPath: (child) => child,
...@@ -1792,7 +1791,6 @@ export async function renderToHTMLOrFlight( ...@@ -1792,7 +1791,6 @@ export async function renderToHTMLOrFlight(
res.statusCode = 404 res.statusCode = 404
} }
// TODO-APP: show error overlay in development. `element` should probably be wrapped in AppRouter for this case.
const renderStream = await renderToInitialStream({ const renderStream = await renderToInitialStream({
ReactDOMServer, ReactDOMServer,
element: ( element: (
......
...@@ -40,7 +40,6 @@ declare module 'react' { ...@@ -40,7 +40,6 @@ declare module 'react' {
nonce?: string nonce?: string
} }
// TODO-APP: check if this is the right type.
function use<T>(promise: Promise<T> | React.Context<T>): T function use<T>(promise: Promise<T> | React.Context<T>): T
function cache<T extends Function>(fn: T): T function cache<T extends Function>(fn: T): T
} }
......
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