Skip to content

Commit fe7545b

Browse files
authored
[communication] Move @azure/communication-common to ESM/vitest (#31419)
### Packages impacted by this PR - @azure/communication-common ### Issues associated with this PR - #31338 ### Describe the problem that is addressed by this PR Updates to ESM/vitest for @azure/communication-common ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary)
1 parent 0cacd21 commit fe7545b

34 files changed

+263
-323
lines changed

common/config/rush/pnpm-lock.yaml

Lines changed: 21 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/communication/communication-common/.nycrc

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

sdk/communication/communication-common/api-extractor.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3-
"mainEntryPointFilePath": "types/src/index.d.ts",
3+
"mainEntryPointFilePath": "dist/esm/index.d.ts",
44
"docModel": {
55
"enabled": true
66
},
@@ -11,7 +11,7 @@
1111
"dtsRollup": {
1212
"enabled": true,
1313
"untrimmedFilePath": "",
14-
"publicTrimmedFilePath": "./types/communication-common.d.ts"
14+
"publicTrimmedFilePath": "dist/communication-common.d.ts"
1515
},
1616
"messages": {
1717
"tsdocMessageReporting": {

sdk/communication/communication-common/karma.conf.js

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

sdk/communication/communication-common/package.json

Lines changed: 62 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,38 @@
33
"version": "2.3.2",
44
"description": "Common package for Azure Communication services.",
55
"sdk-type": "client",
6-
"main": "dist/index.js",
7-
"module": "dist-esm/src/index.js",
8-
"types": "types/communication-common.d.ts",
9-
"browser": {
10-
"./dist-esm/src/credential/cryptoUtils.js": "./dist-esm/src/credential/cryptoUtils.browser.js",
11-
"./dist-esm/src/credential/isNode.js": "./dist-esm/src/credential/isNode.browser.js"
12-
},
6+
"main": "./dist/commonjs/index.js",
7+
"module": "./dist/esm/index.js",
8+
"types": "./dist/commonjs/index.d.ts",
9+
"browser": "./dist/browser/index.js",
1310
"scripts": {
1411
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
15-
"build": "npm run clean && tsc -p . && dev-tool run bundle && dev-tool run extract-api",
16-
"build:browser": "tsc -p . && dev-tool run bundle",
17-
"build:node": "tsc -p . && dev-tool run bundle",
12+
"build": "npm run clean && dev-tool run build-package && dev-tool run extract-api",
13+
"build:browser": "dev-tool run build-package && dev-tool run bundle",
14+
"build:node": "dev-tool run build-package && dev-tool run bundle",
1815
"build:samples": "echo Skipped.",
19-
"build:test": "tsc -p . && dev-tool run bundle",
16+
"build:test": "dev-tool run build-package && dev-tool run bundle",
2017
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
2118
"clean": "rimraf --glob dist dist-* temp types *.tgz *.log",
2219
"execute:samples": "echo skipped",
23-
"extract-api": "tsc -p . && dev-tool run extract-api",
20+
"extract-api": "dev-tool run build-package && dev-tool run extract-api",
2421
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
2522
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
26-
"integration-test:browser": "karma start --single-run",
27-
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'",
23+
"integration-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --no-test-proxy --browser",
24+
"integration-test:node": "dev-tool run test:vitest --no-test-proxy",
2825
"lint": "eslint package.json api-extractor.json README.md src test",
2926
"lint:fix": "eslint package.json api-extractor.json README.md src test --fix --fix-type [problem,suggestion]",
3027
"pack": "npm pack 2>&1",
3128
"test": "npm run build:test && npm run unit-test && npm run integration-test",
3229
"test:browser": "npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
3330
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
3431
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
35-
"unit-test:browser": "karma start --single-run",
36-
"unit-test:node": "dev-tool run test:node-ts-input --no-test-proxy",
32+
"unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --no-test-proxy --browser",
33+
"unit-test:node": "dev-tool run test:vitest --no-test-proxy",
3734
"update-snippets": "echo skipped"
3835
},
3936
"files": [
4037
"dist/",
41-
"dist-esm/src",
42-
"types/communication-common.d.ts",
4338
"README.md",
4439
"LICENSE"
4540
],
@@ -63,45 +58,68 @@
6358
"sideEffects": false,
6459
"prettier": "@azure/eslint-plugin-azure-sdk/prettier.json",
6560
"dependencies": {
66-
"@azure/abort-controller": "^2.0.0",
67-
"@azure/core-auth": "^1.3.0",
68-
"@azure/core-rest-pipeline": "^1.3.2",
69-
"@azure/core-tracing": "^1.0.0",
70-
"@azure/core-util": "^1.0.0",
61+
"@azure/abort-controller": "^2.1.2",
62+
"@azure/core-auth": "^1.8.0",
63+
"@azure/core-rest-pipeline": "^1.17.0",
64+
"@azure/core-tracing": "^1.2.0",
65+
"@azure/core-util": "^1.10.0",
7166
"events": "^3.0.0",
7267
"jwt-decode": "^4.0.0",
73-
"tslib": "^2.2.0"
68+
"tslib": "^2.7.0"
7469
},
7570
"devDependencies": {
71+
"@azure-tools/test-utils-vitest": "^1.0.0",
7672
"@azure/dev-tool": "^1.0.0",
7773
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
7874
"@microsoft/api-extractor": "^7.31.1",
79-
"@types/chai": "^4.1.6",
80-
"@types/chai-as-promised": "^7.1.0",
81-
"@types/mocha": "^10.0.0",
8275
"@types/node": "^18.0.0",
83-
"@types/sinon": "^17.0.0",
84-
"chai": "^4.2.0",
85-
"chai-as-promised": "^7.1.1",
76+
"@vitest/browser": "^2.1.3",
77+
"@vitest/coverage-istanbul": "^2.1.3",
8678
"cross-env": "^7.0.2",
8779
"eslint": "^9.9.0",
8880
"inherits": "^2.0.3",
89-
"karma": "^6.2.0",
90-
"karma-chrome-launcher": "^3.0.0",
91-
"karma-coverage": "^2.0.0",
92-
"karma-env-preprocessor": "^0.1.1",
93-
"karma-firefox-launcher": "^1.1.0",
94-
"karma-junit-reporter": "^2.0.1",
95-
"karma-mocha": "^2.0.1",
96-
"karma-mocha-reporter": "^2.2.5",
97-
"karma-sourcemap-loader": "^0.3.8",
98-
"mocha": "^10.0.0",
9981
"mockdate": "^3.0.5",
100-
"nyc": "^17.0.0",
82+
"playwright": "^1.48.0",
10183
"rimraf": "^5.0.5",
102-
"sinon": "^17.0.0",
103-
"ts-node": "^10.0.0",
10484
"typescript": "~5.6.2",
105-
"util": "^0.12.1"
85+
"util": "^0.12.1",
86+
"vitest": "^2.1.3"
87+
},
88+
"type": "module",
89+
"tshy": {
90+
"exports": {
91+
"./package.json": "./package.json",
92+
".": "./src/index.ts"
93+
},
94+
"dialects": [
95+
"esm",
96+
"commonjs"
97+
],
98+
"esmDialects": [
99+
"browser",
100+
"react-native"
101+
],
102+
"selfLink": false
103+
},
104+
"exports": {
105+
"./package.json": "./package.json",
106+
".": {
107+
"browser": {
108+
"types": "./dist/browser/index.d.ts",
109+
"default": "./dist/browser/index.js"
110+
},
111+
"react-native": {
112+
"types": "./dist/react-native/index.d.ts",
113+
"default": "./dist/react-native/index.js"
114+
},
115+
"import": {
116+
"types": "./dist/esm/index.d.ts",
117+
"default": "./dist/esm/index.js"
118+
},
119+
"require": {
120+
"types": "./dist/commonjs/index.d.ts",
121+
"default": "./dist/commonjs/index.js"
122+
}
123+
}
106124
}
107125
}

sdk/communication/communication-common/review/communication-common.api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
55
```ts
66

7-
import { AbortSignalLike } from '@azure/abort-controller';
8-
import { AccessToken } from '@azure/core-auth';
7+
import type { AbortSignalLike } from '@azure/abort-controller';
8+
import type { AccessToken } from '@azure/core-auth';
99
import { KeyCredential } from '@azure/core-auth';
1010
import { PipelinePolicy } from '@azure/core-rest-pipeline';
1111
import { TokenCredential } from '@azure/core-auth';

sdk/communication/communication-common/rollup.base.config.js

Whitespace-only changes.

sdk/communication/communication-common/src/autoRefreshTokenCredential.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
import { CommunicationGetTokenOptions, TokenCredential } from "./communicationTokenCredential";
5-
import { AbortSignalLike } from "@azure/abort-controller";
6-
import { AccessToken } from "@azure/core-auth";
7-
import { parseToken } from "./tokenParser";
4+
import type {
5+
CommunicationGetTokenOptions,
6+
TokenCredential,
7+
} from "./communicationTokenCredential.js";
8+
import type { AbortSignalLike } from "@azure/abort-controller";
9+
import type { AccessToken } from "@azure/core-auth";
10+
import { parseToken } from "./tokenParser.js";
811

912
/**
1013
* Options for auto-refreshing a Communication Token credential.

0 commit comments

Comments
 (0)