-
-
Notifications
You must be signed in to change notification settings - Fork 246
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
fix(security): Use import.meta.hot
for communication with Vite 6.0.9+ (and 5.4.14+) dev server
#1411
Draft
aklinker1
wants to merge
14
commits into
main
Choose a base branch
from
fix-vite-hmr
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.
Draft
fix(security): Use import.meta.hot
for communication with Vite 6.0.9+ (and 5.4.14+) dev server
#1411
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9bdeb1a
fix: Use HMR API for dev server communication
aklinker1 6d5fdcc
Cleanup
aklinker1 bebb8c9
Cleanup
aklinker1 d213951
Setup module to import from dev server
aklinker1 84d0839
working ESM HMR context
aklinker1 51a16fe
Add missing file
aklinker1 63335dc
fix: Drop support for vite 6.0.9+ until websocket fix is finished
aklinker1 1e7f540
working for type:module
aklinker1 7af3cc6
Working MV2 example
aklinker1 a49463f
Cleanup
aklinker1 c46a5ca
Cleanup
aklinker1 91941ff
cleanup
aklinker1 37b4124
WIP
aklinker1 d815ebf
Replacement working
aklinker1 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 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export default defineBackground({ | ||
// type: 'module', | ||
type: 'module', | ||
|
||
main() { | ||
console.log(browser.runtime.id); | ||
|
This file contains 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 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 | ||||
---|---|---|---|---|---|---|
|
@@ -67,6 +67,10 @@ | |||||
"./modules": { | ||||||
"types": "./dist/modules.d.ts", | ||||||
"default": "./dist/modules.mjs" | ||||||
}, | ||||||
"./background-client": { | ||||||
"types": "./dist/background-client.d.ts", | ||||||
"default": "./dist/background-client.mjs" | ||||||
} | ||||||
}, | ||||||
"scripts": { | ||||||
|
@@ -123,7 +127,7 @@ | |||||
"publish-browser-extension": "^2.2.2", | ||||||
"scule": "^1.3.0", | ||||||
"unimport": "^3.13.1", | ||||||
"vite": "^5.0.0 || ^6.0.0", | ||||||
"vite": "^5.0.0 || <=6.0.8", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"vite-node": "^2.1.4", | ||||||
"web-ext-run": "^0.2.1", | ||||||
"webextension-polyfill": "^0.12.0" | ||||||
|
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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 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 |
---|---|---|
@@ -1,14 +1,6 @@ | ||
import { logger } from '../sandbox/utils/logger'; | ||
import { getDevServerWebSocket } from '../sandbox/dev-server-websocket'; | ||
|
||
if (import.meta.env.COMMAND === 'serve') { | ||
try { | ||
const ws = getDevServerWebSocket(); | ||
ws.addWxtEventListener('wxt:reload-page', (event) => { | ||
// "popup.html" === "/popup.html".substring(1) | ||
if (event.detail === location.pathname.substring(1)) location.reload(); | ||
}); | ||
} catch (err) { | ||
logger.error('Failed to setup web socket connection with dev server', err); | ||
} | ||
if (import.meta.hot) { | ||
import.meta.hot.on('wxt:reload-page', (event) => { | ||
// "popup.html" === "/popup.html".substring(1) | ||
if (event.detail === location.pathname.substring(1)) location.reload(); | ||
}); | ||
} | ||
Comment on lines
+1
to
6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: Test |
11 changes: 0 additions & 11 deletions
11
packages/wxt/src/virtual/utils/keep-service-worker-alive.ts
This file was deleted.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: