-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
build(utils): Add build constant for cdn vs. npm bundles #6904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
rollup/bundleHelpers.js
Outdated
}, | ||
|
||
'.min.js': { | ||
output: { | ||
entryFileNames: chunkInfo => `${baseConfig.output.entryFileNames(chunkInfo)}.min.js`, | ||
}, | ||
plugins: [stripDebuggingPlugin, terserPlugin], | ||
plugins: [stripDebuggingPlugin, terserPlugin, isCDNBundlePlugin], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably do this before terser minifies
rollup/plugins/bundlePlugins.js
Outdated
export function makeIsCDNBundlePlugin(isCDNBundle) { | ||
return replace({ | ||
values: { | ||
__SENTRY_CDN_BUNDLE__: isCDNBundle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could think about making it more explicit that this takes a string but I don't care too much: isCDNBundle ? 'true' : 'false'
rollup/plugins/bundlePlugins.js
Outdated
export function makeIsCDNBundlePlugin(isCDNBundle) { | ||
return replace({ | ||
values: { | ||
__SENTRY_CDN_BUNDLE__: isCDNBundle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC the replace plugin wants us to set some preventAssignment
option. I would set it to false here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should go with a non-boolean approach here. For instance, if we ever wanted to track loader vs regular CDN usage, we'd need to make some changes here. Not sure if I'm missing something but couldn't we just use the rollup replace plugin to replace something like __SDK_SOURCE__
with string literals ('npm' | 'cdn' | 'loader'
)?
adaee78
to
e18ec72
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for addressing my feedback!
ref: #6903
Add
__SENTRY_SDK_SOURCE__
that tracks the source of the sdk. Right now there are 3 specific values for this:'npm' | 'cdn' | 'loader'
.npm
andcdn
are filled in at build time, andloader
will be added via a global flag that the loader itself will set. More details on this soon.