Fable: Library refs break when project name contains a dot

Created on 27 Jul 2016  路  4Comments  路  Source: fable-compiler/Fable

In latest Fable (0.4.4), I'm experiencing a problem when building a project that references another project. If the project being referenced has a dot in the name, then Fable is generating incorrect paths in the require calls. Before upgrading Fable, I did not have the issue.

Imagine you have a solution with three F# projects:Library, Library.Another, and Main. Main references both Library and Library.Another. Now assume the two library projects have already been compiled by Fable to out/library and out/library-another.

Now, if you compile the Main project using this fableconfig.json...

{
  "module": "commonjs",
  "outDir": "out/main",
  "projFile": "Test/Main/Main.fsproj",
  "refs": {
    "Library": "../library",
    "Library.Another": "../library-another"
  }
}

...you will get incorrect require calls in the generated output whenever a module from the Library.Another project is referenced (modules referenced from Library work fine). For example:

var _SomeModule = require("../library/SomeModule");

var _AnotherModule = require("../library-another/Library.Another/AnotherModule");

The first require call works as expected. However, the second require call has Library.Another/ in its path for some reason, which causes a runtime error when trying to resolve the reference.

A similar problem occurs when using the AMD module system.

Note: In my case, the references from Main to the libraries are project references made within the same solution (as opposed to an external DLL) -- not sure if that makes a difference or not.

bug

All 4 comments

Hmm, I'm not sure the dot is the problem because we have a similar reference in the project containing the tests. Is your project public or can you upload a minimal project structure which can reproduce the problem? Is by any chance your directory structure similar to the one below?

/Main/Main.fsproj
/Library/Library.fsproj
         SomeModule.fs
/Library.Another.fsproj
/Library.Another/AnotherModule.fs

Thanks for the report!

My project isn't public, but I created a quick repo with similar structure to show the problem I'm having:

https://github.com/funlambda/fable-project-ref-example

If you clone it and run build-and-run.sh, you should see the module ref run-time error. The problematic path is in out/main/Program.js:

var _AnotherModule = require("../library-another/Library.Another/AnotherModule");

Thanks for taking the time to prepare the structure to reproduce the issue! It was indeed the dot :) I've released [email protected] with the fix. Could you give it a try?

Works perfectly now -- thanks for the fix and the insanely fast turnaround!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AngelMunoz picture AngelMunoz  路  4Comments

forki picture forki  路  3Comments

theprash picture theprash  路  3Comments

alfonsogarciacaro picture alfonsogarciacaro  路  3Comments

et1975 picture et1975  路  3Comments