diff --git a/types/rollup/index.d.ts b/types/rollup/index.d.ts index 36ac764bbd..80a74523a0 100644 --- a/types/rollup/index.d.ts +++ b/types/rollup/index.d.ts @@ -31,7 +31,7 @@ export interface BundleOptions { /** The name to use for the module for UMD/IIFE bundles (required for bundles with exports). */ name?: string /** Mapping of IDs → global variable names. Used for UMD/IIFE bundles. */ - globals?: { [id: string]: string } + globals?: ((id: string) => string) | { [id: string]: string } /** * Function that takes an ID and returns a path, or Object of id: path pairs. * Where supplied, these paths will be used in the generated bundle instead of the module ID, allowing you to (for example) load dependencies from a CDN. diff --git a/types/rollup/rollup-tests.ts b/types/rollup/rollup-tests.ts index 3ec00a357a..b9a9eac5d7 100644 --- a/types/rollup/rollup-tests.ts +++ b/types/rollup/rollup-tests.ts @@ -87,6 +87,22 @@ async function main() { strict: true, }) + await bundle.write({ + format: 'cjs', + file: 'bundle.js', + name: 'myLib', + interop: false, + globals: (x: string) => x.replace("", "/"), + banner: '/* Banner */', + footer: '/* Footer */', + intro: 'var ENV = "production";', + outro: 'var VERSION = "1.0.0";', + indent: ' ', + sourcemap: 'inline', + sourcemapFile: 'bundle.js.map', + strict: true, + }) + const watcher = watch({ input: 'main.js', output: {