From ffcc9d9b7d9518ae2fa31b2af4d1fd4f98599560 Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Mon, 31 Aug 2020 11:00:45 -0400 Subject: [PATCH] Support global extend via amdName (#713) * Support global extend via amdName Using a prefixed name like `{ "amdName": "global.foo" }` will trigger Rollup's `output.extend` option. This addresses the use-case from #709 without adding another CLI flag. * Create chilled-paws-confess.md * Update chilled-paws-confess.md --- .changeset/chilled-paws-confess.md | 5 +++++ src/index.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/chilled-paws-confess.md diff --git a/.changeset/chilled-paws-confess.md b/.changeset/chilled-paws-confess.md new file mode 100644 index 00000000..2824711d --- /dev/null +++ b/.changeset/chilled-paws-confess.md @@ -0,0 +1,5 @@ +--- +"microbundle": patch +--- + +Support [extending a UMD global](https://rollupjs.org/guide/en/#outputextend) by prefixing the package.json `"amdName"` field (eg: `"global.xyz"`). diff --git a/src/index.js b/src/index.js index 87a9601f..7e1a8ee2 100644 --- a/src/index.js +++ b/src/index.js @@ -590,7 +590,8 @@ function createConfig(options, entry, format, writeMeta) { return shebang[options.name]; }, format: modern ? 'es' : format, - name: options.name, + name: options.name && options.name.replace(/^global\./, ''), + extend: /^global\./.test(options.name), dir: outputDir, entryFileNames: outputEntryFileName, },