Skip to content

Conversation

@fisker
Copy link
Member

@fisker fisker commented Nov 29, 2025

Description

The worker version has too many restrictions, it doesn't support plugin with function in language information prettier/prettier#18353 (comment).

Can't import plugin in prettier.config.js

I'm not sure how to test, but I already tested with this config in Prettier code base

// prettier.config.mts
import * as prettierPluginOxc from "./packages/plugin-oxc/index.js";

export default {
  parser: "oxc-ts",
  plugins: [prettierPluginOxc],
};

I even updated the oxc printer to print some debug info, it successfully printed

image
// Formatted by oxc-ts
// from 'D:\Microsoft VS Code'

import * as prettierPluginOxc from "./packages/plugin-oxc/index.js";

export default {
  parser: "oxc-ts",
  plugins: [prettierPluginOxc],
};

It was added to support ESM that prettier v3 requires, now VSCode supports ESM, we don't need this anymore.

Related Issue

Fixes #3796

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/Build changes

Checklist

  • I have read the CONTRIBUTING guidelines
  • My code follows the code style of this project (npm run lint passes)
  • I have run npm run prettier to format my code
  • I have added/updated tests that prove my fix or feature works
  • All new and existing tests pass (npm test)
  • I have updated the CHANGELOG.md with a summary of my changes

@fisker fisker marked this pull request as ready for review November 29, 2025 16:18
@fisker fisker requested review from Copilot and ntotten November 29, 2025 16:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the worker-based Prettier instance implementation (PrettierWorkerInstance) that was previously used for Prettier v3+, replacing it with a unified approach that uses PrettierMainThreadInstance for all Prettier versions. The change enables support for Prettier plugins with function values in language information and allows importing plugins directly in prettier.config.js, which were previously blocked by the worker thread's serialization limitations.

Key changes:

  • Removed worker thread implementation (PrettierWorkerInstance.ts and prettier-instance-worker.js)
  • Simplified module resolution to always use PrettierMainThreadInstance regardless of Prettier version
  • Updated build configuration to remove worker file copying and watching

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/worker/prettier-instance-worker.js Deleted worker thread message handler for Prettier operations
src/PrettierWorkerInstance.ts Deleted TypeScript wrapper for worker-based Prettier instance
src/ModuleResolver.ts Removed version detection logic and worker instance creation; simplified to always use main thread instance
eslint.config.mjs Removed src/worker/** from ESLint ignore patterns
esbuild.mjs Removed worker file copying logic from build process
README.md Fixed trailing whitespace
CONTRIBUTING.md Updated architecture description to remove worker instance reference
CLAUDE.md Updated architecture documentation to reflect main thread only approach
CHANGELOG.md Added entry documenting support for configuration files with imported plugins
.github/instructions/typescript.instructions.md Updated guidelines to remove worker thread pattern
.github/copilot-instructions.md Updated architecture description and removed worker-related performance notes

@ntotten
Copy link
Member

ntotten commented Dec 1, 2025

Superseded by #3860

@ntotten ntotten closed this Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

There is no formatter for 'shellscript' files installed.

3 participants