fix(rollup): globals in BundleOptions can be a method

d92f072627/src/finalisers/shared/setupNamespace.js (L6)
This commit is contained in:
Alan Agius
2017-12-11 09:28:43 +01:00
parent 95a6956b87
commit 8c351e4ff9
2 changed files with 17 additions and 1 deletions

View File

@@ -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.

View File

@@ -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: {