Skip to content

Commit

Permalink
ref(build): Handle JS version in rollup config generation function (#…
Browse files Browse the repository at this point in the history
…4654)

This builds on #4650, which introduced a function to generate rollup configs for our CDN bundles, allowing that function to handle both ES5 and ES6 compilation. No change to bundle contents.

Note: This doesn't make any difference for the four packages the change is applied to here, but will enable `@sentry/browser` to use the new config generation function, a change which will come in a future PR.
  • Loading branch information
lobsterkatie authored Mar 1, 2022
1 parent b692ffb commit dee05a6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/integrations/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function loadAllIntegrations() {
const baseBundleConfig = makeBaseBundleConfig({
input: `src/${file}`,
isAddOn: true,
jsVersion: 'es5',
outputFileBase: `build/${file.replace('.ts', '')}`,
});

Expand Down
1 change: 1 addition & 0 deletions packages/tracing/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const licensePlugin = makeLicensePlugin('@sentry/tracing & @sentry/browser');
const baseBundleConfig = makeBaseBundleConfig({
input: 'src/index.bundle.ts',
isAddOn: false,
jsVersion: 'es5',
outputFileBase: 'build/bundle.tracing',
});

Expand Down
1 change: 1 addition & 0 deletions packages/vue/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const licensePlugin = makeLicensePlugin();
const baseBundleConfig = makeBaseBundleConfig({
input: 'src/index.bundle.ts',
isAddOn: false,
jsVersion: 'es5',
outputFileBase: 'build/bundle.vue',
});

Expand Down
1 change: 1 addition & 0 deletions packages/wasm/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { makeBaseBundleConfig, terserPlugin } from '../../rollup.config';
const baseBundleConfig = makeBaseBundleConfig({
input: 'src/index.ts',
isAddOn: true,
jsVersion: 'es5',
outputFileBase: 'build/wasm',
});

Expand Down
28 changes: 24 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const markAsBrowserBuild = replace({
},
});

export const typescriptPluginES5 = typescript({
const baseTSPluginOptions = {
tsconfig: 'tsconfig.esm.json',
tsconfigOverride: {
compilerOptions: {
Expand All @@ -79,7 +79,27 @@ export const typescriptPluginES5 = typescript({
},
},
include: ['*.ts+(|x)', '**/*.ts+(|x)', '../**/*.ts+(|x)'],
});
};

export const typescriptPluginES5 = typescript(
deepMerge(baseTSPluginOptions, {
tsconfigOverride: {
compilerOptions: {
target: 'es5',
},
},
}),
);

export const typescriptPluginES6 = typescript(
deepMerge(baseTSPluginOptions, {
tsconfigOverride: {
compilerOptions: {
target: 'es6',
},
},
}),
);

export const nodeResolvePlugin = resolve();

Expand Down Expand Up @@ -124,7 +144,7 @@ export const addOnBundleConfig = {
};

export function makeBaseBundleConfig(options) {
const { input, isAddOn, outputFileBase } = options;
const { input, isAddOn, jsVersion, outputFileBase } = options;

const standAloneBundleConfig = {
output: {
Expand Down Expand Up @@ -174,7 +194,7 @@ export function makeBaseBundleConfig(options) {
strict: false,
esModule: false,
},
plugins: [typescriptPluginES5, markAsBrowserBuild, nodeResolvePlugin],
plugins: [jsVersion === 'es5' ? typescriptPluginES5 : typescriptPluginES6, markAsBrowserBuild, nodeResolvePlugin],
treeshake: 'smallest',
};

Expand Down

0 comments on commit dee05a6

Please sign in to comment.