Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Discussion options

You must be logged in to vote

Hi, @nop990!

I made a minimal working example here:

https://github.com/Poliklot/prettier-plugin-java-standalone-browser-example

The main issue is that prettier/standalone does not auto-load plugins from
node_modules. The Java plugin has to be imported and passed directly to
plugins.

The important part is:

import * as prettier from "prettier/standalone";
import prettierPluginJava from "prettier-plugin-java";

const formatted = await prettier.format(source, {
  parser: "java",
  plugins: [prettierPluginJava],
});

I used esbuild instead of Browserify. From a fresh clone this works:

npm install
npm run start:csp-like

So the Prettier standalone API itself works with prettier-plugin-java. The
p…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by fisker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants