I am writing a GreaseMonkey plugin in TypeScript. I am compiling
main.ts
file into main.js
, and then put it on GreaseMonkey. The
output file format looks like vanilla JavaScript, and GreaseMonkey
consumes it happily. Now the project grows larger, I plan to split the
code into several files. However, I failed to find a build system that
works.
Requirements:
- It should bundle everything into a single JavaScript file. GreaseMonkey only takes one file.
- It should generate vanilla JavaScript. I don't think things like
System.import
works in GreaseMonkey.
Possible behavior
Given
// lib.ts
export function greet(name: string) {
console.log(`Hello, ${ name }!`);
}
and
// main.ts
import { greet } from './lib.ts';
greet("Tom");
it returns
// main.js
let lib_public = {};
lib_public.greet = function greet(name: string) {
console.log(`Hello, ${ name }!`);
}
lib_public.greet("Tom");