Skip to content

Commit 4253e06

Browse files
committed
chore: make the @packages/telemetry an independent bundle without needed ts-node to register entrypoint. Both ESM and CJS distributions are built and types are used as source to be compatible with older styles of commonjs bundling. Types are not shipped with the package.
1 parent 9e8777d commit 4253e06

21 files changed

+149
-53
lines changed

packages/app/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Toast, { POSITION } from 'vue-toastification'
1313
import 'vue-toastification/dist/index.css'
1414
import { createWebsocket } from './runner'
1515
import { getRunnerConfigFromWindow } from './runner/get-runner-config-from-window'
16-
import { telemetry } from '@packages/telemetry/src/browser'
16+
import { telemetry } from '@packages/telemetry/browser/client'
1717

1818
// Grab the time just before loading config to include that in the cypress:app span
1919
const now = performance.now()

packages/app/src/runner/event-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { useStudioStore } from '../store/studio-store'
1414
import { getAutIframeModel } from '.'
1515
import { handlePausing } from './events/pausing'
1616
import { addTelemetryListeners } from './events/telemetry'
17-
import { telemetry } from '@packages/telemetry/src/browser'
17+
import { telemetry } from '@packages/telemetry/browser/client'
1818
import { addCaptureProtocolListeners } from './events/capture-protocol'
1919
import { getRunnerConfigFromWindow } from './get-runner-config-from-window'
2020

packages/app/src/runner/events/telemetry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { telemetry } from '@packages/telemetry/src/browser'
1+
import { telemetry } from '@packages/telemetry/browser/client'
22

33
export const addTelemetryListeners = (Cypress: Cypress.Cypress) => {
44
Cypress.on('test:before:run', (attributes, test) => {

packages/driver/src/cypress.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import type { CachedTestState } from '@packages/types'
4848
import { DocumentDomainInjection } from '@packages/network/lib/document-domain-injection'
4949
import { setSpecContentSecurityPolicy } from './util/privileged_channel'
5050

51-
import { telemetry } from '@packages/telemetry/src/browser'
51+
import { telemetry } from '@packages/telemetry/browser/client'
5252

5353
const debug = debugFn('cypress:driver:cypress')
5454

packages/driver/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import './config/bluebird'
44
import './config/jquery'
55
import './config/lodash'
66
import $Cypress from './cypress'
7-
import { telemetry } from '@packages/telemetry/src/browser'
7+
import { telemetry } from '@packages/telemetry/browser/client'
88

99
// Telemetry has already been initialized in the 'app' package
1010
// but since this is a different package we have to link up the instances.

packages/telemetry/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cjs/
2+
esm/
3+
browser/
4+
!src/browser

packages/telemetry/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,18 @@ const { OTLPTraceExporterIPC } = require('@packages/telemetry')
140140
141141
### Browser
142142
143-
To access the browser telemetry singleton use the browser export directly.
143+
To access the browser telemetry singleton use the browser export.
144144
145145
```js
146-
import { telemetry } from '@packages/telemetry/src/browser'
146+
import { telemetry } from '@packages/telemetry/browser/client'
147147

148148
telemetry.init({options})
149149
```
150150
151151
The browser singleton is also stored on window, in some cases when the telemetry package is included in multiple packages you can use the `attach` method to retrieve and setup the singleton from the instance saved on window.
152152
153153
```js
154-
import { telemetry } from '@packages/telemetry/src/browser'
154+
import { telemetry } from '@packages/telemetry/browser/client'
155155

156156
telemetry.attach()
157157
```
@@ -198,7 +198,7 @@ const { telemetry } = require('@packages/telemetry')
198198
Browser:
199199
200200
```js
201-
import { telemetry } from '@packages/telemetry/src/browser'
201+
import { telemetry } from '@packages/telemetry/browser/client'
202202
```
203203
204204
### Spans

packages/telemetry/index.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/telemetry/package.json

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
"version": "0.0.0-development",
44
"description": "open telemetry wrapper used throughout the cypress monorepo to instrument the cypress app",
55
"private": true,
6-
"main": "dist/node.js",
7-
"browser": "src/browser.ts",
6+
"main": "cjs/node.js",
87
"scripts": {
9-
"build": "tsc",
10-
"check-ts": "tsc --noEmit && yarn -s tslint",
11-
"clean": "rimraf dist",
8+
"build": "yarn build:esm && yarn build:cjs && yarn build:browser",
9+
"build-prod": "yarn build",
10+
"build:browser": "rimraf browser && rollup -c rollup.config.mjs",
11+
"build:cjs": "rimraf cjs && tsc -p tsconfig.cjs.json",
12+
"build:esm": "rimraf esm && tsc -p tsconfig.esm.json",
13+
"check-ts": "tsc -p tsconfig.cjs.json --noEmit && yarn -s tslint -p tsconfig.cjs.json",
14+
"clean": "rimraf esm cjs",
15+
"clean-deps": "rimraf node_modules",
1216
"test": "yarn test-unit",
1317
"test-unit": "mocha --config ./test/.mocharc.js",
1418
"tslint": "tslint --config ../ts/tslint.json --project .",
@@ -27,12 +31,18 @@
2731
},
2832
"devDependencies": {
2933
"@packages/ts": "0.0.0-development",
30-
"mocha": "7.0.1"
34+
"@rollup/plugin-typescript": "12.0.0",
35+
"mocha": "7.0.1",
36+
"rimraf": "6.0.1",
37+
"rollup": "4.52.0",
38+
"typescript": "5.6.3"
3139
},
3240
"files": [
33-
"dist",
34-
"src"
41+
"esm",
42+
"cjs",
43+
"browser"
3544
],
36-
"types": "src/node.ts",
45+
"types": "cjs/node.d.ts",
46+
"module": "esm/node.js",
3747
"nx": {}
3848
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import typescript from '@rollup/plugin-typescript'
2+
3+
// inline all the values/imports from the entry point client.ts into the browser/client.js bundle
4+
// and provides declarations for the browser/client.d.ts bundle
5+
const config = [
6+
{
7+
input: 'src/client.ts',
8+
output: {
9+
file: 'browser/client.js',
10+
format: 'esm',
11+
declaration: true,
12+
},
13+
plugins: [
14+
typescript({
15+
tsconfig: 'tsconfig.browser.json',
16+
}),
17+
],
18+
},
19+
]
20+
21+
export default config

0 commit comments

Comments
 (0)