-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(build): Parallelize integration bundling (#4707)
Given that now most of our testing runs in parallel in CI, the biggest bottleneck has become the build step. Within that step, the single slowest thing we do is build integration bundles, simply because of the number of bundles which need to be created. (This is especially true now that we're creating three versions of each bundle rather than two[1].) To speed things up a bit, this parallelizes the building of those bundles. Though it ends up not being as dramatic a time savings as one might hope (because the typescript plugin's caching mechanism doesn't play nicely with concurrent builds[2]), it nonetheless drops the total build time from roughly two minutes down to 70-80 seconds in my local testing. [1] #4699 [2] ezolenko/rollup-plugin-typescript2#15
- Loading branch information
1 parent
ec8da92
commit 57a8997
Showing
3 changed files
with
34 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |