Skip to content

Commit

Permalink
Fix: Only start worker once [publish]
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Mar 21, 2022
1 parent 60c23d5 commit 758b9e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
## 1.0.0

Initial release

## 1.0.1

Fix: Only start worker once
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vite-plugin-tsc-watch",
"description": "Plugs tsc --watch into Vite dev server",
"version": "1.0.0",
"version": "1.0.1",
"license": "MIT",
"author": "Arnaud Barré (https://github.com/ArnaudBarre)",
"main": "dist/index.js",
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import { Worker } from "worker_threads";
import { resolve } from "path";
import { Plugin } from "vite";

let started = false;

export default function tscPlugin(): Plugin {
return {
name: "tsc",
apply: "serve",
configureServer: () => {
configureServer: async () => {
if (started) return;
new Worker(resolve(__dirname, "./worker"));
started = true;
},
};
}

0 comments on commit 758b9e7

Please sign in to comment.