From 7b9535753952e8839cdda69ea04b5521db099e82 Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Wed, 9 Mar 2022 21:25:46 -0800 Subject: [PATCH 1/2] make rollup only build one integration at at time --- packages/integrations/rollup.config.js | 30 +++++++++++--------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/packages/integrations/rollup.config.js b/packages/integrations/rollup.config.js index 2373d2c61e08..c67202fdfdc3 100644 --- a/packages/integrations/rollup.config.js +++ b/packages/integrations/rollup.config.js @@ -1,28 +1,24 @@ -import * as fs from 'fs'; - import commonjs from '@rollup/plugin-commonjs'; import { insertAt, makeBaseBundleConfig, makeConfigVariants } from '../../rollup.config'; const builds = []; -const integrationSourceFiles = fs.readdirSync('./src').filter(file => file != 'index.ts'); +const file = process.env.INTEGRATION_FILE; -integrationSourceFiles.forEach(file => { - const baseBundleConfig = makeBaseBundleConfig({ - input: `src/${file}`, - isAddOn: true, - jsVersion: 'es5', - licenseTitle: '@sentry/integrations', - // TODO this doesn't currently need to be a template string, but soon will need to be, so leaving it in that form - // for now - outputFileBase: `${file.replace('.ts', '')}`, - }); +const baseBundleConfig = makeBaseBundleConfig({ + input: `src/${file}`, + isAddOn: true, + jsVersion: 'es5', + licenseTitle: '@sentry/integrations', + // TODO this doesn't currently need to be a template string, but soon will need to be, so leaving it in that form + // for now + outputFileBase: `${file.replace('.ts', '')}`, +}); - // TODO We only need `commonjs` for localforage (used in the offline plugin). Once that's fixed, this can come out. - baseBundleConfig.plugins = insertAt(baseBundleConfig.plugins, -2, commonjs()); +// TODO We only need `commonjs` for localforage (used in the offline plugin). Once that's fixed, this can come out. +baseBundleConfig.plugins = insertAt(baseBundleConfig.plugins, -2, commonjs()); - builds.push(...makeConfigVariants(baseBundleConfig)); -}); +builds.push(...makeConfigVariants(baseBundleConfig)); export default builds; From e5355ced00d192d14de03ed570c4d5f9995900ba Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Fri, 11 Mar 2022 00:01:47 -0800 Subject: [PATCH 2/2] add script to run integration bundling in parallel --- packages/integrations/package.json | 2 +- packages/integrations/scripts/buildBundles.sh | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 packages/integrations/scripts/buildBundles.sh diff --git a/packages/integrations/package.json b/packages/integrations/package.json index e9493874c55d..adc11b1c481f 100644 --- a/packages/integrations/package.json +++ b/packages/integrations/package.json @@ -26,7 +26,7 @@ }, "scripts": { "build": "run-p build:cjs build:esm build:bundle", - "build:bundle": "rollup --config", + "build:bundle": "bash scripts/buildBundles.sh", "build:cjs": "tsc -p tsconfig.cjs.json", "build:dev": "run-s build:cjs build:esm", "build:es5": "yarn build:cjs # *** backwards compatibility - remove in v7 ***", diff --git a/packages/integrations/scripts/buildBundles.sh b/packages/integrations/scripts/buildBundles.sh new file mode 100644 index 000000000000..013917e3d01b --- /dev/null +++ b/packages/integrations/scripts/buildBundles.sh @@ -0,0 +1,20 @@ +for filepath in ./src/*; do + file=$(basename $filepath) + + # the index file is only there for the purposes of npm builds - for the CDN we create a separate bundle for each + # integration - so we can skip it here + if [[ $file == "index.ts" ]]; then + continue + fi + + # run the build for each integration, pushing each build process into the background once it starts (that's what the + # trailing `&` does) so that we can start another one + echo -e "\nBuilding bundles for \`$file\`..." + INTEGRATION_FILE=$file yarn --silent rollup -c rollup.config.js 2>/dev/null && echo -e "\nFinished building bundles for \`$file\`." & + +done + +# keep the process running until all backgrounded tasks have finished +wait + +echo "Integration bundles built successfully"