Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library refs break when project name contains a dot #287

Closed
funlambda opened this issue Jul 26, 2016 · 4 comments
Closed

Library refs break when project name contains a dot #287

funlambda opened this issue Jul 26, 2016 · 4 comments
Labels

Comments

@funlambda
Copy link

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.

@alfonsogarciacaro
Copy link
Member

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!

@funlambda
Copy link
Author

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");

@alfonsogarciacaro
Copy link
Member

Thanks for taking the time to prepare the structure to reproduce the issue! It was indeed the dot :) I've released fable-compiler@0.4.6 with the fix. Could you give it a try?

@funlambda
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants