From 900a260e4f6e98a6ed5b70165339a669dd2a8d38 Mon Sep 17 00:00:00 2001 From: Parbez Date: Fri, 26 Aug 2022 13:09:40 +0530 Subject: [PATCH] fix: pass globalName to rollup for tree-shaking iife build (#692) --- src/index.ts | 1 + src/plugins/tree-shaking.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index fe469577..9b8f686d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -233,6 +233,7 @@ export async function build(_options: Options) { ...(options.plugins || []), treeShakingPlugin({ treeshake: options.treeshake, + name: options.globalName }), cjsSplitting(), es5(), diff --git a/src/plugins/tree-shaking.ts b/src/plugins/tree-shaking.ts index 63034f94..c862167e 100644 --- a/src/plugins/tree-shaking.ts +++ b/src/plugins/tree-shaking.ts @@ -9,8 +9,10 @@ export type TreeshakingStrategy = export const treeShakingPlugin = ({ treeshake, + name }: { - treeshake?: TreeshakingStrategy + treeshake?: TreeshakingStrategy, + name?: string }): Plugin => { return { name: 'tree-shaking', @@ -42,6 +44,7 @@ export const treeShakingPlugin = ({ format: this.format, file: 'out.js', sourcemap: !!this.options.sourcemap, + name }) for (const file of result.output) {