-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Disable debug ID injection when
sourcemaps.disable
is set (#589)
- Loading branch information
Showing
5 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...ntegration-tests/fixtures/disabled-debug-id-injection/disabled-debug-id-injection.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* eslint-disable jest/no-standalone-expect */ | ||
/* eslint-disable jest/expect-expect */ | ||
import childProcess from "child_process"; | ||
import path from "path"; | ||
import { testIfNodeMajorVersionIsLessThan18 } from "../../utils/testIf"; | ||
|
||
function checkBundle(bundlePath1: string, bundlePath2: string) { | ||
const process1Output = childProcess.execSync(`node ${bundlePath1}`, { encoding: "utf-8" }); | ||
expect(process1Output).toBe("undefined\n"); | ||
|
||
const process2Output = childProcess.execSync(`node ${bundlePath2}`, { encoding: "utf-8" }); | ||
expect(process2Output).toBe("undefined\n"); | ||
} | ||
|
||
describe("should not inject debug IDs when `sourcemaps.disable` is `true`", () => { | ||
test("esbuild bundle", () => { | ||
checkBundle( | ||
path.join(__dirname, "out", "esbuild", "bundle1.js"), | ||
path.join(__dirname, "out", "esbuild", "bundle2.js") | ||
); | ||
}); | ||
|
||
test("rollup bundle", () => { | ||
checkBundle( | ||
path.join(__dirname, "out", "rollup", "bundle1.js"), | ||
path.join(__dirname, "out", "rollup", "bundle2.js") | ||
); | ||
}); | ||
|
||
test("vite bundle", () => { | ||
checkBundle( | ||
path.join(__dirname, "out", "vite", "bundle1.js"), | ||
path.join(__dirname, "out", "vite", "bundle2.js") | ||
); | ||
}); | ||
|
||
testIfNodeMajorVersionIsLessThan18("webpack 4 bundle", () => { | ||
checkBundle( | ||
path.join(__dirname, "out", "webpack4", "bundle1.js"), | ||
path.join(__dirname, "out", "webpack4", "bundle2.js") | ||
); | ||
}); | ||
|
||
test("webpack 5 bundle", () => { | ||
checkBundle( | ||
path.join(__dirname, "out", "webpack5", "bundle1.js"), | ||
path.join(__dirname, "out", "webpack5", "bundle2.js") | ||
); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
packages/integration-tests/fixtures/disabled-debug-id-injection/input/bundle1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// eslint-disable-next-line no-console | ||
console.log(JSON.stringify(global._sentryDebugIds)); | ||
|
||
// Just so the two bundles generate different hashes: | ||
global.iAmBundle1 = 1; |
5 changes: 5 additions & 0 deletions
5
packages/integration-tests/fixtures/disabled-debug-id-injection/input/bundle2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// eslint-disable-next-line no-console | ||
console.log(JSON.stringify(global._sentryDebugIds)); | ||
|
||
// Just so the two bundles generate different hashes: | ||
global.iAmBundle2 = 2; |
18 changes: 18 additions & 0 deletions
18
packages/integration-tests/fixtures/disabled-debug-id-injection/setup.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as path from "path"; | ||
import { createCjsBundles } from "../../utils/create-cjs-bundles"; | ||
|
||
const outputDir = path.resolve(__dirname, "out"); | ||
|
||
createCjsBundles( | ||
{ | ||
bundle1: path.resolve(__dirname, "input", "bundle1.js"), | ||
bundle2: path.resolve(__dirname, "input", "bundle2.js"), | ||
}, | ||
outputDir, | ||
{ | ||
telemetry: false, | ||
sourcemaps: { | ||
disable: true, | ||
}, | ||
} | ||
); |