Fable needs the packages directory to be present

Created on 28 Aug 2017  Â·  13Comments  Â·  Source: fable-compiler/Fable

Description

The packages/ directory can be omitted with Paket 5.91.0. If you do so, Fable can't find the packages anymore.

I also just discovered the NetStandard.Library storage:none line in the template, but the packages/ directory still contains a lot of packages. I'd like to be able to omit it entirely.

Repro code

  1. Create a Fable project which uses an import library
  2. Add the storage: none option to paket.dependencies for the whole group
  3. $ paket install && yarn install && dotnet restore && dotnet fable yarn-run start

Expected and actual results

It would be great if Fable wouldn't need the packages/ directory to be present. Instead, it fails with this error:

ERROR: IO Error trying read project options: Could not find a part of the path 'D:\projects\elmish-http-demo\packages\Fable.Import.Browser\lib'.
   at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1379.Invoke(String message)
   at Fable.CLI.ProjectCracker.retry@385(FSharpChecker checker, String[] define, String projFile, DateTime retryUntil, Unit unitVar0)
   at Fable.CLI.ProjectCracker.retry@385(FSharpChecker checker, String[] define, String projFile, DateTime retryUntil, Unit unitVar0)
   at Fable.CLI.ProjectCracker.retry@385(FSharpChecker checker, String[] define, String projFile, DateTime retryUntil, Unit unitVar0)
   at Fable.CLI.ProjectCracker.retry@385(FSharpChecker checker, String[] define, String projFile, DateTime retryUntil, Unit unitVar0)
   at Fable.CLI.ProjectCracker.retry@385(FSharpChecker checker, String[] define, String projFile, DateTime retryUntil, Unit unitVar0)
   at Fable.CLI.ProjectCracker.retryGetProjectOpts(FSharpChecker checker, String[] define, String projFile)
   at Fable.CLI.ProjectCracker.getFullProjectOpts(FSharpChecker checker, String[] define, String projFile)
   at Fable.CLI.StateUtil.createProject(FSharpChecker checker, Boolean isWatchCompile, FSharpOption`1 prevProject, Message msg, String projFile)
   at Fable.CLI.StateUtil.updateState(FSharpChecker checker, FSharpMap`2 state, Message msg)
   at [email protected](Tuple`2 _arg1)

Related information

  • Fable version (dotnet fable --version): 1.1.22
  • Operating system: Windows 7 x64
  • .NET CLI: 1.0.4

Most helpful comment

Very nice, from not possible into "done" in just a few days :)

All 13 comments

Unfortunately this is not going to be possible as Fable needs to access the source files of the libraries (included in the package content) and those have to be placed locally within the project folder (well, they could be somewhere else, but then Webpack and Babel config becomes much more complicated).

I haven't published the new template yet, but in my tests using NetStandard.Library storage:none reduces the size of packages folder from around 400MB to 14MB which I think is more than acceptable (finally smaller than node_modules). There're still some System.XXX packages but I think they're related to FSharp.Core and will be removed once a netstandard2 version is published :)

they could be somewhere else, but then Webpack and Babel config becomes much more complicated

I wasn't aware of that.

using NetStandard.Library storage:none reduces the size of packages folder from around 400MB to 14MB

It was still about ~240MB for my small project, using Elmish, React and Fable.PowerPack. But as I'm writing this, I remember that the project was still targetting netstandard1.6 :smile:

There're still some System.XXX packages but I think they're related to FSharp.Core and will be removed once a netstandard2 version is published

I guess I should try again with everything being on CLI 2.0/.NET Core 2.0/.NET Standard 2.0.

Feel free to close this for now.

There is something oddly satisfying seeing all the "Garbage collecting …" messages when doing paket update :smile:

I was able to reduce the packages/ directory to ~30 MB. I think that's because I'm referencing FSharp.Core explicitly, but I can live with that.

Ok, I'm working in a solution to locate packages also in the Nuget cache. It seems to work but as commented above we'll need to be a bit more careful with Babel options. I'll try to release a beta today :+1:

@alfonsogarciacaro I think we also need to be careful with bundlers. From my experiences, it can be hard to configure them when all the files are not under the same hierarchy.

I've released dotnet-fable 1.2.0-beta-004 which doesn't need the local packages folder so you can use storage:none on top your paket.dependencies. Can you give it a try and confirm if it works for you?

You can also check latest Fable.Template (1.2.1). As commented above, you need to take some care with Babel options as well as Webpack config.

Very nice, from not possible into "done" in just a few days :)

That's thanks to @enricosada and his Dotnet.ProjInfo lib ;)

@matthid With this hopefully Fable doesn't have so many hidden dependencies on Paket now, so development should be easier for both you and me :wink: The only thing that's still necessary is the list of packages in .paket.resolved as this is the only way for Fable to get references in proper dependency order (in order to find the sources and merge them in a single project later).

Wow, that is more than what I was hoping for :smile: :heart:

I updated everything and changed the configs, but I'm getting this error several times:

ERROR in ./src/Root.fs
Module not found: Error: Can't resolve './C:/Users/nosikil/.nuget/packages/fable.elmish/0.9.2/fable/program.fs' in 'D:\projects\elmish-http-demo\src'
 @ ./src/Root.fs 1:0-103
 @ ./src/elmish-http.fsproj
 @ multi (webpack)-dev-server/client?http://localhost:8080 ./src/elmish-http.fsproj

The project is on my D:\ drive instead of C:\, and that seems to break the path concatenation, because when I copy the project directory to C:\, it works.

BTW, when I undo the configuration changes and use the packages/ directory again, I get the same error.

@inosik I've released dotnet-fable 1.2.0-beta-005, could you please try again? I couldn't test because I'm on macOS, but hopefully this solves the problem of paths with different drive letters on Windows.

@alfonsogarciacaro Works now! :sparkles: :champagne:

It seems that now we always need the configuration tweaks for Babel and Webpack.

That's one of the errors I get now when I don't change the configs:

ERROR in C:/Users/nosikil/.nuget/packages/fable.core/1.2.0-beta-003/fable-core/Result.js
Module build failed: ReferenceError: Unknown plugin "transform-runtime" specified in "base" at 22, attempted to resolve relative to "C:\\Users\\nosikil\\.nuget\\packages\\fable.core\\1.2.0-beta-003\\fable-core"
    at D:\projects\elmish-http-demo\node_modules\babel-core\lib\transformation\file\options\option-manager.js:180:17
    at Array.map (native)
    at Function.normalisePlugins (D:\projects\elmish-http-demo\node_modules\babel-core\lib\transformation\file\options\option-manager.js:158:20)
    at OptionManager.mergeOptions (D:\projects\elmish-http-demo\node_modules\babel-core\lib\transformation\file\options\option-manager.js:234:36)
    at OptionManager.init (D:\projects\elmish-http-demo\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
    at File.initOptions (D:\projects\elmish-http-demo\node_modules\babel-core\lib\transformation\file\index.js:212:65)
    at new File (D:\projects\elmish-http-demo\node_modules\babel-core\lib\transformation\file\index.js:135:24)
    at Pipeline.transform (D:\projects\elmish-http-demo\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
    at transpile (D:\projects\elmish-http-demo\node_modules\babel-loader\lib\index.js:46:20)
    at Object.module.exports (D:\projects\elmish-http-demo\node_modules\babel-loader\lib\index.js:163:20)
 @ C:/Users/nosikil/.nuget/packages/fable.powerpack/1.2.0/fable/src/Promise.fs 5:0-78 6:0-77
 @ ./src/Giphy.fs
 @ ./src/App.fs
 @ ./src/Root.fs
 @ ./src/elmish-http.fsproj

I'm OK with that, but we need to document it and provide samples for fable-splitter and the Rollup plugin.

Great, thanks a lot for the confirmation! Yes, unfortunately the Babel options must be updated or Babel won't be able to find the plugins. Rollup and fable-splitter should be similar. The first is working for me on macOS but unfortunately it seems to give problems on Windows.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alfonsogarciacaro picture alfonsogarciacaro  Â·  3Comments

ncave picture ncave  Â·  3Comments

krauthaufen picture krauthaufen  Â·  3Comments

alfonsogarciacaro picture alfonsogarciacaro  Â·  3Comments

et1975 picture et1975  Â·  3Comments