Unverified Commit a929bf7c authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

update turbopack and add HMR test case (#57304)

### What?

adds a test case for HMR, which is fixed by the turbopack update

### Why?

### How?

### Turbopack Changes

* https://github.com/vercel/turbo/pull/6245 
* https://github.com/vercel/turbo/pull/6212 
* https://github.com/vercel/turbo/pull/6255 
* https://github.com/vercel/turbo/pull/6259 
* https://github.com/vercel/turbo/pull/6261 
* https://github.com/vercel/turbo/pull/6260 

Closes WEB-1836
parent 96337342
This diff is collapsed.
...@@ -40,11 +40,11 @@ swc_core = { version = "0.86.10", features = [ ...@@ -40,11 +40,11 @@ swc_core = { version = "0.86.10", features = [
testing = { version = "0.35.0" } testing = { version = "0.35.0" }
# Turbo crates # Turbo crates
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231023.1" } turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231024.2" }
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros.. # [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros..
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231023.1" } turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231024.2" }
# [TODO]: need to refactor embed_directory! macro usage in next-core # [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231023.1" } turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-231024.2" }
# General Deps # General Deps
......
...@@ -193,7 +193,7 @@ ...@@ -193,7 +193,7 @@
"@types/ws": "8.2.0", "@types/ws": "8.2.0",
"@vercel/ncc": "0.34.0", "@vercel/ncc": "0.34.0",
"@vercel/nft": "0.22.6", "@vercel/nft": "0.22.6",
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231023.1", "@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231024.2",
"acorn": "8.5.0", "acorn": "8.5.0",
"amphtml-validator": "1.0.35", "amphtml-validator": "1.0.35",
"anser": "1.4.9", "anser": "1.4.9",
......
...@@ -1061,8 +1061,8 @@ importers: ...@@ -1061,8 +1061,8 @@ importers:
specifier: 0.22.6 specifier: 0.22.6
version: 0.22.6 version: 0.22.6
'@vercel/turbopack-ecmascript-runtime': '@vercel/turbopack-ecmascript-runtime':
specifier: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231023.1 specifier: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231024.2
version: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231023.1(react-refresh@0.12.0)(webpack@5.86.0)' version: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231024.2(react-refresh@0.12.0)(webpack@5.86.0)'
acorn: acorn:
specifier: 8.5.0 specifier: 8.5.0
version: 8.5.0 version: 8.5.0
...@@ -24947,9 +24947,9 @@ packages: ...@@ -24947,9 +24947,9 @@ packages:
/zwitch@2.0.4: /zwitch@2.0.4:
resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}
'@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231023.1(react-refresh@0.12.0)(webpack@5.86.0)': '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231024.2(react-refresh@0.12.0)(webpack@5.86.0)':
resolution: {registry: https://registry.npmjs.org/, tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231023.1} resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231024.2}
id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231023.1' id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-231024.2'
name: '@vercel/turbopack-ecmascript-runtime' name: '@vercel/turbopack-ecmascript-runtime'
version: 0.0.0 version: 0.0.0
dependencies: dependencies:
......
...@@ -561,4 +561,56 @@ describe('next.rs api', () => { ...@@ -561,4 +561,56 @@ describe('next.rs api', () => {
} }
}) })
} }
it('should allow to make many HMR updates', async () => {
console.log('start')
await new Promise((r) => setTimeout(r, 1000))
const entrypointsSubscribtion = project.entrypointsSubscribe()
const entrypoints: TurbopackResult<Entrypoints> = (
await entrypointsSubscribtion.next()
).value
const route = entrypoints.routes.get('/')
entrypointsSubscribtion.return()
if (route.type !== 'page') throw new Error('unknown route type')
await route.htmlEndpoint.writeToDisk()
const result = await project.hmrIdentifiersSubscribe().next()
expect(result.done).toBe(false)
const identifiers = result.value.identifiers
const subscriptions = identifiers.map((identifier) =>
project.hmrEvents(identifier)
)
await Promise.all(
subscriptions.map(async (subscription) => {
const result = await subscription.next()
expect(result.done).toBe(false)
expect(result.value).toHaveProperty('resource', expect.toBeObject())
expect(result.value).toHaveProperty('type', 'issues')
expect(result.value).toHaveProperty('diagnostics', expect.toBeEmpty())
})
)
const merged = raceIterators(subscriptions)
const file = 'pages/index.js'
let currentContent = await next.readFile(file)
let nextContent = pagesIndexCode('hello world2')
const count = process.env.CI ? 300 : 1000
for (let i = 0; i < count; i++) {
await next.patchFileFast(file, nextContent)
const content = currentContent
currentContent = nextContent
nextContent = content
while (true) {
const { value, done } = await merged.next()
expect(done).toBe(false)
if (value.type === 'partial') {
break
}
}
}
}, 300000)
}) })
...@@ -465,6 +465,10 @@ export class NextInstance { ...@@ -465,6 +465,10 @@ export class NextInstance {
await this.handleDevWatchDelayAfterChange(filename) await this.handleDevWatchDelayAfterChange(filename)
} }
} }
public async patchFileFast(filename: string, content: string) {
const outputPath = path.join(this.testDir, filename)
await fs.writeFile(outputPath, content)
}
public async renameFile(filename: string, newFilename: string) { public async renameFile(filename: string, newFilename: string) {
await this.handleDevWatchDelayBeforeChange(filename) await this.handleDevWatchDelayBeforeChange(filename)
......
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