-
Notifications
You must be signed in to change notification settings - Fork 50
ref(release-injector): Inject by importing in every module #24
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Lms24
approved these changes
Aug 22, 2022
Comment on lines
+32
to
+65
| * ```text | ||
| * index.js (user file) | ||
| * ┌───────────────────┐ ┌─────────────────────────────────────────────────┐ | ||
| * │ │ │ import { myFunction } from "./my-library.js"; │ | ||
| * │ sentry-unplugin │ │ │ | ||
| * │ │ │ const myResult = myFunction(); │ | ||
| * └---------│---------┘ │ export { myResult }; │ | ||
| * │ │ │ | ||
| * │ injects │ // injected by sentry-unplugin │ | ||
| * ├───────────────────► import "sentry-release-injector"; ─────────────────────┐ | ||
| * │ └─────────────────────────────────────────────────┘ │ | ||
| * │ │ | ||
| * │ │ | ||
| * │ my-library.js (user file) │ | ||
| * │ ┌─────────────────────────────────────────────────┐ │ | ||
| * │ │ export function myFunction() { │ │ | ||
| * │ │ return "Hello world!"; │ │ | ||
| * │ │ } │ │ | ||
| * │ │ │ │ | ||
| * │ injects │ // injected by sentry-unplugin │ │ | ||
| * └───────────────────► import "sentry-release-injector"; ─────────────────────┤ | ||
| * └─────────────────────────────────────────────────┘ │ | ||
| * │ | ||
| * │ | ||
| * sentry-release-injector │ | ||
| * ┌──────────────────────────────────┐ │ | ||
| * │ │ is resolved │ | ||
| * │ global.SENTRY_RELEASE = { ... } │ by unplugin │ | ||
| * │ // + a little more logic │<─────────────────────┘ | ||
| * │ │ (only once) | ||
| * └──────────────────────────────────┘ | ||
| * ``` | ||
| * | ||
| * Source maps upload: |
Member
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 love this, explains it very well!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR rethinks the entire approach of how we're injecting the global release variable. We're moving from prepending the injector code in entry files to injecting an import statement into all user files.
It sounds a bit dubious that we're injecting appending the same import to all user files but it has its reasons: With the way
unpluginand bundlers work, we do not always have the information we need to only inject code at the top of an entry file. ThetransformandtransformIncludehooks don't have any information as to whether a file is an entry file - so they need context from another hook for that. The only location where we can determine if a file is an entry file is theresolveIdhook - sadly in this hook, we do not have an guaranteed absolute path of the file we're looking at, which would require us to do a heuristic (usingprocess.cwd()) which isn't bulletproof.