rollup-plugin-tla
raw JSON → 0.0.2 verified Mon Apr 27 auth: no javascript
A Rollup plugin that enables top-level await (TLA) support for IIFE and UMD output formats, which Rollup does not natively support. Version 0.0.2 adds TypeScript declarations and supports Node.js >=14.18. It works by transforming the output to use a dynamic import or wrapper to handle TLA. Differentiators: lightweight, no additional runtime dependencies, and specifically targets IIFE/UMD where Rollup's own TLA handling is absent.
Common errors
error Error: [object Object] is not a Rollup plugin ↓
cause Using a named import instead of default import leads to the plugin object being malformed.
fix
Change import { tla } from 'rollup-plugin-tla' to import tla from 'rollup-plugin-tla'.
error ${tla} is not a function ↓
cause Trying to use require() in an ESM-only context – require returns the module object, not the plugin function.
fix
Use import instead of require.
error Top-level await is not supported in the configured output format ↓
cause Output format is not IIFE or UMD; Rollup fails natively.
fix
Set output.format to 'iife' or 'umd'.
Warnings
gotcha Plugin only works for IIFE and UMD formats; for ESM or CJS, Rollup natively supports TLA and this plugin is unnecessary. ↓
fix Ensure output format is 'iife' or 'umd'.
gotcha The plugin transforms the output to use a dynamic import or wrapper; this may cause side effects if not used carefully with other plugins that manipulate the AST. ↓
fix Test the bundle thoroughly with your specific plugin chain.
deprecated Package has not been updated since early 2023; compatibility with newer Rollup versions (>=3) is not guaranteed. ↓
fix Consider alternative approaches or test with Rollup v3+.
Install
npm install rollup-plugin-tla yarn add rollup-plugin-tla pnpm add rollup-plugin-tla Imports
- default wrong
const tla = require('rollup-plugin-tla')correctimport tla from 'rollup-plugin-tla' - tla wrong
import { tla } from 'rollup-plugin-tla'correctimport tla from 'rollup-plugin-tla' - Plugin type (TypeScript) wrong
import tla from 'rollup-plugin-tla'; const plugin = tla(); // works but no type safetycorrectimport type { Plugin } from 'rollup'; import tla from 'rollup-plugin-tla'; const plugin: Plugin = tla();
Quickstart
import tla from 'rollup-plugin-tla';
export default {
input: 'src/index.js',
output: {
format: 'iife',
file: 'dist/bundle.js'
},
plugins: [
tla()
]
};