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

Sample doesn't compile #52

Open
ImaginaryDevelopment opened this issue Jun 8, 2021 · 3 comments
Open

Sample doesn't compile #52

ImaginaryDevelopment opened this issue Jun 8, 2021 · 3 comments

Comments

@ImaginaryDevelopment
Copy link

ImaginaryDevelopment commented Jun 8, 2021

Description

Following the code from https://elmish.github.io/react/native.html does not compile

Repro code

steps

  1. create paket.dependencies from https://github.com/elmish/react/blob/v3.x/paket.dependencies
  2. dotnet new fable
  3. dotnet tool install paket - and remove the nuget references inside App.fsproj
  4. dotnet paket convert-from-nuget --force
  5. manually add the files from paket.dependencies to paket.references
  6. dotnet paket install
  7. npm install
  8. npm start -> runs just fine
  9. change the App.fs to match the Fable React Elmish sample code -> No Compilation
    fable-elmish-react-fail.zip
source https://nuget.org/api/v2
storage: none
nuget Fable.Browser.Dom 2.2.0
nuget Fable.Elmish.React
nuget FSharp.Core redirects:force, content:none
nuget Fable.Core 3.2.3
nuget Fable.React
nuget Fable.Elmish

paket.references

Fable.Browser.Dom
Fable.Elmish.React
FSharp.Core
Fable.Core
Fable.React
Fable.Elmish

Expected and actual results

Expected dotnet build and npm start still work

Actual

Description

Following the code from https://elmish.github.io/react/native.html does not compile

Repro code

steps

  1. create paket.dependencies from https://github.com/elmish/react/blob/v3.x/paket.dependencies
  2. add Fable.React.Elmish
  3. dotnet new fable
  4. dotnet tool install paket
  5. dotnet paket convert-from-nuget --force
  6. manually add the files from paket.dependencies to paket.references
  7. paket install
  8. npm install
  9. npm start -> runs just fine
  10. change the App.fs to match the Fable React Elmish sample code -> No Compilation
source https://nuget.org/api/v2
storage: none
nuget Fable.Elmish.React
nuget FSharp.Core redirects:force, content:none
nuget Fable.Core
nuget Fable.React
nuget Fable.Elmish

paket.references

FSharp.Core
Fable.Core
Fable.React
Fable.Elmish
Fable.Elmish.React

Expected and actual results

Expected dotnet build and npm start still work

Actual

Neither works, both complain about missing namespaces

>dotnet build
Microsoft (R) Build Engine version 16.9.0+57a23d249 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Paket version 5.257.0
  The last restore is still up to date. Nothing left to do.
  Performance: - Runtime: 120 milliseconds
  Paket version 5.257.0
  Starting restore process.
  Performance: - Runtime: 784 milliseconds
  Restored D:\projects\insertprojectnamehere\App.fsproj (in 147 ms).
D:\projects\insertprojectnamehere\App.fs(16,19): error FS0039: The namespace 'ReactNative' is not defined. [D:\projects\insertprojectnamehere\App.fsproj]
D:\projects\insertprojectnamehere\App.fs(17,12): error FS0039: The namespace 'Helpers' is not defined. [D:\projects\insertprojectnamehere\App.fsproj]
D:\projects\insertprojectnamehere\App.fs(21,5): error FS0039: The value or constructor 'text' is not defined. Maybe you want one of the following:↔   Text↔   exn↔   exp↔   exn [D:\projects\insertprojectnamehere\App.fsproj]
D:\projects\insertprojectnamehere\App.fs(27,8): error FS0039: The value or constructor 'touchableHighlightWithChild' is not defined. [D:\projects\insertprojectnamehere\App.fsproj]
D:\projects\insertprojectnamehere\App.fs(40,5): error FS0039: The value or constructor 'view' is not defined. [D:\projects\insertprojectnamehere\App.fsproj]

Build FAILED.

D:\projects\insertprojectnamehere\App.fs(16,19): error FS0039: The namespace 'ReactNative' is not defined. [D:\projects\insertprojectnamehere\App.fsproj]
D:\projects\insertprojectnamehere\App.fs(17,12): error FS0039: The namespace 'Helpers' is not defined. [D:\projects\insertprojectnamehere\App.fsproj]
D:\projects\insertprojectnamehere\App.fs(21,5): error FS0039: The value or constructor 'text' is not defined. Maybe you want one of the following:↔   Text↔   exn↔   exp↔   exn [D:\projects\insertprojectnamehere\App.fsproj]
D:\projects\insertprojectnamehere\App.fs(27,8): error FS0039: The value or constructor 'touchableHighlightWithChild' is not defined. [D:\projects\insertprojectnamehere\App.fsproj]
D:\projects\insertprojectnamehere\App.fs(40,5): error FS0039: The value or constructor 'view' is not defined. [D:\projects\insertprojectnamehere\App.fsproj]
    0 Warning(s)
    5 Error(s)

Time Elapsed 00:00:04.11

Related information

  • elmish version: 3.1 (Fable.Elmish.React 3.0.1)
  • fable-compiler version: where is this stored?
  • fable-core version: Fable.Core 3.2.7
  • Operating system: Windows 10
@et1975
Copy link
Member

et1975 commented Jun 8, 2021

Sadly RN story has been neglected and I don't see myself updating it. A new sample needs to be built from scratch using the latest RN tooling and current Fable compiler (this sample was written for Fable 2.x). Not sure how well the two still fit together.
PR would be welcome.

@ImaginaryDevelopment
Copy link
Author

ImaginaryDevelopment commented Jun 8, 2021 via email

@MangelMaxime
Copy link
Member

Hello @ImaginaryDevelopment with Fable 3 it is now easier to integrate Fable into JavaScript tooling because Fable 3 generates JavaScript files directly on the disk.

If the standard JavaScript workflow is:

  1. Write JavaScript code
  2. Have the JS tooling detect change from the JavaScript file

Now with Fable it is:

  1. Write F# code
  2. Have Fable watch the F# code and generate the JavaScript files
  3. Have the JS tooling detect change from the JavaScript files

It removes the needs to have custom loader or plugin for the JavaScript tools.


Knowing that, setting up Fable looks like that:

  1. dotnet new tool-manifest

  2. dotnet tool install fable

  3. Setup an F# project

  4. Run dotnet fable <path to your fsproj proj> --watch this will generate the the files along side the F# files.

    If you prefer to have them in their own folder, you can use dotnet fable <path to your fsproj proj> --watch --outDir fableBuild, this will place the generated files into the fableBuild directory

  5. Setup the RN toolchain from here using the generated files

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

No branches or pull requests

3 participants