Skip to content

Commit f65f0e2

Browse files
committed
fix: spotlight shaking
1 parent 2e977f7 commit f65f0e2

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ export function makeDebugBuildStatementReplacePlugin() {
7373
}
7474

7575
export function makeProductionReplacePlugin() {
76-
const pattern = /\/\* rollup-include-development-only \*\/[\s\S]*?\/\* rollup-include-development-only-end \*\/\s*/g;
76+
// Use legal comments (/*!) so they're preserved by Rolldown
77+
// NOTE: Due to a Rolldown limitation, the ending comment must be placed before a statement
78+
// (e.g., before a return) rather than after a block, otherwise it gets stripped.
79+
// See: https://github.com/rolldown/rolldown/issues/[TODO: file issue]
80+
const pattern =
81+
/\/\*! rollup-include-development-only \*\/[\s\S]*?\/\*! rollup-include-development-only-end \*\/\s*/g;
7782

7883
function stripDevBlocks(code) {
7984
if (!code) return null;

packages/browser/src/sdk.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,14 @@ export function init(options: BrowserOptions = {}): Client | undefined {
9494
let defaultIntegrations =
9595
options.defaultIntegrations == null ? getDefaultIntegrations(options) : options.defaultIntegrations;
9696

97-
/* rollup-include-development-only */
97+
/*! rollup-include-development-only */
9898
if (options.spotlight) {
9999
if (!defaultIntegrations) {
100100
defaultIntegrations = [];
101101
}
102102
const args = typeof options.spotlight === 'string' ? { sidecarUrl: options.spotlight } : undefined;
103103
defaultIntegrations.push(spotlightBrowserIntegration(args));
104104
}
105-
/* rollup-include-development-only-end */
106105

107106
const clientOptions: BrowserClientOptions = {
108107
...options,
@@ -114,6 +113,9 @@ export function init(options: BrowserOptions = {}): Client | undefined {
114113
}),
115114
transport: options.transport || makeFetchTransport,
116115
};
116+
// TODO: This is here to avoid the Rolldown limitation of not being able to place the ending comment after a block
117+
// Should be moved back after the if block once the Rolldown limitation is fixed
118+
/*! rollup-include-development-only-end */
117119
return initAndBind(BrowserClient, clientOptions);
118120
}
119121

0 commit comments

Comments
 (0)