formality-loader
v0.1.0
Published
Formality language loader for webpack
Downloads
2
Readme
formality-loader
formality-loader
compiles imported Formality files into a JavaScript module.
Install
With webpack correctly installed, add formality-loader
and formality-lang
as dependencies:
$ npm install formality-loader formality-lang --save-dev
Then add the loader to your webpack
config file:
webpack.config.js
const formalityResolver = require('formality-loader').resolver
module.exports = {
resolve: { plugins: [formalityResolver] },
module: {
rules: [
{
test: /\.fm$/,
loader: 'formality-loader',
options: {
typeCheckMode: 'all' // Options: all, none, production, development. Default: all
}
}
]
}
}
Using
In your JavaScript file, import (or require) your Formality files including the .fm
extension.
src/index.js
import app from './App.fm' // import all terms of local file 'App.fm'
import main from './App.fm/main' // import term 'main' of local file 'App.fm'
import area from 'Area#o99z.fm' // all terms of global file 'Area#o99z.fm'
import circleArea from 'Area#o99z.fm/circle_area' // all term 'circle_area' global file 'Area#o99z.fm'
console.log(app.main(10))
src/App.fm
import Base#
main(n: Number) : Number
2 .*. n
Check the example folder for more info.