Skip to content

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

Merged
merged 6 commits into from
Apr 30, 2021
Merged

fix: Add tslib dependecy for next.js + fixes #3487

merged 6 commits into from
Apr 30, 2021

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.

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.
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 and others added 2 commits April 30, 2021 11:45
Co-authored-by: iker barriocanal <32816711+iker-barriocanal@users.noreply.github.com>
@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
2 participants