fable-core
Fable core lib and bindings for native JS objects, browser and node APIs
RELEASE NOTES · Follow us on Twitter!
Installation
npm install --save fable-core
Usage
For general information on how to use Fable, check the docs.
The default file when you import fable-core
uses universal modules (UMD)
which can be understood by node (commonjs) or require.js (amd). There's also
a minified version fable-core.min.js
, and if you need the library in other
module formats you can import fable-core/es2015
or fable-core/commonjs
instead.
F# project (.fsproj)
<ItemGroup>
<Reference Include="node_modules/fable-core/Fable.Core.dll" />
</ItemGroup>
F# script (.fsx)
#r "node_modules/fable-core/Fable.Core.dll"
open Fable.Core
open Fable.Import
require.js
When targeting the browser and using AMD instead of a module bundler,
you can load Fable's core lib with require.js as follows:
<script src="node_modules/requirejs/require.js"></script>
<script>
requirejs.config({
baseUrl: 'out',
paths: {
'fable-core': '../node_modules/fable-core/fable-core.min'
}
});
requirejs(["app"]);
</script>
Development
The source is written in TypeScript. The use of a TypeScript-aware editor
(like VSCode or ALM)
is highly recommended.
Output files are generated as shown below:
fable-core.ts
(source)
es2015.js
(Created from fable-core.ts |> tsc --target ES2015
)
fable-core.js
(Created from es2015.js |> babel --plugins ...umd
)
fable-core.min.js
(Created from fable-core.js |> uglifyjs
)
commonjs.js
(Created from es2015.js |> babel --plugins ...commonjs
)
To build
From Fable root project folder, simply run:
build FableCore