Open sambacha opened 2 years ago
just following up, what are the benefits/costs of an approach like this https://github.com/devongovett/dprint-node @dsherret ?
Thanks
Sorry, I have just been making some foundational changes to this plugin and didn't want to add support when it would all be changing. It should be fairly trivial to add this now (hopefully), by updating this folder: https://github.com/dprint/dprint-plugin-prettier/tree/main/js/node
just following up, what are the benefits/costs of an approach like this https://github.com/devongovett/dprint-node
That's a node API version of dprint-plugin-typescript only. I wouldn't recommend using it as it seems out of date. If you need an API in Node instead you can use https://github.com/dprint/js-formatter#nodejs which supports using any version of a dprint wasm plugin and the plugins are kept up to date on npm.
This dprint-plugin-prettier though is only for the dprint CLI and it formats code using Prettier and is much faster than Prettier's CLI (especially with incremental formatting enabled).
Sorry, I have just been making some foundational changes to this plugin and didn't want to add support when it would all be changing. It should be fairly trivial to add this now (hopefully), by updating this folder: https://github.com/dprint/dprint-plugin-prettier/tree/main/js/node
just following up, what are the benefits/costs of an approach like this devongovett/dprint-node
That's a node API version of dprint-plugin-typescript only. I wouldn't recommend using it as it seems out of date. If you need an API in Node instead you can use dprint/js-formatter#nodejs which supports using any version of a dprint wasm plugin and the plugins are kept up to date on npm.
This dprint-plugin-prettier though is only for the dprint CLI and it formats code using Prettier and is much faster than Prettier's CLI (especially with incremental formatting enabled).
thank you for the response and for the consideration of potential changes, good to know! Will circle back around this weekend and get back to you, thanks!
I looked into this a bit today and gave up after a while. Basically solidity-parser/parser needs to be made to work in a Browser, but right now it uses the "assert" package and "util" node package. I worked around those by patching the package, but then I got this:
error: Uncaught ReferenceError: __dirname is not defined
module2.exports = require_fs().readFileSync(require_path().join(__dirname, "./antlr/Solidity.tokens")).toString();
...and gave up at that point. Probably it could be fixed by manually inlining that file when patching the package, but it's too much work for me. If someone wants to take this on by either patching the package to make it work in this repo (using https://www.npmjs.com/package/patch-package... essentially change this directory https://github.com/dprint/dprint-plugin-prettier/tree/main/js/node then run deno task build
and ensure deno task test
works after adding a test for solidity in https://github.com/dprint/dprint-plugin-prettier/blob/main/js/startup.test.ts) or by ideally updating solidity-parser/parser to work in the browser that would be helpful.
Hello, would like to know if you are open to a PR for accepting the prettier-plugin-solidity integration?
see github.com/prettier-solidity/prettier-plugin-solidity