Skip to content

ref(build): Handle JS version in rollup config generation function #4654

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
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