I'm trying to use fable powerpack in a fable elmish template project. During compilation there is a warning:
warning FABLE: Nested option in option won't work at runtime
The compiled code (using the fable powerpack code in test) does not work either.
The code:
let openCursor(index: Browser.IDBIndex, keyCursor: bool, range: Browser.IDBKeyRange option, direction: DBCursorDirection option, step: uint32 option) =
let range = defaultArg range Unchecked.defaultof<Browser.IDBKeyRange>
let direction = (defaultArg direction DBCursorDirection.Default).ToString()
let step = defaultArg step 1u
let request =
match keyCursor with
| false -> index.openCursor(range, direction) //warning here
| true -> index.openKeyCursor(range, direction)//warning here
Translates to:
function openCursor(index, keyCursor, range, direction, step) {
var range_1 = range != null ? range : null;
var direction_1 = Object(__WEBPACK_IMPORTED_MODULE_3__nuget_packages_fable_core_1_2_4_fable_core_Util__["y"/* toString */
])(direction != null ? direction : DBCursorDirection.Default);
var step_1 = step != null ? step : 1;
var request = keyCursor ? index.openKeyCursor(Object(__WEBPACK_IMPORTED_MODULE_3__nuget_packages_fable_core_1_2_4_fable_core_Util__["x"/* some */
])(range_1), direction_1) : index.openCursor(Object(__WEBPACK_IMPORTED_MODULE_3__nuget_packages_fable_core_1_2_4_fable_core_Util__["x"/* some */
])(range_1), direction_1);
range_1 is null, no problem but
Object(__WEBPACK_IMPORTED_MODULE_3__nuget_packages_fable_core_1_2_4_fable_core_Util__["x"/* some */])(null)
returns {} instead of undefined, if it returns undefined (or null?) then it would be no problem
Cloned the powerpack project and that works, openCursor is translated to:
function openCursor(index, keyCursor, range, direction, step) {
var range_1 = range != null ? range : null;
var direction_1 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__nuget_packages_fable_core_1_2_0_beta_003_fable_core_Util__["f" /* toString */])(direction != null ? direction : DBCursorDirection.Default);
var step_1 = step != null ? step : 1;
var request = keyCursor ? index.openKeyCursor(range_1, direction_1) : index.openCursor(range_1, direction_1);
I could see it uses a different dotnet-fable (1.2.4 from fable elmish template) so changed the paket.lock to downgrade (1.2.0-beta-005 from fable-powerpack) and did a dotnet restore.
Now it won't compile at all with the error (maybe fable react cannot work with fable versions used by powerpack):
ERROR in /home/harm/.nuget/packages/fable.react/1.2.1/fable/Fable.Helpers.React.fs /home/harm/.nuget/packages/fable.react/1.2.1/fable/Fable.Helpers.React.fs(588,53): (588,62) error FSHARP: The type 'ParamList' is not defined. @ ./src/App.fs 5:0-107 @ ./src/sale.fsproj @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/sale.fsproj
Cloned the Fable compiler and build it (does not generate nuget package but some folders with binaries).
In the fable powerpack linked to the build:
ln -s ../Fable/build/fable ./fable
Then tried to build the power pack indexeddb (changed tests/Main.fs and Tests.fsproj to use Program.fs of indexeddb)
dotnet ./fable/dotnet-fable.dll yarn-run pretest
Sure enough that doesn't work either:
ERROR in ./src/IndexedDB.fs Module not found: Error: Can't resolve '../../../.nuget/packages/fable.core/1.2.0-beta-003/fable-core/Option' in '/home/harm/dev/fable-powerpack/src' @ ./src/IndexedDB.fs 9:0-102 @ ./tests/Program.fs @ ./tests/Main.fs @ ./tests/Tests.fsproj
ERROR in ./src/PromiseSeq/Module.fs Module not found: Error: Can't resolve '../../../../.nuget/packages/fable.core/1.2.0-beta-003/fable-core/Option' in '/home/harm/dev/fable-powerpack/src/PromiseSeq' @ ./src/PromiseSeq/Module.fs 10:0-99 @ ./src/PromiseSeq/Extensions.fs @ ./tests/Program.fs @ ./tests/Main.fs @ ./tests/Tests.fsproj
The directory ~/.nuget/packages/fable.core/1.2.0-beta-003/fable-core/ exist but I guess the relative path is incorrect. Also where does it get the 1.2.0 from, the fable core from Fable build is version 1.3.0-beta-002 so even though I'm using dotnet-fable version 1.3.0-beta-002 for some reason it does not use the fable core generated by the build to compile.
Is dotnet-fable using paket.lock? If so then why doesn't building Fable provide a nuget package because you have to install it if you don't want to spend the next 3 days fiddling around copying/linking files and messing with the packet.lock.
The fable compiler is missing some instructions on how to actually use it. I can compile it but since it doesn't generate a nuget there is no way to install it. Running the binaries directly doesn't seem to work either.
Is there a way to build a project using the binaries generated by the latest build from the fable compiler git repo and use that to transpile a project?
I tried installing the newer versions by changing paket.dependencies:
source https://www.nuget.org/api/v2
nuget Fable.Compiler 1.3.0-beta-002 beta
nuget FSharp.Core
nuget Fable.Core prerelease
nuget Fable.Import.Browser
clitool dotnet-fable 1.3.0-beta-002
group Build
framework: net46
source https://nuget.org/api/v2
nuget FSharp.Core redirects:force, content:none
nuget FAKE
Then tried the following command
dotnet restore
That doesn't seem to do anything so tried:
mono .paket/paket.exe update
That changed the paket.lock to:
dotnet-fable (1.3.0-beta-002) - clitool: true
...
Fable.Compiler (1.3.0-beta-002)
...
Fable.Core (1.3.0-beta-002)
But still dotnet fable will not run 1.3.0:
[harm@localhost fable-powerpack]$ dotnet fable yarn-run pretest
Fable (1.2.0-beta-005) daemon started on port 61225
Source is still transpiled with fable core 1.2.0 so just for the hell of it tried the following command again:
dotnet restore
And now try to transpile:
[harm@localhost fable-powerpack]$ dotnet fable yarn-run pretest
Fable (1.3.0-beta-002) daemon started on port 61225
That results in warnings:
WARNING in ./src/IndexedDB.fs
157:30-34 "export 'Some' was not found in '../../../.nuget/packages/fable.core/1.2.0-beta-003/fable-core/Util'
And code that doesn't work:
TypeError: __WEBPACK_IMPORTED_MODULE_1__nuget_packages_fable_core_1_2_0_beta_003_fable_core_Util__.Some is not a constructor at openCursor (file:///home/harm/dev/fable-powerpack/build/tests.bundle.js:3527:191) at IDBObjectStore_openCursorAsync (file:///home/harm/dev/fable-powerpack/build/tests.bundle.js:3668:10) at file:///home/harm/dev/fable-powerpack/build/tests.bundle.js:4685:123 at file:///home/harm/dev/fable-powerpack/build/tests.bundle.js:4642:28 at Object.then (file:///home/harm/dev/fable-powerpack/build/tests.bundle.js:1936:22) at IDBOpenDBRequest.request.onsuccess (file:///home/harm/dev/fable-powerpack/build/tests.bundle.js:3803:36)
message
:
"__WEBPACK_IMPORTED_MODULE_1__nuget_packages_fable_core_1_2_0_beta_003_fable_core_Util__.Some is not a constructor"
stack
:
"TypeError: __WEBPACK_IMPORTED_MODULE_1__nuget_packages_fable_core_1_2_0_beta_003_fable_core_Util__.Some is not a constructor↵ at openCursor (file:///home/harm/dev/fable-powerpack/build/tests.bundle.js:3527:191)↵ at IDBObjectStore_openCursorAsync (file:///home/harm/dev/fable-powerpack/build/tests.bundle.js:3668:10)↵ at file:///home/harm/dev/fable-powerpack/build/tests.bundle.js:4685:123↵ at file:///home/harm/dev/fable-powerpack/build/tests.bundle.js:4642:28↵ at Object.then (file:///home/harm/dev/fable-powerpack/build/tests.bundle.js:1936:22)↵ at IDBOpenDBRequest.request.onsuccess (file:///home/harm/dev/fable-powerpack/build/tests.bundle.js:3803:36)"
__proto__
:
Error
Still stubbornly trying fable core 1.2.0
So looking for this version:
[harm@localhost fable-powerpack]$ grep -rl "1.2.0.beta.003"
obj/fsac.cache
tests/obj/project.assets.json
tests/obj/fsac.cache
build/tests.bundle.js
The tests/obj/project.assets.json has over 5400 lines so not going to fiddle with that one.
So tried the following:
[harm@localhost fable-powerpack]$ cd tests/
[harm@localhost tests]$ mono ../.paket/paket.exe update
[harm@localhost tests]$ dotnet restore
That seems to take care of that:
[harm@localhost fable-powerpack]$ grep -rl "1.2.0.beta.003"
obj/fsac.cache
tests/obj/fsac.cache
build/tests.bundle.js
...
That seems to use latest fable but latest fable compiles to:
function openCursor(index, keyCursor, range, direction, step) {
var range_1 = range != null ? range : null;
var direction_1 = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__nuget_packages_fable_core_1_3_0_beta_002_fable_core_Util__["g" /* toString */])(direction != null ? direction : DBCursorDirection.Default);
var step_1 = step != null ? step : 1;
var request = keyCursor ? index.openKeyCursor(new __WEBPACK_IMPORTED_MODULE_1__nuget_packages_fable_core_1_3_0_beta_002_fable_core_Util__["f" /* Some */](range_1), direction_1) : index.openCursor(new __WEBPACK_IMPORTED_MODULE_1__nuget_packages_fable_core_1_3_0_beta_002_fable_core_Util__["f" /* Some */](range_1), direction_1);
Same as 1.2.4 so errors when running script.