Skip to content

Commit

Permalink
[core-amqp] move to shared rollup config (#19588)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
jeremymeng authored Jan 4, 2022
1 parent 298b38a commit 2736006
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 188 deletions.
2 changes: 1 addition & 1 deletion sdk/core/core-amqp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"util": "^0.12.1"
},
"devDependencies": {
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@microsoft/api-extractor": "^7.18.11",
"@rollup/plugin-commonjs": "11.0.2",
Expand All @@ -98,7 +99,6 @@
"chai": "^4.2.0",
"cross-env": "^7.0.2",
"debug": "^4.1.1",
"dotenv": "^8.2.0",
"downlevel-dts": "~0.4.0",
"eslint": "^7.15.0",
"karma": "^6.2.0",
Expand Down
154 changes: 0 additions & 154 deletions sdk/core/core-amqp/rollup.base.config.js

This file was deleted.

15 changes: 2 additions & 13 deletions sdk/core/core-amqp/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { makeConfig } from "@azure/dev-tool/shared-config/rollup";

import * as base from "./rollup.base.config";

const inputs = [];

if (!process.env.ONLY_BROWSER) {
inputs.push(base.nodeConfig());
}

if (!process.env.ONLY_NODE) {
inputs.push(base.browserConfig());
}

export default inputs;
export default makeConfig(require("./package.json"));
61 changes: 56 additions & 5 deletions sdk/core/core-amqp/rollup.test.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,58 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import cjs from "@rollup/plugin-commonjs";
import inject from "@rollup/plugin-inject";
import json from "@rollup/plugin-json";
import multiEntry from "@rollup/plugin-multi-entry";
import nodeResolve from "@rollup/plugin-node-resolve";
import replace from "@rollup/plugin-replace";
import shim from "rollup-plugin-shim";
import sourcemaps from "rollup-plugin-sourcemaps";
import { makeConfig, makeBrowserTestConfig } from "@azure/dev-tool/shared-config/rollup";

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

// Node tests are run via ts-node
export default [base.browserConfig(true)];
if (!process.env.ONLY_NODE) {
// service-bus has many dependencies that we do not
// want to bring into the shared rollup config, so
// replace the original test config with a patched one
inputs[1] = makeBrowserTestConfigPatch();
}

function makeBrowserTestConfigPatch() {
const config = { ...makeBrowserTestConfig(require("./package.json")) };
config.plugins = [
multiEntry({ exports: false }),
sourcemaps(),
replace({
delimiters: ["", ""],
}),
// fs, net, and tls are used by rhea and need to be shimmed
shim({
os: `export default { }`,
path: `export default { }`,
}),
nodeResolve({
mainFields: ["module", "browser"],
preferBuiltins: false,
}),
cjs({
namedExports: {
chai: ["should", "assert"],
assert: ["equal", "deepEqual", "notEqual"],
},
}),
// rhea and rhea-promise use the Buffer global which requires
// injection to shim properly
inject({
modules: {
Buffer: ["buffer", "Buffer"],
process: "process",
},
exclude: ["./**/package.json"],
}),
json(),
];

return config;
}

export default inputs;
3 changes: 2 additions & 1 deletion sdk/core/core-amqp/src/cbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
SenderOptions,
generate_uuid,
} from "rhea-promise";
import { StandardAbortMessage, translate } from "./errors";
import { translate } from "./errors";
import { StandardAbortMessage } from "./util/constants";
import { logErrorStackTrace, logger } from "./log";
import { Constants } from "./util/constants";
import { RequestResponseLink } from "./requestResponseLink";
Expand Down
6 changes: 0 additions & 6 deletions sdk/core/core-amqp/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ import { AmqpError, AmqpResponseStatusCode, isAmqpError as rheaIsAmqpError } fro
import { isDefined, isObjectWithProperties } from "./util/typeGuards";
import { isNode, isNumber, isString } from "../src/util/utils";

/**
* The standard error message accompanying an AbortError.
* @hidden
*/
export const StandardAbortMessage = "The operation was aborted.";

/**
* Maps the conditions to the numeric AMQP Response status codes.
* @internal
Expand Down
3 changes: 1 addition & 2 deletions sdk/core/core-amqp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export { TokenType } from "./auth/token";
export { ConnectionConfig, ConnectionConfigOptions } from "./connectionConfig/connectionConfig";

export { CbsClient, CbsResponse } from "./cbs";
export { Constants } from "./util/constants";
export { Constants, StandardAbortMessage } from "./util/constants";
export { AmqpMessageHeader } from "./messageHeader";
export { AmqpMessageProperties } from "./messageProperties";
export {
Expand All @@ -28,7 +28,6 @@ export {
isSystemError,
SystemErrorConditionMapper,
NetworkSystemError,
StandardAbortMessage,
} from "./errors";
export {
delay,
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-amqp/src/requestResponseLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT license.

import { AbortError, AbortSignalLike } from "@azure/abort-controller";
import { ConditionStatusMapper, StandardAbortMessage, translate } from "./errors";
import { ConditionStatusMapper, translate } from "./errors";
import {
Connection,
EventContext,
Expand All @@ -17,7 +17,7 @@ import {
generate_uuid,
} from "rhea-promise";
import { logErrorStackTrace, logger } from "./log";
import { Constants } from "./util/constants";
import { Constants, StandardAbortMessage } from "./util/constants";
import { isDefined } from "./util/typeGuards";

/**
Expand Down
6 changes: 6 additions & 0 deletions sdk/core/core-amqp/src/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,9 @@ export const Constants = {
falseFilterList: 83483426824,
},
} as const;

/**
* The standard error message accompanying an AbortError.
* @hidden
*/
export const StandardAbortMessage = "The operation was aborted.";
2 changes: 1 addition & 1 deletion sdk/core/core-amqp/src/util/lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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

/**
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-amqp/src/util/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { AbortError, AbortSignalLike } from "@azure/abort-controller";
import { CancellableAsyncLock, CancellableAsyncLockImpl } from "./lock";
import { StandardAbortMessage } from "../errors";
import { StandardAbortMessage } from "./constants";
import { WebSocketImpl } from "rhea-promise";
import { isDefined } from "./typeGuards";

Expand Down
2 changes: 0 additions & 2 deletions sdk/core/core-amqp/test/retry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license.

import * as chai from "chai";
import * as dotenv from "dotenv";
import {
Constants,
MessagingError,
Expand All @@ -18,7 +17,6 @@ import debugModule from "debug";

const debug = debugModule("azure:core-amqp:retry-spec");
const should = chai.should();
dotenv.config();

[RetryMode.Exponential, RetryMode.Fixed].forEach((mode) => {
describe(`retry function for "${
Expand Down

0 comments on commit 2736006

Please sign in to comment.