Skip to content

feat(build): Allow for multiple bundle entrypoints #5143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/browser/rollup.bundle.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const builds = [];
['es5', 'es6'].forEach(jsVersion => {
const baseBundleConfig = makeBaseBundleConfig({
bundleType: 'standalone',
input: 'src/index.ts',
entrypoints: ['src/index.ts'],
jsVersion,
licenseTitle: '@sentry/browser',
outputFileBase: `bundles/bundle${jsVersion === 'es5' ? '.es5' : ''}`,
outputFileBase: () => `bundles/bundle${jsVersion === 'es5' ? '.es5' : ''}`,
});

builds.push(...makeBundleConfigVariants(baseBundleConfig));
Expand Down
4 changes: 2 additions & 2 deletions packages/integrations/rollup.bundle.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const jsVersion = process.env.JS_VERSION;

const baseBundleConfig = makeBaseBundleConfig({
bundleType: 'addon',
input: `src/${file}`,
entrypoints: [`src/${file}`],
jsVersion,
licenseTitle: '@sentry/integrations',
outputFileBase: `bundles/${file.replace('.ts', '')}${jsVersion === 'ES5' ? '.es5' : ''}`,
outputFileBase: ({ name: entrypoint }) => `bundles/${entrypoint}${jsVersion === 'ES5' ? '.es5' : ''}`,
});

// TODO We only need `commonjs` for localforage (used in the offline plugin). Once that's fixed, this can come out.
Expand Down
4 changes: 2 additions & 2 deletions packages/tracing/rollup.bundle.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const builds = [];
['es5', 'es6'].forEach(jsVersion => {
const baseBundleConfig = makeBaseBundleConfig({
bundleType: 'standalone',
input: 'src/index.bundle.ts',
entrypoints: ['src/index.bundle.ts'],
jsVersion,
licenseTitle: '@sentry/tracing & @sentry/browser',
outputFileBase: `bundles/bundle.tracing${jsVersion === 'es5' ? '.es5' : ''}`,
outputFileBase: () => `bundles/bundle.tracing${jsVersion === 'es5' ? '.es5' : ''}`,
});

builds.push(...makeBundleConfigVariants(baseBundleConfig));
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/rollup.bundle.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { makeBaseBundleConfig, makeBundleConfigVariants } from '../../rollup/ind

const baseBundleConfig = makeBaseBundleConfig({
bundleType: 'standalone',
input: 'src/index.bundle.ts',
entrypoints: ['src/index.bundle.ts'],
jsVersion: 'es6',
licenseTitle: '@sentry/vue',
outputFileBase: 'bundle.vue',
outputFileBase: () => 'bundle.vue',
});

export default makeBundleConfigVariants(baseBundleConfig);
4 changes: 2 additions & 2 deletions packages/wasm/rollup.bundle.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { makeBaseBundleConfig, makeBundleConfigVariants } from '../../rollup/ind

const baseBundleConfig = makeBaseBundleConfig({
bundleType: 'addon',
input: 'src/index.ts',
entrypoints: ['src/index.ts'],
jsVersion: 'es6',
licenseTitle: '@sentry/wasm',
outputFileBase: 'bundles/wasm',
outputFileBase: () => 'bundles/wasm',
});

export default makeBundleConfigVariants(baseBundleConfig);
13 changes: 7 additions & 6 deletions rollup/bundleHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import { mergePlugins } from './utils';

export function makeBaseBundleConfig(options) {
const { bundleType, input, jsVersion, licenseTitle, outputFileBase } = options;
const { bundleType, entrypoints, jsVersion, licenseTitle, outputFileBase } = options;

const nodeResolvePlugin = makeNodeResolvePlugin();
const sucrasePlugin = makeSucrasePlugin();
Expand Down Expand Up @@ -91,10 +91,11 @@ export function makeBaseBundleConfig(options) {

// used by all bundles
const sharedBundleConfig = {
input,
input: entrypoints,
output: {
// a file extension will be added to this base value when we specify either a minified or non-minified build
file: `build/${outputFileBase}`,
entryFileNames: outputFileBase,
dir: 'build',
sourcemap: true,
strict: false,
esModule: false,
Expand Down Expand Up @@ -136,7 +137,7 @@ export function makeBundleConfigVariants(baseConfig) {
const variantSpecificConfigs = [
{
output: {
file: `${baseConfig.output.file}.js`,
entryFileNames: chunkInfo => `${baseConfig.output.entryFileNames(chunkInfo)}.js`,
},
plugins: [includeDebuggingPlugin],
},
Expand All @@ -150,13 +151,13 @@ export function makeBundleConfigVariants(baseConfig) {
// },
{
output: {
file: `${baseConfig.output.file}.min.js`,
entryFileNames: chunkInfo => `${baseConfig.output.entryFileNames(chunkInfo)}.min.js`,
},
plugins: [stripDebuggingPlugin, terserPlugin],
},
{
output: {
file: `${baseConfig.output.file}.debug.min.js`,
entryFileNames: chunkInfo => `${baseConfig.output.entryFileNames(chunkInfo)}.debug.min.js`,
},
plugins: [terserPlugin],
},
Expand Down