Skip to content

Commit 66d93fa

Browse files
committed
fixes
1 parent 5ed0084 commit 66d93fa

10 files changed

Lines changed: 90 additions & 46 deletions

File tree

‎dev-packages/e2e-tests/test-applications/node-esbuild/assert.mjs‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,20 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
1818
const BUILD_TIME_TRANSFORM_MARKER = 'g.bundler=g.bundler||[]';
1919

2020
function bundleText(name) {
21-
const dir = join(__dirname, 'dist', name);
22-
return readdirSync(dir)
23-
.map(f => readFileSync(join(dir, f), 'utf8'))
21+
const files = [];
22+
const walk = dir => {
23+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
24+
const full = join(dir, entry.name);
25+
if (entry.isDirectory()) {
26+
walk(full);
27+
} else {
28+
files.push(full);
29+
}
30+
}
31+
};
32+
walk(join(__dirname, 'dist', name));
33+
return files
34+
.map(f => readFileSync(f, 'utf8'))
2435
.join('\n')
2536
.replace(/\s+/g, '');
2637
}
@@ -35,10 +46,7 @@ function check(condition, message) {
3546
const plain = bundleText('plain');
3647
const plugin = bundleText('plugin');
3748

38-
check(
39-
!plain.includes(BUILD_TIME_TRANSFORM_MARKER),
40-
'plain build (no plugin) does not run build-time instrumentation',
41-
);
49+
check(!plain.includes(BUILD_TIME_TRANSFORM_MARKER), 'plain build (no plugin) does not run build-time instrumentation');
4250
check(
4351
plugin.includes(BUILD_TIME_TRANSFORM_MARKER),
4452
'sentryEsbuildPlugin runs build-time instrumentation (injects the orchestrion banner)',

‎dev-packages/e2e-tests/test-applications/node-esbuild/build.mjs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// - `plain`: no Sentry plugin.
33
// - `plugin`: with `sentryEsbuildPlugin` (build-time instrumentation).
44
// Only the `plugin` build runs the orchestrion code transform, which prepends the "bundler ran"
5-
// banner to the entry chunk. Kept unminified so assert.mjs can match the banner verbatim.
5+
// banner to the entry chunk. Kept unminified so the banner keeps its identifiers (a minifier would
6+
// rename them); assert.mjs matches it whitespace-insensitively.
67
import { dirname, join } from 'node:path';
78
import { fileURLToPath } from 'node:url';
89
import { build } from 'esbuild';
@@ -13,7 +14,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
1314
function run(name, plugins) {
1415
return build({
1516
entryPoints: [join(__dirname, 'src', 'entry.mjs')],
16-
outfile: join(__dirname, 'dist', name, 'main.mjs'),
17+
outdir: join(__dirname, 'dist', name),
1718
bundle: true,
1819
platform: 'node',
1920
format: 'esm',

‎dev-packages/e2e-tests/test-applications/node-rolldown/assert.mjs‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
2-
* Asserts that `sentryRollupPlugin` performs build-time instrumentation when bundling with Rolldown:
3-
* its code transform injects the orchestrion "bundler ran" banner into the entry chunk. A plain build
4-
* (no plugin) does not.
2+
* Asserts that `sentryRollupPlugin` performs build-time instrumentation when bundling with Rolldown: its code transform injects
3+
* the orchestrion "bundler ran" banner into the entry chunk. A plain build (no plugin) does not.
54
*
65
* @module
76
*/
@@ -19,9 +18,20 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
1918
const BUILD_TIME_TRANSFORM_MARKER = 'g.bundler=g.bundler||[]';
2019

2120
function bundleText(name) {
22-
const dir = join(__dirname, 'dist', name);
23-
return readdirSync(dir)
24-
.map(f => readFileSync(join(dir, f), 'utf8'))
21+
const files = [];
22+
const walk = dir => {
23+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
24+
const full = join(dir, entry.name);
25+
if (entry.isDirectory()) {
26+
walk(full);
27+
} else {
28+
files.push(full);
29+
}
30+
}
31+
};
32+
walk(join(__dirname, 'dist', name));
33+
return files
34+
.map(f => readFileSync(f, 'utf8'))
2535
.join('\n')
2636
.replace(/\s+/g, '');
2737
}
@@ -36,10 +46,7 @@ function check(condition, message) {
3646
const plain = bundleText('plain');
3747
const plugin = bundleText('plugin');
3848

39-
check(
40-
!plain.includes(BUILD_TIME_TRANSFORM_MARKER),
41-
'plain build (no plugin) does not run build-time instrumentation',
42-
);
49+
check(!plain.includes(BUILD_TIME_TRANSFORM_MARKER), 'plain build (no plugin) does not run build-time instrumentation');
4350
check(
4451
plugin.includes(BUILD_TIME_TRANSFORM_MARKER),
4552
'sentryRollupPlugin runs build-time instrumentation (injects the orchestrion banner)',

‎dev-packages/e2e-tests/test-applications/node-rolldown/build.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// - `plain`: no Sentry plugin.
33
// - `plugin`: with `sentryRollupPlugin` (build-time instrumentation).
44
// Only the `plugin` build runs the orchestrion code transform, which prepends the "bundler ran"
5-
// banner to the entry chunk. Kept unminified so assert.mjs can match the banner verbatim.
5+
// banner to the entry chunk. Kept unminified so the banner keeps its identifiers (a minifier would
6+
// rename them); assert.mjs matches it whitespace-insensitively.
67
// Rolldown is Rollup API-compatible, so it consumes the same `@sentry/node/rollup` plugin; it also
78
// resolves node modules and CommonJS natively, so no extra resolve/commonjs plugins are needed.
89
import { builtinModules } from 'node:module';

‎dev-packages/e2e-tests/test-applications/node-rollup/assert.mjs‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,20 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
1818
const BUILD_TIME_TRANSFORM_MARKER = 'g.bundler=g.bundler||[]';
1919

2020
function bundleText(name) {
21-
const dir = join(__dirname, 'dist', name);
22-
return readdirSync(dir)
23-
.map(f => readFileSync(join(dir, f), 'utf8'))
21+
const files = [];
22+
const walk = dir => {
23+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
24+
const full = join(dir, entry.name);
25+
if (entry.isDirectory()) {
26+
walk(full);
27+
} else {
28+
files.push(full);
29+
}
30+
}
31+
};
32+
walk(join(__dirname, 'dist', name));
33+
return files
34+
.map(f => readFileSync(f, 'utf8'))
2435
.join('\n')
2536
.replace(/\s+/g, '');
2637
}
@@ -35,10 +46,7 @@ function check(condition, message) {
3546
const plain = bundleText('plain');
3647
const plugin = bundleText('plugin');
3748

38-
check(
39-
!plain.includes(BUILD_TIME_TRANSFORM_MARKER),
40-
'plain build (no plugin) does not run build-time instrumentation',
41-
);
49+
check(!plain.includes(BUILD_TIME_TRANSFORM_MARKER), 'plain build (no plugin) does not run build-time instrumentation');
4250
check(
4351
plugin.includes(BUILD_TIME_TRANSFORM_MARKER),
4452
'sentryRollupPlugin runs build-time instrumentation (injects the orchestrion banner)',

‎dev-packages/e2e-tests/test-applications/node-rollup/build.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// - `plain`: no Sentry plugin.
33
// - `plugin`: with `sentryRollupPlugin` (build-time instrumentation).
44
// Only the `plugin` build runs the orchestrion code transform, which prepends the "bundler ran"
5-
// banner to the entry chunk. Kept unminified so assert.mjs can match the banner verbatim.
5+
// banner to the entry chunk. Kept unminified so the banner keeps its identifiers (a minifier would
6+
// rename them); assert.mjs matches it whitespace-insensitively.
67
import { builtinModules } from 'node:module';
78
import { dirname, join } from 'node:path';
89
import { fileURLToPath } from 'node:url';

‎dev-packages/e2e-tests/test-applications/node-vite/assert.mjs‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Asserts that `sentryVitePlugin` performs build-time instrumentation: its code transform injects the
3-
* orchestrion "bundler ran" banner into the entry chunk. A plain build (no plugin) does not.
2+
* Asserts that `sentryVitePlugin` performs build-time instrumentation: its code transform injects
3+
* the orchestrion "bundler ran" banner into the entry chunk. A plain build (no plugin) does not.
44
*
55
* @module
66
*/
@@ -18,9 +18,20 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
1818
const BUILD_TIME_TRANSFORM_MARKER = 'g.bundler=g.bundler||[]';
1919

2020
function bundleText(name) {
21-
const dir = join(__dirname, 'dist', name);
22-
return readdirSync(dir)
23-
.map(f => readFileSync(join(dir, f), 'utf8'))
21+
const files = [];
22+
const walk = dir => {
23+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
24+
const full = join(dir, entry.name);
25+
if (entry.isDirectory()) {
26+
walk(full);
27+
} else {
28+
files.push(full);
29+
}
30+
}
31+
};
32+
walk(join(__dirname, 'dist', name));
33+
return files
34+
.map(f => readFileSync(f, 'utf8'))
2435
.join('\n')
2536
.replace(/\s+/g, '');
2637
}
@@ -35,10 +46,7 @@ function check(condition, message) {
3546
const plain = bundleText('plain');
3647
const plugin = bundleText('plugin');
3748

38-
check(
39-
!plain.includes(BUILD_TIME_TRANSFORM_MARKER),
40-
'plain build (no plugin) does not run build-time instrumentation',
41-
);
49+
check(!plain.includes(BUILD_TIME_TRANSFORM_MARKER), 'plain build (no plugin) does not run build-time instrumentation');
4250
check(
4351
plugin.includes(BUILD_TIME_TRANSFORM_MARKER),
4452
'sentryVitePlugin runs build-time instrumentation (injects the orchestrion banner)',

‎dev-packages/e2e-tests/test-applications/node-vite/build.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
// The Sentry vite plugin's build-time code transform only applies to server builds (it gates itself
55
// on `consumer === 'server'`), so this uses an SSR build rather than a client `lib` build. Only the
66
// `plugin` build then injects the orchestrion "bundler ran" banner into the entry chunk. Kept
7-
// unminified so assert.mjs can match the banner verbatim.
7+
// unminified so the banner keeps its identifiers (a minifier would rename them); assert.mjs matches
8+
// it whitespace-insensitively.
89
import { builtinModules } from 'node:module';
910
import { dirname, join } from 'node:path';
1011
import { fileURLToPath } from 'node:url';

‎dev-packages/e2e-tests/test-applications/node-webpack/assert.mjs‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,20 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
1818
const BUILD_TIME_TRANSFORM_MARKER = 'g.bundler=g.bundler||[]';
1919

2020
function bundleText(name) {
21-
const dir = join(__dirname, 'dist', name);
22-
return readdirSync(dir)
23-
.map(f => readFileSync(join(dir, f), 'utf8'))
21+
const files = [];
22+
const walk = dir => {
23+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
24+
const full = join(dir, entry.name);
25+
if (entry.isDirectory()) {
26+
walk(full);
27+
} else {
28+
files.push(full);
29+
}
30+
}
31+
};
32+
walk(join(__dirname, 'dist', name));
33+
return files
34+
.map(f => readFileSync(f, 'utf8'))
2435
.join('\n')
2536
.replace(/\s+/g, '');
2637
}
@@ -35,10 +46,7 @@ function check(condition, message) {
3546
const plain = bundleText('plain');
3647
const plugin = bundleText('plugin');
3748

38-
check(
39-
!plain.includes(BUILD_TIME_TRANSFORM_MARKER),
40-
'plain build (no plugin) does not run build-time instrumentation',
41-
);
49+
check(!plain.includes(BUILD_TIME_TRANSFORM_MARKER), 'plain build (no plugin) does not run build-time instrumentation');
4250
check(
4351
plugin.includes(BUILD_TIME_TRANSFORM_MARKER),
4452
'sentryWebpackPlugin runs build-time instrumentation (injects the orchestrion banner)',

‎dev-packages/e2e-tests/test-applications/node-webpack/build.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// - `plain`: no Sentry plugin.
33
// - `plugin`: with `sentryWebpackPlugin` (build-time instrumentation).
44
// Only the `plugin` build runs the orchestrion code transform, which injects the "bundler ran" banner
5-
// into the entry chunk. Kept unminified so assert.mjs can match the banner verbatim.
5+
// into the entry chunk. Kept unminified so the banner keeps its identifiers (a minifier would
6+
// rename them); assert.mjs matches it whitespace-insensitively.
67
import { dirname, join } from 'node:path';
78
import { fileURLToPath } from 'node:url';
89
import webpack from 'webpack';

0 commit comments

Comments
 (0)