Transpilation
Lacona addons make use of a lot of syntactic sugar provided by ES2015 and JSX.
Addons are compiled using Babel.
Additionally, the Lacona command execution environment cannot make use of
the require
function to load external modules. As a result, any modular code
(or any code using external modules like lodash
or rxjs
) must be
compiled using Browserify.
This setup is all handled for you with lacona init
.
You do not need to use transpilation, but it is heavily recommended.
Example
/** @jsx createElement */
import {URL} from 'lacona-phrases'
import {createElement} from 'elliptical'
const MyHomepagePhrase = {
extends: [URL],
describe () {
return (
<argument text='homepage'>
<literal text='my homepage' value='http://lacona.io' />
</argument>
)
}
}
export default [MyHomepagePhrase]
-- becomes --
var URL = require('lacona-phrases').URL
var createElement = require('elliptical').createElement
var MyHomepagePhrase = {
extends: [laconaPhrases.URL],
describe: function describe () {
return createElement('argument', {text: 'homepage'},
createElement('literal', {text: 'my homepage', value: 'http://lacona.io'})
)
}
}
exports.default = [MyHomepagePhrase]