Skip to content

Commit

Permalink
feat!: set compilation target to es2022 for all packages but api an…
Browse files Browse the repository at this point in the history
…d semantic-conventions (#5456)

Co-authored-by: Trent Mick <trentm@gmail.com>
  • Loading branch information
david-luna and trentm authored Feb 21, 2025
1 parent 492ed35 commit f2d4e54
Show file tree
Hide file tree
Showing 29 changed files with 125 additions and 74 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se
* (user-facing): `ENVIRONMENT` has been removed without replacement
* (user-facing): `RAW_ENVIRONMENT` has been removed without replacement
* (user-facing): `parseEnvironment` has been removed without replacement
* feat!: set compilation target to ES2022 for all packages except `@opentelemetry/api`, `@opentelemetry/api-logs`, `@opentelemetry/api-events`, and `@opentelemetry/semantic-conventions` [#5456](/~https://github.com/open-telemetry/opentelemetry-js/pull/5456) @david-luna
* (user-facing): drops browser runtimes which do not support ES2022 features

### :rocket: (Enhancement)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ underlying language features used.
The current minumum language feature support is set as [ECMAScript 2020](https://262.ecma-international.org/11.0/) that are available
in all modern browsers / runtimes.

This means that if you are targeting or your end-users are using a browser / runtime that does not support ES2020, you will need
This means that if you are targeting or your end-users are using a browser / runtime that does not support ES2022, you will need
to transpile the code and provide any necessary polyfills for the missing features to ensure compatibility with your target
environments. Any support issues that arise from using a browser or runtime that does not support ES2020 will be closed as "won't fix".
environments. Any support issues that arise from using a browser or runtime that does not support ES2022 will be closed as "won't fix".

This minimum support level is subject to change as the project evolves and as the underlying language features evolve.

Expand Down
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
},
"devDependencies": {
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"@types/node": "^8.10.66",
"@types/sinon": "17.0.3",
"@types/webpack": "5.28.5",
"@types/webpack-env": "1.16.3",
Expand Down
2 changes: 1 addition & 1 deletion api/src/platform/browser/globalThis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ export const _globalThis: typeof globalThis =
: typeof window === 'object'
? window
: typeof global === 'object'
? global
? (global as unknown as typeof globalThis)
: ({} as typeof globalThis);
4 changes: 3 additions & 1 deletion api/test/common/baggage/Baggage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ describe('Baggage', () => {

const entry = bag.getEntry('key');
assert.ok(entry);
entry.value = 'mutated';
if (entry) {
entry.value = 'mutated';
}

assert.strictEqual(bag.getEntry('key')?.value, 'value');
});
Expand Down
4 changes: 2 additions & 2 deletions api/test/tree-shaking/tree-shaking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import * as assert from 'assert';
import { webpack, Stats } from 'webpack';
import * as path from 'path';
import { Union } from 'unionfs';
import { IFS, Union } from 'unionfs';
import { fs as mfs } from 'memfs';
import * as realFs from 'fs';

Expand Down Expand Up @@ -86,7 +86,7 @@ describe('tree-shaking', function () {
});

const fs = new Union();
fs.use(mfs as any).use(realFs);
fs.use(mfs as any).use(realFs as unknown as IFS);

// direct webpack to use unionfs for file input
// needs workaround from /~https://github.com/webpack/webpack/issues/18242#issuecomment-2018116985 since webpack 5.91.0
Expand Down
5 changes: 5 additions & 0 deletions api/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"extends": "../tsconfig.base.esm.json",
"compilerOptions": {
"lib": [
"es2017",
"dom"
],
"outDir": "build/esm",
"rootDir": "src",
"target": "es2017",
"tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo"
},
"include": [
Expand Down
5 changes: 5 additions & 0 deletions api/tsconfig.esnext.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"extends": "../tsconfig.base.esnext.json",
"compilerOptions": {
"lib": [
"es2017",
"dom"
],
"outDir": "build/esnext",
"rootDir": "src",
"target": "es2017",
"tsBuildInfoFile": "build/esnext/tsconfig.esnext.tsbuildinfo"
},
"include": [
Expand Down
7 changes: 6 additions & 1 deletion api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"lib": [
"es2017",
"dom"
],
"outDir": "build",
"rootDir": "."
"rootDir": ".",
"target": "es2017"
},
"files": [],
"include": [
Expand Down
4 changes: 2 additions & 2 deletions experimental/packages/api-events/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"author": "OpenTelemetry Authors",
"license": "Apache-2.0",
"engines": {
"node": "^18.19.0 || >=20.6.0"
"node": ">=8.0.0"
},
"files": [
"build/esm/**/*.js",
Expand All @@ -65,7 +65,7 @@
},
"devDependencies": {
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"@types/node": "^8.10.66",
"@types/webpack-env": "1.16.3",
"babel-plugin-istanbul": "7.0.0",
"cross-var": "1.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ export const _globalThis: typeof globalThis =
: typeof window === 'object'
? window
: typeof global === 'object'
? global
? (global as unknown as typeof globalThis)
: ({} as typeof globalThis);
5 changes: 5 additions & 0 deletions experimental/packages/api-events/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"extends": "../../../tsconfig.base.esm.json",
"compilerOptions": {
"lib": [
"es2017",
"dom"
],
"outDir": "build/esm",
"rootDir": "src",
"target": "es2017",
"tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo"
},
"include": [
Expand Down
5 changes: 5 additions & 0 deletions experimental/packages/api-events/tsconfig.esnext.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"extends": "../../../tsconfig.base.esnext.json",
"compilerOptions": {
"lib": [
"es2017",
"dom"
],
"outDir": "build/esnext",
"rootDir": "src",
"target": "es2017",
"tsBuildInfoFile": "build/esnext/tsconfig.esnext.tsbuildinfo"
},
"include": [
Expand Down
7 changes: 6 additions & 1 deletion experimental/packages/api-events/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"lib": [
"es2017",
"dom"
],
"outDir": "build",
"rootDir": "."
"rootDir": ".",
"target": "es2017"
},
"files": [],
"include": [
Expand Down
4 changes: 2 additions & 2 deletions experimental/packages/api-logs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"author": "OpenTelemetry Authors",
"license": "Apache-2.0",
"engines": {
"node": "^18.19.0 || >=20.6.0"
"node": ">=8.0.0"
},
"files": [
"build/esm/**/*.js",
Expand All @@ -64,7 +64,7 @@
},
"devDependencies": {
"@types/mocha": "10.0.10",
"@types/node": "18.6.5",
"@types/node": "^8.10.66",
"@types/webpack-env": "1.16.3",
"babel-plugin-istanbul": "7.0.0",
"cross-var": "1.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ export const _globalThis: typeof globalThis =
: typeof window === 'object'
? window
: typeof global === 'object'
? global
? (global as unknown as typeof globalThis)
: ({} as typeof globalThis);
5 changes: 5 additions & 0 deletions experimental/packages/api-logs/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"extends": "../../../tsconfig.base.esm.json",
"compilerOptions": {
"lib": [
"es2017",
"dom"
],
"outDir": "build/esm",
"rootDir": "src",
"target": "es2017",
"tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo"
},
"include": [
Expand Down
5 changes: 5 additions & 0 deletions experimental/packages/api-logs/tsconfig.esnext.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"extends": "../../../tsconfig.base.esnext.json",
"compilerOptions": {
"lib": [
"es2017",
"dom"
],
"outDir": "build/esnext",
"rootDir": "src",
"target": "es2017",
"tsBuildInfoFile": "build/esnext/tsconfig.esnext.tsbuildinfo"
},
"include": [
Expand Down
7 changes: 6 additions & 1 deletion experimental/packages/api-logs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"lib": [
"es2017",
"dom"
],
"outDir": "build",
"rootDir": "."
"rootDir": ".",
"target": "es2017"
},
"files": [],
"include": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ export class HttpInstrumentation extends InstrumentationBase<HttpInstrumentation
/** keep track on spans not ended */
private readonly _spanNotEnded: WeakSet<Span> = new WeakSet<Span>();
private _headerCapture;
private _oldHttpServerDurationHistogram!: Histogram;
private _stableHttpServerDurationHistogram!: Histogram;
private _oldHttpClientDurationHistogram!: Histogram;
private _stableHttpClientDurationHistogram!: Histogram;
declare private _oldHttpServerDurationHistogram: Histogram;
declare private _stableHttpServerDurationHistogram: Histogram;
declare private _oldHttpClientDurationHistogram: Histogram;
declare private _stableHttpClientDurationHistogram: Histogram;

private _semconvStability = SemconvStability.OLD;

Expand Down
Loading

0 comments on commit f2d4e54

Please sign in to comment.