Programming Language
The programming language for Babel is TypeScript, commonly abbreviated as TS, with the supported version being 5.0.
Module
Each Babel Element is a module. When you create a Function Element named "myFunc", the corresponding module name is #elements/myFunc
, which has a default export. You can import and use myFunc
in other Babel Elements through the import declaration.
import myFunc from "#elements/myFunc";
Special Modules
Special modules include: #config
and #elements
.
The default export of the #config
module is the configuration object set by Config.
import mySecrets from "#config";
let key = mySecrets.XXX_API_KEY
// call XXX API with the key
// ...
The named exports of the #elements
module include all reusable Babel Elements (due to implementation limitations, neon elements are not included).
import * as Koa from "koa";
import { getBookChapter, markdownToHTML } from "#elements";
// The line above is equivalent to
// import getBookChapter from "#elements/getBookChapterHTML";
// import markdownToHTML from "#elements/markdownToHTML";
/** GET /:book/:chapter */
export default async function respond(request: Koa.Request, response: Koa.Response) {
let { book, chapter } = request.params
let markdown = await getBookChapter(book, chapter)
return markdownToHTML(markdown)
}
Built-in Dependencies
Babel comes with the following packages, which do not need to be declared in Dependency.
koa
(Version:2.13.x)