Skip to content

Conversation

@HazAT
Copy link
Member

@HazAT HazAT commented Apr 30, 2021

Fixes #3486
Fixes #3485

@github-actions
Copy link
Contributor

github-actions bot commented Apr 30, 2021

size-limit report

Path Size
@sentry/browser - CDN Bundle (gzipped) 20.63 KB (-0.01% 🔽)
@sentry/browser - Webpack 21.5 KB (0%)
@sentry/react - Webpack 21.53 KB (0%)
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 27.92 KB (-0.01% 🔽)

@HazAT HazAT changed the title fix: Add tslib dependecy fix: Add tslib dependecy for next.js + fixes Apr 30, 2021
Comment on lines 41 to 70
// 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];
}

Copy link
Member Author

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.

// 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.
Copy link
Member Author

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.

@HazAT HazAT merged commit d5b335d into master Apr 30, 2021
@HazAT HazAT deleted the fix/tslib-nextjs branch April 30, 2021 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants