diff --git a/.rollup/index.mjs b/.rollup/index.mjs index c630b5bc9..33425d8cb 100644 --- a/.rollup/index.mjs +++ b/.rollup/index.mjs @@ -14,19 +14,30 @@ const defaultOptions = () => ({ output: undefined }) +const sharedOutput = { + dir: 'dist', + entryFileNames: '[name].js', + preserveModules: true, + generatedCode: { + preset: 'es2015', + } +} + function createRollupConfig (options = defaultOptions()) { const packageJson = JSON.parse(fs.readFileSync(`${process.cwd()}/package.json`)) return { input: options.input || 'src/index.ts', - output: options.output || { - dir: 'dist', - format: 'esm', - preserveModules: true, - generatedCode: { - preset: 'es2015', + output: options.output || [ + { + ...sharedOutput, + format: 'cjs' + }, + { + ...sharedOutput, + format: 'esm' } - }, + ], external: ['@bugsnag/core'].concat(options.external), plugins: [ replace({ diff --git a/packages/plugin-app-duration/rollup.config.npm.mjs b/packages/plugin-app-duration/rollup.config.npm.mjs index 328994acc..1501d039d 100644 --- a/packages/plugin-app-duration/rollup.config.npm.mjs +++ b/packages/plugin-app-duration/rollup.config.npm.mjs @@ -1,25 +1,5 @@ import createRollupConfig from '../../.rollup/index.mjs' export default createRollupConfig({ - input: 'src/app-duration.ts', - output: [ - { - dir: `dist`, - entryFileNames: '[name].js', - format: 'cjs', - preserveModules: true, - generatedCode: { - preset: 'es2015', - } - }, - { - dir: `dist`, - entryFileNames: '[name].mjs', - format: 'esm', - preserveModules: true, - generatedCode: { - preset: 'es2015', - } - } - ] + input: 'src/app-duration.ts' }) diff --git a/packages/plugin-window-onerror/rollup.config.npm.mjs b/packages/plugin-window-onerror/rollup.config.npm.mjs index f001dd2b8..356d458f9 100644 --- a/packages/plugin-window-onerror/rollup.config.npm.mjs +++ b/packages/plugin-window-onerror/rollup.config.npm.mjs @@ -1,25 +1,5 @@ import createRollupConfig from '../../.rollup/index.mjs' export default createRollupConfig({ - input: 'src/onerror.ts', - output: [ - { - dir: `dist`, - entryFileNames: '[name].js', - format: 'cjs', - preserveModules: true, - generatedCode: { - preset: 'es2015', - } - }, - { - dir: `dist`, - entryFileNames: '[name].mjs', - format: 'esm', - preserveModules: true, - generatedCode: { - preset: 'es2015', - } - } - ] + input: 'src/onerror.ts' }) diff --git a/packages/plugin-window-unhandled-rejection/rollup.config.npm.mjs b/packages/plugin-window-unhandled-rejection/rollup.config.npm.mjs index 6b32b19f9..ce422d72a 100644 --- a/packages/plugin-window-unhandled-rejection/rollup.config.npm.mjs +++ b/packages/plugin-window-unhandled-rejection/rollup.config.npm.mjs @@ -1,25 +1,5 @@ import createRollupConfig from '../../.rollup/index.mjs' export default createRollupConfig({ - input: 'src/unhandled-rejection.ts', - output: [ - { - dir: `dist`, - entryFileNames: '[name].js', - format: 'cjs', - preserveModules: true, - generatedCode: { - preset: 'es2015', - } - }, - { - dir: `dist`, - entryFileNames: '[name].mjs', - format: 'esm', - preserveModules: true, - generatedCode: { - preset: 'es2015', - } - } - ] + input: 'src/unhandled-rejection.ts' })