From d3324f4efa4a50a8beb5d1e02590fa26731eb0ae Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Tue, 25 Oct 2022 15:36:44 -0700 Subject: [PATCH] prevent rollup from adding `[Symbol.toStringTag]: 'Module'` to CJS files --- rollup/npmHelpers.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rollup/npmHelpers.js b/rollup/npmHelpers.js index b7d0fd187e14..e1657f7ef598 100644 --- a/rollup/npmHelpers.js +++ b/rollup/npmHelpers.js @@ -44,8 +44,14 @@ export function makeBaseNPMConfig(options = {}) { // output individual files rather than one big bundle preserveModules: true, - // any wrappers or helper functions generated by rollup can use ES6 features - generatedCode: 'es2015', + // Allow wrappers or helper functions generated by rollup to use any ES6 features except symbols. (Symbols in + // general are fine, but the `[Symbol.toStringTag]: 'Module'` which Rollup adds alongside `__esModule: + // true` in CJS modules makes it so that Jest <= 29.2.2 crashes when trying to mock generated `@sentry/xxx` + // packages. See https://github.com/getsentry/sentry-javascript/pull/6043.) + generatedCode: { + preset: 'es2015', + symbols: false, + }, // don't add `"use strict"` to the top of cjs files strict: false,