I'm having real trouble trying to get started with FunScript, I really love the idea of F# -> Javascript but constantly frustrated by the amount information/documentation of how to work with such beautiful-looking technologies.
Here's the problem:
The FunScript Project (No Hosting) template cannot be installed because: "You need Nuget Installed", says VS when I try to download it. // Dah, I do have Nuget and just updated it to latest release. I'm using VS2013 Ultimate.
I did the following:
I created a new FSharp Library Project and then I ran the Package Maneger command for getting the needed FunScript Libs:
PM> Install-Package FunScript
that worked nice but then . . . When I look at a FunScript example I see the open FunScript.TypeScript
in the program which currently does not exist when I type that as it says TypeScript is not defines, and looking at the examples FunScript.TypeScript gives the ability to use jQuery and interact with the DOM. so without it i can't do anything here
I did notice the 3rd-party libs on Nuget for FunScript, the:
FuncScript.TypeScript.Bindings.(lib|jquery)
but i can't reference those in an "open [namespace]" statement.
and at last, there must be a "do Runtime components ..." something at the end of the program. this also is 'not defined'
Do you guys have a complete FunScript example that I can start with? (I have already searched the web alot, the programs i saw didn't work with me)
Sorry, the project is still a bit thin on documentation. We will try to improve this soon.
I have now updated the FunScript Visual Studio Project Template to remove the NuGet Package Manager dependency. From v1.1.0.15
It should work on Visual Studio 2013. Note: you may need to build twice to restore the NuGet packages correctly.
You only get the basic F# to JS compiler (and some FSharp.Data type provider mappings) in the main NuGet package. If you want to access JavaScript through TypeScript bindings you must add references to those "Bindings" packages you mentioned.
The names of these packages don't actually reflect any namespace within the assemblies. Currently, they import types into the global namespace (i.e., they should just become available in intellisense without opening any namespaces). Unless the TypeScript contains modules, in which case the functions and types are mapped to the corresponding .NET namespaces.
E.g., Globals.alert(message)
should type-check after you have added the FunScript.TypeScript.Binding.lib
NuGet package.
Please note, we may move these definitions all up into the FunScript.TypeScript
namespace in future to avoid polluting the global namespace.
The do Runtime.Run(components)
call in the examples is actually just a helper method. We should probably remove this from the examples, as it confuses a lot of people. The only method call you really need is Compiler.Compile(<@ main() @>, noReturn = true)
, which compiles the quotation and returns a string of JavaScript. It is then up to the user what they do with this JavaScript (e.g., put it in a hosted page).
I'll be adding more documentation around using FunScript when I release another project called HashBang, which makes use of FunScript to build crawlable-dynamic-websites. This will include step-by-step tutorials for building and deploying with HashBang/FunScript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With