fix turbopack invalidations (#57362)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Leah 2023-10-26 07:04:04 +02:00 committed by GitHub
parent 18d797e3fd
commit c80fb27446
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 31 deletions

View file

@ -366,7 +366,6 @@ async function startWatcher(opts: SetupOpts) {
const serverPathState = new Map<string, string>()
async function processResult(
id: string,
result: TurbopackResult<WrittenEndpoint>
): Promise<TurbopackResult<WrittenEndpoint>> {
// Figure out if the server files have changed
@ -374,23 +373,10 @@ async function startWatcher(opts: SetupOpts) {
for (const { path: p, contentHash } of result.serverPaths) {
// We ignore source maps
if (p.endsWith('.map')) continue
let key = `${id}:${p}`
const localHash = serverPathState.get(key)
const globaHash = serverPathState.get(p)
if (
(localHash && localHash !== contentHash) ||
(globaHash && globaHash !== contentHash)
) {
const previousHash = serverPathState.get(p)
if (previousHash !== contentHash) {
hasChange = true
serverPathState.set(key, contentHash)
serverPathState.set(p, contentHash)
} else {
if (!localHash) {
serverPathState.set(key, contentHash)
}
if (!globaHash) {
serverPathState.set(p, contentHash)
}
}
}
@ -1087,7 +1073,6 @@ async function startWatcher(opts: SetupOpts) {
if (middleware) {
const processMiddleware = async () => {
const writtenEndpoint = await processResult(
'middleware',
await middleware.endpoint.writeToDisk()
)
processIssues('middleware', 'middleware', writtenEndpoint)
@ -1313,7 +1298,6 @@ async function startWatcher(opts: SetupOpts) {
try {
if (globalEntries.app) {
const writtenEndpoint = await processResult(
'_app',
await globalEntries.app.writeToDisk()
)
processIssues('_app', '_app', writtenEndpoint)
@ -1323,7 +1307,6 @@ async function startWatcher(opts: SetupOpts) {
if (globalEntries.document) {
const writtenEndpoint = await processResult(
'_document',
await globalEntries.document.writeToDisk()
)
changeSubscription(
@ -1341,7 +1324,6 @@ async function startWatcher(opts: SetupOpts) {
if (globalEntries.error) {
const writtenEndpoint = await processResult(
'_error',
await globalEntries.error.writeToDisk()
)
processIssues(page, page, writtenEndpoint)
@ -1411,7 +1393,6 @@ async function startWatcher(opts: SetupOpts) {
try {
if (globalEntries.app) {
const writtenEndpoint = await processResult(
'_app',
await globalEntries.app.writeToDisk()
)
processIssues('_app', '_app', writtenEndpoint)
@ -1421,7 +1402,6 @@ async function startWatcher(opts: SetupOpts) {
if (globalEntries.document) {
const writtenEndpoint = await processResult(
'_document',
await globalEntries.document.writeToDisk()
)
@ -1439,7 +1419,6 @@ async function startWatcher(opts: SetupOpts) {
await loadPagesManifest('_document')
const writtenEndpoint = await processResult(
page,
await route.htmlEndpoint.writeToDisk()
)
@ -1497,7 +1476,6 @@ async function startWatcher(opts: SetupOpts) {
finishBuilding = startBuilding(buildingKey)
const writtenEndpoint = await processResult(
page,
await route.endpoint.writeToDisk()
)
@ -1522,7 +1500,6 @@ async function startWatcher(opts: SetupOpts) {
case 'app-page': {
finishBuilding = startBuilding(buildingKey)
const writtenEndpoint = await processResult(
page,
await route.htmlEndpoint.writeToDisk()
)
@ -1573,7 +1550,6 @@ async function startWatcher(opts: SetupOpts) {
case 'app-route': {
finishBuilding = startBuilding(buildingKey)
const writtenEndpoint = await processResult(
page,
await route.endpoint.writeToDisk()
)

View file

@ -3197,11 +3197,9 @@
"app dir - hooks from pages should have the correct hooks",
"app dir - hooks useDraftMode should genenerate rand when draft mode enabled",
"app dir - hooks useDraftMode should use initial rand when draft mode be disabled",
"app dir - hooks useRouter should allow access to the router"
],
"failed": [
"app dir - hooks usePathname should have the canonical url pathname on rewrite",
"app dir - hooks usePathname should have the correct pathname",
"app dir - hooks useRouter should allow access to the router",
"app dir - hooks useSearchParams should have the canonical url search params on rewrite",
"app dir - hooks useSearchParams should have the correct search params",
"app dir - hooks useSelectedLayoutSegment should have the correct layout segment at /hooks/use-selected-layout-segment/first",
@ -3216,6 +3214,7 @@
"app dir - hooks useSelectedLayoutSegments should have the correct layout segments at /hooks/use-selected-layout-segment/rewritten-middleware",
"app dir - hooks useSelectedLayoutSegments should return an empty array in pages"
],
"failed": [],
"pending": [],
"flakey": [],
"runtimeError": false
@ -13519,7 +13518,6 @@
"test/integration/react-streaming/test/index.test.js": {
"passed": [
"streaming dev dev should not stream to crawlers or google pagerender bot",
"streaming dev dev should render 500 error correctly",
"streaming dev dev should render fallback if error raised from suspense during streaming",
"streaming dev dev should support streaming for fizz response"
],
@ -13530,7 +13528,7 @@
"production mode streaming prod prod should render fallback if error raised from suspense during streaming",
"production mode streaming prod prod should support streaming for fizz response"
],
"flakey": [],
"flakey": ["streaming dev dev should render 500 error correctly"],
"runtimeError": false
},
"test/integration/read-only-source-hmr/test/index.test.js": {