Imports
Plugins can add imports to be used in scripts files & hephaestus editor.
To add a new import you need to use the addImport
from the plugin setup, you have to define a name
and an absolute filename
Tip: you can use the resolve function to get a absolute path relative to the plugin folder location
.is/plugins/hello/index.js
export default {
name: "Hello plugin",
setup({ addImport, resolve }){
addImport('hello', resolve('message.js'))
}
}
Here is the message file we are exposing
.is/plugins/hello/message.js
export function message(value = 'Hello word'){
alert(value)
}
Then you can use the new import in hephaestus setup block
:: setup
import { message } from 'hello'
function show(v){
return message(v)
}
::
:: button { @click="message('Hello button')" }
Hello
::