Fable: Recompile dependant files on watch compilation

Created on 19 Sep 2016  路  12Comments  路  Source: fable-compiler/Fable

Ok I open a new issue, since I am not sure it is related to the previous one with same title.

Description

I have got two files A.fsx and B.fsx.
A loads B.
A.fsx and B.fsx are not in the same path.
When compiling A.js is generated as well as B-xxx.js in an fable_external folder relative to A.js location.

Manual compilation (no watch)
A and B are both compiled.

Using -watch
First start: both files get compiled.

  1. modify B.fsx: Nothing happens which seems to be ok.
  2. modify A.fsx: a new compilation happens and a new A.js is generated.
  3. modify B.fsx then A.fsx (to trigger compilation): A.js is updated. B-xxx.js is not updated.. In fact in the compiler output, only A.fsx gets compiled.

Command used:
fable --projFile A.fsx --outDir out -s -w

Is it ok? And so do I need to add something to the command line to force B compilation?
or
is it a bug?

Related information

  • Fable Version 0.6.3
  • .NET Runtime, CoreCLR or Mono Version Latest
  • Operating system Windows 10
discussion

All 12 comments

This shouldn't be the proper behaviour: B.fsx should recompile on modification. Would it be possible to create a repository (or a gist) with the files to reproduce the issue?

Ok I created a sample there: https://github.com/whitetigle/fableissue424 and have been able to reproduce the error.

Use case is written in README.md.

The problem lies when A is located in a sub folder and B in another subfolder. For instance:

src/A.fsx
lib/B.fsx

But the following sample is working:
A.fsx
lib/B.fsx

Test was done on windows 10.
Thanks!

Great, thanks! I'm a bit busy these days but I'll have a look as soon as I have time :)

Just some follow up using watch:
I get a new error each time I do some refactoring like this:

  1. remove some MyType type from current script and put it in a new script file named MyType.fsx
  2. add #load MyType.fsx and Open MyType from former file and save

Compiler then shouts:
ERROR: Cannot find replacement for MyScript.MyScript.ctor

I restart compilation and everything compiles.
Did this a lot this morning. Happens each time.
Do you want me to submit a new issue?

Hi there! Sorry for the late reply. I could finally reproduce the problem thanks to the repository you kindly prepared but I now realized I should have understood the situation from your description alone.

At the moment, the file watcher is only watching for changes in the directory where the project file is. We can change it so it looks at the directory where fableconfig.json is (if present). Would that work for you? (Note that you would need a fableconfig.json file on a directory that is common to all relevant files to the project.)

About the other issue, there's a type cache that may get confounded if you move types around. You can write another issue if you want or we can just leave this one here until I check how difficult fixing this would be.

Hi! Thanks for the feedback.
Don't change anything unless other find this relevant. I will adapt myself :)
Regarding the second issue let it remain there for now.

Hi @whitetigle! With the latest Fable version, you can pass a string (or a string array) to the watch option in fableconfig.json to indicate the directories that must be watched. Can you please give it a try?

I'm closing the issue for now, but please feel free to reopen it if you've any other question or comment.

Oh well this morning, seems I need some coffee: can't get past this error.

fable-compiler 0.7.18: Start compilation...
[ERROR] Fable.Core 0.7.14 required, please upgrade the project reference

But I do have fable-core 0.7.14 installed.
Here's my package.json:

{
  "private": true,
  "name": "fable-issue-424",
  "version": "1.0.0",
  "description": "test case for issue 424",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "fable-core": "^0.7.14",
    "babel-runtime":"^6.11.6"
  },
  "devDependencies": {
    "requirejs": "^2.3.2",
    "babel-plugin-transform-runtime": "^6.15.0",
    "finalhandler": "^0.5.0",
    "open": "0.0.5",
    "rollup-plugin-replace": "^1.1.1"
  }
}

here's my fableconfig.json:

{
  "projFile": "a.fsx",
  "sourceMaps": true,
  "watch":["alternate_src"],
  "babelPlugins": ["transform-runtime"],
  "rollup": {
    "dest": "out/bundle.js"
  }
}

Fable compiler is installed globally.
No worries though, when you have 2 minutes and any idea, I'm ok to try again :)

@whitetigle Did you try reinstalling the packages. If necessary, please remove node_modules and run npm i again :)

Yes. I did all that.

  • I removed all the packages using npm.
  • I removed the node_modules folder.
  • I uninstalled/installed fable-compiler again globally
  • installed all again using npm i
  • closed my console prior and after

Since, I have some things todo on another project, I will try on that project and see if things are working better.

Thanks for your help!

Ok!
watch + folder list works on side project so let's say it's ok 馃憤 (and let the mystery remain on the other project 馃槈 )

Thanks!

@whitetigle By the way, I recommend installing fable-compiler locally rather than globally. That way anybody who tries to install your project (including yourself!) is guaranteed to get the correct version of the compiler.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alfonsogarciacaro picture alfonsogarciacaro  路  3Comments

SirUppyPancakes picture SirUppyPancakes  路  3Comments

tomcl picture tomcl  路  4Comments

alfonsogarciacaro picture alfonsogarciacaro  路  3Comments

MangelMaxime picture MangelMaxime  路  3Comments