Skip to content
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

perf(dev): use @parcel/watcher whenever available #95

Merged
merged 1 commit into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"test": "pnpm lint && vitest run --coverage"
},
"dependencies": {
"@parcel/watcher": "^2.2.0",
"@parcel/watcher-wasm": "2.3.0-alpha.1",
"citty": "^0.1.2",
"clipboardy": "^3.0.0",
Expand Down
124 changes: 124 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions src/server/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@
};

// Start watcher
// https://github.com/parcel-bundler/watcher#wasm
try {
const { default: init, subscribe } = await import("@parcel/watcher-wasm");
// https://github.com/parcel-bundler/watcher
const subscribe = await import("@parcel/watcher")
.then((r) => r.subscribe)
.catch(() =>
import("@parcel/watcher-wasm").then((r) =>
(r.default || r)().then(() => r.subscribe),
),
);

Check warning on line 55 in src/server/watcher.ts

View check run for this annotation

Codecov / codecov/patch

src/server/watcher.ts#L48-L55

Added lines #L48 - L55 were not covered by tests

const jsExts = new Set([".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"]);

await (init as any)();

watcher = await subscribe(
devServer.cwd,
(_error, events) => {
Expand Down