fix(core): Avoid console output and telemetry init when plugins are disabled #741
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In #714, we extracted a lot of the plugin pre-initialization logic into the
createSentryBuildPluginManager
function. Only after this manager was created, we'd check for thedisabled
option. However, within the plugin manager creation function, we'd already do validation on passed options, as well as initialize the Sentry SDK. Which both previously only happened after we checked for disabled (h/t @s1gr1d and @Jimmy89 for finding this).This PR ensures we early-return within the
createSentryBuildPluginManager
function, so that we return a manager that no-ops in some methods. Not the prettiest solution in the world but unfortunately we have to normalize the user options first and merge them withprocess.env
and an optional.env
file, before we can reliably check fordisabled
. In the future, we could also returnundefined
increateSentryBuildPluginManager
in case of the plugin being disabled but this would be a breaking change and also somewhat inconvenient.Additionally, I refactored some of the return types to ensure we don't accidentally introduce breaking changes.
fixes #740