GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat(bundler-plugins): Add the call-site rewriter core by timfish · Pull Request #26101 · getsentry/sentry-javascript Conversation
|
size-limit report 📦Compared: 42a4a6f (PR test merge using develop at a12f1aa) Against: a12f1aa (develop) · base run #68171 ✅ Baseline matches: this diff contains only this PR's changes.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Optional E2E testsSome optional checks were not successful. They do not block the merge. 7 not successful, 49 successful. See the run.
Successful checks
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
03fd861 to
d2efbeb
Compare
fe24b4d to
8b2355d
Compare
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Stale Bugbot comment from a previous run.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (include.basename && !include.basename.test(basename(id))) return false; | ||
| if (include.contains && !include.contains.every(substring => code.includes(substring))) return false; | ||
| return true; | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Medium Severity
matches tests include.id and include.basename against the raw module id, while langFromId already strips query and hash via stripUrlQueryAndFragment. Vite IDs commonly look like +page.ts?t=123 or file.ts?v=hash, so patterns such as /\.ts$/ and /^\+page\.ts$/ fail to match and the module is left uninstrumented.
Reviewed by Cursor Bugbot for commit 8b2355d. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The SDK plugins test the raw id on develop too, so this keeps current behaviour; query ids can come in a follow-up.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (classNode.id?.name) classes.set(classNode.id.name, classNode); | ||
| } | ||
| return classes; | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Medium Severity
collectTopLevelClasses and findClassesExtending unwrap only export class via declarationOf, so export default class Foo extends Base {} never enters the class map. shapeFromAst in the same package does record that form. Callers that wrap named re-exports of Foo then miss the local class, skip wrappedLocals, and can wrap the default export a second time.
Reviewed by Cursor Bugbot for commit 8b2355d. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This code moved unchanged from the Cloudflare plugin on develop, so it is not new in this PR.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| "types": "./build/types/rewriter/index.d.ts", | ||
| "import": "./build/esm/rewriter/index.js", | ||
| "require": "./build/cjs/rewriter/index.js" | ||
| }, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Low Severity
This was flagged because it is called out in the review rules file: a new ./rewriter export that can load on Node, while @sentry/bundler-plugins has no entry in CASES or BUILD_TIME_CASES in dev-packages/bundler-tests/tests/runtime-entries.test.ts. That test is what keeps server runtime entries from pulling in build-time tooling.
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit 8b2355d. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
./rewriter is build-time code that only the SDK Vite plugins import, and BUILD_TIME_PATTERNS already fails any runtime entry that pulls in @sentry/bundler-plugins.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| return wrappedName ? `${wrappedName} as ${name}` : name; | ||
| }); | ||
| // A second call for another name of this declaration overwrites the same range again. | ||
| state.ms.overwrite(exportNode.start, declaration.start, `export { ${specifiers.join(', ')} };\n`); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
In Cloudflare we have wrapInlineClassExport, keep in mind that the snippet right now does not support classes as it would cut the class keyword from the export.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This only replaces the export text before the class, so the class keyword stays (export class A {} becomes export { __SENTRY_WRAPPED_A__ as A }; then class A {}). Testing it did show that @dec export class A {} gave invalid output. b449f6a now puts the export clause before the decorators and adds tests.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
b449f6a to
65ef1b6
Compare
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Stale Bugbot comment from a previous run.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| /** The declaration a top-level statement makes, looking through `export` (`export const x = ...`). */ | ||
| export function declarationOf(node: BaseNode): BaseNode | null | undefined { | ||
| return node.type === 'ExportNamedDeclaration' ? (node as ExportNamedNode).declaration : node; | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Medium Severity
declarationOf only unwraps ExportNamedDeclaration, so findClassesExtending, collectTopLevelClasses, and collectDeclaringStatements never see export default class Foo {} or export default function foo() {}. shapeFromAst already records those named default classes, so the collectors disagree on the same module. A default-exported WorkerEntrypoint subclass is a common Cloudflare form and would not be found.
Reviewed by Cursor Bugbot for commit 65ef1b6. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The Cloudflare class scans on develop also skip export default class, so this is not new in this PR.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const warning = formatReport(state.report, id); | ||
| if (warning) options.logger?.warn(warning); | ||
| if (!state.ms.hasChanged()) return null; | ||
| return { code: state.ms.toString(), map: state.ms.generateMap({ hires: true }) }; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Low Severity
generateMap is called with only hires: true, even though transform already has the module id. MagicString then emits sources: [null] and no sourcesContent. The component-annotation transform in this same package passes source and includeContent so composed maps keep a real path. Debuggers and overlay tools can fail to map rewritten frames back to the user file.
Reviewed by Cursor Bugbot for commit 65ef1b6. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This matches the generateMap({ hires: true }) call the Cloudflare and SvelteKit plugins use on develop, and Vite fills in the source path when it combines the maps.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
65ef1b6 to
5ec67be
Compare
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Stale Bugbot comment from a previous run.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| const wrappedName = `__SENTRY_WRAPPED_${localName}__`; | ||
| state.wrappedLocals.set(localName, wrappedName); | ||
| state.ms.appendLeft(declaringNode.end, `\nconst ${wrappedName} = ${wrap(localName)};\n`); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Medium Severity
wrapLocalBinding always binds the wrapper with const, and wrapInlineExport re-points the export at that binding. A hoisted export function is then a live binding to a const still in the temporal dead zone, so a circular import that previously read the function during evaluation now throws and can stop the module from loading. The default-export path already uses var for this reason.
Reviewed by Cursor Bugbot for commit 5ec67be. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
A circular import that calls an entry export or load while its module is still loading is rare enough that we keep const, since var would only trade the error for undefined.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const decorators = state.ms.original.slice(start, exportNode.start); | ||
| // A second call for another name of this declaration overwrites the same range again. | ||
| state.ms.overwrite(start, declaration.start, `export { ${specifiers.join(', ')} };\n${decorators}`); | ||
| return true; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Medium Severity
wrapInlineExport treats every export function with a matching name as a runtime declaration, including TypeScript overload signatures that have no body. Combined with findNamedExports, wrapping load emits a second export { __SENTRY_WRAPPED_load__ as load } and inserts const __SENTRY_WRAPPED_load__ = wrap(load) between the overload and its implementation, which is invalid TypeScript and a duplicate export.
Reviewed by Cursor Bugbot for commit 5ec67be. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Overload signatures parse as TSDeclareFunction, which declaredNames skips, so only the implementation is wrapped once and the signature is stripped with the other types.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
3208230 to
f96f39e
Compare
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 8 total unresolved issues (including 7 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f96f39e. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const wrappedName = `__SENTRY_WRAPPED_${exportedAs}__`; | ||
| prelude.push(`const ${wrappedName} = ${wrap(target)};`); | ||
| state.needsImport = true; | ||
| return `${wrappedName} as ${exportedAs}`; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Medium Severity
exportedName() now unwraps string literal export and import names, but wrapForeignExport and importAs interpolate those values as bare identifiers. String names that are not valid identifiers, including reserved words, produce invalid import/export clauses and broken __SENTRY_* bindings. The previous Identifier-only path left those specifiers unchanged.
Reviewed by Cursor Bugbot for commit f96f39e. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The Cloudflare and SvelteKit callers only pass identifier names to these helpers and skip string-literal locals, so no generated clause gets a name that needs quotes.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Three SDKs rewrite user modules at build time with three parsers and their own export handling. Fixes for one export form landed in one SDK only. This adds one core under `@sentry/bundler-plugins/rewriter` for them to share. It parses with oxc, so raw TypeScript parses too, and it keeps the edits in one MagicString, so every rewrite carries a source map. When the plugin context is Rolldown's, the host parses with its `this.parse`, which reads TypeScript. Rollup's cannot, so other bundlers parse with oxc. oxc loads with a dynamic import, so a platform without its native binary gets a warning and unchanged modules instead of a failed build.
CodeQL flagged `/[?#].*$/` as slow on ids with many `#` characters. `stripUrlQueryAndFragment` from `@sentry/core` splits at the first `?` or `#` instead.
…inline class export
768623f to
f54f2e3
Compare
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.