Skip to content

Commit 1948f3b

Browse files
Andaristcodex
andcommitted
fix(bundler-plugins): Resolve directive injection CI regressions
Co-Authored-By: OpenAI Codex <codex@openai.com>
1 parent 8094166 commit 1948f3b

25 files changed

Lines changed: 103 additions & 59 deletions

‎dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.config.js‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import * as esbuild from "esbuild";
22
import { sentryEsbuildPlugin } from "@sentry/bundler-plugins/esbuild";
33

44
await esbuild.build({
5-
entryPoints: ["./src/cjs-directives.js"],
5+
entryPoints: {
6+
strict: "./src/strict-mode.cjs",
7+
sloppy: "./src/sloppy-mode.cjs",
8+
},
69
bundle: true,
7-
outfile: "./out/cjs-directives/static-injection.cjs",
10+
outdir: "./out/cjs-directives/static-injection",
11+
outExtension: { ".js": ".cjs" },
812
minify: false,
913
format: "cjs",
1014
plugins: [
@@ -17,9 +21,13 @@ await esbuild.build({
1721
});
1822

1923
await esbuild.build({
20-
entryPoints: ["./src/cjs-directives.js"],
24+
entryPoints: {
25+
strict: "./src/strict-mode.cjs",
26+
sloppy: "./src/sloppy-mode.cjs",
27+
},
2128
bundle: true,
22-
outfile: "./out/cjs-directives/debug-id-injection.cjs",
29+
outdir: "./out/cjs-directives/debug-id-injection",
30+
outExtension: { ".js": ".cjs" },
2331
minify: false,
2432
format: "cjs",
2533
sourcemap: true,

‎dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/cjs-directives.test.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@ import { test } from "./utils";
44
test(import.meta.url, ({ runBundler, runFileInNode }) => {
55
runBundler();
66

7-
expect(JSON.parse(runFileInNode("static-injection.cjs"))).toEqual({
7+
expect(JSON.parse(runFileInNode("static-injection/strict.cjs"))).toEqual({
88
strictModePreserved: true,
9+
releaseInjected: true,
10+
debugIdInjected: false,
11+
});
12+
expect(JSON.parse(runFileInNode("static-injection/sloppy.cjs"))).toEqual({
913
sloppyModePreserved: true,
1014
releaseInjected: true,
1115
debugIdInjected: false,
1216
});
13-
expect(JSON.parse(runFileInNode("debug-id-injection.cjs"))).toEqual({
17+
expect(JSON.parse(runFileInNode("debug-id-injection/strict.cjs"))).toEqual({
1418
strictModePreserved: true,
19+
releaseInjected: false,
20+
debugIdInjected: true,
21+
});
22+
expect(JSON.parse(runFileInNode("debug-id-injection/sloppy.cjs"))).toEqual({
1523
sloppyModePreserved: true,
1624
releaseInjected: false,
1725
debugIdInjected: true,

‎dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/cjs-directives.js‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/sloppy-mode.cjs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,11 @@ globalThis.sloppyModePreserved =
22
(function () {
33
return this;
44
})() === globalThis;
5+
6+
console.log(
7+
JSON.stringify({
8+
sloppyModePreserved: globalThis.sloppyModePreserved,
9+
releaseInjected: globalThis.SENTRY_RELEASE?.id === "strict-mode-release",
10+
debugIdInjected: Object.keys(globalThis._sentryDebugIds || {}).length === 1,
11+
})
12+
);

‎dev-packages/bundler-plugin-integration-tests/fixtures/esbuild/src/strict-mode.cjs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,11 @@ globalThis.strictModePreserved =
44
(function () {
55
return this;
66
})() === undefined;
7+
8+
console.log(
9+
JSON.stringify({
10+
strictModePreserved: globalThis.strictModePreserved,
11+
releaseInjected: globalThis.SENTRY_RELEASE?.id === "strict-mode-release",
12+
debugIdInjected: Object.keys(globalThis._sentryDebugIds || {}).length === 1,
13+
})
14+
);

‎dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/after-upload-deletion.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
55
runBundler();
66
expect(readOutputFiles()).toMatchInlineSnapshot(`
77
{
8-
"basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();
9-
/******/ (() => { // webpackBootstrap
8+
"basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();
9+
(() => { // webpackBootstrap
1010
/******/ "use strict";
1111
// eslint-disable-next-line no-console
1212
console.log("hello world");

‎dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/application-key.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => {
55
runBundler();
66
expect(readOutputFiles()).toMatchInlineSnapshot(`
77
{
8-
"basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],{"_sentryBundlerPluginAppKey:1234567890abcdef":true});var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();
9-
/******/ (() => { // webpackBootstrap
8+
"basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],{"_sentryBundlerPluginAppKey:1234567890abcdef":true});var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();
9+
(() => { // webpackBootstrap
1010
/******/ "use strict";
1111
// eslint-disable-next-line no-console
1212
console.log("hello world");

‎dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-cjs.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
55
runBundler();
66
expect(readOutputFiles()).toMatchInlineSnapshot(`
77
{
8-
"basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();
9-
/******/ (() => { // webpackBootstrap
8+
"basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();
9+
(() => { // webpackBootstrap
1010
/******/ "use strict";
1111
// eslint-disable-next-line no-console
1212
console.log("hello world");

‎dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-release-disabled.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles }) => {
55
runBundler();
66
expect(readOutputFiles()).toMatchInlineSnapshot(`
77
{
8-
"basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();
9-
/******/ (() => { // webpackBootstrap
8+
"basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();
9+
(() => { // webpackBootstrap
1010
/******/ "use strict";
1111
// eslint-disable-next-line no-console
1212
console.log("hello world");

‎dev-packages/bundler-plugin-integration-tests/fixtures/webpack5/basic-sourcemaps.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
55
runBundler();
66
expect(readOutputFiles()).toMatchInlineSnapshot(`
77
{
8-
"basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();
9-
/******/ (() => { // webpackBootstrap
8+
"basic.js": "/******/ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="00000000-0000-0000-0000-000000000000",e._sentryDebugIdIdentifier="sentry-dbid-00000000-0000-0000-0000-000000000000");}catch(e){}}();
9+
(() => { // webpackBootstrap
1010
/******/ "use strict";
1111
// eslint-disable-next-line no-console
1212
console.log("hello world");

0 commit comments

Comments
 (0)