improve rrdom robustness (#1091)

This commit is contained in:
Yun Feng
2026-04-01 12:00:00 +08:00
committed by GitHub
parent a9c01eb8d0
commit 12c2671644
7 changed files with 872 additions and 176 deletions

View File

@@ -0,0 +1,26 @@
import * as rollup from 'rollup';
import * as typescript from 'rollup-plugin-typescript2';
import resolve from '@rollup/plugin-node-resolve';
const _typescript = (typescript as unknown) as typeof typescript.default;
/**
* Use rollup to compile an input TS script into JS code string.
*/
export async function compileTSCode(inputFilePath: string) {
const bundle = await rollup.rollup({
input: inputFilePath,
plugins: [
(resolve() as unknown) as rollup.Plugin,
(_typescript({
tsconfigOverride: { compilerOptions: { module: 'ESNext' } },
}) as unknown) as rollup.Plugin,
],
});
const {
output: [{ code: _code }],
} = await bundle.generate({
name: 'rrdom',
format: 'iife',
});
return _code;
}