sinusbundler v0.1.0
SinusBundler 📦
Overview
SinusBundler is a small JS/TS bundler based on Rollup, that allows you to split your SinusBot scripts into separate files. Besides that, you have an access to new JavaScript features as it is later transpiled down to ES5.
Installation
Using npm:
$ npm i sinusbundler -DUsing yarn:
$ yarn add sinusbundler --devUsage
Manifest
As opposed to standard SinusBot scripts, you do not specify plugin manifest in your script file. Instead, you should create JSON file (SinusBundler will look for script.manifest.json on default) where you store script's metadata:
{
"name": "Hello World",
"version": "1.0.0",
"description": "Prints 'Hello World!'",
"author": "Aleksander Ciesielski",
"vars": []
}Imports
After creating a manifest, you can start writing actual script. If you want to access SinusBot API, you can import everything from SinusBundler like this:
import * as sinusbot from "sinusbundler";Or if you want to import just some of the modules (e.g. media):
import { media } from "sinusbundler";Events
In addition to using event names you can also use Event enum
import { event, Event } from "sinusbundler";
event.on(Event.Chat, message => {
const { client } = message;
const nick = client.nick();
client.chat(`Hello ${nick}!`);
});Promises
Because you are able to use Promise (and also async/await syntax), some of the methods were changed to return Promise instead of relying on callbacks:
http.simpleRequestgraphics.setBannernet.connectdb.connect(alsoexecandquerymethods of an object that it returns)
Bundling everything up
CLI Settings:
| name | description | default | ||
|---|---|---|---|---|
| --input | Path to input file (.js or .ts) | |||
| --output | Path to output file (.js) | |||
| --manifest | Path to manifest file (.json) | script.manifest.json | ||
| --tsconfig | Path to tsconfig.json, if you are not using TypeScript ignore this option | tsconfig.json |
Warning: You should keep target set to es5 in tsconfig compilerOptions.
Example:
sinusbundler --input src/index.ts --output dist/bundle.jsYou can also create a npm script for bundling your script:
{
"scripts": {
"build": "sinusbundler --input src/index.ts --output dist/bundle.js"
}
}Usage:
npm run buildyarn build6 years ago