Skip to content

Commit

Permalink
build(bundles): Use ES2017 for bundles (drop ES5 support) (#10911)
Browse files Browse the repository at this point in the history
ref #9829
  • Loading branch information
s1gr1d authored Mar 7, 2024
1 parent f688034 commit ebbdc8e
Show file tree
Hide file tree
Showing 60 changed files with 148 additions and 370 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module.exports = {
root: true,
env: {
es6: true,
es2017: true,
},
parserOptions: {
ecmaVersion: 2018,
Expand Down
28 changes: 11 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,6 @@ jobs:
run: yarn lint:lerna
- name: Lint C++ files
run: yarn lint:clang
- name: Validate ES5 builds
run: yarn validate:es5

job_check_format:
name: Check file formatting
Expand Down Expand Up @@ -627,28 +625,24 @@ jobs:
matrix:
bundle:
- esm
- bundle_es5
- bundle_es5_min
- bundle_es6
- bundle_es6_min
- bundle_replay_es6
- bundle_replay_es6_min
- bundle_tracing_es5
- bundle_tracing_es5_min
- bundle_tracing_es6
- bundle_tracing_es6_min
- bundle_tracing_replay_es6
- bundle_tracing_replay_es6_min
- bundle
- bundle_min
- bundle_replay
- bundle_replay_min
- bundle_tracing
- bundle_tracing_min
- bundle_tracing_replay
- bundle_tracing_replay_min
project:
- chromium
include:
# Only check all projects for esm & full bundle
# We also shard the tests as they take the longest
- bundle: bundle_tracing_replay_es6_min
- bundle: bundle_tracing_replay_min
project: ''
shard: 1
shards: 2
- bundle: bundle_tracing_replay_es6_min
- bundle: bundle_tracing_replay_min
project: ''
shard: 2
shards: 2
Expand All @@ -665,7 +659,7 @@ jobs:
shards: 3
exclude:
# Do not run the default chromium-only tests
- bundle: bundle_tracing_replay_es6_min
- bundle: bundle_tracing_replay_min
project: 'chromium'
- bundle: esm
project: 'chromium'
Expand Down
27 changes: 9 additions & 18 deletions .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,64 +76,55 @@ module.exports = [
limit: '28 KB',
},

// Browser CDN bundles (ES6)
// Browser CDN bundles
{
name: '@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped)',
name: '@sentry/browser (incl. Tracing, Replay, Feedback) - CDN Bundle (gzipped)',
path: 'packages/browser/build/bundles/bundle.tracing.replay.feedback.min.js',
gzip: true,
limit: '90 KB',
},
{
name: '@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped)',
name: '@sentry/browser (incl. Tracing, Replay) - CDN Bundle (gzipped)',
path: 'packages/browser/build/bundles/bundle.tracing.replay.min.js',
gzip: true,
limit: '75 KB',
},
{
name: '@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped)',
name: '@sentry/browser (incl. Tracing) - CDN Bundle (gzipped)',
path: 'packages/browser/build/bundles/bundle.tracing.min.js',
gzip: true,
limit: '37 KB',
},
{
name: '@sentry/browser - ES6 CDN Bundle (gzipped)',
name: '@sentry/browser - CDN Bundle (gzipped)',
path: 'packages/browser/build/bundles/bundle.min.js',
gzip: true,
limit: '28 KB',
},

// browser CDN bundles (ES6 + non-gzipped)
// browser CDN bundles (non-gzipped)
{
name: '@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed)',
name: '@sentry/browser (incl. Tracing, Replay) - CDN Bundle (minified & uncompressed)',
path: 'packages/browser/build/bundles/bundle.tracing.replay.min.js',
gzip: false,
brotli: false,
limit: '260 KB',
},
{
name: '@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed)',
name: '@sentry/browser (incl. Tracing) - CDN Bundle (minified & uncompressed)',
path: 'packages/browser/build/bundles/bundle.tracing.min.js',
gzip: false,
brotli: false,
limit: '105 KB',
},
{
name: '@sentry/browser - ES6 CDN Bundle (minified & uncompressed)',
name: '@sentry/browser - CDN Bundle (minified & uncompressed)',
path: 'packages/browser/build/bundles/bundle.min.js',
gzip: false,
brotli: false,
limit: '80 KB',
},

// Browser CDN bundles (ES5)
// Replay is not supported in ES5 mode
{
name: '@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped)',
path: 'packages/browser/build/bundles/bundle.tracing.es5.min.js',
gzip: true,
limit: '40 KB',
},

// React
{
name: '@sentry/react (incl. Tracing, Replay) - Webpack (gzipped)',
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ With that, the repo is fully set up and you are ready to run all commands.
Since we are using [`TypeScript`](https://www.typescriptlang.org/), you need to transpile the code to JavaScript to be
able to use it. From the top level of the repo, there are three commands available:

- `yarn build:dev`, which runs a one-time build of ES5 and ES6 versions of every package
- `yarn build:dev`, which runs a one-time build of every package
- `yarn build:dev:filter <name of npm package>`, which runs `yarn build:dev` only in projects relevant to the given
package (so, for example, running `yarn build:dev:filter @sentry/react` will build the `react` package, all of its
dependencies (`utils`, `core`, `browser`, etc), and all packages which depend on it (currently `gatsby` and `nextjs`))
Expand Down
10 changes: 5 additions & 5 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ stable release of `8.x` comes out).
`@sentry/node` and all of our node-based server-side sdks (`@sentry/nextjs`, `@sentry/serverless`, etc.). We no longer
test against Node 8, 10, or 12 and cannot guarantee that the SDK will work as expected on these versions.

**Browser**: Our browser SDKs (`@sentry/browser`, `@sentry/react`, `@sentry/vue`, etc.) now require ES6+ compatible
**Browser**: Our browser SDKs (`@sentry/browser`, `@sentry/react`, `@sentry/vue`, etc.) now require ES2017+ compatible
browsers. This means that we no longer support IE11 (end of an era). This also means that the Browser SDK requires the
fetch API to be available in the environment.

New minimum supported browsers:

- Chrome 51
- Chrome 58
- Edge 15
- Safari/iOS Safari 10
- Safari/iOS Safari 11
- Firefox 54
- Opera 38
- Samnsung Internet 5
- Opera 45
- Samsung Internet 7.2

For IE11 support please transpile your code to ES5 using babel or similar and add required polyfills.

Expand Down
2 changes: 1 addition & 1 deletion dev-packages/browser-integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ To filter tests by their title:
You can refer to [Playwright documentation](https://playwright.dev/docs/test-cli) for other CLI options.

You can set env variable `PW_BUNDLE` to set specific build or bundle to test against.
Available options: `esm`, `cjs`, `bundle_es5`, `bundle_es5_min`, `bundle_es6`, `bundle_es6_min`
Available options: `esm`, `cjs`, `bundle`, `bundle_min`

### Troubleshooting

Expand Down
21 changes: 7 additions & 14 deletions dev-packages/browser-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@
"pretest": "yarn clean && yarn type-check",
"test": "yarn test:all --project='chromium'",
"test:all": "npx playwright test -c playwright.browser.config.ts",
"test:bundle:es5": "PW_BUNDLE=bundle_es5 yarn test",
"test:bundle:es5:min": "PW_BUNDLE=bundle_es5_min yarn test",
"test:bundle:es6": "PW_BUNDLE=bundle_es6 yarn test",
"test:bundle:es6:min": "PW_BUNDLE=bundle_es6_min yarn test",
"test:bundle:replay:es6": "PW_BUNDLE=bundle_replay_es6 yarn test",
"test:bundle:replay:es6:min": "PW_BUNDLE=bundle_replay_es6_min yarn test",
"test:bundle:tracing:es5": "PW_BUNDLE=bundle_tracing_es5 yarn test",
"test:bundle:tracing:es5:min": "PW_BUNDLE=bundle_tracing_es5_min yarn test",
"test:bundle:tracing:es6": "PW_BUNDLE=bundle_tracing_es6 yarn test",
"test:bundle:tracing:es6:min": "PW_BUNDLE=bundle_tracing_es6_min yarn test",
"test:bundle:tracing:replay:es6": "PW_BUNDLE=bundle_tracing_replay_es6 yarn test",
"test:bundle:tracing:replay:es6:min": "PW_BUNDLE=bundle_tracing_replay_es6_min yarn test",
"test:bundle": "PW_BUNDLE=bundle yarn test",
"test:bundle:min": "PW_BUNDLE=bundle_min yarn test",
"test:bundle:replay": "PW_BUNDLE=bundle_replay yarn test",
"test:bundle:replay:min": "PW_BUNDLE=bundle_replay_min yarn test",
"test:bundle:tracing": "PW_BUNDLE=bundle_tracing yarn test",
"test:bundle:tracing:min": "PW_BUNDLE=bundle_tracing_min yarn test",
"test:cjs": "PW_BUNDLE=cjs yarn test",
"test:esm": "PW_BUNDLE=esm yarn test",
"test:loader": "npx playwright test -c playwright.loader.config.ts --project='chromium'",
Expand All @@ -40,8 +34,7 @@
"test:loader:debug": "PW_BUNDLE=loader_debug yarn test:loader",
"test:ci": "yarn test:all --reporter='line'",
"test:update-snapshots": "yarn test:all --update-snapshots",
"test:detect-flaky": "ts-node scripts/detectFlakyTests.ts",
"validate:es5": "es-check es5 'fixtures/loader.js'"
"test:detect-flaky": "ts-node scripts/detectFlakyTests.ts"
},
"dependencies": {
"@babel/preset-typescript": "^7.16.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function delay(ms: number) {

sentryTest('should queue and retry events when they fail to send', async ({ getLocalTestPath, page }) => {
// makeBrowserOfflineTransport is not included in any CDN bundles
if (process.env.PW_BUNDLE && process.env.PW_BUNDLE.startsWith('bundle_')) {
if (process.env.PW_BUNDLE && process.env.PW_BUNDLE.startsWith('bundle')) {
sentryTest.skip();
}

Expand Down
40 changes: 17 additions & 23 deletions dev-packages/browser-integration-tests/utils/generatePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,32 @@ const BUNDLE_PATHS: Record<string, Record<string, string>> = {
browser: {
cjs: 'build/npm/cjs/index.js',
esm: 'build/npm/esm/index.js',
bundle_es5: 'build/bundles/bundle.es5.js',
bundle_es5_min: 'build/bundles/bundle.es5.min.js',
bundle_es6: 'build/bundles/bundle.js',
bundle_es6_min: 'build/bundles/bundle.min.js',
bundle_replay_es6: 'build/bundles/bundle.replay.js',
bundle_replay_es6_min: 'build/bundles/bundle.replay.min.js',
bundle_tracing_es5: 'build/bundles/bundle.tracing.es5.js',
bundle_tracing_es5_min: 'build/bundles/bundle.tracing.es5.min.js',
bundle_tracing_es6: 'build/bundles/bundle.tracing.js',
bundle_tracing_es6_min: 'build/bundles/bundle.tracing.min.js',
bundle_tracing_replay_es6: 'build/bundles/bundle.tracing.replay.js',
bundle_tracing_replay_es6_min: 'build/bundles/bundle.tracing.replay.min.js',
loader_base: 'build/bundles/bundle.es5.min.js',
loader_eager: 'build/bundles/bundle.es5.min.js',
loader_debug: 'build/bundles/bundle.es5.debug.min.js',
loader_tracing: 'build/bundles/bundle.tracing.es5.min.js',
bundle: 'build/bundles/bundle.js',
bundle_min: 'build/bundles/bundle.min.js',
bundle_replay: 'build/bundles/bundle.replay.js',
bundle_replay_min: 'build/bundles/bundle.replay.min.js',
bundle_tracing: 'build/bundles/bundle.tracing.js',
bundle_tracing_min: 'build/bundles/bundle.tracing.min.js',
bundle_tracing_replay: 'build/bundles/bundle.tracing.replay.js',
bundle_tracing_replay_min: 'build/bundles/bundle.tracing.replay.min.js',
loader_base: 'build/bundles/bundle.min.js',
loader_eager: 'build/bundles/bundle.min.js',
loader_debug: 'build/bundles/bundle.debug.min.js',
loader_tracing: 'build/bundles/bundle.tracing.min.js',
loader_replay: 'build/bundles/bundle.replay.min.js',
loader_tracing_replay: 'build/bundles/bundle.tracing.replay.debug.min.js',
},
integrations: {
cjs: 'build/npm/cjs/index.js',
esm: 'build/npm/esm/index.js',
bundle_es5: 'build/bundles/[INTEGRATION_NAME].es5.js',
bundle_es5_min: 'build/bundles/[INTEGRATION_NAME].es5.min.js',
bundle_es6: 'build/bundles/[INTEGRATION_NAME].js',
bundle_es6_min: 'build/bundles/[INTEGRATION_NAME].min.js',
bundle: 'build/bundles/[INTEGRATION_NAME].js',
bundle_min: 'build/bundles/[INTEGRATION_NAME].min.js',
},
wasm: {
cjs: 'build/npm/cjs/index.js',
esm: 'build/npm/esm/index.js',
bundle_es6: 'build/bundles/wasm.js',
bundle_es6_min: 'build/bundles/wasm.min.js',
bundle: 'build/bundles/wasm.js',
bundle_min: 'build/bundles/wasm.min.js',
},
};

Expand Down Expand Up @@ -229,7 +223,7 @@ class SentryScenarioGenerationPlugin {
});
}

// Convert e.g. bundle_tracing_es5_min to bundle_es5_min
// Convert e.g. bundle_tracing_min to bundle_min
const integrationBundleKey = bundleKey
.replace('loader_', 'bundle_')
.replace('_replay', '')
Expand Down
4 changes: 2 additions & 2 deletions dev-packages/browser-integration-tests/utils/wasmHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* We can only test WASM tests in certain bundles/packages:
* - NPM (ESM, CJS)
* - ES6 CDN bundles
* - CDN bundles
* - On browsers other than WebKit
*
* @returns `true` if we should skip the replay test
Expand All @@ -11,5 +11,5 @@ export function shouldSkipWASMTests(browser: string): boolean {
return true;
}
const bundle = process.env.PW_BUNDLE as string | undefined;
return bundle != null && bundle.includes('es5');
return bundle != null;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"include": ["index.ts"],
"compilerOptions": {
"lib": ["es6", "DOM"],
"lib": ["es2017", "DOM"],
"skipLibCheck": false,
"noEmit": true,
"types": [],
"target": "es6",
"target": "es2017",
"moduleResolution": "node"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"types": ["node"],
"esModuleInterop": true,
"lib": ["ES6"],
"lib": ["es2017"],
"strict": true,
"outDir": "dist",
"target": "ESNext",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"types": ["node"],
"esModuleInterop": true,
"lib": ["ES6"],
"lib": ["es2017"],
"strict": true,
"outDir": "dist"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand Down
Loading

0 comments on commit ebbdc8e

Please sign in to comment.