Skip to content

Commit 8314ed9

Browse files
committed
WIP
1 parent 0a54f8f commit 8314ed9

File tree

5 files changed

+165
-25
lines changed

5 files changed

+165
-25
lines changed

dev-packages/rollup-utils/npmHelpers.mjs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@ export function makeBaseNPMConfig(options = {}) {
3333
esModuleInterop = false,
3434
hasBundles = false,
3535
packageSpecificConfig = {},
36-
addPolyfills = true,
3736
sucrase = {},
3837
bundledBuiltins = [],
3938
} = options;
4039

4140
const nodeResolvePlugin = makeNodeResolvePlugin();
42-
const sucrasePlugin = makeSucrasePlugin({}, { disableESTransforms: !addPolyfills, ...sucrase });
41+
const sucrasePlugin = makeSucrasePlugin({}, sucrase);
4342
const debugBuildStatementReplacePlugin = makeDebugBuildStatementReplacePlugin();
4443
const importMetaUrlReplacePlugin = makeImportMetaUrlReplacePlugin();
4544
const cleanupPlugin = makeCleanupPlugin();
@@ -64,13 +63,9 @@ export function makeBaseNPMConfig(options = {}) {
6463
// output individual files rather than one big bundle
6564
preserveModules: true,
6665

67-
// Allow wrappers or helper functions generated by rollup to use any ES2015 features except symbols. (Symbols in
68-
// general are fine, but the `[Symbol.toStringTag]: 'Module'` which Rollup adds alongside `__esModule:
69-
// true` in CJS modules makes it so that Jest <= 29.2.2 crashes when trying to mock generated `@sentry/xxx`
70-
// packages. See https://github.com/getsentry/sentry-javascript/pull/6043.)
66+
// Allow wrappers or helper functions generated by rollup to use any ES2015 features
7167
generatedCode: {
7268
preset: 'es2015',
73-
symbols: false,
7469
},
7570

7671
// don't add `"use strict"` to the top of cjs files

dev-packages/rollup-utils/plugins/npmPlugins.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export function makeSucrasePlugin(options = {}, sucraseOptions = {}) {
2929
},
3030
{
3131
transforms: ['typescript', 'jsx'],
32+
// We use a custom forked version of sucrase,
33+
// where optional chaining & nullish coalescing are never polyfilled (even if this is false)
34+
// If this is disabled, then numeric separators & class fields are not polyfilled anymore, which we rely on
35+
disableESTransforms: false,
3236
...sucraseOptions,
3337
},
3438
);

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"lint:lerna": "lerna run lint",
3232
"lint:biome": "biome check .",
3333
"lint:prettier": "prettier \"**/*.md\" \"**/*.css\" --check",
34+
"lint:es-compatibility": "es-check es2020 ./packages/*/build/{bundles,npm/cjs,cjs}/*.js && es-check es2020 ./packages/*/build/{npm/esm,esm}/*.js --module=true",
3435
"postpublish": "lerna run --stream --concurrency 1 postpublish",
3536
"test": "lerna run --ignore \"@sentry-internal/{browser-integration-tests,e2e-tests,integration-shims,node-integration-tests}\" test",
3637
"test:unit": "lerna run --ignore \"@sentry-internal/{browser-integration-tests,e2e-tests,integration-shims,node-integration-tests}\" test:unit",
@@ -115,6 +116,7 @@
115116
"@vitest/coverage-v8": "^1.6.0",
116117
"deepmerge": "^4.2.2",
117118
"downlevel-dts": "~0.11.0",
119+
"es-check": "^7.2.1",
118120
"eslint": "7.32.0",
119121
"jest": "^27.5.1",
120122
"jest-environment-node": "^27.5.1",
@@ -144,7 +146,8 @@
144146
"resolutions": {
145147
"gauge/strip-ansi": "6.0.1",
146148
"wide-align/string-width": "4.2.3",
147-
"cliui/wrap-ansi": "7.0.0"
149+
"cliui/wrap-ansi": "7.0.0",
150+
"**/sucrase": "getsentry/sucrase#es2020-polyfills"
148151
},
149152
"version": "0.0.0",
150153
"name": "sentry-javascript",

packages/node/rollup.anr-worker.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export function createWorkerCodeBuilder(entry, outDir) {
77
makeBaseBundleConfig({
88
bundleType: 'node-worker',
99
entrypoints: [entry],
10-
sucrase: { disableESTransforms: true },
1110
licenseTitle: '@sentry/node',
1211
outputFileBase: () => 'worker-script.js',
1312
packageSpecificConfig: {

0 commit comments

Comments
 (0)