File tree Expand file tree Collapse file tree
dev-packages/rollup-utils/plugins Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,18 +63,19 @@ export function makeIsDebugBuildPlugin(includeDebugging) {
6363}
6464
6565/**
66- * Replaces the comment marker `/* __SENTRY_SDK_SOURCE__ *\/` in core's `getSDKSource()` with a
66+ * Replaces the comment marker `/*! __SENTRY_SDK_SOURCE__ *\/` in core's `getSDKSource()` with a
6767 * `return '<source>';` statement so the bundle reports the correct distribution channel.
6868 *
69- * Because the marker is a block comment, esbuild would strip it during transpile — so the plugin
70- * sort order in utils.mjs pins this name before `esbuild`.
69+ * The marker uses the `/*! ... *\/` legal-comment syntax so it survives esbuild's transpile
70+ * (esbuild strips ordinary block comments). The plugin sort order in utils.mjs also pins
71+ * this name before `esbuild`, in case it ever runs on un-transpiled source directly.
7172 */
7273export function makeSetSDKSourcePlugin ( sdkSource ) {
7374 const plugin = replace ( {
7475 preventAssignment : false ,
7576 delimiters : [ '' , '' ] ,
7677 values : {
77- '/* __SENTRY_SDK_SOURCE__ */' : `return ${ JSON . stringify ( sdkSource ) } ;` ,
78+ '/*! __SENTRY_SDK_SOURCE__ */' : `return ${ JSON . stringify ( sdkSource ) } ;` ,
7879 } ,
7980 } ) ;
8081 plugin . name = 'replace-sdk-source' ;
Original file line number Diff line number Diff line change @@ -121,12 +121,14 @@ export function makeDebugBuildStatementReplacePlugin() {
121121}
122122
123123export function makeProductionReplacePlugin ( ) {
124- const pattern = / \/ \* r o l l u p - i n c l u d e - d e v e l o p m e n t - o n l y \* \/ [ \s \S ] * ?\/ \* r o l l u p - i n c l u d e - d e v e l o p m e n t - o n l y - e n d \* \/ \s * / g;
125-
126- // Must run as a `transform` (per-module) hook rather than `renderChunk`: esbuild
127- // strips arbitrary block comments during transpile, so by the time `renderChunk`
128- // would fire, the `rollup-include-development-only` marker comments are gone.
124+ // Markers use the `/*! ... */` legal-comment syntax so esbuild preserves them through
125+ // transpile. We still run as a `transform` (per-module) hook rather than `renderChunk`:
126+ // the block typically uses imports declared at the module top, and stripping it before
127+ // rollup analyses module-graph imports lets those now-unused imports be tree-shaken away.
129128 // The plugin sort order in utils.mjs pins this before `esbuild`.
129+ const pattern =
130+ / \/ \* ! r o l l u p - i n c l u d e - d e v e l o p m e n t - o n l y \* \/ [ \s \S ] * ?\/ \* ! r o l l u p - i n c l u d e - d e v e l o p m e n t - o n l y - e n d \* \/ \s * / g;
131+
130132 return {
131133 name : 'remove-dev-mode-blocks' ,
132134 transform ( code ) {
Original file line number Diff line number Diff line change @@ -98,15 +98,15 @@ export function init(options: BrowserOptions = {}): Client | undefined {
9898 let defaultIntegrations =
9999 options . defaultIntegrations == null ? getDefaultIntegrations ( options ) : options . defaultIntegrations ;
100100
101- /* rollup-include-development-only */
101+ /*! rollup-include-development-only */
102102 if ( options . spotlight ) {
103103 if ( ! defaultIntegrations ) {
104104 defaultIntegrations = [ ] ;
105105 }
106106 const args = typeof options . spotlight === 'string' ? { sidecarUrl : options . spotlight } : undefined ;
107107 defaultIntegrations . push ( spotlightBrowserIntegration ( args ) ) ;
108108 }
109- /* rollup-include-development-only-end */
109+ /*! rollup-include-development-only-end */
110110
111111 const clientOptions : BrowserClientOptions = {
112112 ...options ,
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ export function isBrowserBundle(): boolean {
3030 * Get source of SDK.
3131 */
3232export function getSDKSource ( ) : SdkSource {
33- // This comment is used to identify this line in the CDN bundle build step and replace this with "return 'cdn';"
34- /* __SENTRY_SDK_SOURCE__ */ return 'npm' ;
33+ // The `/*! ... */` marker is replaced by our CDN bundle build step with `return 'cdn';`.
34+ // It uses the `/*!` legal-comment syntax specifically so it survives esbuild's transpile
35+ // (which strips ordinary `/* ... */` block comments).
36+ /*! __SENTRY_SDK_SOURCE__ */ return 'npm' ;
3537}
You can’t perform that action at this time.
0 commit comments