Skip to content

Commit a6b8d24

Browse files
authored
Revert "[core-rest-pipeline] Add conditional exports (Azure#22804)" (Azure#23699)
This reverts commit 02f6ad6. ### Packages impacted by this PR `@azure/core-rest-pipeline` ### Describe the problem that is addressed by this PR Making core-rest-pipeline ESM with conditional exports broke notification-hubs. Reverting the change while investigating.
1 parent 8b85210 commit a6b8d24

File tree

72 files changed

+718
-850
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+718
-850
lines changed

common/config/rush/pnpm-lock.yaml

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

common/tools/dev-tool/src/commands/run/bundle.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,9 @@ export default leafCommand(commandInfo, async (options) => {
7070

7171
try {
7272
const bundle = await rollup.rollup(baseConfig);
73-
const cjsFilename = info.packageJson.main;
74-
if (!cjsFilename) {
75-
throw new Error("Expecting valid main entry");
76-
}
73+
7774
await bundle.write({
78-
file: cjsFilename,
75+
file: "dist/index.js",
7976
format: "cjs",
8077
sourcemap: true,
8178
exports: "named",

common/tools/eslint-plugin-azure-sdk/docs/rules/ts-package-json-main-is-cjs.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ts-package-json-main-is-cjs
22

3-
Requires `main` in `package.json` to be point to a CommonJS or UMD module. In this case, its assumed that it points to `"dist/index.js"` or `"dist/index.cjs"`.
3+
Requires `main` in `package.json` to be point to a CommonJS or UMD module. In this case, its assumed that it points to `"dist/index.js"`.
44

55
This rule is fixable using the `--fix` option.
66

@@ -14,14 +14,6 @@ This rule is fixable using the `--fix` option.
1414
}
1515
```
1616

17-
### Good
18-
19-
```json
20-
{
21-
"main": "dist/index.cjs"
22-
}
23-
```
24-
2517
### Bad
2618

2719
```json

common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-main-is-cjs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ export = {
4545
const nodeValue = node.value as Literal;
4646
const main = nodeValue.value as string;
4747

48-
if (!/^(\.\/)?dist\/index\.(c)?js$/.test(main)) {
48+
if (!/^(\.\/)?dist\/index\.js$/.test(main)) {
4949
context.report({
5050
node: nodeValue,
51-
message: `main is set to ${main} when it should be set to dist/index.js or dist/index.cjs`,
51+
message: `main is set to ${main} when it should be set to dist/index.js`,
5252
fix: (fixer: Rule.RuleFixer): Rule.Fix =>
5353
fixer.replaceText(nodeValue, `"dist/index.js"`),
5454
});

common/tools/eslint-plugin-azure-sdk/tests/rules/ts-package-json-main-is-cjs.ts

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,6 @@ ruleTester.run("ts-package-json-main-is-cjs", rule, {
263263
code: '{"main": "./dist/index.js"}',
264264
filename: "package.json",
265265
},
266-
{
267-
// correct format #1
268-
code: '{"main": "dist/index.cjs"}',
269-
filename: "package.json",
270-
},
271-
{
272-
// correct format #2
273-
code: '{"main": "./dist/index.cjs"}',
274-
filename: "package.json",
275-
},
276266
{
277267
// a full example package.json (taken from https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/event-hubs/package.json with "scripts" removed for testing purposes)
278268
code: examplePackageGood,
@@ -310,8 +300,7 @@ ruleTester.run("ts-package-json-main-is-cjs", rule, {
310300
filename: "package.json",
311301
errors: [
312302
{
313-
message:
314-
"main is set to dist//index.js when it should be set to dist/index.js or dist/index.cjs",
303+
message: "main is set to dist//index.js when it should be set to dist/index.js",
315304
},
316305
],
317306
output: '{"main": "dist/index.js"}',
@@ -321,8 +310,7 @@ ruleTester.run("ts-package-json-main-is-cjs", rule, {
321310
filename: "package.json",
322311
errors: [
323312
{
324-
message:
325-
"main is set to .dist/index.js when it should be set to dist/index.js or dist/index.cjs",
313+
message: "main is set to .dist/index.js when it should be set to dist/index.js",
326314
},
327315
],
328316
output: '{"main": "dist/index.js"}',
@@ -332,8 +320,7 @@ ruleTester.run("ts-package-json-main-is-cjs", rule, {
332320
filename: "package.json",
333321
errors: [
334322
{
335-
message:
336-
"main is set to /dist/index.js when it should be set to dist/index.js or dist/index.cjs",
323+
message: "main is set to /dist/index.js when it should be set to dist/index.js",
337324
},
338325
],
339326
output: '{"main": "dist/index.js"}',
@@ -344,7 +331,7 @@ ruleTester.run("ts-package-json-main-is-cjs", rule, {
344331
filename: "package.json",
345332
errors: [
346333
{
347-
message: "main is set to dist when it should be set to dist/index.js or dist/index.cjs",
334+
message: "main is set to dist when it should be set to dist/index.js",
348335
},
349336
],
350337
output: '{"main": "dist/index.js"}',
@@ -354,8 +341,7 @@ ruleTester.run("ts-package-json-main-is-cjs", rule, {
354341
filename: "package.json",
355342
errors: [
356343
{
357-
message:
358-
"main is set to index.js when it should be set to dist/index.js or dist/index.cjs",
344+
message: "main is set to index.js when it should be set to dist/index.js",
359345
},
360346
],
361347
output: '{"main": "dist/index.js"}',
@@ -365,8 +351,7 @@ ruleTester.run("ts-package-json-main-is-cjs", rule, {
365351
filename: "package.json",
366352
errors: [
367353
{
368-
message:
369-
"main is set to dist/src/index.js when it should be set to dist/index.js or dist/index.cjs",
354+
message: "main is set to dist/src/index.js when it should be set to dist/index.js",
370355
},
371356
],
372357
output: '{"main": "dist/index.js"}',
@@ -377,8 +362,7 @@ ruleTester.run("ts-package-json-main-is-cjs", rule, {
377362
filename: "package.json",
378363
errors: [
379364
{
380-
message:
381-
"main is set to index.js when it should be set to dist/index.js or dist/index.cjs",
365+
message: "main is set to index.js when it should be set to dist/index.js",
382366
},
383367
],
384368
output: examplePackageGood,

sdk/core/core-rest-pipeline/CHANGELOG.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# Release History
22

3-
## 1.10.0 (Unreleased)
3+
## 1.9.3 (Unreleased)
44

55
### Features Added
66

7-
- Added conditional exports for CommonJS and ESM. [#22804](https://github.com/Azure/azure-sdk-for-js/pull/22804)
8-
97
### Breaking Changes
108

119
### Bugs Fixed

sdk/core/core-rest-pipeline/core-rest-pipeline.d.cts

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

sdk/core/core-rest-pipeline/core-rest-pipeline.shims-3_1.d.cts

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

sdk/core/core-rest-pipeline/package.json

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
{
22
"name": "@azure/core-rest-pipeline",
3-
"version": "1.10.0",
3+
"version": "1.9.3",
44
"description": "Isomorphic client library for making HTTP requests in node.js and browser.",
55
"sdk-type": "client",
6-
"main": "dist/index.cjs",
6+
"main": "dist/index.js",
77
"module": "dist-esm/src/index.js",
8-
"type": "module",
9-
"export": {
10-
".": {
11-
"require": {
12-
"types": "core-rest-pipeline.shims.d.ts",
13-
"default": "./dist/index.cjs"
14-
},
15-
"import": {
16-
"types": "core-rest-pipeline.shims.d.cts",
17-
"default": "./dist-esm/src/index.js"
18-
}
19-
}
20-
},
218
"browser": {
229
"./dist-esm/src/defaultHttpClient.js": "./dist-esm/src/defaultHttpClient.browser.js",
2310
"./dist-esm/src/policies/decompressResponsePolicy.js": "./dist-esm/src/policies/decompressResponsePolicy.browser.js",
@@ -27,7 +14,7 @@
2714
"./dist-esm/src/util/userAgentPlatform.js": "./dist-esm/src/util/userAgentPlatform.browser.js"
2815
},
2916
"react-native": {
30-
"./dist/index.cjs": "./dist-esm/src/index.js",
17+
"./dist/index.js": "./dist-esm/src/index.js",
3118
"./dist-esm/src/defaultHttpClient.js": "./dist-esm/src/defaultHttpClient.native.js",
3219
"./dist-esm/src/util/userAgentPlatform.js": "./dist-esm/src/util/userAgentPlatform.native.js"
3320
},
@@ -36,9 +23,6 @@
3623
"<3.6": {
3724
"core-rest-pipeline.shims.d.ts": [
3825
"core-rest-pipeline.shims-3_1.d.ts"
39-
],
40-
"core-rest-pipeline.shims.d.cts": [
41-
"core-rest-pipeline.shims-3_1.d.cts"
4226
]
4327
}
4428
},
@@ -62,16 +46,14 @@
6246
"test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
6347
"test:node": "npm run clean && tsc -p . && npm run unit-test:node && npm run integration-test:node",
6448
"test": "npm run clean && tsc -p . && npm run unit-test:node && dev-tool run bundle && npm run unit-test:browser && npm run integration-test",
65-
"unit-test:browser": "karma start karma.conf.cjs --single-run",
66-
"unit-test:node": "mocha --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace --exclude \"test/**/browser/*.spec.ts\" \"test/**/*.spec.ts\"",
49+
"unit-test:browser": "karma start --single-run",
50+
"unit-test:node": "mocha -r esm -r ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace --exclude \"test/**/browser/*.spec.ts\" \"test/**/*.spec.ts\"",
6751
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
6852
},
6953
"files": [
7054
"dist/",
7155
"dist-esm/src/",
72-
"types/3.1/src/",
7356
"types/3.1/core-rest-pipeline.d.ts",
74-
"types/latest/src/",
7557
"types/latest/core-rest-pipeline.d.ts",
7658
"core-rest-pipeline.shims.d.ts",
7759
"core-rest-pipeline.shims-3_1.d.ts",
@@ -143,19 +125,15 @@
143125
"karma-sourcemap-loader": "^0.3.8",
144126
"karma": "^6.3.0",
145127
"mocha-junit-reporter": "^2.0.0",
146-
"mocha": "^10.0.0",
128+
"mocha": "^7.1.1",
147129
"prettier": "^2.5.1",
148130
"puppeteer": "^14.0.0",
149131
"rimraf": "^3.0.0",
150132
"sinon": "^9.0.2",
151133
"source-map-support": "^0.5.9",
152-
"ts-node": "^10.0.0",
153-
"typescript": "~4.7.0",
134+
"typescript": "~4.6.0",
154135
"util": "^0.12.1"
155136
},
156-
"mocha": {
157-
"loader": "ts-node/esm"
158-
},
159137
"//sampleConfiguration": {
160138
"skipFolder": true,
161139
"disableDocsMs": true,

0 commit comments

Comments
 (0)