From a8d5637a072422c19676cb57f416d29d23e94457 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 15 Oct 2024 09:24:58 +0100 Subject: [PATCH 01/15] chore: :construction_worker: install rollup --- .eslintrc.js | 3 +- .rollup/index.mjs | 52 +++++ package-lock.json | 581 ++++++++++++++++++++++++++++++++++++++++++---- package.json | 3 + 4 files changed, 594 insertions(+), 45 deletions(-) create mode 100644 .rollup/index.mjs diff --git a/.eslintrc.js b/.eslintrc.js index 5d56a803b8..4155e6cc3e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -44,7 +44,8 @@ module.exports = { parser: '@typescript-eslint/parser', parserOptions: { jsx: true, - ecmaVersion: 2018 + ecmaVersion: 2018, + sourceType: 'module' }, overrides: [ // linting for js files diff --git a/.rollup/index.mjs b/.rollup/index.mjs new file mode 100644 index 0000000000..cad6c32cb0 --- /dev/null +++ b/.rollup/index.mjs @@ -0,0 +1,52 @@ +import typescript from '@rollup/plugin-typescript' +import replace from '@rollup/plugin-replace' +import fs from 'fs' + +const defaultOptions = () => ({ + // additional variables to define with '@rollup/plugin-replace' + // e.g. '{ ABC: 123 }' is equivalent to running 'globalThis.ABC = 123' + additionalReplacements: {}, + // additional external dependencies, such as '@bugsnag/browser' + external: [], + // the entry point for the bundle + input: undefined, +}) + +function createRollupConfig (options = defaultOptions()) { + const packageJson = JSON.parse(fs.readFileSync(`${process.cwd()}/package.json`)) + + return { + input: options.input || 'src/index.ts', + output: { + dir: 'dist', + format: 'esm', + preserveModules: true, + generatedCode: { + preset: 'es2015', + }, + }, + external: ['@bugsnag/core'].concat(options.external), + plugins: [ + replace({ + preventAssignment: true, + values: { + __VERSION__: packageJson.version, + ...options.additionalReplacements, + }, + }), + typescript({ + // don't output anything if there's a TS error + noEmitOnError: true, + // turn on declaration files and declaration maps + compilerOptions: { + declaration: true, + declarationMap: true, + emitDeclarationOnly: true, + declarationDir: 'dist/types', + }, + }), + ], + } +} + +export default createRollupConfig diff --git a/package-lock.json b/package-lock.json index 621182e084..afde1a31a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,6 +29,8 @@ "@babel/preset-typescript": "^7.23.3", "@cucumber/cucumber": "^7.2.1", "@jest-runner/electron": "^3.0.1", + "@rollup/plugin-replace": "^6.0.1", + "@rollup/plugin-typescript": "^12.1.0", "@types/jest": "^26.0.14", "@types/ncp": "^2.0.4", "@types/node": "^13.7.1", @@ -76,6 +78,7 @@ "react-native": "^0.63.4", "react-test-renderer": "^16.13.1", "rimraf": "^3.0.0", + "rollup": "^4.24.0", "semver": "^5.5.1", "source-map": "^0.5.7", "timekeeper": "^2.2.0", @@ -6750,9 +6753,9 @@ } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.15", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", - "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", "dev": true }, "node_modules/@jridgewell/trace-mapping": { @@ -9639,6 +9642,292 @@ "nanoid": "^3.1.15" } }, + "node_modules/@rollup/plugin-replace": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-6.0.1.tgz", + "integrity": "sha512-2sPh9b73dj5IxuMmDAsQWVFT7mR+yoHweBaXG2W/R8vQ+IWZlnaI7BR7J6EguVQUp1hd8Z7XuozpDjEKQAAC2Q==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "magic-string": "^0.30.3" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-replace/node_modules/magic-string": { + "version": "0.30.12", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.12.tgz", + "integrity": "sha512-Ea8I3sQMVXr8JhN4z+H/d8zwo+tYDgHE9+5G4Wnrwhs0gaK9fXTKx0Tw5Xwsd/bCPTTZNRAdpyzvoeORe9LYpw==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, + "node_modules/@rollup/plugin-typescript": { + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-12.1.0.tgz", + "integrity": "sha512-Kzs8KGJofe7cfTRODsnG1jNGxSvU8gVoNNd7Z/QaY25AYwe2LSSUpx/kPxqF38NYkpR8de3m51r9uwJpDlz6dg==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.1.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.14.0||^3.0.0||^4.0.0", + "tslib": "*", + "typescript": ">=3.7.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + }, + "tslib": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.2.tgz", + "integrity": "sha512-/FIdS3PyZ39bjZlwqFnWqCOVnW7o963LtKMwQOD0NhQqw22gSr2YY1afu3FxRip4ZCZNsD5jq6Aaz6QV3D/Njw==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.24.0.tgz", + "integrity": "sha512-Q6HJd7Y6xdB48x8ZNVDOqsbh2uByBhgK8PiQgPhwkIw/HC/YX5Ghq2mQY5sRMZWHb3VsFkWooUVOZHKr7DmDIA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.24.0.tgz", + "integrity": "sha512-ijLnS1qFId8xhKjT81uBHuuJp2lU4x2yxa4ctFPtG+MqEE6+C5f/+X/bStmxapgmwLwiL3ih122xv8kVARNAZA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.24.0.tgz", + "integrity": "sha512-bIv+X9xeSs1XCk6DVvkO+S/z8/2AMt/2lMqdQbMrmVpgFvXlmde9mLcbQpztXm1tajC3raFDqegsH18HQPMYtA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.24.0.tgz", + "integrity": "sha512-X6/nOwoFN7RT2svEQWUsW/5C/fYMBe4fnLK9DQk4SX4mgVBiTA9h64kjUYPvGQ0F/9xwJ5U5UfTbl6BEjaQdBQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.24.0.tgz", + "integrity": "sha512-0KXvIJQMOImLCVCz9uvvdPgfyWo93aHHp8ui3FrtOP57svqrF/roSSR5pjqL2hcMp0ljeGlU4q9o/rQaAQ3AYA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.24.0.tgz", + "integrity": "sha512-it2BW6kKFVh8xk/BnHfakEeoLPv8STIISekpoF+nBgWM4d55CZKc7T4Dx1pEbTnYm/xEKMgy1MNtYuoA8RFIWw==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.24.0.tgz", + "integrity": "sha512-i0xTLXjqap2eRfulFVlSnM5dEbTVque/3Pi4g2y7cxrs7+a9De42z4XxKLYJ7+OhE3IgxvfQM7vQc43bwTgPwA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.24.0.tgz", + "integrity": "sha512-9E6MKUJhDuDh604Qco5yP/3qn3y7SLXYuiC0Rpr89aMScS2UAmK1wHP2b7KAa1nSjWJc/f/Lc0Wl1L47qjiyQw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.24.0.tgz", + "integrity": "sha512-2XFFPJ2XMEiF5Zi2EBf4h73oR1V/lycirxZxHZNc93SqDN/IWhYYSYj8I9381ikUFXZrz2v7r2tOVk2NBwxrWw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.24.0.tgz", + "integrity": "sha512-M3Dg4hlwuntUCdzU7KjYqbbd+BLq3JMAOhCKdBE3TcMGMZbKkDdJ5ivNdehOssMCIokNHFOsv7DO4rlEOfyKpg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.24.0.tgz", + "integrity": "sha512-mjBaoo4ocxJppTorZVKWFpy1bfFj9FeCMJqzlMQGjpNPY9JwQi7OuS1axzNIk0nMX6jSgy6ZURDZ2w0QW6D56g==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.24.0.tgz", + "integrity": "sha512-ZXFk7M72R0YYFN5q13niV0B7G8/5dcQ9JDp8keJSfr3GoZeXEoMHP/HlvqROA3OMbMdfr19IjCeNAnPUG93b6A==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.24.0.tgz", + "integrity": "sha512-w1i+L7kAXZNdYl+vFvzSZy8Y1arS7vMgIy8wusXJzRrPyof5LAb02KGr1PD2EkRcl73kHulIID0M501lN+vobQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.24.0.tgz", + "integrity": "sha512-VXBrnPWgBpVDCVY6XF3LEW0pOU51KbaHhccHw6AS6vBWIC60eqsH19DAeeObl+g8nKAz04QFdl/Cefta0xQtUQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.24.0.tgz", + "integrity": "sha512-xrNcGDU0OxVcPTH/8n/ShH4UevZxKIO6HJFK0e15XItZP2UcaiLFd5kiX7hJnqCbSztUF8Qot+JWBC/QXRPYWQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.24.0.tgz", + "integrity": "sha512-fbMkAF7fufku0N2dE5TBXcNlg0pt0cJue4xBRE2Qc5Vqikxr4VCgKj/ht6SMdFcOacVA9rqF70APJ8RN/4vMJw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@rtsao/scc": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@rtsao/scc/-/scc-1.1.0.tgz", @@ -17175,23 +17464,6 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, - "node_modules/eslint-import-resolver-node/node_modules/resolve": { - "version": "1.22.8", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", - "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", - "dev": true, - "dependencies": { - "is-core-module": "^2.13.0", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - }, - "bin": { - "resolve": "bin/resolve" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/eslint-module-utils": { "version": "2.12.0", "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.12.0.tgz", @@ -17725,6 +17997,12 @@ "estree-is-identifier": "^1.0.0" } }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, "node_modules/esutils": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", @@ -33622,13 +33900,17 @@ "dev": true }, "node_modules/resolve": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", - "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", "dev": true, "dependencies": { - "is-core-module": "^2.2.0", - "path-parse": "^1.0.6" + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -33801,6 +34083,41 @@ "dev": true, "optional": true }, + "node_modules/rollup": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.24.0.tgz", + "integrity": "sha512-DOmrlGSXNk1DM0ljiQA+i+o0rSLhtii1je5wgk60j49d1jHT5YYttBv1iWOnYSTG+fZZESUOSNiAl89SIet+Cg==", + "dev": true, + "dependencies": { + "@types/estree": "1.0.6" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.24.0", + "@rollup/rollup-android-arm64": "4.24.0", + "@rollup/rollup-darwin-arm64": "4.24.0", + "@rollup/rollup-darwin-x64": "4.24.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.24.0", + "@rollup/rollup-linux-arm-musleabihf": "4.24.0", + "@rollup/rollup-linux-arm64-gnu": "4.24.0", + "@rollup/rollup-linux-arm64-musl": "4.24.0", + "@rollup/rollup-linux-powerpc64le-gnu": "4.24.0", + "@rollup/rollup-linux-riscv64-gnu": "4.24.0", + "@rollup/rollup-linux-s390x-gnu": "4.24.0", + "@rollup/rollup-linux-x64-gnu": "4.24.0", + "@rollup/rollup-linux-x64-musl": "4.24.0", + "@rollup/rollup-win32-arm64-msvc": "4.24.0", + "@rollup/rollup-win32-ia32-msvc": "4.24.0", + "@rollup/rollup-win32-x64-msvc": "4.24.0", + "fsevents": "~2.3.2" + } + }, "node_modules/rsvp": { "version": "4.8.5", "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", @@ -46406,9 +46723,9 @@ } }, "@jridgewell/sourcemap-codec": { - "version": "1.4.15", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", - "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", "dev": true }, "@jridgewell/trace-mapping": { @@ -48589,6 +48906,160 @@ "nanoid": "^3.1.15" } }, + "@rollup/plugin-replace": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-6.0.1.tgz", + "integrity": "sha512-2sPh9b73dj5IxuMmDAsQWVFT7mR+yoHweBaXG2W/R8vQ+IWZlnaI7BR7J6EguVQUp1hd8Z7XuozpDjEKQAAC2Q==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^5.0.1", + "magic-string": "^0.30.3" + }, + "dependencies": { + "magic-string": { + "version": "0.30.12", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.12.tgz", + "integrity": "sha512-Ea8I3sQMVXr8JhN4z+H/d8zwo+tYDgHE9+5G4Wnrwhs0gaK9fXTKx0Tw5Xwsd/bCPTTZNRAdpyzvoeORe9LYpw==", + "dev": true, + "requires": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + } + } + }, + "@rollup/plugin-typescript": { + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-12.1.0.tgz", + "integrity": "sha512-Kzs8KGJofe7cfTRODsnG1jNGxSvU8gVoNNd7Z/QaY25AYwe2LSSUpx/kPxqF38NYkpR8de3m51r9uwJpDlz6dg==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^5.1.0", + "resolve": "^1.22.1" + } + }, + "@rollup/pluginutils": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.2.tgz", + "integrity": "sha512-/FIdS3PyZ39bjZlwqFnWqCOVnW7o963LtKMwQOD0NhQqw22gSr2YY1afu3FxRip4ZCZNsD5jq6Aaz6QV3D/Njw==", + "dev": true, + "requires": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + } + }, + "@rollup/rollup-android-arm-eabi": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.24.0.tgz", + "integrity": "sha512-Q6HJd7Y6xdB48x8ZNVDOqsbh2uByBhgK8PiQgPhwkIw/HC/YX5Ghq2mQY5sRMZWHb3VsFkWooUVOZHKr7DmDIA==", + "dev": true, + "optional": true + }, + "@rollup/rollup-android-arm64": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.24.0.tgz", + "integrity": "sha512-ijLnS1qFId8xhKjT81uBHuuJp2lU4x2yxa4ctFPtG+MqEE6+C5f/+X/bStmxapgmwLwiL3ih122xv8kVARNAZA==", + "dev": true, + "optional": true + }, + "@rollup/rollup-darwin-arm64": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.24.0.tgz", + "integrity": "sha512-bIv+X9xeSs1XCk6DVvkO+S/z8/2AMt/2lMqdQbMrmVpgFvXlmde9mLcbQpztXm1tajC3raFDqegsH18HQPMYtA==", + "dev": true, + "optional": true + }, + "@rollup/rollup-darwin-x64": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.24.0.tgz", + "integrity": "sha512-X6/nOwoFN7RT2svEQWUsW/5C/fYMBe4fnLK9DQk4SX4mgVBiTA9h64kjUYPvGQ0F/9xwJ5U5UfTbl6BEjaQdBQ==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.24.0.tgz", + "integrity": "sha512-0KXvIJQMOImLCVCz9uvvdPgfyWo93aHHp8ui3FrtOP57svqrF/roSSR5pjqL2hcMp0ljeGlU4q9o/rQaAQ3AYA==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-arm-musleabihf": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.24.0.tgz", + "integrity": "sha512-it2BW6kKFVh8xk/BnHfakEeoLPv8STIISekpoF+nBgWM4d55CZKc7T4Dx1pEbTnYm/xEKMgy1MNtYuoA8RFIWw==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-arm64-gnu": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.24.0.tgz", + "integrity": "sha512-i0xTLXjqap2eRfulFVlSnM5dEbTVque/3Pi4g2y7cxrs7+a9De42z4XxKLYJ7+OhE3IgxvfQM7vQc43bwTgPwA==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-arm64-musl": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.24.0.tgz", + "integrity": "sha512-9E6MKUJhDuDh604Qco5yP/3qn3y7SLXYuiC0Rpr89aMScS2UAmK1wHP2b7KAa1nSjWJc/f/Lc0Wl1L47qjiyQw==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.24.0.tgz", + "integrity": "sha512-2XFFPJ2XMEiF5Zi2EBf4h73oR1V/lycirxZxHZNc93SqDN/IWhYYSYj8I9381ikUFXZrz2v7r2tOVk2NBwxrWw==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-riscv64-gnu": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.24.0.tgz", + "integrity": "sha512-M3Dg4hlwuntUCdzU7KjYqbbd+BLq3JMAOhCKdBE3TcMGMZbKkDdJ5ivNdehOssMCIokNHFOsv7DO4rlEOfyKpg==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-s390x-gnu": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.24.0.tgz", + "integrity": "sha512-mjBaoo4ocxJppTorZVKWFpy1bfFj9FeCMJqzlMQGjpNPY9JwQi7OuS1axzNIk0nMX6jSgy6ZURDZ2w0QW6D56g==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-x64-gnu": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.24.0.tgz", + "integrity": "sha512-ZXFk7M72R0YYFN5q13niV0B7G8/5dcQ9JDp8keJSfr3GoZeXEoMHP/HlvqROA3OMbMdfr19IjCeNAnPUG93b6A==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-x64-musl": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.24.0.tgz", + "integrity": "sha512-w1i+L7kAXZNdYl+vFvzSZy8Y1arS7vMgIy8wusXJzRrPyof5LAb02KGr1PD2EkRcl73kHulIID0M501lN+vobQ==", + "dev": true, + "optional": true + }, + "@rollup/rollup-win32-arm64-msvc": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.24.0.tgz", + "integrity": "sha512-VXBrnPWgBpVDCVY6XF3LEW0pOU51KbaHhccHw6AS6vBWIC60eqsH19DAeeObl+g8nKAz04QFdl/Cefta0xQtUQ==", + "dev": true, + "optional": true + }, + "@rollup/rollup-win32-ia32-msvc": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.24.0.tgz", + "integrity": "sha512-xrNcGDU0OxVcPTH/8n/ShH4UevZxKIO6HJFK0e15XItZP2UcaiLFd5kiX7hJnqCbSztUF8Qot+JWBC/QXRPYWQ==", + "dev": true, + "optional": true + }, + "@rollup/rollup-win32-x64-msvc": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.24.0.tgz", + "integrity": "sha512-fbMkAF7fufku0N2dE5TBXcNlg0pt0cJue4xBRE2Qc5Vqikxr4VCgKj/ht6SMdFcOacVA9rqF70APJ8RN/4vMJw==", + "dev": true, + "optional": true + }, "@rtsao/scc": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@rtsao/scc/-/scc-1.1.0.tgz", @@ -54822,17 +55293,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true - }, - "resolve": { - "version": "1.22.8", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", - "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", - "dev": true, - "requires": { - "is-core-module": "^2.13.0", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - } } } }, @@ -55200,6 +55660,12 @@ "estree-is-identifier": "^1.0.0" } }, + "estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, "esutils": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", @@ -67536,13 +68002,14 @@ "dev": true }, "resolve": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", - "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", "dev": true, "requires": { - "is-core-module": "^2.2.0", - "path-parse": "^1.0.6" + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" } }, "resolve-alpn": { @@ -67677,6 +68144,32 @@ } } }, + "rollup": { + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.24.0.tgz", + "integrity": "sha512-DOmrlGSXNk1DM0ljiQA+i+o0rSLhtii1je5wgk60j49d1jHT5YYttBv1iWOnYSTG+fZZESUOSNiAl89SIet+Cg==", + "dev": true, + "requires": { + "@rollup/rollup-android-arm-eabi": "4.24.0", + "@rollup/rollup-android-arm64": "4.24.0", + "@rollup/rollup-darwin-arm64": "4.24.0", + "@rollup/rollup-darwin-x64": "4.24.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.24.0", + "@rollup/rollup-linux-arm-musleabihf": "4.24.0", + "@rollup/rollup-linux-arm64-gnu": "4.24.0", + "@rollup/rollup-linux-arm64-musl": "4.24.0", + "@rollup/rollup-linux-powerpc64le-gnu": "4.24.0", + "@rollup/rollup-linux-riscv64-gnu": "4.24.0", + "@rollup/rollup-linux-s390x-gnu": "4.24.0", + "@rollup/rollup-linux-x64-gnu": "4.24.0", + "@rollup/rollup-linux-x64-musl": "4.24.0", + "@rollup/rollup-win32-arm64-msvc": "4.24.0", + "@rollup/rollup-win32-ia32-msvc": "4.24.0", + "@rollup/rollup-win32-x64-msvc": "4.24.0", + "@types/estree": "1.0.6", + "fsevents": "~2.3.2" + } + }, "rsvp": { "version": "4.8.5", "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", diff --git a/package.json b/package.json index 4357dc3afb..8b08634dcc 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,8 @@ "@babel/preset-typescript": "^7.23.3", "@cucumber/cucumber": "^7.2.1", "@jest-runner/electron": "^3.0.1", + "@rollup/plugin-replace": "^6.0.1", + "@rollup/plugin-typescript": "^12.1.0", "@types/jest": "^26.0.14", "@types/ncp": "^2.0.4", "@types/node": "^13.7.1", @@ -68,6 +70,7 @@ "react-native": "^0.63.4", "react-test-renderer": "^16.13.1", "rimraf": "^3.0.0", + "rollup": "^4.24.0", "semver": "^5.5.1", "source-map": "^0.5.7", "timekeeper": "^2.2.0", From 58187122e33da768f52f7d10c3a8f59ca1af90b7 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 15 Oct 2024 09:25:20 +0100 Subject: [PATCH 02/15] refactor: :recycle: convert plugin-window-onerror to typescript --- packages/plugin-window-onerror/package.json | 10 +++++-- .../rollup.config.npm.mjs | 5 ++++ .../{onerror.js => src/onerror.ts} | 27 ++++++++++++------- .../test/onerror.test.ts | 2 +- packages/plugin-window-onerror/tsconfig.json | 8 ++++++ tsconfig.json | 1 - 6 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 packages/plugin-window-onerror/rollup.config.npm.mjs rename packages/plugin-window-onerror/{onerror.js => src/onerror.ts} (75%) create mode 100644 packages/plugin-window-onerror/tsconfig.json diff --git a/packages/plugin-window-onerror/package.json b/packages/plugin-window-onerror/package.json index 72b7149a8b..75292fa336 100644 --- a/packages/plugin-window-onerror/package.json +++ b/packages/plugin-window-onerror/package.json @@ -1,7 +1,8 @@ { "name": "@bugsnag/plugin-window-onerror", "version": "8.0.0", - "main": "onerror.js", + "main": "dist/onerror.js", + "types": "dist/types/onerror.d.ts", "description": "@bugsnag/js plugin to report unhandled exceptions in browsers", "homepage": "https://www.bugsnag.com/", "repository": { @@ -12,7 +13,7 @@ "access": "public" }, "files": [ - "*.js" + "dist" ], "author": "Bugsnag", "license": "MIT", @@ -21,5 +22,10 @@ }, "peerDependencies": { "@bugsnag/core": "^8.0.0" + }, + "scripts": { + "build": "npm run build:npm", + "build:npm": "rollup --config rollup.config.npm.mjs", + "clean": "rm -rf dist/*" } } diff --git a/packages/plugin-window-onerror/rollup.config.npm.mjs b/packages/plugin-window-onerror/rollup.config.npm.mjs new file mode 100644 index 0000000000..356d458f94 --- /dev/null +++ b/packages/plugin-window-onerror/rollup.config.npm.mjs @@ -0,0 +1,5 @@ +import createRollupConfig from '../../.rollup/index.mjs' + +export default createRollupConfig({ + input: 'src/onerror.ts' +}) diff --git a/packages/plugin-window-onerror/onerror.js b/packages/plugin-window-onerror/src/onerror.ts similarity index 75% rename from packages/plugin-window-onerror/onerror.js rename to packages/plugin-window-onerror/src/onerror.ts index 2f25a10d0d..8f588900e8 100644 --- a/packages/plugin-window-onerror/onerror.js +++ b/packages/plugin-window-onerror/src/onerror.ts @@ -2,13 +2,18 @@ * Automatically notifies Bugsnag when window.onerror is called */ -module.exports = (win = window, component = 'window onerror') => ({ - load: (client) => { +import type { Client, Stackframe } from 'packages/core/types' + +export default (win = window, component = 'window onerror') => ({ + load: (client: Client) => { + // @ts-expect-error _config is private API if (!client._config.autoDetectErrors) return - if (!client._config.enabledErrorTypes.unhandledExceptions) return - function onerror (messageOrEvent, url, lineNo, charNo, error) { + // @ts-expect-error _config is private API + if (!client._config.enabledErrorTypes?.unhandledExceptions) return + function onerror (messageOrEvent: string | Event, url?: string, lineNo?: number, charNo?: number, error?: Error) { // Ignore errors with no info due to CORS settings - if (lineNo === 0 && /Script error\.?/.test(messageOrEvent)) { + if (lineNo === 0 && /Script error\.?/.test(messageOrEvent.toString())) { + // @ts-expect-error _logger is private API client._logger.warn('Ignoring cross-domain or eval script error. See docs: https://tinyurl.com/yy3rn63z') } else { // any error sent to window.onerror is unhandled and has severity=error @@ -41,11 +46,13 @@ module.exports = (win = window, component = 'window onerror') => ({ const name = messageOrEvent.type ? `Event: ${messageOrEvent.type}` : 'Error' // attempt to find a message from one of the conventional properties, but // default to empty string (the event will fill it with a placeholder) + // @ts-expect-error TODO: messageOrEvent has no message or detail property const message = messageOrEvent.message || messageOrEvent.detail || '' event = client.Event.create({ name, message }, true, handledState, component, 1) // provide the original thing onerror received – not our error-like object we passed to _notify + // @ts-expect-error originalError is readonly event.originalError = messageOrEvent // include the raw input as metadata – it might contain more info than we extracted @@ -60,7 +67,7 @@ module.exports = (win = window, component = 'window onerror') => ({ client._notify(event) } - if (typeof prevOnError === 'function') prevOnError.apply(this, arguments) + if (typeof prevOnError === 'function') prevOnError.apply(win, [messageOrEvent, url, lineNo, charNo, error]) } const prevOnError = win.onerror @@ -71,18 +78,20 @@ module.exports = (win = window, component = 'window onerror') => ({ // Sometimes the stacktrace has less information than was passed to window.onerror. // This function will augment the first stackframe with any useful info that was // received as arguments to the onerror callback. -const decorateStack = (stack, url, lineNo, charNo) => { - if (!stack[0]) stack.push({}) +const decorateStack = (stack: Stackframe[], url?: string, lineNo?: number, charNo?: number) => { + if (!stack[0]) stack.push({ file: '' }) const culprit = stack[0] if (!culprit.file && typeof url === 'string') culprit.file = url if (!culprit.lineNumber && isActualNumber(lineNo)) culprit.lineNumber = lineNo if (!culprit.columnNumber) { if (isActualNumber(charNo)) { culprit.columnNumber = charNo + // @ts-expect-error event.errorCharacter does not exist on type 'Event' (deprecated) } else if (window.event && isActualNumber(window.event.errorCharacter)) { + // @ts-expect-error event.errorCharacter does not exist on type 'Event' (deprecated) culprit.columnNumber = window.event.errorCharacter } } } -const isActualNumber = (n) => typeof n === 'number' && String.call(n) !== 'NaN' +const isActualNumber = (n: unknown): n is number => typeof n === 'number' && String.call(n) !== 'NaN' diff --git a/packages/plugin-window-onerror/test/onerror.test.ts b/packages/plugin-window-onerror/test/onerror.test.ts index 1bd7eeee27..b37b621d66 100644 --- a/packages/plugin-window-onerror/test/onerror.test.ts +++ b/packages/plugin-window-onerror/test/onerror.test.ts @@ -1,6 +1,6 @@ /* eslint-disable jest/no-commented-out-tests */ -import plugin from '../' +import plugin from '../src/onerror' import Client, { EventDeliveryPayload } from '@bugsnag/core/client' diff --git a/packages/plugin-window-onerror/tsconfig.json b/packages/plugin-window-onerror/tsconfig.json new file mode 100644 index 0000000000..c76cdab7cd --- /dev/null +++ b/packages/plugin-window-onerror/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src/**/*.ts"], + "compilerOptions": { + "target": "ES2020" + } +} + \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 08c8cd0543..6decaad4e2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -82,7 +82,6 @@ "packages/node", "packages/plugin-client-ip", "packages/plugin-window-unhandled-rejection", - "packages/plugin-window-onerror", "packages/plugin-strip-query-string", "packages/plugin-strip-project-root", "packages/plugin-interaction-breadcrumbs", From 546268e225f3f2ae6ab633612e3a65141cab0a52 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 15 Oct 2024 10:03:11 +0100 Subject: [PATCH 03/15] update rollup configuration --- .rollup/index.mjs | 14 +++++++----- packages/plugin-window-onerror/package.json | 7 ++++++ .../rollup.config.npm.mjs | 22 ++++++++++++++++++- packages/plugin-window-onerror/src/onerror.ts | 13 +++++------ 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/.rollup/index.mjs b/.rollup/index.mjs index cad6c32cb0..c630b5bc9d 100644 --- a/.rollup/index.mjs +++ b/.rollup/index.mjs @@ -10,6 +10,8 @@ const defaultOptions = () => ({ external: [], // the entry point for the bundle input: undefined, + // output directory for the bundle + output: undefined }) function createRollupConfig (options = defaultOptions()) { @@ -17,13 +19,13 @@ function createRollupConfig (options = defaultOptions()) { return { input: options.input || 'src/index.ts', - output: { + output: options.output || { dir: 'dist', format: 'esm', preserveModules: true, generatedCode: { preset: 'es2015', - }, + } }, external: ['@bugsnag/core'].concat(options.external), plugins: [ @@ -32,7 +34,7 @@ function createRollupConfig (options = defaultOptions()) { values: { __VERSION__: packageJson.version, ...options.additionalReplacements, - }, + } }), typescript({ // don't output anything if there's a TS error @@ -43,9 +45,9 @@ function createRollupConfig (options = defaultOptions()) { declarationMap: true, emitDeclarationOnly: true, declarationDir: 'dist/types', - }, - }), - ], + } + }) + ] } } diff --git a/packages/plugin-window-onerror/package.json b/packages/plugin-window-onerror/package.json index 75292fa336..f963156e9e 100644 --- a/packages/plugin-window-onerror/package.json +++ b/packages/plugin-window-onerror/package.json @@ -3,6 +3,13 @@ "version": "8.0.0", "main": "dist/onerror.js", "types": "dist/types/onerror.d.ts", + "exports": { + ".": { + "import": "./dist/onerror.mjs", + "require": "./dist/onerror.js", + "types": "./dist/types/onerror.d.ts" + } + }, "description": "@bugsnag/js plugin to report unhandled exceptions in browsers", "homepage": "https://www.bugsnag.com/", "repository": { diff --git a/packages/plugin-window-onerror/rollup.config.npm.mjs b/packages/plugin-window-onerror/rollup.config.npm.mjs index 356d458f94..f001dd2b87 100644 --- a/packages/plugin-window-onerror/rollup.config.npm.mjs +++ b/packages/plugin-window-onerror/rollup.config.npm.mjs @@ -1,5 +1,25 @@ import createRollupConfig from '../../.rollup/index.mjs' export default createRollupConfig({ - input: 'src/onerror.ts' + input: 'src/onerror.ts', + output: [ + { + dir: `dist`, + entryFileNames: '[name].js', + format: 'cjs', + preserveModules: true, + generatedCode: { + preset: 'es2015', + } + }, + { + dir: `dist`, + entryFileNames: '[name].mjs', + format: 'esm', + preserveModules: true, + generatedCode: { + preset: 'es2015', + } + } + ] }) diff --git a/packages/plugin-window-onerror/src/onerror.ts b/packages/plugin-window-onerror/src/onerror.ts index 8f588900e8..3bd872b17d 100644 --- a/packages/plugin-window-onerror/src/onerror.ts +++ b/packages/plugin-window-onerror/src/onerror.ts @@ -2,14 +2,14 @@ * Automatically notifies Bugsnag when window.onerror is called */ -import type { Client, Stackframe } from 'packages/core/types' +import type { Plugin, Stackframe } from 'packages/core/types' -export default (win = window, component = 'window onerror') => ({ - load: (client: Client) => { +export default (win = window, component = 'window onerror'): Plugin => ({ + load: (client) => { // @ts-expect-error _config is private API - if (!client._config.autoDetectErrors) return - // @ts-expect-error _config is private API - if (!client._config.enabledErrorTypes?.unhandledExceptions) return + if (!client._config.autoDetectErrors || !client._config.enabledErrorTypes?.unhandledExceptions) return + + const prevOnError = win.onerror function onerror (messageOrEvent: string | Event, url?: string, lineNo?: number, charNo?: number, error?: Error) { // Ignore errors with no info due to CORS settings if (lineNo === 0 && /Script error\.?/.test(messageOrEvent.toString())) { @@ -70,7 +70,6 @@ export default (win = window, component = 'window onerror') => ({ if (typeof prevOnError === 'function') prevOnError.apply(win, [messageOrEvent, url, lineNo, charNo, error]) } - const prevOnError = win.onerror win.onerror = onerror } }) From 7fe5c82d1987e8d8c14972ea82a37718f7e9eaeb Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 15 Oct 2024 10:08:14 +0100 Subject: [PATCH 04/15] install additional rollup plugins --- package-lock.json | 458 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 2 + 2 files changed, 452 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index afde1a31a0..13446a8965 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,6 +29,8 @@ "@babel/preset-typescript": "^7.23.3", "@cucumber/cucumber": "^7.2.1", "@jest-runner/electron": "^3.0.1", + "@rollup/plugin-commonjs": "^28.0.0", + "@rollup/plugin-node-resolve": "^15.3.0", "@rollup/plugin-replace": "^6.0.1", "@rollup/plugin-typescript": "^12.1.0", "@types/jest": "^26.0.14", @@ -4994,6 +4996,18 @@ "node": ">=8" } }, + "node_modules/@jest-runner/electron/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/@jest-runner/electron/node_modules/read-pkg": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", @@ -5725,6 +5739,18 @@ "node": ">=8" } }, + "node_modules/@jest/core/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/@jest/core/node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -6573,6 +6599,18 @@ "node": ">=8" } }, + "node_modules/@jest/transform/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/@jest/transform/node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -9642,6 +9680,86 @@ "nanoid": "^3.1.15" } }, + "node_modules/@rollup/plugin-commonjs": { + "version": "28.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-28.0.0.tgz", + "integrity": "sha512-BJcu+a+Mpq476DMXG+hevgPSl56bkUoi88dKT8t3RyUp8kGuOh+2bU8Gs7zXDlu+fyZggnJ+iOBGrb/O1SorYg==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "commondir": "^1.0.1", + "estree-walker": "^2.0.2", + "fdir": "^6.1.1", + "is-reference": "1.2.1", + "magic-string": "^0.30.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=16.0.0 || 14 >= 14.17" + }, + "peerDependencies": { + "rollup": "^2.68.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/magic-string": { + "version": "0.30.12", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.12.tgz", + "integrity": "sha512-Ea8I3sQMVXr8JhN4z+H/d8zwo+tYDgHE9+5G4Wnrwhs0gaK9fXTKx0Tw5Xwsd/bCPTTZNRAdpyzvoeORe9LYpw==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "15.3.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.3.0.tgz", + "integrity": "sha512-9eO5McEICxMzJpDW9OnMYSv4Sta3hmt7VtBFz5zR9273suNOydOyq/FrGeGy+KsTRFm8w0SLVhzig2ILFT63Ag==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-node-resolve/node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/@rollup/plugin-replace": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-6.0.1.tgz", @@ -9720,6 +9838,18 @@ } } }, + "node_modules/@rollup/pluginutils/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.24.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.24.0.tgz", @@ -11331,6 +11461,12 @@ "@types/react": "^16" } }, + "node_modules/@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true + }, "node_modules/@types/responselike": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.3.tgz", @@ -12469,6 +12605,18 @@ "node": ">= 8" } }, + "node_modules/anymatch/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/apache-md5": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/apache-md5/-/apache-md5-1.1.2.tgz", @@ -13341,6 +13489,18 @@ "node": ">=8.6" } }, + "node_modules/babel-jest/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/babel-jest/node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -18646,6 +18806,18 @@ "node": ">=8.6" } }, + "node_modules/fast-glob/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/fast-glob/node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -18788,6 +18960,20 @@ "pend": "~1.2.0" } }, + "node_modules/fdir": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.0.tgz", + "integrity": "sha512-3oB133prH1o4j/L5lLW7uOCF1PlD+/It2L0eL/iAqWMB91RBbqTewABqxhj0ibBd90EEmWZq7ntIWzVaWcXTGQ==", + "dev": true, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, "node_modules/figgy-pudding": { "version": "3.5.2", "resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.2.tgz", @@ -21407,6 +21593,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", + "dev": true + }, "node_modules/is-negative-zero": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.3.tgz", @@ -21488,6 +21680,15 @@ "integrity": "sha1-DFLlS8yjkbssSUsh6GJtczbG45c=", "dev": true }, + "node_modules/is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "dependencies": { + "@types/estree": "*" + } + }, "node_modules/is-regex": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", @@ -22506,6 +22707,18 @@ "node": ">=8" } }, + "node_modules/jest-config/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/jest-config/node_modules/pretty-format": { "version": "26.4.2", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-26.4.2.tgz", @@ -23186,6 +23399,18 @@ "node": ">=8" } }, + "node_modules/jest-haste-map/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/jest-haste-map/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -23827,6 +24052,18 @@ "node": ">=8" } }, + "node_modules/jest-message-util/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/jest-message-util/node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -25152,6 +25389,18 @@ "node": ">=8" } }, + "node_modules/jest-util/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/jest-util/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -32430,12 +32679,14 @@ "dev": true }, "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", "dev": true, + "optional": true, + "peer": true, "engines": { - "node": ">=8.6" + "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/jonschlinkert" @@ -33556,6 +33807,18 @@ "node": ">=8.10.0" } }, + "node_modules/readdirp/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/realpath-native": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/realpath-native/-/realpath-native-2.0.0.tgz", @@ -36520,6 +36783,18 @@ "node": ">=8.6" } }, + "node_modules/ts-loader/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/ts-loader/node_modules/semver": { "version": "7.6.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", @@ -45351,6 +45626,12 @@ "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, "read-pkg": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", @@ -45922,6 +46203,12 @@ "picomatch": "^2.0.5" } }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, "slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -46581,6 +46868,12 @@ "picomatch": "^2.0.5" } }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, "slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -48906,6 +49199,59 @@ "nanoid": "^3.1.15" } }, + "@rollup/plugin-commonjs": { + "version": "28.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-28.0.0.tgz", + "integrity": "sha512-BJcu+a+Mpq476DMXG+hevgPSl56bkUoi88dKT8t3RyUp8kGuOh+2bU8Gs7zXDlu+fyZggnJ+iOBGrb/O1SorYg==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^5.0.1", + "commondir": "^1.0.1", + "estree-walker": "^2.0.2", + "fdir": "^6.1.1", + "is-reference": "1.2.1", + "magic-string": "^0.30.3", + "picomatch": "^2.3.1" + }, + "dependencies": { + "magic-string": { + "version": "0.30.12", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.12.tgz", + "integrity": "sha512-Ea8I3sQMVXr8JhN4z+H/d8zwo+tYDgHE9+5G4Wnrwhs0gaK9fXTKx0Tw5Xwsd/bCPTTZNRAdpyzvoeORe9LYpw==", + "dev": true, + "requires": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + } + } + }, + "@rollup/plugin-node-resolve": { + "version": "15.3.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.3.0.tgz", + "integrity": "sha512-9eO5McEICxMzJpDW9OnMYSv4Sta3hmt7VtBFz5zR9273suNOydOyq/FrGeGy+KsTRFm8w0SLVhzig2ILFT63Ag==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "dependencies": { + "deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true + } + } + }, "@rollup/plugin-replace": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-6.0.1.tgz", @@ -48946,6 +49292,14 @@ "@types/estree": "^1.0.0", "estree-walker": "^2.0.2", "picomatch": "^2.3.1" + }, + "dependencies": { + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + } } }, "@rollup/rollup-android-arm-eabi": { @@ -50313,6 +50667,12 @@ "@types/react": "^16" } }, + "@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true + }, "@types/responselike": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.3.tgz", @@ -51227,6 +51587,14 @@ "requires": { "normalize-path": "^3.0.0", "picomatch": "^2.0.4" + }, + "dependencies": { + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + } } }, "apache-md5": { @@ -51916,6 +52284,12 @@ "picomatch": "^2.3.1" } }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, "slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -56177,6 +56551,12 @@ "picomatch": "^2.3.1" } }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, "to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -56319,6 +56699,13 @@ "pend": "~1.2.0" } }, + "fdir": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.0.tgz", + "integrity": "sha512-3oB133prH1o4j/L5lLW7uOCF1PlD+/It2L0eL/iAqWMB91RBbqTewABqxhj0ibBd90EEmWZq7ntIWzVaWcXTGQ==", + "dev": true, + "requires": {} + }, "figgy-pudding": { "version": "3.5.2", "resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.2.tgz", @@ -58286,6 +58673,12 @@ "integrity": "sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw==", "dev": true }, + "is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", + "dev": true + }, "is-negative-zero": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.3.tgz", @@ -58343,6 +58736,15 @@ "integrity": "sha1-DFLlS8yjkbssSUsh6GJtczbG45c=", "dev": true }, + "is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "requires": { + "@types/estree": "*" + } + }, "is-regex": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", @@ -59308,6 +59710,12 @@ "picomatch": "^2.0.5" } }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, "pretty-format": { "version": "26.4.2", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-26.4.2.tgz", @@ -59831,6 +60239,12 @@ "picomatch": "^2.0.5" } }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -60324,6 +60738,12 @@ "picomatch": "^2.0.5" } }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, "slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -61331,6 +61751,12 @@ "picomatch": "^2.0.5" } }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -66841,10 +67267,12 @@ "dev": true }, "picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true, + "optional": true, + "peer": true }, "pify": { "version": "5.0.0", @@ -67731,6 +68159,14 @@ "dev": true, "requires": { "picomatch": "^2.2.1" + }, + "dependencies": { + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + } } }, "realpath-native": { @@ -70098,6 +70534,12 @@ "picomatch": "^2.3.1" } }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, "semver": { "version": "7.6.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", diff --git a/package.json b/package.json index 8b08634dcc..ff6e50823d 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,8 @@ "@babel/preset-typescript": "^7.23.3", "@cucumber/cucumber": "^7.2.1", "@jest-runner/electron": "^3.0.1", + "@rollup/plugin-commonjs": "^28.0.0", + "@rollup/plugin-node-resolve": "^15.3.0", "@rollup/plugin-replace": "^6.0.1", "@rollup/plugin-typescript": "^12.1.0", "@types/jest": "^26.0.14", From 50405f3e8a98747f7a4200e7e6b275bcea86c4ad Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 15 Oct 2024 10:13:38 +0100 Subject: [PATCH 05/15] remove optional chaining --- packages/plugin-window-onerror/src/onerror.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-window-onerror/src/onerror.ts b/packages/plugin-window-onerror/src/onerror.ts index 3bd872b17d..3e9f199329 100644 --- a/packages/plugin-window-onerror/src/onerror.ts +++ b/packages/plugin-window-onerror/src/onerror.ts @@ -7,7 +7,7 @@ import type { Plugin, Stackframe } from 'packages/core/types' export default (win = window, component = 'window onerror'): Plugin => ({ load: (client) => { // @ts-expect-error _config is private API - if (!client._config.autoDetectErrors || !client._config.enabledErrorTypes?.unhandledExceptions) return + if (!client._config.autoDetectErrors || !client._config.enabledErrorTypes.unhandledExceptions) return const prevOnError = win.onerror function onerror (messageOrEvent: string | Event, url?: string, lineNo?: number, charNo?: number, error?: Error) { From 8445c774172a80d8ab333f1fb05ba066fb542112 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 15 Oct 2024 10:14:01 +0100 Subject: [PATCH 06/15] update eslint rules --- .eslintrc.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.eslintrc.js b/.eslintrc.js index 4155e6cc3e..ade43f4788 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -31,6 +31,12 @@ const ruleOverrides = { '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off', '@typescript-eslint/prefer-includes': 'off', '@typescript-eslint/no-for-in-array': 'off', + + // Optional chaining compiles to a lot more code + '@typescript-eslint/prefer-optional-chain': 'off', + + // Support TypeScript 3.8 by disallowing import { type Module } from 'module' + 'import/consistent-type-specifier-style': ['warn', 'prefer-top-level'] } module.exports = { From 9ea85d7053b6ca5b58bf616befd35eb31c69d41c Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 15 Oct 2024 10:17:49 +0100 Subject: [PATCH 07/15] copy rollup config --- dockerfiles/Dockerfile.browser | 1 + dockerfiles/Dockerfile.ci | 1 + 2 files changed, 2 insertions(+) diff --git a/dockerfiles/Dockerfile.browser b/dockerfiles/Dockerfile.browser index 12fb309c8b..701e8c54ac 100644 --- a/dockerfiles/Dockerfile.browser +++ b/dockerfiles/Dockerfile.browser @@ -8,6 +8,7 @@ WORKDIR /app COPY package*.json ./ COPY babel.config.js lerna.json .eslintignore .eslintrc.js jest.config.js tsconfig.json ./ ADD min_packages.tar . +COPY .rollup ./.rollup COPY bin ./bin COPY packages ./packages diff --git a/dockerfiles/Dockerfile.ci b/dockerfiles/Dockerfile.ci index 9548f64d5f..b8560c6d7b 100644 --- a/dockerfiles/Dockerfile.ci +++ b/dockerfiles/Dockerfile.ci @@ -8,6 +8,7 @@ WORKDIR /app COPY package*.json ./ COPY babel.config.js lerna.json .eslintignore .eslintrc.js jest.config.js tsconfig.json ./ ADD min_packages.tar . +COPY .rollup ./.rollup COPY bin ./bin COPY scripts ./scripts COPY test ./test From f0aaa7dbc361b6594c63d9b8f8fb187cb26eeb50 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 15 Oct 2024 11:27:30 +0100 Subject: [PATCH 08/15] update main and browser fields --- packages/plugin-window-onerror/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/plugin-window-onerror/package.json b/packages/plugin-window-onerror/package.json index f963156e9e..1d4f76b14e 100644 --- a/packages/plugin-window-onerror/package.json +++ b/packages/plugin-window-onerror/package.json @@ -1,7 +1,8 @@ { "name": "@bugsnag/plugin-window-onerror", "version": "8.0.0", - "main": "dist/onerror.js", + "main": "dist/onerror.mjs", + "browser": "dist/onerror.js", "types": "dist/types/onerror.d.ts", "exports": { ".": { From 691a4f9d6b2e2d2b580c235ea6f2f270ae08bbc6 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 15 Oct 2024 14:32:02 +0100 Subject: [PATCH 09/15] update main entry --- packages/plugin-window-onerror/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/plugin-window-onerror/package.json b/packages/plugin-window-onerror/package.json index 1d4f76b14e..f963156e9e 100644 --- a/packages/plugin-window-onerror/package.json +++ b/packages/plugin-window-onerror/package.json @@ -1,8 +1,7 @@ { "name": "@bugsnag/plugin-window-onerror", "version": "8.0.0", - "main": "dist/onerror.mjs", - "browser": "dist/onerror.js", + "main": "dist/onerror.js", "types": "dist/types/onerror.d.ts", "exports": { ".": { From ef418638e91fd98eda90ff0c2b9a4c280ac8b181 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 15 Oct 2024 14:59:45 +0100 Subject: [PATCH 10/15] fix lerna build script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ff6e50823d..7e889f9605 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "xvfb-maybe": "^0.2.1" }, "scripts": { - "build": "lerna run build --scope '@bugsnag/node' --scope '@bugsnag/browser' && lerna run build --ignore '@bugsnag/node' --ignore '@bugsnag/browser'", + "build": "lerna run build", "build:electron": "lerna run build --scope '@bugsnag/plugin-electron-ipc' --scope '@bugsnag/plugin-electron-app' --scope '@bugsnag/plugin-electron-client-state-persistence'", "test:lint": "eslint --ext .ts,.js --report-unused-disable-directives --max-warnings=0 .", "test:lint-native": "bash scripts/cppcheck.sh", From 46a2a8b4f46eeddf7c3cf16ae40d9e604d7170b3 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 15 Oct 2024 14:59:53 +0100 Subject: [PATCH 11/15] update test import --- packages/plugin-window-onerror/test/onerror.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-window-onerror/test/onerror.test.ts b/packages/plugin-window-onerror/test/onerror.test.ts index b37b621d66..1bd7eeee27 100644 --- a/packages/plugin-window-onerror/test/onerror.test.ts +++ b/packages/plugin-window-onerror/test/onerror.test.ts @@ -1,6 +1,6 @@ /* eslint-disable jest/no-commented-out-tests */ -import plugin from '../src/onerror' +import plugin from '../' import Client, { EventDeliveryPayload } from '@bugsnag/core/client' From c5a1b55715d89e8988e6a232ad1146948c75025f Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 15 Oct 2024 15:00:00 +0100 Subject: [PATCH 12/15] copy rollup config --- dockerfiles/Dockerfile.node | 1 + 1 file changed, 1 insertion(+) diff --git a/dockerfiles/Dockerfile.node b/dockerfiles/Dockerfile.node index f2e40ae999..187ec60a9d 100644 --- a/dockerfiles/Dockerfile.node +++ b/dockerfiles/Dockerfile.node @@ -8,6 +8,7 @@ WORKDIR /app COPY package*.json ./ COPY babel.config.js lerna.json .eslintignore .eslintrc.js jest.config.js tsconfig.json ./ ADD min_packages.tar . +COPY .rollup ./.rollup COPY bin ./bin COPY packages ./packages From 32fef66fe6e29ff2aa76f6206464dd5eefd87613 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 15 Oct 2024 15:10:55 +0100 Subject: [PATCH 13/15] move types before module exports --- packages/plugin-window-onerror/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/plugin-window-onerror/package.json b/packages/plugin-window-onerror/package.json index f963156e9e..da3512ea9f 100644 --- a/packages/plugin-window-onerror/package.json +++ b/packages/plugin-window-onerror/package.json @@ -5,9 +5,9 @@ "types": "dist/types/onerror.d.ts", "exports": { ".": { - "import": "./dist/onerror.mjs", - "require": "./dist/onerror.js", - "types": "./dist/types/onerror.d.ts" + "types": "./dist/types/onerror.d.ts", + "default": "./dist/onerror.js", + "import": "./dist/onerror.mjs" } }, "description": "@bugsnag/js plugin to report unhandled exceptions in browsers", From 0815dc594302d65a6f37219570eea688294712e0 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 15 Oct 2024 15:18:21 +0100 Subject: [PATCH 14/15] exclude built js files from type check --- tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 6decaad4e2..194cb11f2f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -98,6 +98,7 @@ "packages/browser" ], "exclude": [ - "packages/react-native/src/NativeBugsnag.ts" + "packages/react-native/src/NativeBugsnag.ts", + "packages/**/dist/**/*.js" ] } From 282e8c62c3f34d1fd8115af90b50c489decc7aa8 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 15 Oct 2024 15:26:22 +0100 Subject: [PATCH 15/15] build all packages for electron --- .buildkite/basic/electron-pipeline.yml | 2 +- .github/workflows/test-electron.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.buildkite/basic/electron-pipeline.yml b/.buildkite/basic/electron-pipeline.yml index d24907428a..8e425c02b3 100644 --- a/.buildkite/basic/electron-pipeline.yml +++ b/.buildkite/basic/electron-pipeline.yml @@ -27,7 +27,7 @@ steps: - echo "Running on Node `node -v`" - npm install electron@${ELECTRON_VERSION} --no-audit --progress=false --no-save - npm ci --no-audit --progress=false - - npm run build:electron + - npm run build - defaults write com.apple.CrashReporter DialogType none - npm run test:unit:electron-runner - npm run test:electron diff --git a/.github/workflows/test-electron.yml b/.github/workflows/test-electron.yml index ec091cc2ff..833ac83491 100644 --- a/.github/workflows/test-electron.yml +++ b/.github/workflows/test-electron.yml @@ -43,7 +43,7 @@ jobs: - run: npm ci --no-audit --progress=false env: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 - - run: npm run build:electron + - run: npm run build shell: bash - run: sudo apt-get install cppcheck --assume-yes name: Install cppcheck