-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: Add tslib dependecy for next.js + fixes #3487
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
size-limit report
|
packages/nextjs/src/utils/config.ts
Outdated
// In case we inject our client config, we need to add it after the frontend code | ||
// otherwise the runtime config isn't loaded. See: https://github.com/getsentry/sentry-javascript/issues/3485 | ||
const isClient = injectee === './sentry.client.config.js'; | ||
|
||
// Object -> Add it | ||
if (injectedInto != null && typeof injectedInto == 'object' && !Array.isArray(injectedInto)) { | ||
let importVal: string | string[] | EntryPointObject; | ||
if (typeof injectedInto.import === 'string') { | ||
importVal = isClient ? [injectedInto.import, injectee] : [injectee, injectedInto.import]; | ||
} else { | ||
// If it's not a string, the inner value is an array | ||
importVal = isClient ? [...injectedInto.import, injectee] : [injectee, ...injectedInto.import]; | ||
} | ||
|
||
injectedInto = { | ||
...injectedInto, | ||
import: importVal, | ||
}; | ||
} | ||
|
||
// Array -> Add it | ||
if (Array.isArray(injectedInto)) { | ||
injectedInto = isClient ? [...injectedInto, injectee] : [injectee, ...injectedInto]; | ||
} | ||
|
||
// String -> We need to make it an array | ||
if (typeof injectedInto === 'string') { | ||
injectedInto = isClient ? [injectedInto, injectee] : [injectee, injectedInto]; | ||
} | ||
|
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.
Having a few ifs
here makes it easier to understand what's happening. Especially with the client/server different inject order now.
entryProperty[injectionPoint] = injectedInto; | ||
}; | ||
|
||
const injectSentry = async (origEntryProperty: EntryProperty, isServer: boolean): Promise<EntryProperty> => { | ||
// Out of the box, nextjs uses the `() => Promise<EntryPropertyObject>)` flavor of EntryProperty, where the returned | ||
// object has string arrays for values. But because we don't know whether someone else has come along before us and | ||
// changed that, we need to check a few things along the way. | ||
// object has string arrays for values. |
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 have the same sentence below: repetition.
Co-authored-by: iker barriocanal <32816711+iker-barriocanal@users.noreply.github.com>
Fixes #3486
Fixes #3485