Skip to content

Commit a0cb3bb

Browse files
authored
feat(integrations): Make ES6 integration bundles (#4718)
This changes the build config in the `integrations` package to generate ES6 bundles as well as ES5 bundles, in preparation for going ES6-first in v7. Which JS version to build is controlled by an environment variable, in order that the builds be parallelizable.
1 parent c17b752 commit a0cb3bb

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

packages/integrations/rollup.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ import { insertAt, makeBaseBundleConfig, makeConfigVariants } from '../../rollup
55
const builds = [];
66

77
const file = process.env.INTEGRATION_FILE;
8+
const jsVersion = process.env.JS_VERSION;
89

910
const baseBundleConfig = makeBaseBundleConfig({
1011
input: `src/${file}`,
1112
isAddOn: true,
12-
jsVersion: 'es5',
13+
jsVersion,
1314
licenseTitle: '@sentry/integrations',
14-
// TODO this doesn't currently need to be a template string, but soon will need to be, so leaving it in that form
15-
// for now
16-
outputFileBase: `${file.replace('.ts', '')}`,
15+
outputFileBase: `${file.replace('.ts', '')}${jsVersion === 'ES6' ? '.es6' : ''}`,
1716
});
1817

1918
// TODO We only need `commonjs` for localforage (used in the offline plugin). Once that's fixed, this can come out.
2019
baseBundleConfig.plugins = insertAt(baseBundleConfig.plugins, -2, commonjs());
2120

21+
// this makes non-minified, minified, and minified-with-debug-logging versions of each bundle
2222
builds.push(...makeConfigVariants(baseBundleConfig));
2323

2424
export default builds;
Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
for filepath in ./src/*; do
2-
file=$(basename $filepath)
2+
for js_version in "ES5" "ES6"; do
33

4-
# the index file is only there for the purposes of npm builds - for the CDN we create a separate bundle for each
5-
# integration - so we can skip it here
6-
if [[ $file == "index.ts" ]]; then
7-
continue
8-
fi
4+
file=$(basename $filepath)
95

10-
# run the build for each integration, pushing each build process into the background once it starts (that's what the
11-
# trailing `&` does) so that we can start another one
12-
echo -e "\nBuilding bundles for \`$file\`..."
13-
INTEGRATION_FILE=$file yarn --silent rollup -c rollup.config.js 2>/dev/null && echo -e "\nFinished building bundles for \`$file\`." &
6+
# the index file is only there for the purposes of npm builds - for the CDN we create a separate bundle for each
7+
# integration - so we can skip it here
8+
if [[ $file == "index.ts" ]]; then
9+
continue
10+
fi
1411

12+
# run the build for each integration, pushing each build process into the background once it starts (that's what the
13+
# trailing `&` does) so that we can start another one
14+
echo -e "Building $js_version bundles for \`$file\`..."
15+
INTEGRATION_FILE=$file JS_VERSION=$js_version \
16+
yarn --silent rollup -c rollup.config.js &&
17+
echo -e "Finished building $js_version bundles for \`$file\`." &
18+
19+
done
1520
done
1621

1722
# keep the process running until all backgrounded tasks have finished
1823
wait
1924

20-
echo "Integration bundles built successfully"
25+
echo -e "\nIntegration bundles built successfully"

rollup.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ export function makeBaseBundleConfig(options) {
9494
},
9595
},
9696
include: ['*.ts+(|x)', '**/*.ts+(|x)', '../**/*.ts+(|x)'],
97+
// the typescript plugin doesn't handle concurrency very well, so clean the cache between builds
98+
// (see https://github.com/ezolenko/rollup-plugin-typescript2/issues/15)
99+
clean: true,
100+
// TODO: For the moment, the above issue seems to have stopped spamming the build with (non-blocking) errors, as it
101+
// was originally. If it starts again, this will suppress that output. If we get to the end of the bundle revamp and
102+
// it still seems okay, we can take this out entirely.
103+
// verbosity: 0,
97104
};
98105

99106
const typescriptPluginES5 = typescript(

0 commit comments

Comments
 (0)