Targeting python with Fable.Mocha dependency returns error.
Description
Hey i am currently working on a Fable.Mocha equivalent for python. That means i have an Expecto test project with
#if FABLE_COMPILER_PYTHON
open Fable.Pyxpecto
#endif
// #elif does not work
#if FABLE_COMPILER_JAVASCRIPT
open Fable.Mocha
#endif
#if !FABLE_COMPILER
open Expecto
#endif
So as you can see Fable.Mocha is not opened/used in any way when transpiling to python.
But i still get the following error:
.\tests\py\fable_modules\fable_mocha\Mocha.fs(546,26): (546,46) error FABLE: Fable.Core.Extensions.Async.StartAsPromise.Static is not supported, try updating fable tool
Compilation failed
Repro code
Repro code can be found here
The necessary build targets are listed here
Expected and actual results
I would expect ignoring unused dependencies or them not raissing errors if they are not used.
Hello @Freymaurer,
Hum this a new situation that arise from Fable 4 multiple target nature. In the past, we only needed to support Fable JavaScript and .NET so all Fable packages where always compatible.
I think by default Fable compiles all the referenced projects and then the F# compiler / Bundler decide if the files should actually be used or not.
I don't know yet if there is an easy way to improve this situation. In the past, there were talks about adding Fable as an MSBuild runtime but people said it was complex and the benefit were too few at the time. Sorry I don't have link to that discussion as it happens 3-4 years ago.
On the bright side, you can use MSBuild condition in order to activate or deactivate a dependency in your project. It seems to be working for me in your test repro, but I am unsure if this will works if the project is published as a NuGet package.
<PackageReference Condition="'$(FABLE_COMPILER_JAVASCRIPT)' == 'true'" Include="Fable.Mocha" Version="2.17.0" />
With this line Fable.Mocha is only included if Fable targets JavaScript.
Ahh thanks! That is a good work around for now!