From eb3829846868782a2a4e77ca5059c00ca310286e Mon Sep 17 00:00:00 2001 From: Milton Date: Thu, 19 Jan 2023 15:40:48 -0300 Subject: [PATCH] =?UTF-8?q?fix(rollup-config):=20prevented=20pixi=20from?= =?UTF-8?q?=20being=20bundled=20ever=20again=20A=20Pixi=20extension=20must?= =?UTF-8?q?=20never=20bundle=20`@pixi/*`=20packages=20or=20it=20would=20en?= =?UTF-8?q?d=20up=20with=20a=20duplicate=20version.=20By=20forcing=20rollu?= =?UTF-8?q?p=20to=20never=20bundle=20anything=20pixi=20we=20solve=20crypti?= =?UTF-8?q?c=20problems=20with=20browser=20builds=20pulling=20chunks=20of?= =?UTF-8?q?=20pixi=20into=20themselves.=20(Fun=20fact:=20This=20means=20ou?= =?UTF-8?q?r=20browser=20builds=20get=20even=20smaller=20=F0=9F=98=85)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/rollup-config/index.mjs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/rollup-config/index.mjs b/tools/rollup-config/index.mjs index faae004c..cdadfbb8 100644 --- a/tools/rollup-config/index.mjs +++ b/tools/rollup-config/index.mjs @@ -23,12 +23,7 @@ export default (extensionConfig, pkg) => { ` */`, ].join('\n'); - // External dependencies, not bundled - const externalBrowser = [].concat(Object.keys(pkg.peerDependencies || {})); - - const externalNpm = [].concat(Object.keys(pkg.peerDependencies || {})).concat(Object.keys(pkg.dependencies || {})); - - const builtInPackages = [ + const pixiPackages = [ 'accessibility', 'app', 'assets', @@ -70,7 +65,18 @@ export default (extensionConfig, pkg) => { 'text', 'ticker', 'unsafe-eval', - ].reduce((acc, name) => ({ ...acc, [`@pixi/${name}`]: 'PIXI' }), {}); + ]; + // Create the PIXI.* namespace for the browser bundle + const builtInPackages = pixiPackages.reduce((acc, name) => ({ ...acc, [`@pixi/${name}`]: 'PIXI' }), {}); + + // Create the @pixi/* array so we NEVER EVER bundle anything that belongs to pixi + const externalPixi = pixiPackages.map((name) => `@pixi/${name}`); + + // External dependencies, not bundled + const externalBrowser = externalPixi.concat(Object.keys(pkg.peerDependencies || {})); + + const externalNpm = externalPixi.concat(Object.keys(pkg.peerDependencies || {})).concat(Object.keys(pkg.dependencies || {})); + // Plugins for module and browser output const plugins = [