diff --git a/dev-packages/rollup-utils/npmHelpers.mjs b/dev-packages/rollup-utils/npmHelpers.mjs index 2c8235ef70ff..e34b515f0538 100644 --- a/dev-packages/rollup-utils/npmHelpers.mjs +++ b/dev-packages/rollup-utils/npmHelpers.mjs @@ -30,7 +30,6 @@ const packageDotJSON = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), '. export function makeBaseNPMConfig(options = {}) { const { entrypoints = ['src/index.ts'], - esModuleInterop = false, hasBundles = false, packageSpecificConfig = {}, sucrase = {}, @@ -56,9 +55,8 @@ export function makeBaseNPMConfig(options = {}) { sourcemap: true, - // Include __esModule property when generating exports - // Before the upgrade to Rollup 4 this was included by default and when it was gone it broke tests - esModule: true, + // Include __esModule property when there is a default prop + esModule: 'if-default-prop', // output individual files rather than one big bundle preserveModules: true, @@ -84,16 +82,7 @@ export function makeBaseNPMConfig(options = {}) { // (We don't need it, so why waste the bytes?) freeze: false, - // Equivalent to `esModuleInterop` in tsconfig. - // Controls whether rollup emits helpers to handle special cases where turning - // `import * as dogs from 'dogs'` - // into - // `const dogs = require('dogs')` - // doesn't work. - // - // `auto` -> emit helpers - // `esModule` -> don't emit helpers - interop: esModuleInterop ? 'auto' : 'esModule', + interop: 'esModule', }, plugins: [ diff --git a/packages/react/rollup.npm.config.mjs b/packages/react/rollup.npm.config.mjs index 4014705e5eb4..923dfafb85d7 100644 --- a/packages/react/rollup.npm.config.mjs +++ b/packages/react/rollup.npm.config.mjs @@ -2,7 +2,6 @@ import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollu export default makeNPMConfigVariants( makeBaseNPMConfig({ - esModuleInterop: true, packageSpecificConfig: { external: ['react', 'react/jsx-runtime'], }, diff --git a/packages/react/test/sdk.test.ts b/packages/react/test/sdk.test.ts index 50e9b485cd3e..825ade6f0b25 100644 --- a/packages/react/test/sdk.test.ts +++ b/packages/react/test/sdk.test.ts @@ -2,6 +2,13 @@ import * as SentryBrowser from '@sentry/browser'; import { version } from 'react'; import { init } from '../src/sdk'; +jest.mock('@sentry/browser', () => { + return { + __esModule: true, + ...jest.requireActual('@sentry/browser'), + }; +}); + describe('init', () => { it('sets the React version (if available) in the global scope', () => { const setContextSpy = jest.spyOn(SentryBrowser, 'setContext'); diff --git a/packages/remix/test/index.client.test.ts b/packages/remix/test/index.client.test.ts index 365794e0f213..139f27f12076 100644 --- a/packages/remix/test/index.client.test.ts +++ b/packages/remix/test/index.client.test.ts @@ -2,6 +2,13 @@ import * as SentryReact from '@sentry/react'; import { init } from '../src/index.client'; +jest.mock('@sentry/react', () => { + return { + __esModule: true, + ...jest.requireActual('@sentry/react'), + }; +}); + const reactInit = jest.spyOn(SentryReact, 'init'); describe('Client init()', () => { diff --git a/packages/remix/test/index.server.test.ts b/packages/remix/test/index.server.test.ts index 842684a4640a..b710e295ed1e 100644 --- a/packages/remix/test/index.server.test.ts +++ b/packages/remix/test/index.server.test.ts @@ -2,6 +2,13 @@ import * as SentryNode from '@sentry/node'; import { init } from '../src/index.server'; +jest.mock('@sentry/node', () => { + return { + __esModule: true, + ...jest.requireActual('@sentry/node'), + }; +}); + const nodeInit = jest.spyOn(SentryNode, 'init'); describe('Server init()', () => {