fable-compiler / repl

Fable online REPL
http://fable.io/repl
MIT License
64 stars 37 forks source link

Steps to include custom dependency in sample #102

Closed PawelStadnicki closed 4 years ago

PawelStadnicki commented 4 years ago

In docs there is description how to add own samples. However I struggle to add a sample that uses my domain code from other assembly (and I want to keep it there) If I put "open mydomain.subdomain" in my sample in REPL it cannot be compiled (the namespace or module is not defined). I added my dll (with .txt extension as well) to metadata folder.

I tried by adding my domain code via paket or nuget and I can see it is compiled to js but I still cannot compile the samples in Repl. Is there additional file to configure the mapping or any additional step? I tried to look at similar sample with Recharts but I do not understand the workflow of adding such a dependencies.

alfonsogarciacaro commented 4 years ago

Well, unfortunately this is a somewhat complicated process. Dependencies in the REPL are precompiled for better performance, but this is causes problems with Fable (inlined code, namespace resolution) so we used several hacks to make it work for this particular case.

Again, this was implemented in a quick and dirty way and it was not designed to be used general. But I think you can add extra dependencies following these steps:

PawelStadnicki commented 4 years ago

Thanks Alfonso. So I was almost there but even with your suggestion I still cannot see my domain. In paket I specify my github repository, my 2 files are downloaded and after adding to Repl Lib project they are successfully compiled and the lib folder is as follow: image

wrometr.domain has two js files: Address.js and District.js Repl-lib-map after modification contains following entry:

"wrometr.domain.addresses":["wrometr.domain.addresses", "wrometr.domain/Address"]

I'm compailing the repl.lib project and copying the dll (dll.txt) to metadata folder Still cannot find the domain in Repl: image

PawelStadnicki commented 4 years ago

well, it worked with yet another building, strange but maybe common. I'm playing now with typical bindings like simple-statistics, turfjs, D3js. If no further problems I will close the issue and maybe do the PR, do you welcome such a samples?