-
Notifications
You must be signed in to change notification settings - Fork 3.8k
devserver: fix watching entrypoint #21874
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
Open
zackradisic
wants to merge
18
commits into
main
Choose a base branch
from
zack/devserver-fix-watching-entrypoint
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6b793a8
yay
zackradisic 4ec13b1
Added a test
zackradisic 84f7568
Merge branch 'main' into zack/devserver-fix-watching-entrypoint
zackradisic 53dd3a2
wip
zackradisic c809e0b
Fix entrypoing watching on macos
zackradisic 880fe5c
fix crash when html entrypoint is deleted
zackradisic 408e60a
[autofix.ci] apply automated fixes
autofix-ci[bot] 2835ccc
use open instead of stat
zackradisic bf1a5d5
Merge branch 'zack/devserver-fix-watching-entrypoint' of github.com:o…
zackradisic 465c253
Fix missing deleted_entrypoints field in VoidFieldTypes
2760f02
[autofix.ci] apply automated fixes
autofix-ci[bot] 95fb5a6
refactor
zackradisic c796200
update
zackradisic f5662a7
Merge branch 'zack/devserver-fix-watching-entrypoint' of github.com:o…
zackradisic e610061
Fix compile errors in devserver memory cost calculation
51088d9
Fix banned word usage and Windows test failure
1bdf3f1
disable test on windows due to rename not having posix semantics
zackradisic ff58806
[autofix.ci] apply automated fixes
autofix-ci[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,59 @@ | ||
| import { expect } from "bun:test"; | ||
| import * as fs from "node:fs"; | ||
| import * as path from "node:path"; | ||
| import { devTest } from "../bake-harness"; | ||
|
|
||
| devTest("vim file swap hot reload for entrypoints", { | ||
| files: { | ||
| "index.html": `<!DOCTYPE html> | ||
| <head> | ||
| <title>Test</title> | ||
| </head> | ||
| <body> | ||
| <p>Test foo</p> | ||
| <script type="module" src="index.ts"></script> | ||
| </body>`, | ||
| "index.ts": ``, | ||
| }, | ||
| async test(dev) { | ||
| await using c = await dev.client("/"); | ||
|
|
||
| // Verify initial load works | ||
| const initialResponse = await dev.fetch("/"); | ||
| expect(initialResponse.status).toBe(200); | ||
| const initialText = await initialResponse.text(); | ||
| expect(initialText).toContain("Test foo"); | ||
|
|
||
| // Simulate vim-style file editing multiple times to increase reliability | ||
| for (let i = 0; i < 3; i++) { | ||
| const updatedContent = `<!DOCTYPE html> | ||
| <head> | ||
| <title>Test</title> | ||
| </head> | ||
| <body> | ||
| <p>Test bar ${i + 1}</p> | ||
| <script type="module" src="index.ts"></script> | ||
| </body>`; | ||
|
|
||
| // Step 1: Create .index.html.swp file with new content | ||
| const swapFile = path.join(dev.rootDir, ".index.html.swp"); | ||
| await Bun.file(swapFile).write(updatedContent); | ||
|
|
||
| // Step 2: Delete original index.html | ||
| const originalFile = path.join(dev.rootDir, "index.html"); | ||
| fs.unlinkSync(originalFile); | ||
|
|
||
| // Step 3: Rename .index.html.swp to index.html | ||
| fs.cpSync(swapFile, originalFile); | ||
|
|
||
| // Wait a bit for file watcher to detect changes | ||
| await new Promise(resolve => setTimeout(resolve, 100)); | ||
|
|
||
| // Verify the content was updated | ||
| const response = await dev.fetch("/"); | ||
| expect(response.status).toBe(200); | ||
| const text = await response.text(); | ||
| expect(text).toContain(`Test bar ${i + 1}`); | ||
| } | ||
| }, | ||
| }); |
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.