You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm writing a web extension that uses Prism and Prettier to format code on a webpage. Since I am using standalone Prettier, I have to add the plugins to the Prettier.format() call directly. The included plugins (typescript, estree, babel, etc.) import fine with require() statements, but I cannot figure out how to do this for the prettier-java-plugin. More info/code samples on my stack-overflow post
The text was updated successfully, but these errors were encountered:
As of version 2.6.0, this plugin is now an ECMAScript module, so you cannot require() it. Try using import instead. You can see an example in our own website's source here.
That throws an error in the build (using the esmify one) with this message: Error: Can't walk dependency graph: Cannot find module 'java-parser' from 'node_modules\prettier-plugin-java\dist\parser.js'. I think I've had that before and the "solution" I found was to explicitly define the dependency paths for java-parser, chevrotain, and chevrotain-allstar in the browserify process. The error would disappear and the extension would build, but when you would call the function to format the Java code, it would just hang.
My solution for now has been running the Prettier API in a Node.js server that the web extension can call. It's not ideal, but it at least works.
I'm writing a web extension that uses Prism and Prettier to format code on a webpage. Since I am using standalone Prettier, I have to add the plugins to the Prettier.format() call directly. The included plugins (typescript, estree, babel, etc.) import fine with require() statements, but I cannot figure out how to do this for the prettier-java-plugin. More info/code samples on my stack-overflow post
The text was updated successfully, but these errors were encountered: