build(utils): Add build constant for cdn vs. npm bundles#6904
build(utils): Add build constant for cdn vs. npm bundles#6904AbhiPrasad merged 4 commits intomasterfrom
Conversation
rollup/bundleHelpers.js
Outdated
| entryFileNames: chunkInfo => `${baseConfig.output.entryFileNames(chunkInfo)}.min.js`, | ||
| }, | ||
| plugins: [stripDebuggingPlugin, terserPlugin], | ||
| plugins: [stripDebuggingPlugin, terserPlugin, isCDNBundlePlugin], |
There was a problem hiding this comment.
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.
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.
IIRC the replace plugin wants us to set some preventAssignment option. I would set it to false here.
Lms24
left a comment
There was a problem hiding this comment.
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
Lms24
left a comment
There was a problem hiding this comment.
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'.npmandcdnare filled in at build time, andloaderwill be added via a global flag that the loader itself will set. More details on this soon.