-
Notifications
You must be signed in to change notification settings - Fork 253
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
Refactor @bugsnag/browser #2252
base: integration/typescript
Are you sure you want to change the base?
Conversation
a04fe2c
to
1b9a68e
Compare
a881ec2
to
5519d06
Compare
9a4591e
to
7bbbff9
Compare
5519d06
to
08a3dc9
Compare
08a3dc9
to
8c78faf
Compare
jest.config.js
Outdated
@@ -49,7 +49,9 @@ module.exports = { | |||
'plugin-simple-throttle', | |||
'plugin-console-breadcrumbs', | |||
'plugin-browser-session' | |||
]), | |||
], { | |||
setupFiles: ['<rootDir>/jest/setup/mockEventTarget.js'] |
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.
See jsdom/jsdom#2156
This is needed to fix the TypeError: 'addEventListener' called on an object that is not a valid instance of EventTarget.
seen in the integration tests following the rollup changes
packages/browser/package.json
Outdated
"build:dist": "cross-env NODE_ENV=production bash -c '../../bin/bundle src/notifier.js --standalone=Bugsnag | ../../bin/extract-source-map dist/bugsnag.js'", | ||
"build:dist:min": "cross-env NODE_ENV=production bash -c '../../bin/bundle src/notifier.js --standalone=Bugsnag | ../../bin/minify dist/bugsnag.min.js'", |
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.
can these be removed?
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.
yep - and possibly the minification scripts, too?
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.
Not yet as they are being used for e.g. plugin-react and others
packages/browser/src/index-umd.ts
Outdated
export default assign(Bugsnag, { Client, Event, Session, Breadcrumb }) | ||
export type { BrowserBugsnagStatic, BrowserConfig } from './bugsnag' | ||
|
||
export type { Client, Event, Session, Breadcrumb, Plugin } from '@bugsnag/core' |
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.
Ideally we would do export type * from '@bugsnag/core'
but that's not supported with the current version of TypeScript we're using
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.
TODO: Check what other types need exporting here
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.
Actually I don't think any types need exporting from cjs/umd entry points
import pluginNavigationBreadcrumbs from '@bugsnag/plugin-navigation-breadcrumbs' | ||
import pluginInteractionBreadcrumbs from '@bugsnag/plugin-interaction-breadcrumbs' | ||
// @ts-ignore | ||
import pluginInlineScriptContent from '@bugsnag/plugin-inline-script-content' |
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 reverted the TS conversion of this plugin from this PR because it was broken
|
||
const sharedOutput = { | ||
...commonSharedOutput, | ||
strict: false, // 'use strict' in WebKit enables Tail Call Optimization, which breaks stack trace handling |
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.
There is one tail call in out stack and our depth handling does not handle it. With TCO enabled the stack frame for the tail call is removed, which then causes problems with stack processing leading to unexpected results (only in WebKit browsers since that's the only one supporting TCO):
Dropping 'use strict'
prevents TCO being enabled and resolves the issue
This reverts commit 0438ff1.
"@rollup/plugin-node-resolve": "^16.0.0", | ||
"@rollup/plugin-replace": "^6.0.2", | ||
"@rollup/plugin-terser": "^0.4.4", | ||
"tslib": "^2.8.1" |
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.
tslib is required for target: es3
Goal
This PR converts the last of the internal browser plugins and the browser client to TypeScript, using Rollup to bundle both common js and es modules
Following this work, we can then validate a flattened module (fesm) with a modern angular app
Design
Changeset
Testing
Existing test suite