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/browser #2215

Closed
wants to merge 14 commits into from
Closed
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
80 changes: 40 additions & 40 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@ steps:
- exit_status: "*"
limit: 1

- label: ":aws-lambda: AWS Lambda tests"
timeout_in_minutes: 35
agents:
queue: "macos-14"
env:
NODE_VERSION: "18"
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
plugins:
test-collector#v1.10.2:
files: "test/aws-lambda/reports/TEST-*.xml"
format: "junit"
branch: "^main|next$$"
api-token-env-name: "JS_AWS_LAMBDA_BUILDKITE_ANALYTICS_TOKEN"
commands:
# force the NPM registry as the default on CI is artifactory, which can't
# currently install from our lockfile
- npm ci --registry https://registry.npmjs.org
- cd test/aws-lambda
- bundle install
- bundle exec maze-runner
# - label: ":aws-lambda: AWS Lambda tests"
# timeout_in_minutes: 35
# agents:
# queue: "macos-14"
# env:
# NODE_VERSION: "18"
# PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
# plugins:
# test-collector#v1.10.2:
# files: "test/aws-lambda/reports/TEST-*.xml"
# format: "junit"
# branch: "^main|next$$"
# api-token-env-name: "JS_AWS_LAMBDA_BUILDKITE_ANALYTICS_TOKEN"
# commands:
# # force the NPM registry as the default on CI is artifactory, which can't
# # currently install from our lockfile
# - npm ci --registry https://registry.npmjs.org
# - cd test/aws-lambda
# - bundle install
# - bundle exec maze-runner

#
# Core tests and checks
Expand Down Expand Up @@ -111,30 +111,30 @@ steps:
commands:
- buildkite-agent pipeline upload .buildkite/basic/browser-pipeline.yml

- label: ":large_blue_circle: :large_blue_circle: :large_blue_circle: ELECTRON STEPS :large_blue_circle: :large_blue_circle: :large_blue_circle:"
commands:
- buildkite-agent pipeline upload .buildkite/basic/electron-pipeline.yml
# - label: ":large_blue_circle: :large_blue_circle: :large_blue_circle: ELECTRON STEPS :large_blue_circle: :large_blue_circle: :large_blue_circle:"
# commands:
# - buildkite-agent pipeline upload .buildkite/basic/electron-pipeline.yml

- label: ":large_blue_circle: :large_blue_circle: :large_blue_circle: NODE STEPS :large_blue_circle: :large_blue_circle: :large_blue_circle:"
depends_on: "package-js"
commands:
- buildkite-agent pipeline upload .buildkite/basic/node-pipeline.yml
# - label: ":large_blue_circle: :large_blue_circle: :large_blue_circle: NODE STEPS :large_blue_circle: :large_blue_circle: :large_blue_circle:"
# depends_on: "package-js"
# commands:
# - buildkite-agent pipeline upload .buildkite/basic/node-pipeline.yml

- label: ":large_blue_circle: :large_blue_circle: :large_blue_circle: REACT NATIVE (ANDROID) STEPS :large_blue_circle: :large_blue_circle: :large_blue_circle:"
depends_on:
- "publish-js"
commands:
- buildkite-agent pipeline upload .buildkite/basic/react-native-android-pipeline.yml
# - label: ":large_blue_circle: :large_blue_circle: :large_blue_circle: REACT NATIVE (ANDROID) STEPS :large_blue_circle: :large_blue_circle: :large_blue_circle:"
# depends_on:
# - "publish-js"
# commands:
# - buildkite-agent pipeline upload .buildkite/basic/react-native-android-pipeline.yml

- label: ":large_blue_circle: :large_blue_circle: :large_blue_circle: REACT NATIVE (IOS) STEPS :large_blue_circle: :large_blue_circle: :large_blue_circle:"
depends_on:
- "publish-js"
commands:
- buildkite-agent pipeline upload .buildkite/basic/react-native-ios-pipeline.yml
# - label: ":large_blue_circle: :large_blue_circle: :large_blue_circle: REACT NATIVE (IOS) STEPS :large_blue_circle: :large_blue_circle: :large_blue_circle:"
# depends_on:
# - "publish-js"
# commands:
# - buildkite-agent pipeline upload .buildkite/basic/react-native-ios-pipeline.yml

#
# Conditionally trigger full pipeline
#
- label: 'Conditionally trigger full set of tests'
timeout_in_minutes: 30
command: sh -c .buildkite/pipeline_trigger.sh
# - label: 'Conditionally trigger full set of tests'
# timeout_in_minutes: 30
# command: sh -c .buildkite/pipeline_trigger.sh
11 changes: 10 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ 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 = {
root: true,
reportUnusedDisableDirectives: true,
plugins: [
'react'
],
Expand All @@ -44,7 +52,8 @@ module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
jsx: true,
ecmaVersion: 2018
ecmaVersion: 2018,
sourceType: 'module'
},
overrides: [
// linting for js files
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,
// the output configuration 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
16 changes: 16 additions & 0 deletions .rollup/no-tree-shaking.plugin.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// when functional components are used in JSX tags, rollup doesn't recognise them as actually being used and tree-shakes them away
// this plugin prevents that from happening by explicity telling rollup not to tree-shake the module
function noTreeShakingPlugin(files) {
return {
name: 'no-treeshaking-plugin',
transform(code, id) {
for (const file of files) {
if (id.indexOf(file) >= 0) {
return { moduleSideEffects: 'no-treeshake' }
}
}
}
}
}

export default noTreeShakingPlugin
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = api => {
const overrides = []

if (api && api.env('test')) {
presets.push('@babel/preset-env')
presets.push('@babel/preset-typescript')
plugins.push(['@babel/plugin-proposal-class-properties', { loose: true }])
plugins.push('@babel/plugin-transform-modules-commonjs')
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/Dockerfile.browser
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ COPY babel.config.js lerna.json .eslintignore .eslintrc.js jest.config.js tsconf
ADD min_packages.tar .
COPY bin ./bin
COPY packages ./packages
COPY .rollup ./.rollup

RUN npm install
RUN npm run build
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ COPY package*.json ./
COPY babel.config.js lerna.json .eslintignore .eslintrc.js jest.config.js tsconfig.json ./
ADD min_packages.tar .
COPY bin ./bin
COPY .rollup ./.rollup
COPY scripts ./scripts
COPY test ./test
COPY packages ./packages
Expand Down
9 changes: 8 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"packages": ["packages/*"],
"version": "8.0.0",
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"command": {
"create": {
"homepage": "https://www.bugsnag.com/",
"license": "MIT",
"esModule": true
}
}
}
Loading
Loading