Skip to content

Commit decf076

Browse files
committed
Remove the worker instance
1 parent f323ebc commit decf076

File tree

8 files changed

+7
-255
lines changed

8 files changed

+7
-255
lines changed

.github/copilot-instructions.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Core components:
2323
- `src/extension.ts` - Extension activation, creates ModuleResolver, PrettierEditService, and StatusBar
2424
- `src/PrettierEditService.ts` - Registers VS Code document formatting providers, handles format requests
2525
- `src/ModuleResolver.ts` - Resolves local/global Prettier installations, falls back to bundled Prettier
26-
- `src/PrettierInstance.ts` - Interface for Prettier loading, with `PrettierMainThreadInstance` and `PrettierWorkerInstance` implementations
26+
- `src/PrettierInstance.ts` - Interface for Prettier loading, with `PrettierMainThreadInstance` implementations
2727

2828
esbuild produces two bundles:
2929

@@ -62,14 +62,13 @@ When reviewing pull requests, focus on:
6262

6363
### Prettier Compatibility
6464

65-
- Changes work with both Prettier v2 (sync) and v3+ (async/worker)
65+
- Changes work with both Prettier v2 (sync) and v3+ (async)
6666
- Module resolution fallback chain is maintained: local → global → bundled
6767
- Config file watching covers all Prettier config formats
6868

6969
### Performance
7070

7171
- Avoid blocking the extension host main thread
72-
- `PrettierWorkerInstance` runs Prettier in a worker thread to avoid blocking
7372
- Module and config resolution results are cached appropriately
7473

7574
### Browser Compatibility

.github/instructions/typescript.instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This is a VS Code extension. Follow these patterns:
2828
## Prettier Integration
2929

3030
- Support both Prettier v2 and v3+ via `PrettierInstance` interface
31-
- `PrettierMainThreadInstance` loads directly, `PrettierWorkerInstance` uses worker thread
31+
- `PrettierMainThreadInstance` loads directly
3232
- Module resolution: local install → global install → bundled Prettier
3333
- Handle `.prettierrc`, `.prettierignore`, and `package.json` prettier config
3434

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All notable changes to the "prettier-vscode" extension will be documented in thi
66

77
## [unreleased]
88

9+
- Support configuration file with imported plugins
910
- [BREAKING CHANGE] Bundled Prettier upgraded from v2.8.8 to v3.x
1011
- [BREAKING CHANGE] Updated `trailingComma` default from `"es5"` to `"all"` to match Prettier 3
1112
- Maintained backward compatibility with projects using Prettier v2.x (projects with explicit Prettier v2 dependencies will continue to use their local version)

CLAUDE.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,10 @@ Web tests are located in `src/test/web/suite/` and test the extension's browser
8686
- Caches resolved modules and configurations
8787
- Handles Workspace Trust restrictions
8888

89-
**Prettier Instance** (`PrettierInstance.ts`, `PrettierMainThreadInstance.ts`, `PrettierWorkerInstance.ts`):
89+
**Prettier Instance** (`PrettierInstance.ts`, `PrettierMainThreadInstance.ts`):
9090

9191
- `PrettierInstance` is an interface with two implementations
9292
- `PrettierMainThreadInstance` loads Prettier directly via `require()`
93-
- `PrettierWorkerInstance` loads Prettier in a worker thread to avoid blocking
94-
- Works with both Prettier v2 and v3+
9593

9694
### Bundling
9795

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Key components:
9090

9191
- `PrettierEditService.ts` - Handles document formatting
9292
- `ModuleResolver.ts` - Resolves Prettier installations (local, global, or bundled)
93-
- `PrettierInstance.ts` - Interface for Prettier, with `PrettierMainThreadInstance` and `PrettierWorkerInstance` implementations
93+
- `PrettierInstance.ts` - Interface for Prettier, with `PrettierMainThreadInstance` implementations
9494

9595
## Submitting Changes
9696

src/ModuleResolver.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ import {
3131
getWorkspaceRelativePath,
3232
} from "./utils/workspace";
3333
import { PrettierInstance } from "./PrettierInstance";
34-
import { PrettierWorkerInstance } from "./PrettierWorkerInstance";
3534
import { PrettierMainThreadInstance } from "./PrettierMainThreadInstance";
3635
import { loadNodeModule, resolveConfigPlugins } from "./utils/resolvers";
37-
import { isAboveV3 } from "./utils/versions";
3836

3937
const minPrettierVersion = "1.13.0";
4038

@@ -246,16 +244,8 @@ export class ModuleResolver implements ModuleResolverInterface {
246244
return moduleInstance;
247245
} else {
248246
try {
249-
const prettierVersion =
250-
this.loadPrettierVersionFromPackageJson(modulePath);
247+
moduleInstance = new PrettierMainThreadInstance(modulePath);
251248

252-
const isAboveVersion3 = isAboveV3(prettierVersion);
253-
254-
if (isAboveVersion3) {
255-
moduleInstance = new PrettierWorkerInstance(modulePath);
256-
} else {
257-
moduleInstance = new PrettierMainThreadInstance(modulePath);
258-
}
259249
if (moduleInstance) {
260250
this.path2Module.set(modulePath, moduleInstance);
261251
}

src/PrettierWorkerInstance.ts

Lines changed: 0 additions & 138 deletions
This file was deleted.

src/worker/prettier-instance-worker.js

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)