Skip to content

Commit 2736006

Browse files
authored
[core-amqp] move to shared rollup config (Azure#19588)
* [core-amqp] Move to shared rollup config - Use the shared rollup config from dev-tool for product. while working on this, move `StandardAbortMessage` from error.ts to util/constants.ts to break the circular dependency of errors -> utils -> errors. * Remove rollup.base.config.js while keeping rollup.test.config.js. Core-amqp has some dependencies that we don't want to add into the shared rollup config so we take an approach similar to what has been done to Event Hubs and Service Bus tests. * Remove unused `dotenv` code
1 parent 298b38a commit 2736006

File tree

12 files changed

+72
-188
lines changed

12 files changed

+72
-188
lines changed

sdk/core/core-amqp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"util": "^0.12.1"
8282
},
8383
"devDependencies": {
84+
"@azure/dev-tool": "^1.0.0",
8485
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
8586
"@microsoft/api-extractor": "^7.18.11",
8687
"@rollup/plugin-commonjs": "11.0.2",
@@ -98,7 +99,6 @@
9899
"chai": "^4.2.0",
99100
"cross-env": "^7.0.2",
100101
"debug": "^4.1.1",
101-
"dotenv": "^8.2.0",
102102
"downlevel-dts": "~0.4.0",
103103
"eslint": "^7.15.0",
104104
"karma": "^6.2.0",

sdk/core/core-amqp/rollup.base.config.js

Lines changed: 0 additions & 154 deletions
This file was deleted.
Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
3+
import { makeConfig } from "@azure/dev-tool/shared-config/rollup";
34

4-
import * as base from "./rollup.base.config";
5-
6-
const inputs = [];
7-
8-
if (!process.env.ONLY_BROWSER) {
9-
inputs.push(base.nodeConfig());
10-
}
11-
12-
if (!process.env.ONLY_NODE) {
13-
inputs.push(base.browserConfig());
14-
}
15-
16-
export default inputs;
5+
export default makeConfig(require("./package.json"));
Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,58 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
2-
// Licensed under the MIT License.
1+
import cjs from "@rollup/plugin-commonjs";
2+
import inject from "@rollup/plugin-inject";
3+
import json from "@rollup/plugin-json";
4+
import multiEntry from "@rollup/plugin-multi-entry";
5+
import nodeResolve from "@rollup/plugin-node-resolve";
6+
import replace from "@rollup/plugin-replace";
7+
import shim from "rollup-plugin-shim";
8+
import sourcemaps from "rollup-plugin-sourcemaps";
9+
import { makeConfig, makeBrowserTestConfig } from "@azure/dev-tool/shared-config/rollup";
310

4-
import * as base from "./rollup.base.config";
11+
const inputs = makeConfig(require("./package.json"));
512

6-
// Node tests are run via ts-node
7-
export default [base.browserConfig(true)];
13+
if (!process.env.ONLY_NODE) {
14+
// service-bus has many dependencies that we do not
15+
// want to bring into the shared rollup config, so
16+
// replace the original test config with a patched one
17+
inputs[1] = makeBrowserTestConfigPatch();
18+
}
19+
20+
function makeBrowserTestConfigPatch() {
21+
const config = { ...makeBrowserTestConfig(require("./package.json")) };
22+
config.plugins = [
23+
multiEntry({ exports: false }),
24+
sourcemaps(),
25+
replace({
26+
delimiters: ["", ""],
27+
}),
28+
// fs, net, and tls are used by rhea and need to be shimmed
29+
shim({
30+
os: `export default { }`,
31+
path: `export default { }`,
32+
}),
33+
nodeResolve({
34+
mainFields: ["module", "browser"],
35+
preferBuiltins: false,
36+
}),
37+
cjs({
38+
namedExports: {
39+
chai: ["should", "assert"],
40+
assert: ["equal", "deepEqual", "notEqual"],
41+
},
42+
}),
43+
// rhea and rhea-promise use the Buffer global which requires
44+
// injection to shim properly
45+
inject({
46+
modules: {
47+
Buffer: ["buffer", "Buffer"],
48+
process: "process",
49+
},
50+
exclude: ["./**/package.json"],
51+
}),
52+
json(),
53+
];
54+
55+
return config;
56+
}
57+
58+
export default inputs;

sdk/core/core-amqp/src/cbs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
SenderOptions,
1313
generate_uuid,
1414
} from "rhea-promise";
15-
import { StandardAbortMessage, translate } from "./errors";
15+
import { translate } from "./errors";
16+
import { StandardAbortMessage } from "./util/constants";
1617
import { logErrorStackTrace, logger } from "./log";
1718
import { Constants } from "./util/constants";
1819
import { RequestResponseLink } from "./requestResponseLink";

sdk/core/core-amqp/src/errors.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ import { AmqpError, AmqpResponseStatusCode, isAmqpError as rheaIsAmqpError } fro
66
import { isDefined, isObjectWithProperties } from "./util/typeGuards";
77
import { isNode, isNumber, isString } from "../src/util/utils";
88

9-
/**
10-
* The standard error message accompanying an AbortError.
11-
* @hidden
12-
*/
13-
export const StandardAbortMessage = "The operation was aborted.";
14-
159
/**
1610
* Maps the conditions to the numeric AMQP Response status codes.
1711
* @internal

sdk/core/core-amqp/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export { TokenType } from "./auth/token";
1010
export { ConnectionConfig, ConnectionConfigOptions } from "./connectionConfig/connectionConfig";
1111

1212
export { CbsClient, CbsResponse } from "./cbs";
13-
export { Constants } from "./util/constants";
13+
export { Constants, StandardAbortMessage } from "./util/constants";
1414
export { AmqpMessageHeader } from "./messageHeader";
1515
export { AmqpMessageProperties } from "./messageProperties";
1616
export {
@@ -28,7 +28,6 @@ export {
2828
isSystemError,
2929
SystemErrorConditionMapper,
3030
NetworkSystemError,
31-
StandardAbortMessage,
3231
} from "./errors";
3332
export {
3433
delay,

sdk/core/core-amqp/src/requestResponseLink.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT license.
33

44
import { AbortError, AbortSignalLike } from "@azure/abort-controller";
5-
import { ConditionStatusMapper, StandardAbortMessage, translate } from "./errors";
5+
import { ConditionStatusMapper, translate } from "./errors";
66
import {
77
Connection,
88
EventContext,
@@ -17,7 +17,7 @@ import {
1717
generate_uuid,
1818
} from "rhea-promise";
1919
import { logErrorStackTrace, logger } from "./log";
20-
import { Constants } from "./util/constants";
20+
import { Constants, StandardAbortMessage } from "./util/constants";
2121
import { isDefined } from "./util/typeGuards";
2222

2323
/**

sdk/core/core-amqp/src/util/constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,9 @@ export const Constants = {
122122
falseFilterList: 83483426824,
123123
},
124124
} as const;
125+
126+
/**
127+
* The standard error message accompanying an AbortError.
128+
* @hidden
129+
*/
130+
export const StandardAbortMessage = "The operation was aborted.";

sdk/core/core-amqp/src/util/lock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { AbortError, AbortSignalLike } from "@azure/abort-controller";
55
import { OperationTimeoutError } from "rhea-promise";
6-
import { StandardAbortMessage } from "../errors";
6+
import { StandardAbortMessage } from "./constants";
77
import { logger } from "../log";
88

99
/**

0 commit comments

Comments
 (0)