Giter Site home page Giter Site logo

Comments (4)

sambacha avatar sambacha commented on May 14, 2024

just following up, what are the benefits/costs of an approach like this https://github.com/devongovett/dprint-node @dsherret ?

Thanks

from dprint-plugin-prettier.

dsherret avatar dsherret commented on May 14, 2024

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).

from dprint-plugin-prettier.

sambacha avatar sambacha commented on May 14, 2024

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!

from dprint-plugin-prettier.

dsherret avatar dsherret commented on May 14, 2024

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.

from dprint-plugin-prettier.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.