minify-html icon indicating copy to clipboard operation
minify-html copied to clipboard

Add bindings for dart

Open m-haisham opened this issue 1 year ago • 3 comments

This pull request adds Dart bindings to this library. The bindings will allow Dart to load and interact with the library using C-Interop.

I've also included an example file, example/minify_html_example.dart, in the example folder to demonstrate how to use your library with Dart.

TODO: Documentation

Run

Move into dart directory

cd dart

Run the following command to build and move the library to an accessible place

cargo build -r --manifest-path native/Cargo.toml && mv native/target/release/libminifyhtml.so .dart_tool/minifyhtml

Run the example

dart run example/minify_html_example.dart

m-haisham avatar Mar 06 '23 16:03 m-haisham

This is looking great, thanks @m-haisham. Don't worry about the docs, I'll add those and do some more general package cleanup tasks myself once it's merged, including structuring the project, some minor reformatting, and setting up CI.

How will the native binary be distributed? It looks like we can publish to the official pub.dev, but does that allow for bundling binary files? Alternatively, we'll need a post-install script that downloads the appropriate binary for the platform.

wilsonzlin avatar Mar 07 '23 01:03 wilsonzlin

How will the native binary be distributed?

The easiest solution would be to have it download the appropriate library files for each platform during build

m-haisham avatar Mar 10 '23 09:03 m-haisham

Hello m-haisham,

Thank you for your contribution to the library by adding Dart bindings! It's great to see the community working together to improve the library.

The example file you included in the example folder is helpful and makes it easier for developers to use the library with Dart. However, as you mentioned, it would be great to have documentation to go along with the bindings.

GladisHosterXY avatar Mar 17 '23 14:03 GladisHosterXY