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

Typescript plugin window onerror #2220

Merged
merged 15 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildkite/basic/electron-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -44,7 +50,8 @@ module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
jsx: true,
ecmaVersion: 2018
ecmaVersion: 2018,
sourceType: 'module'
},
overrides: [
// linting for js files
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-electron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 54 additions & 0 deletions .rollup/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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,
// output directory for the bundle
output: undefined
})

function createRollupConfig (options = defaultOptions()) {
const packageJson = JSON.parse(fs.readFileSync(`${process.cwd()}/package.json`))

return {
input: options.input || 'src/index.ts',
output: options.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
1 change: 1 addition & 0 deletions dockerfiles/Dockerfile.browser
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions dockerfiles/Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/Dockerfile.node
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading
Loading