Skip to content

Commit

Permalink
fix(rollup-config): prevented pixi from being bundled ever again
Browse files Browse the repository at this point in the history
A Pixi extension must never bundle `@pixi/*` packages or it would end up with a duplicate version. By forcing rollup to never bundle anything pixi we solve cryptic problems with browser builds pulling chunks of pixi into themselves.
(Fun fact: This means our browser builds get even smaller 😅)
  • Loading branch information
miltoncandelero committed Jan 19, 2023
1 parent 844fee8 commit eb38298
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tools/rollup-config/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 = [
Expand Down

0 comments on commit eb38298

Please sign in to comment.