-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include improved TS library in this package #52
Comments
FYI I started looking into out how to add the library to ReactMapGL https://visgl.github.io/react-map-gl/ in an Astro Project. Any hints on that are welcome, did anyone add it to a react project, yet? |
I was wondering if the package is following the recommendations on how to export methods, because it looks like VS Code / Typescript magic that allows to "import package" when using a function seems to not work. Using the import used in your svelte example I get… Updates: Those tools might be helpful to test the package
|
Hmm, the package config is auto-generated by wasm-pack and might be kind of strange. The one difference that jumps out is that I think you have to do If you want to start with the newer TS package, then as an immediate work-around, you could try copying https://github.com/dabreegster/ltn/blob/main/web/src/common/snapper/route_tool.ts into your code. The only svelte-specific bit here is My next step on this issue is to figure out how to include the .ts library in the NPM package. The wasm-pack generated package.json looks like this:
So there will be a little work to figure out what a normal TS NPM package looks like, and get the auto-generated |
I've got some ideas to simplify things here -- I'm going to try building + publishing just the WASM library as one NPM package, then making a second package with the nice TS wrapper. I'm having trouble finding a minimal working template to do that, though -- I've been trying the Vite vanilla TS starter, but it doesn't appear suitable for publishing libraries, as it's insisting on an |
In the main projects actually using the route-snapper, I'm not using https://github.com/dabreegster/route_snapper/blob/main/route-snapper/lib.js. Instead there's a newer TS version of this library, split into a few pieces:
At least that first piece should be included in the NPM package here. The other two pieces could be listed as example references, but since they're Svelte specific, not much code, and make UI choices about wording / styling that's not likely to be general, I don't think they belong in the package.
I need to figure out how to include a TS file in an NPM package correctly. The NPM package is partly generated by
wasm-pack
and already includes some auto-generated type declarations, so it has to play well with that. Shouldn't be too hard though.CC @tordans -- if you'd want to use the TS library and not just copy in the short-term, I'll prioritize this
The text was updated successfully, but these errors were encountered: