From cf178f56205ae470f9f1bd2dd3aa4cf1c6028ff3 Mon Sep 17 00:00:00 2001 From: t2t2 Date: Fri, 30 Apr 2021 20:26:07 +0300 Subject: [PATCH] feat: add ESM builds for packages used in browser (#459) * feat: add ESM builds for packages used in browser * fix(id-generator-aws-xray): missed including esm files --- examples/web/package.json | 6 +++--- metapackages/auto-instrumentations-web/package.json | 7 ++++--- .../auto-instrumentations-web/tsconfig.esm.json | 12 ++++++++++++ .../package.json | 11 ++++++++--- .../tsconfig.esm.json | 11 +++++++++++ .../package.json | 11 ++++++++--- .../tsconfig.esm.json | 11 +++++++++++ .../package.json | 11 ++++++++--- .../tsconfig.esm.json | 13 +++++++++++++ .../opentelemetry-plugin-react-load/package.json | 11 ++++++++--- .../tsconfig.esm.json | 12 ++++++++++++ .../opentelemetry-propagator-aws-xray/package.json | 10 +++++++--- .../tsconfig.esm.json | 11 +++++++++++ .../opentelemetry-propagator-ot-trace/package.json | 10 +++++++--- .../tsconfig.esm.json | 11 +++++++++++ tsconfig.base.esm.json | 7 +++++++ 16 files changed, 141 insertions(+), 24 deletions(-) create mode 100644 metapackages/auto-instrumentations-web/tsconfig.esm.json create mode 100644 packages/opentelemetry-id-generator-aws-xray/tsconfig.esm.json create mode 100644 plugins/web/opentelemetry-instrumentation-document-load/tsconfig.esm.json create mode 100644 plugins/web/opentelemetry-instrumentation-user-interaction/tsconfig.esm.json create mode 100644 plugins/web/opentelemetry-plugin-react-load/tsconfig.esm.json create mode 100644 propagators/opentelemetry-propagator-aws-xray/tsconfig.esm.json create mode 100644 propagators/opentelemetry-propagator-ot-trace/tsconfig.esm.json create mode 100644 tsconfig.base.esm.json diff --git a/examples/web/package.json b/examples/web/package.json index d3752ce096..9847616733 100644 --- a/examples/web/package.json +++ b/examples/web/package.json @@ -35,13 +35,13 @@ }, "dependencies": { "@opentelemetry/api": "^1.0.0-rc.0", - "@opentelemetry/auto-instrumentations-web": "^0.15.0", + "@opentelemetry/auto-instrumentations-web": "^0.16.0", "@opentelemetry/context-zone": "^0.19.0", "@opentelemetry/core": "^0.19.0", "@opentelemetry/exporter-collector": "^0.19.0", "@opentelemetry/instrumentation": "^0.19.0", - "@opentelemetry/instrumentation-document-load": "^0.15.0", - "@opentelemetry/instrumentation-user-interaction": "^0.15.0", + "@opentelemetry/instrumentation-document-load": "^0.16.0", + "@opentelemetry/instrumentation-user-interaction": "^0.16.0", "@opentelemetry/instrumentation-xml-http-request": "^0.19.0", "@opentelemetry/propagator-b3": "^0.19.0", "@opentelemetry/tracing": "^0.19.0", diff --git a/metapackages/auto-instrumentations-web/package.json b/metapackages/auto-instrumentations-web/package.json index 37a43d1470..f7c4b27deb 100644 --- a/metapackages/auto-instrumentations-web/package.json +++ b/metapackages/auto-instrumentations-web/package.json @@ -9,19 +9,20 @@ "access": "public" }, "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js-contrib", "scripts": { - "clean": "tsc --build --clean", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", - "compile": "tsc --build", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "precompile": "tsc --version", "prepare": "npm run compile", "test:browser": "nyc karma start --single-run", "version": "node ../../scripts/version-update.js", - "watch": "tsc --build --watch" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "bugs": { "url": "https://github.com/open-telemetry/opentelemetry-js-contrib/issues" diff --git a/metapackages/auto-instrumentations-web/tsconfig.esm.json b/metapackages/auto-instrumentations-web/tsconfig.esm.json new file mode 100644 index 0000000000..356b6d0307 --- /dev/null +++ b/metapackages/auto-instrumentations-web/tsconfig.esm.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "skipLibCheck": true, + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/packages/opentelemetry-id-generator-aws-xray/package.json b/packages/opentelemetry-id-generator-aws-xray/package.json index 8bf8713e47..bb53497cee 100644 --- a/packages/opentelemetry-id-generator-aws-xray/package.json +++ b/packages/opentelemetry-id-generator-aws-xray/package.json @@ -6,23 +6,25 @@ "publishConfig": { "access": "public" }, + "module": "build/esm/index.js", "browser": { "./src/platform/index.ts": "./src/platform/browser/index.ts", + "./build/esm/platform/index.js": "./build/esm/platform/browser/index.js", "./build/src/platform/index.js": "./build/src/platform/browser/index.js" }, "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js-contrib", "scripts": { "precompile": "tsc --version", - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts", "test:browser": "nyc karma start --single-run", "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "version": "node ../../scripts/version-update.js", - "watch": "tsc --build --watch", + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json", "prepare": "npm run compile" }, "keywords": [ @@ -39,6 +41,9 @@ "node": ">=8.5.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", diff --git a/packages/opentelemetry-id-generator-aws-xray/tsconfig.esm.json b/packages/opentelemetry-id-generator-aws-xray/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/packages/opentelemetry-id-generator-aws-xray/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/plugins/web/opentelemetry-instrumentation-document-load/package.json b/plugins/web/opentelemetry-instrumentation-document-load/package.json index 8e4f1f9742..beef6b354a 100644 --- a/plugins/web/opentelemetry-instrumentation-document-load/package.json +++ b/plugins/web/opentelemetry-instrumentation-document-load/package.json @@ -3,20 +3,21 @@ "version": "0.16.0", "description": "OpenTelemetry document-load automatic instrumentation package.", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js-contrib", "scripts": { - "clean": "rimraf build/*", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "precompile": "tsc --version", "version:update": "node ../../../scripts/version-update.js", - "compile": "npm run version:update && tsc -p .", + "compile": "npm run version:update && tsc --build tsconfig.json tsconfig.esm.json", "prepare": "npm run compile", "tdd": "karma start", "test:browser": "nyc karma start --single-run", - "watch": "tsc -w" + "watch": "tsc --build -watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -32,7 +33,11 @@ "node": ">=8.0.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", + "build/src/**/*.map", "build/src/**/*.d.ts", "doc", "LICENSE", diff --git a/plugins/web/opentelemetry-instrumentation-document-load/tsconfig.esm.json b/plugins/web/opentelemetry-instrumentation-document-load/tsconfig.esm.json new file mode 100644 index 0000000000..379f547a46 --- /dev/null +++ b/plugins/web/opentelemetry-instrumentation-document-load/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/package.json b/plugins/web/opentelemetry-instrumentation-user-interaction/package.json index 2d0396b45a..b9961c599e 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/package.json +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/package.json @@ -3,20 +3,21 @@ "version": "0.16.0", "description": "OpenTelemetry UserInteraction automatic instrumentation package.", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js-contrib", "scripts": { "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", - "clean": "rimraf build/*", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "precompile": "tsc --version", "version:update": "node ../../../scripts/version-update.js", - "compile": "npm run version:update && tsc -p .", + "compile": "npm run version:update && tsc --build tsconfig.json tsconfig.esm.json", "prepare": "npm run compile", "tdd": "karma start", "test:browser": "nyc karma start --single-run", - "watch": "tsc -w" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -32,7 +33,11 @@ "node": ">=8.0.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", + "build/src/**/*.map", "build/src/**/*.d.ts", "doc", "LICENSE", diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/tsconfig.esm.json b/plugins/web/opentelemetry-instrumentation-user-interaction/tsconfig.esm.json new file mode 100644 index 0000000000..0bbc54d329 --- /dev/null +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/tsconfig.esm.json @@ -0,0 +1,13 @@ +{ + "extends": "../../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "skipLibCheck": true, + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "files": [ "node_modules/zone.js/dist/zone.js.d.ts"], + "include": [ + "src/**/*.ts" + ] +} diff --git a/plugins/web/opentelemetry-plugin-react-load/package.json b/plugins/web/opentelemetry-plugin-react-load/package.json index cd66e90f3b..3e1c2891d8 100644 --- a/plugins/web/opentelemetry-plugin-react-load/package.json +++ b/plugins/web/opentelemetry-plugin-react-load/package.json @@ -3,20 +3,21 @@ "version": "0.16.0", "description": "OpenTelemetry React loading automatic instrumentation package.", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js-contrib", "scripts": { - "clean": "rimraf build/*", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../", "precompile": "tsc --version", "version:update": "node ../../../scripts/version-update.js", - "compile": "npm run version:update && tsc -p .", + "compile": "npm run version:update && tsc --build tsconfig.json tsconfig.esm.json", "prepare": "npm run compile", "tdd": "karma start", "test:browser": "nyc karma start --single-run", - "watch": "tsc -w" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -32,7 +33,11 @@ "node": ">=8.0.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", + "build/src/**/*.map", "build/src/**/*.d.ts", "doc", "LICENSE", diff --git a/plugins/web/opentelemetry-plugin-react-load/tsconfig.esm.json b/plugins/web/opentelemetry-plugin-react-load/tsconfig.esm.json new file mode 100644 index 0000000000..c7913fa6a2 --- /dev/null +++ b/plugins/web/opentelemetry-plugin-react-load/tsconfig.esm.json @@ -0,0 +1,12 @@ +{ + "extends": "../../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "jsx": "react", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/propagators/opentelemetry-propagator-aws-xray/package.json b/propagators/opentelemetry-propagator-aws-xray/package.json index 1dd84af6cf..9404b7a248 100644 --- a/propagators/opentelemetry-propagator-aws-xray/package.json +++ b/propagators/opentelemetry-propagator-aws-xray/package.json @@ -3,19 +3,20 @@ "version": "0.16.0", "description": "OpenTelemetry AWS Xray propagator provides context propagation for systems that are using AWS X-Ray format.", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js-contrib", "scripts": { "precompile": "tsc --version", - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts", "test:browser": "nyc karma start --single-run", "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "version": "node ../../scripts/version-update.js", - "watch": "tsc --build --watch", + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json", "prepare": "npm run compile" }, "keywords": [ @@ -31,6 +32,9 @@ "node": ">=8.0.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", diff --git a/propagators/opentelemetry-propagator-aws-xray/tsconfig.esm.json b/propagators/opentelemetry-propagator-aws-xray/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/propagators/opentelemetry-propagator-aws-xray/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/propagators/opentelemetry-propagator-ot-trace/package.json b/propagators/opentelemetry-propagator-ot-trace/package.json index 700aff940f..834742b132 100644 --- a/propagators/opentelemetry-propagator-ot-trace/package.json +++ b/propagators/opentelemetry-propagator-ot-trace/package.json @@ -3,19 +3,20 @@ "version": "0.16.0", "description": "The OpenTelemetry OTTracepropagator implements the propagation format used by the \"basic tracer\" implementations from the OpenTracing project", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js-contrib", "scripts": { "precompile": "tsc --version", - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts", "test:browser": "nyc karma start --single-run", "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "version": "node ../../scripts/version-update.js", - "watch": "tsc --build --watch", + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json", "prepare": "npm run compile" }, "keywords": [ @@ -33,6 +34,9 @@ "node": ">=8.5.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", diff --git a/propagators/opentelemetry-propagator-ot-trace/tsconfig.esm.json b/propagators/opentelemetry-propagator-ot-trace/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/propagators/opentelemetry-propagator-ot-trace/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/tsconfig.base.esm.json b/tsconfig.base.esm.json new file mode 100644 index 0000000000..5dbd1afb11 --- /dev/null +++ b/tsconfig.base.esm.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "ES6", + "moduleResolution": "node" + } +}