Fable F# > js编译多个.fsx文件

Fable F# > js compile multiple .fsx files

如何使用 Fable 编译多个 .fsx 文件?

我(天真地)试图像这样在 fable.config 文件中传递它们的数组:

{
    "outDir": "app",
    "projFile":["app/index.fsx", "app/testmod.fsx"],
    "sourceMaps": true,
    "targets": {
        "production": {
            "sourceMaps": false
        }
    }
}

但收到警告:

ARG ERROR: TypeError: Path must be a string. Received [ 'app/index.fsx', 'app/testmod.fsx' ]

我知道我可以制作一个完整的 .fsproj 文件并将 fable 编译器指向该文件,但仅仅为了添加引用而这样做似乎有点过分了。

感觉好像少了一些很简单的东西?

好吧,我真的错过了一些简单的东西!

真正直接的解决方案就是在 .fsx 文件本身中使用引用,而不必担心将 Fable 指向引用文件。

index.fsx:

module App

#load "testmod.fsx" //this reference is all thats needed!

那我们就不需要里面的引用了 fable.config:

{
    "outDir": "app",
    "projFile":"app/index.fsx",
    "sourceMaps": true,
    "targets": {
        "production": {
            "sourceMaps": false
        }
    }
}

自我注意 - 在 Stack Overflow 上发帖之前先尝试最简单的解决方案!