a-b-street / osm2lanes

A common library and set of test cases for transforming OSM tags to lane specifications
https://a-b-street.github.io/osm2lanes/
Apache License 2.0
34 stars 2 forks source link

Rust NPM Package #60

Closed droogmic closed 2 years ago

droogmic commented 2 years ago

In response to https://github.com/3DStreet/3dstreet/issues/138#issuecomment-1030523013

dabreegster commented 2 years ago

I wonder if following this template is overkill. New dependencies on Travis and Appveyor build systems? We don't need full automation for publishing to NPM every time we commit here; we don't want that even! To start, if we manually run a few commands to publish, that'd almost be preferable.

Also not sure we need a new crate to expose a JS interface. In another project, I just tacked on the tiny WASM interface at the end: https://github.com/zonebuilders/zonebuilder-rust/blob/a3070b9332227f9ebc074c6879448d050ea99887/src/lib.rs#L272

I may have some time this weekend to play around with all of this. I'm fine moving forward with something working, but I would like to eventually go back and simplify it

droogmic commented 2 years ago

I wonder if following this template is overkill. New dependencies on Travis and Appveyor build systems? We don't need full automation for publishing to NPM every time we commit here; we don't want that even! To start, if we manually run a few commands to publish, that'd almost be preferable.

Oh, I need to cleanup the template (draft). I wuold expect a simple Github Actions based deployment...

Also not sure we need a new crate to expose a JS interface. In another project, I just tacked on the tiny WASM interface at the end: https://github.com/zonebuilders/zonebuilder-rust/blob/a3070b9332227f9ebc074c6879448d050ea99887/src/lib.rs#L272

Agreed, but I don't want to bring any WASM stuff into the default osm2lanes crate. So either tack it onto osm2lanes-web or make it a feature flag on osm2lanes? I like the sound of the second option, if we can do it in a way that is hidden from rust x86 clients.

dabreegster commented 2 years ago

So either tack it onto osm2lanes-web or make it a feature flag on osm2lanes?

osm2lanes-web is all about rendering / Yew; it's an "end-user app" at the moment, so probably not there.

The feature flags should be pretty simple: https://github.com/zonebuilders/zonebuilder-rust/blob/a3070b9332227f9ebc074c6879448d050ea99887/Cargo.toml#L21

So ideally all we need to do is add that to osm2lanes crate, do wasm-pack build --release, then do a few things to take the generated directory and get it on NPM. I don't know how NPM works yet, so maybe it's more elaborate than that

droogmic commented 2 years ago

I ran into some problems where target + crate-type + features could not be configured correctly to do the right thing.

See open issues like: https://github.com/rust-lang/cargo/issues/1197

I am leaning back again to making this a separate crate :/