Skip to content
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

drop @bugsnag/core/(client|event|session) exports #2317

Merged
merged 8 commits into from
Feb 14, 2025

Conversation

djskinner
Copy link
Contributor

@djskinner djskinner commented Feb 10, 2025

Drop these importing directly from source and use the compiled assets in @bugsnag/core

I first tried to split this by doing client only first but there were issue where the client was then referring to the compiled version of Event whilst other places referred to a different Event, that of the source code

Copy link

github-actions bot commented Feb 10, 2025

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 77.20 kB 17.45 kB
After 51.47 kB 15.76 kB
± -25,734 bytes -1,691 bytes

code coverage diff

<temporarily disabled>

Generated by 🚫 dangerJS against dc7c41e

const external = [
'@bugsnag/cuid',
]
const external = [/node_modules/]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as i mentioned in previous PR i think its right that core externalises all its dependencies leaving the individual notifiers to bundle what they need

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be misunderstanding the point of the external dependencies, but why do we need node_modules here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement makes rollup treat all node_modules as external - see https://stackoverflow.com/questions/44844088/how-to-set-as-external-all-node-modules-in-rollup

This means that instead of pulling a load of code into the core bundle they contine to be referenced externally:

const require$$0 = require('error-stack-parser');
const StackGenerator = require('stack-generator');
const require$$2 = require('@bugsnag/safe-json-stringify');
const require$$0$1 = require('iserror');
const cuid = require('@bugsnag/cuid');

// esm version
import require$$0 from 'error-stack-parser';
import StackGenerator from 'stack-generator';
import require$$2 from '@bugsnag/safe-json-stringify';
import require$$0$1 from 'iserror';
import cuid from '@bugsnag/cuid';

The thing is if core copied @bugsnag/cuid into its bundle then a number of other plugins also did this then there would be multiple copies of @bugsnag/cuid code and what's more different instances of it which may cause issues in some situations.

What I'm saying is that for all these shared libraries like core and plugins that are consumed by multiple notifiers they should externalise all their dependencies. Then its left to the notifier builds themselves to pull in a single copy of every external dependency (as you would always want for a browser build). You may or may not want this for a node notifier build, but this gives use the option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, understood! that definitely makes sense then. thanks! 👍🏻

@@ -0,0 +1,115 @@
export interface Schema {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

schema is now being exported from @bugsnag/core - these are the manually crafted types for that (for now) - copied from the internal typings against the js source

Base automatically changed from plat-12947-5 to integration/typescript February 13, 2025 08:38
@djskinner djskinner changed the title remove @bugsnag/core/client export drop @bugsnag/core/(client|event|session) exports Feb 13, 2025
@@ -1,12 +1,10 @@
import ClientWithInternals from '@bugsnag/core/client'
import type { BugsnagStatic, Config, Client } from '@bugsnag/core'
import { BugsnagStatic, Config, Client, schema as baseConfig } from '@bugsnag/core'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also exporting schema now

@djskinner djskinner marked this pull request as ready for review February 13, 2025 15:46
@djskinner djskinner requested a review from gingerbenw February 13, 2025 15:46
@djskinner djskinner merged commit 419f45f into integration/typescript Feb 14, 2025
56 checks passed
@djskinner djskinner deleted the plat-12947-6 branch February 14, 2025 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants