-
-
Notifications
You must be signed in to change notification settings - Fork 41
Description
We stumbled across a very intricate, general problem with Fable. The base problem is, that python fable transpilation fails, if emitted javascript code is referenced somewhere down the line.
In order to fix this, we use conditional dependencies in https://github.com/nfdi4plants/ARCtrl/blob/main/src/Json/ARCtrl.Json.fsproj:
<ItemGroup>
<PackageReference Include="Thoth.Json.Core" Version="0.2.1" />
<PackageReference Include="Thoth.Json.Newtonsoft" Version="0.1.0" />
<PackageReference Condition="'$(FABLE_COMPILER_PYTHON)' == 'true'" Include="Thoth.Json.Python" Version="0.2.0" />
<PackageReference Condition="'$(FABLE_COMPILER_JAVASCRIPT)' == 'true'" Include="Thoth.Json.JavaScript" Version="0.1.0" />
</ItemGroup>
This works in the repository, when calling the published package on nuget and also the javascript package in npm and the python package in pypi work.
However, a downstream library depending on the nuget package cannot be transpiled to js or python, as the dependencies to Thoth.Json.Python and Thoth.Json.JavaScript are not included in the nuget package. Fable therefore does not include these dependencies.
I looked at this from many different angles, and the only working solution I found is the following:
https://github.com/CSBiology/DynamicObj/pull/38/files
Always use compiler directives for js and py only code, even on the lowest level. To still have intellisense, one can also include the !FABLE_COMPILER as an or case:
#if FABLE_COMPILER_JAVASCRIPT || FABLE_COMPILER_TYPESCRIPT || !FABLE_COMPILER
We use Thoth.Json in many places, would it be possible to add these directives to the js and py parts of the repo?