-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: skip id query string in transform (fixes #23)
- Loading branch information
1 parent
6f3e372
commit 7f22049
Showing
13 changed files
with
143 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { test } from "@playwright/test"; | ||
import { | ||
setupDevServer, | ||
setupBuildAndPreview, | ||
setupWaitForLogs, | ||
} from "../../utils"; | ||
|
||
test("Worker build", async ({ page }) => { | ||
const { testUrl, server } = await setupBuildAndPreview("worker"); | ||
const waitForLogs = await setupWaitForLogs(page); | ||
await page.goto(testUrl); | ||
await waitForLogs("Worker lives!", "Worker imported!"); | ||
|
||
await server.httpServer.close(); | ||
}); | ||
|
||
test("Worker HMR", async ({ page }) => { | ||
const { testUrl, server, editFile } = await setupDevServer("worker"); | ||
const waitForLogs = await setupWaitForLogs(page); | ||
await page.goto(testUrl); | ||
await waitForLogs("Worker lives!", "Worker imported!"); | ||
|
||
editFile("src/worker-via-url.ts", ["Worker lives!", "Worker updates!"]); | ||
await waitForLogs("Worker updates!"); | ||
|
||
await server.close(); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite + React + Worker</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/index.tsx"></script> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "playground-hmr", | ||
"private": true, | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build" | ||
}, | ||
"dependencies": { | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react-dom": "^18.0.9", | ||
"@types/react": "^18.0.26", | ||
"@vitejs/plugin-react-swc": "../../dist" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { useState } from "react"; | ||
import MyWorker from "./worker-via-import?worker&inline"; | ||
|
||
new MyWorker(); | ||
|
||
export const App = () => { | ||
const [count, setCount] = useState(0); | ||
|
||
return <button onClick={() => setCount(count + 1)}>count is {count}</button>; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { StrictMode } from "react"; | ||
import { createRoot } from "react-dom/client"; | ||
import { App } from "./App"; | ||
|
||
new Worker(new URL("./worker-via-url.ts", import.meta.url), { type: "module" }); | ||
|
||
createRoot(document.getElementById("root")!).render( | ||
<StrictMode> | ||
<App /> | ||
</StrictMode>, | ||
); |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function printAlive(): void { | ||
console.log("Worker imported!"); | ||
} | ||
|
||
printAlive(); | ||
|
||
export {}; |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function printAlive(): void { | ||
console.log("Worker lives!"); | ||
} | ||
|
||
printAlive(); | ||
|
||
export {}; |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"include": ["src", "vite.config.ts"], | ||
"compilerOptions": { | ||
"module": "ESNext", | ||
"lib": ["ESNext", "DOM", "DOM.Iterable"], | ||
"target": "ESNext", | ||
"jsx": "react-jsx", | ||
"types": ["vite/client"], | ||
"noEmit": true, | ||
"isolatedModules": true, | ||
"skipLibCheck": true, | ||
|
||
/* Imports */ | ||
"moduleResolution": "node", // Allow `index` imports | ||
"resolveJsonModule": true, // Allow json import | ||
"forceConsistentCasingInFileNames": true, // Avoid difference in case between file name and import | ||
"esModuleInterop": false, | ||
|
||
/* Linting */ | ||
"strict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"useUnknownInCatchVariables": true | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { defineConfig } from "vite"; | ||
import react from "@vitejs/plugin-react-swc"; | ||
|
||
export default defineConfig({ | ||
plugins: [react()], | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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