[rollup] - Fix bug in circular dependency warning suppression (#19012)

## What

- Fix incorrect logic when suppressing chai's circular dependency warnings
- Move to the common dev-tool configuration where possible

## Why

This is a longstanding issue that we have, where an incorrect logic was copy-pasted to other places. I figured while cleaning this up that any package I touch can just convert over to the shared dev-tool configuration. Where I was unable
to do that, I just fixed this bug to avoid too many changes in one PR.

Fixes #14292
Resolves #17818 
Resolves #17816 
Resolves #17815 
Resolves #17814 
Resolves #17813 
Resolves #17810
This commit is contained in:
Maor Leger 2021-12-09 11:00:32 -08:00 коммит произвёл GitHub
Родитель d810a31be0
Коммит 3c97db3a18
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
53 изменённых файлов: 66 добавлений и 1888 удалений

Просмотреть файл

@ -1661,6 +1661,7 @@ packages:
/@opentelemetry/node/0.22.0_@opentelemetry+api@1.0.3:
resolution: {integrity: sha512-+HhGbDruQ7cwejVOIYyxRa28uosnG8W95NiQZ6qE8PXXPsDSyGeftAPbtYpGit0H2f5hrVcMlwmWHeAo9xkSLA==}
engines: {node: '>=8.0.0'}
deprecated: Package renamed to @opentelemetry/sdk-trace-node
peerDependencies:
'@opentelemetry/api': ^1.0.0
dependencies:
@ -8399,7 +8400,7 @@ packages:
dev: false
file:projects/ai-anomaly-detector.tgz:
resolution: {integrity: sha512-k60gU9MY6seTzTWHkWIZ2sH7xdTTfZMz99y00dJRNs11gu/sfqyn1MgCh3xMSvCB9FkTazsLd6oPGklpNDMpnw==, tarball: file:projects/ai-anomaly-detector.tgz}
resolution: {integrity: sha512-8zK6kKlIk/JYDC8Cpl7YKLvef5nOSfhL91pk8kEZ4xw1/BbeU+ZIVHlzB4ciIIstJMrqWTRnRCQiajmOccNupQ==, tarball: file:projects/ai-anomaly-detector.tgz}
name: '@rush-temp/ai-anomaly-detector'
version: 0.0.0
dependencies:
@ -8647,7 +8648,7 @@ packages:
dev: false
file:projects/app-configuration.tgz:
resolution: {integrity: sha512-h9nLQwnEqw1OjRBrG2YmgFUD/wOCQe+fC+/45l/Kpeh2QBkLKXeJslgi5fme0YsUC0wmSsZqYaQZtn9mOCLjlw==, tarball: file:projects/app-configuration.tgz}
resolution: {integrity: sha512-HBZl2EancfACeRLK2hWk+nCAgXrptXnS9hX5E5SLleYzlPHovsJRBWf3bv0NopaHCgFPdRcAw5xwKa1C2tPz2g==, tarball: file:projects/app-configuration.tgz}
name: '@rush-temp/app-configuration'
version: 0.0.0
dependencies:
@ -11274,7 +11275,7 @@ packages:
dev: false
file:projects/digital-twins-core.tgz:
resolution: {integrity: sha512-JbiaAZTKbpTEXkwM3tXpIGF37Byi68uXKyabs92a93o5jbFaJEnlENvQjQ+xpAQR7kg/Yy1Bt/wOfEj8JopBWQ==, tarball: file:projects/digital-twins-core.tgz}
resolution: {integrity: sha512-LUm22jksNdxH1YVaRs5AGV46xuZ0dlNe2Ghuhfj2UkFrdimYbbqVBqceRsOmygzQncWwotAEqwW0t+agqr/knA==, tarball: file:projects/digital-twins-core.tgz}
name: '@rush-temp/digital-twins-core'
version: 0.0.0
dependencies:
@ -11447,7 +11448,7 @@ packages:
dev: false
file:projects/event-processor-host.tgz:
resolution: {integrity: sha512-1bsUaKknmTfFOC0w6wjYVciwePXLbmv5WQ8+YE0WLn04UW7kZala/RhlIolUx1TlS35vDKb73NHLz87KGe3g9w==, tarball: file:projects/event-processor-host.tgz}
resolution: {integrity: sha512-laogoDpT1udxqofK9IBRPOpvYQ/NBJcIVc9V6gPx1LB8pvbCZEkSTm0kLy1QDeI7iEyqRke4OXFcfNF/kSxing==, tarball: file:projects/event-processor-host.tgz}
name: '@rush-temp/event-processor-host'
version: 0.0.0
dependencies:
@ -11565,7 +11566,7 @@ packages:
dev: false
file:projects/eventhubs-checkpointstore-blob.tgz:
resolution: {integrity: sha512-Xy7VJKNs9xSRvm8bpeiwnhIxeqFC38msj+rzdOPsbGOTKAHShf9GWzkt6icvkNWjTUarp0vjQIb90qIhnx6InA==, tarball: file:projects/eventhubs-checkpointstore-blob.tgz}
resolution: {integrity: sha512-0eUlLaPKDNrmy9rO+dhIqEs2nyap9EUEhreSguDGf6XHnRXv6khUYxE6HhOPgkqEVw0RdT2KEDnRyNd4Ln3D6Q==, tarball: file:projects/eventhubs-checkpointstore-blob.tgz}
name: '@rush-temp/eventhubs-checkpointstore-blob'
version: 0.0.0
dependencies:
@ -11631,7 +11632,7 @@ packages:
dev: false
file:projects/eventhubs-checkpointstore-table.tgz:
resolution: {integrity: sha512-XqPBz9OE+MtEICebS8nkcYVz8VaLgcjCrYoOvt/O5lkiuzsIJ5epCvwGG9Q0kk5HiOEjVvH63dlLzqrwH1VB9g==, tarball: file:projects/eventhubs-checkpointstore-table.tgz}
resolution: {integrity: sha512-7TfDPvP47kYCnypCRVDath61kPdiTKykx5ZVgFRPBfTOCYQpNeoPVFVMDmCcaa3OB4VOQaogGwsz8L18CzOimg==, tarball: file:projects/eventhubs-checkpointstore-table.tgz}
name: '@rush-temp/eventhubs-checkpointstore-table'
version: 0.0.0
dependencies:
@ -13001,7 +13002,7 @@ packages:
dev: false
file:projects/quantum-jobs.tgz:
resolution: {integrity: sha512-36C2mZUJMdHi31RmxsAYWIPKGx9Qbjx0/jm36UatiDvJIZOvT5D/W+Un3kfIiNIoL910MFW5TyKkipEmvUdMsw==, tarball: file:projects/quantum-jobs.tgz}
resolution: {integrity: sha512-RLW7PtmPkoOi+WDgc6OfeIcp8y+pCJLKAG+DOM6LR9sy37u3IR1O0cD1LgkD+MHjnmW3pZpEiSRYZjZ1K500CA==, tarball: file:projects/quantum-jobs.tgz}
name: '@rush-temp/quantum-jobs'
version: 0.0.0
dependencies:
@ -13157,7 +13158,7 @@ packages:
dev: false
file:projects/search-documents.tgz:
resolution: {integrity: sha512-1vVVrXpDsNF6D0jfxy6e4EIJz1anhCYtCki2uiP6bMX171TGLMFWCNpKk0Xxw2FMeJqAIVt4/UcoOpOy0dby1w==, tarball: file:projects/search-documents.tgz}
resolution: {integrity: sha512-mwmuvS/Y1AJF2VZiBBiUymuDe52iBz4Kwm9DrfRVFGSyRgyKuMaymSuo5Q6Q/FnSRFDnYLRMTFcetQGXAr1JFQ==, tarball: file:projects/search-documents.tgz}
name: '@rush-temp/search-documents'
version: 0.0.0
dependencies:
@ -13217,7 +13218,7 @@ packages:
dev: false
file:projects/service-bus.tgz:
resolution: {integrity: sha512-k0NCGj25Mmp4w98MNi3B+2+sdwYOd0oWiWYLsUcH8YstzS/PuSlbZ6A67IGJeJptdzCQhUZkRctfEXKGrn34hQ==, tarball: file:projects/service-bus.tgz}
resolution: {integrity: sha512-ytqGlI90K4bkj/C9qGW6iS3O+ePWtrKA7esCS6Q+Gkn1tcNGwPUitzwX3Jd7bmTih0DaEr3ByUk1ahZ2G4+8kQ==, tarball: file:projects/service-bus.tgz}
name: '@rush-temp/service-bus'
version: 0.0.0
dependencies:

Просмотреть файл

@ -125,7 +125,7 @@ export function makeBrowserTestConfig(): RollupOptions {
// Chai's strange internal architecture makes it impossible to statically
// analyze its exports.
chai: ["version", "use", "util", "config", "expect", "should", "assert"],
...openTelemetryCommonJs()
events: ["EventEmitter"]
}
}),
json(),

Просмотреть файл

@ -14,7 +14,7 @@
"build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
"build:samples": "echo Obsolete.",
"build:test": "tsc -p . && rollup -c rollup.test.config.js 2>&1",
"build:test": "tsc -p . && rollup -c 2>&1",
"build": "npm run clean && tsc -p . && rollup -c 2>&1 && api-extractor run --local",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
"clean": "rimraf dist dist-* temp types *.tgz *.log",
@ -22,7 +22,7 @@
"extract-api": "tsc -p . && api-extractor run --local",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
"integration-test:browser": "karma start --single-run",
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 5000000 --full-trace dist-esm/test/**/*.spec.js",
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 5000000 --full-trace \"dist-esm/test/{,!(browser)/**/}*.spec.js\"",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
"lint": "eslint package.json api-extractor.json src test --ext .ts",
@ -31,7 +31,7 @@
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
"test": "npm run build:test && npm run unit-test && npm run integration-test",
"unit-test:browser": "karma start --single-run",
"unit-test:node": "mocha --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace dist-test/index.node.js",
"unit-test:node": "mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/{,!(browser)/**/}*.spec.ts\"",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src"
},
@ -73,11 +73,6 @@
"@azure/identity": "^2.0.1",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@microsoft/api-extractor": "^7.18.11",
"@rollup/plugin-commonjs": "11.0.2",
"@rollup/plugin-json": "^4.0.0",
"@rollup/plugin-multi-entry": "^3.0.0",
"@rollup/plugin-node-resolve": "^8.0.0",
"@rollup/plugin-replace": "^2.2.0",
"@types/chai": "^4.1.6",
"@types/mocha": "^7.0.2",
"@types/node": "^12.0.0",
@ -104,10 +99,6 @@
"prettier": "^1.16.4",
"rimraf": "^3.0.0",
"rollup": "^1.16.3",
"rollup-plugin-shim": "^1.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-terser": "^5.1.1",
"rollup-plugin-visualizer": "^4.0.4",
"typescript": "~4.2.0",
"util": "^0.12.1",
"@azure-tools/test-recorder": "^1.0.0",

Просмотреть файл

@ -1,137 +0,0 @@
import path from "path";
import nodeResolve from "@rollup/plugin-node-resolve";
import multiEntry from "@rollup/plugin-multi-entry";
import cjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import replace from "@rollup/plugin-replace";
import { terser } from "rollup-plugin-terser";
import shim from "rollup-plugin-shim";
import sourcemaps from "rollup-plugin-sourcemaps";
import viz from "rollup-plugin-visualizer";
import { openTelemetryCommonJs } from "@azure/dev-tool/shared-config/rollup";
const pkg = require("./package.json");
const depNames = Object.keys(pkg.dependencies);
const devDepNames = Object.keys(pkg.devDependencies);
const input = "dist-esm/src/index.js";
const production = process.env.NODE_ENV === "production";
export function nodeConfig(test = false) {
const externalNodeBuiltins = [];
const baseConfig = {
input: input,
external: depNames.concat(externalNodeBuiltins),
output: { file: "dist/index.js", format: "cjs", sourcemap: true },
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
// replace dynamic checks with if (true) since this is for node only.
// Allows rollup's dead code elimination to be more aggressive.
"if (isNode)": "if (true)"
}),
nodeResolve({ preferBuiltins: true }),
json(),
cjs()
]
};
if (test) {
// Entry points - test files under the `test` folder(common for both browser and node), node specific test files
baseConfig.input = ["dist-esm/test/*.spec.js", "dist-esm/test/node/*.spec.js"];
baseConfig.plugins.unshift(multiEntry({ exports: false }));
// different output file
baseConfig.output.file = "dist-test/index.node.js";
// mark devdeps as external
baseConfig.external.push(...devDepNames);
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
} else if (production) {
baseConfig.plugins.push(terser());
}
return baseConfig;
}
export function browserConfig(test = false) {
const baseConfig = {
input: input,
external: ["fs-extra", "nock", "path"],
output: {
file: "dist-browser/ai-anomaly-detector.js",
format: "umd",
name: "Azure.CogniteveServicesAnomalyDetector",
sourcemap: true,
globals: { "@azure/core-http": "Azure.Core.HTTP" }
},
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
// replace dynamic checks with if (false) since this is for
// browser only. Rollup's dead code elimination will remove
// any code guarded by if (isNode) { ... }
"if (isNode)": "if (false)"
}),
shim({
fs: `export default {}`,
path: `export function join() {}`,
stream: `export default {}`,
dotenv: `export function config() { }`,
os: `
export function arch() { return "javascript" }
export function type() { return "Browser" }
export function release() { typeof navigator === 'undefined' ? '' : navigator.appVersion }
`,
constants: `export default {}`
}),
nodeResolve({
mainFields: ["module", "browser"],
preferBuiltins: false
}),
json(),
cjs({
namedExports: {
chai: ["assert"],
...openTelemetryCommonJs()
}
}),
viz({ filename: "dist-browser/browser-stats.html", sourcemap: false })
]
};
if (test) {
// Entry points - test files under the `test` folder(common for both browser and node), browser specific test files
baseConfig.input = ["dist-esm/test/*.spec.js", "dist-esm/test/browser/*.spec.js"];
baseConfig.plugins.unshift(multiEntry({ exports: false }));
baseConfig.output.file = "dist-test/index.browser.js";
baseConfig.onwarn = (warning) => {
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;
}
console.error(`(!) ${warning.message}`);
};
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
}
return baseConfig;
}

Просмотреть файл

@ -1,13 +1,3 @@
import * as base from "./rollup.base.config";
import { makeConfig } from "@azure/dev-tool/shared-config/rollup";
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"));

Просмотреть файл

@ -1,3 +0,0 @@
import * as base from "./rollup.base.config";
export default [base.nodeConfig(true), base.browserConfig(true)];

Просмотреть файл

@ -3,15 +3,12 @@
import { Context } from "mocha";
import * as dotenv from "dotenv";
import { env, Recorder, record, RecorderEnvironmentSetup } from "@azure-tools/test-recorder";
import { ClientSecretCredential } from "@azure/identity";
import { AnomalyDetectorClient } from "../../src/AnomalyDetectorClient";
import { AzureKeyCredential } from "@azure/core-auth";
dotenv.config();
export interface RecordedRecognizerClient {
client: AnomalyDetectorClient;
recorder: Recorder;

Просмотреть файл

@ -34,10 +34,7 @@ const ignoreKnownWarnings = (warning) => {
return;
}
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
) {
if (warning.code === "CIRCULAR_DEPENDENCY" && warning.importer.includes("node_modules/chai")) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;
}

Просмотреть файл

@ -17,12 +17,7 @@ import {
} from "@azure-tools/test-recorder";
import * as assert from "assert";
// allow loading from a .env file as an alternative to defining the variable
// in the environment
import * as dotenv from "dotenv";
import { DefaultAzureCredential, TokenCredential } from "@azure/identity";
dotenv.config();
let connectionStringNotPresentWarning = false;
let tokenCredentialsNotPresentWarning = false;

Просмотреть файл

@ -127,7 +127,7 @@ export function browserConfig(test = false) {
baseConfig.onwarn = (warning) => {
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
warning.importer.includes("node_modules/chai")
) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;

Просмотреть файл

@ -105,7 +105,7 @@ export function browserConfig(test = false) {
baseConfig.onwarn = (warning) => {
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
warning.importer.includes("node_modules/chai")
) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;

Просмотреть файл

@ -116,7 +116,7 @@ export function browserConfig(test = false) {
baseConfig.onwarn = (warning) => {
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
warning.importer.includes("node_modules/chai")
) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;

Просмотреть файл

@ -116,7 +116,7 @@ export function browserConfig(test = false) {
baseConfig.onwarn = (warning) => {
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
warning.importer.includes("node_modules/chai")
) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;

Просмотреть файл

@ -126,7 +126,7 @@ export function browserConfig(test = false) {
baseConfig.onwarn = (warning) => {
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
warning.importer.includes("node_modules/chai")
) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;

Просмотреть файл

@ -126,7 +126,7 @@ export function browserConfig(test = false) {
baseConfig.onwarn = (warning) => {
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
warning.importer.includes("node_modules/chai")
) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;

Просмотреть файл

@ -124,7 +124,7 @@ export function browserConfig(test = false) {
baseConfig.onwarn = (warning) => {
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
warning.importer.includes("node_modules/chai")
) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;

Просмотреть файл

@ -16,9 +16,9 @@
"build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1 && npm run extract-api",
"build": "npm run clean && tsc -p . && rollup -c 2>&1 && api-extractor run --local",
"build:test:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c rollup.test.config.js 2>&1",
"build:test:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c rollup.test.config.js 2>&1",
"build:test": "tsc -p . && rollup -c rollup.test.config.js 2>&1",
"build:test:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:test:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
"build:test": "tsc -p . && rollup -c 2>&1",
"build:samples": "echo Obsolete.",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"clean": "rimraf dist dist-esm dist-browser test-dist test-browser types *.tgz *.log",
@ -28,7 +28,7 @@
"extract-api": "tsc -p . && api-extractor run --local",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"integration-test:browser": "npm run build:test:browser && cross-env TEST_MODE=live karma start --single-run",
"integration-test:node": "npm run build:test:node && nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 180000 --full-trace \"dist-esm/test/*.spec.js\" \"dist-esm/test/**/*.spec.js\" --harmony",
"integration-test:node": "npm run build:test:node && nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 180000 --full-trace \"dist-esm/test/{,!(browser)/**/}*.spec.js\"",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
"lint": "eslint package.json api-extractor.json src test --ext .ts",
@ -37,7 +37,7 @@
"test:browser": "npm run clean && npm run build:test:browser && npm run unit-test:browser",
"test": "npm run clean && npm run build:test && npm run unit-test",
"unit-test:browser": "karma start --single-run",
"unit-test:node": "mocha --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 180000 --full-trace \"dist-test/index.node.js\" --harmony",
"unit-test:node": "mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 180000 --full-trace \"test/{,!(browser)/**/}*.spec.ts\"",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src"
},
@ -77,11 +77,6 @@
"@azure/identity": "^2.0.1",
"@azure-tools/test-recorder": "^1.0.0",
"@microsoft/api-extractor": "^7.18.11",
"@rollup/plugin-commonjs": "11.0.2",
"@rollup/plugin-json": "^4.0.0",
"@rollup/plugin-multi-entry": "^3.0.0",
"@rollup/plugin-node-resolve": "^8.0.0",
"@rollup/plugin-replace": "^2.2.0",
"@types/chai": "^4.1.6",
"@types/mocha": "^7.0.2",
"@types/node": "^12.0.0",
@ -110,10 +105,6 @@
"prettier": "^1.16.4",
"rimraf": "^3.0.0",
"rollup": "^1.16.3",
"rollup-plugin-shim": "^1.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-terser": "^5.1.1",
"rollup-plugin-visualizer": "^4.0.4",
"sinon": "^9.0.2",
"typescript": "~4.2.0",
"util": "^0.12.1",

Просмотреть файл

@ -1,155 +0,0 @@
import nodeResolve from "@rollup/plugin-node-resolve";
import multiEntry from "@rollup/plugin-multi-entry";
import cjs from "@rollup/plugin-commonjs";
import replace from "@rollup/plugin-replace";
import { terser } from "rollup-plugin-terser";
import sourcemaps from "rollup-plugin-sourcemaps";
import shim from "rollup-plugin-shim";
import json from "@rollup/plugin-json";
import * as path from "path";
import inject from "@rollup/plugin-inject";
import { openTelemetryCommonJs } from "@azure/dev-tool/shared-config/rollup";
const pkg = require("./package.json");
const depNames = Object.keys(pkg.dependencies);
const devDepNames = Object.keys(pkg.devDependencies);
const input = "dist-esm/src/index.js";
const production = process.env.NODE_ENV === "production";
const ignoreKnownWarnings = (warning) => {
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;
}
console.error(`(!) ${warning.message}`);
};
export function nodeConfig(test = false) {
const externalNodeBuiltins = ["events", "path"];
const baseConfig = {
input: input,
external: depNames.concat(externalNodeBuiltins),
output: { file: "dist/index.js", format: "cjs", sourcemap: true },
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
// replace dynamic checks with if (true) since this is for node only.
// Allows rollup's dead code elimination to be more aggressive.
"if (isNode)": "if (true)"
}),
nodeResolve({ preferBuiltins: true }),
cjs()
]
};
if (test) {
// Entry points - test files under the `test` folder(common for both browser and node), node specific test files
baseConfig.input = [
"dist-esm/test/*.spec.js",
"dist-esm/test/unit/*.spec.js",
"dist-esm/test/public/*.spec.js"
];
baseConfig.plugins.unshift(multiEntry({ exports: false }));
// different output file
baseConfig.output.file = "dist-test/index.node.js";
// mark devdeps as external
baseConfig.external.push(...devDepNames);
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
} else if (production) {
baseConfig.plugins.push(terser());
}
return baseConfig;
}
export function browserConfig(test = false) {
const baseConfig = {
input: input,
output: {
file: "dist-browser/digital-twins-core.js",
format: "umd",
name: "Azure.DigitialTwins",
globals: {
"@azure/core-http": "Azure.Core.HTTP"
},
sourcemap: true
},
external: ["nock", "fs-extra"],
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""]
}),
nodeResolve({
mainFields: ["module", "browser"],
preferBuiltins: false
}),
cjs({
namedExports: {
chai: ["assert", "expect", "use"],
assert: ["ok", "equal", "strictEqual", "deepEqual", "fail", "throws", "notEqual"],
events: ["EventEmitter"],
...openTelemetryCommonJs()
}
}),
inject({
modules: {
process: "process"
},
exclude: ["./**/package.json"]
}),
json()
]
};
baseConfig.onwarn = ignoreKnownWarnings;
if (test) {
baseConfig.input = [
"dist-esm/test/*.spec.js",
"dist-esm/test/unit/*.spec.js",
"dist-esm/test/public/*.spec.js"
];
baseConfig.external.unshift(...["process"]);
baseConfig.output.globals = {
...baseConfig.output.globals,
nock: "nock",
fs: "fs-extra",
"fs-extra": "fs",
process: "process",
path: "path"
};
baseConfig.plugins.unshift(multiEntry({ exports: false }));
baseConfig.plugins.unshift(
...[shim({ path: `export function join() {}`, dotenv: `export function config() { }` })]
);
baseConfig.output.file = "dist-test/index.browser.js";
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
}
return baseConfig;
}

Просмотреть файл

@ -1,13 +1,3 @@
import * as base from "./rollup.base.config";
import { makeConfig } from "@azure/dev-tool/shared-config/rollup";
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"));

Просмотреть файл

@ -1,13 +0,0 @@
import * as base from "./rollup.base.config";
const inputs = [];
if (!process.env.ONLY_BROWSER) {
inputs.push(base.nodeConfig({ test: true }));
}
if (!process.env.ONLY_NODE) {
inputs.push(base.browserConfig({ test: true }));
}
export default inputs;

Просмотреть файл

@ -63,7 +63,7 @@
"build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
"build:samples": "echo Obsolete",
"build:test": "tsc -p . && rollup -c rollup.test.config.js 2>&1",
"build:test": "tsc -p . && rollup -c 2>&1",
"build": "npm run clean && tsc -p . && rollup -c 2>&1 && api-extractor run --local",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"clean": "rimraf dist dist-browser dist-esm dist-test temp types *.tgz *.log",
@ -81,7 +81,7 @@
"test:node": "npm run clean && npm run build:test && npm run unit-test:node",
"test": "npm run clean && npm run build:test && npm run unit-test",
"unit-test:browser": "karma start --single-run",
"unit-test:node": "mocha --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"dist-test/index.node.js\"",
"unit-test:node": "mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/{,!(browser)/**/}*.spec.ts\"",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src"
},

Просмотреть файл

@ -1,134 +0,0 @@
import path from "path";
import nodeResolve from "@rollup/plugin-node-resolve";
import multiEntry from "@rollup/plugin-multi-entry";
import cjs from "@rollup/plugin-commonjs";
import replace from "@rollup/plugin-replace";
import shim from "rollup-plugin-shim";
import { terser } from "rollup-plugin-terser";
import sourcemaps from "rollup-plugin-sourcemaps";
import viz from "rollup-plugin-visualizer";
import { openTelemetryCommonJs } from "@azure/dev-tool/shared-config/rollup";
const pkg = require("./package.json");
const depNames = Object.keys(pkg.dependencies);
const devDepNames = Object.keys(pkg.devDependencies);
const input = "dist-esm/src/index.js";
const production = process.env.NODE_ENV === "production";
export function nodeConfig(test = false) {
const externalNodeBuiltins = [];
const baseConfig = {
input: input,
external: depNames.concat(externalNodeBuiltins),
output: { file: "dist/index.js", format: "cjs", sourcemap: true },
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
values: {
// replace dynamic checks with if (true) since this is for node only.
// Allows rollup's dead code elimination to be more aggressive.
"if (isNode)": "if (true)"
}
}),
nodeResolve({ preferBuiltins: true }),
cjs()
]
};
if (test) {
// Entry points - test files under the `test` folder(common for both browser and node), node specific test files
baseConfig.input = ["dist-esm/test/internal/**/*.spec.js", "dist-esm/test/public/**/*.spec.js"];
baseConfig.plugins.unshift(multiEntry({ exports: false }));
// different output file
baseConfig.output.file = "dist-test/index.node.js";
// mark devdeps as external
baseConfig.external.push(...devDepNames);
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
} else if (production) {
baseConfig.plugins.push(terser());
}
return baseConfig;
}
export function browserConfig(test = false, production = false) {
const baseConfig = {
input: input,
output: {
file: "dist-browser/azure-eventgrid.js",
format: "umd",
name: "Azure.MessagingEventGrid",
sourcemap: true
},
preserveSymlinks: false,
external: ["fs-extra"],
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
values: {
// replace dynamic checks with if (false) since this is for
// browser only. Rollup's dead code elimination will remove
// any code guarded by if (isNode) { ... }
"if (isNode)": "if (false)"
}
}),
shim({
constants: `export default {}`,
fs: `export default {}`,
os: `export default {}`,
dotenv: `export function config() { }`,
path: `export default {}`
}),
nodeResolve({
mainFields: ["module", "browser"],
preferBuiltins: false
}),
cjs({
namedExports: {
chai: ["assert", "expect", "use"],
events: ["EventEmitter"],
...openTelemetryCommonJs()
}
}),
viz({ filename: "dist-browser/browser-stats.html", sourcemap: false })
]
};
if (test) {
// Entry points - test files under the `test` folder(common for both browser and node), browser specific test files
baseConfig.input = ["dist-esm/test/internal/**/*.spec.js", "dist-esm/test/public/**/*.spec.js"];
baseConfig.plugins.unshift(multiEntry({ exports: false }));
baseConfig.output.file = "dist-test/index.browser.js";
baseConfig.onwarn = (warning) => {
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;
}
console.error(`(!) ${warning.message}`);
};
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
} else if (production) {
baseConfig.output.file = "dist-browser/azure-eventgrid.min.js";
baseConfig.plugins.push(terser());
}
return baseConfig;
}

Просмотреть файл

@ -1,14 +1,3 @@
import * as base from "./rollup.base.config";
import { makeConfig } from "@azure/dev-tool/shared-config/rollup";
const inputs = [];
if (!process.env.ONLY_BROWSER) {
inputs.push(base.nodeConfig());
}
if (!process.env.ONLY_NODE) {
inputs.push(base.browserConfig());
inputs.push(base.browserConfig(false, true));
}
export default inputs;
export default makeConfig(require("./package.json"));

Просмотреть файл

@ -1,3 +0,0 @@
import * as base from "./rollup.base.config";
export default [base.nodeConfig(true), base.browserConfig(true)];

Просмотреть файл

@ -2,18 +2,12 @@
// Licensed under the MIT license.
import { Context } from "mocha";
import * as dotenv from "dotenv";
import { env, Recorder, record, RecorderEnvironmentSetup } from "@azure-tools/test-recorder";
import { isNode } from "./testUtils";
import { EventGridPublisherClient, InputSchema } from "../../../src";
import { KeyCredential } from "@azure/core-auth";
if (isNode) {
dotenv.config();
}
export interface RecordedClient<T extends InputSchema> {
client: EventGridPublisherClient<T>;
recorder: Recorder;

Просмотреть файл

@ -48,9 +48,9 @@
"build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
"build:samples": "echo Obsolete.",
"build:test:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c rollup.test.config.js 2>&1",
"build:test:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c rollup.test.config.js 2>&1",
"build:test": "tsc -p . && rollup -c rollup.test.config.js 2>&1 && npm run generate-certs",
"build:test:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:test:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
"build:test": "tsc -p . && rollup -c 2>&1 && npm run generate-certs",
"build:types": "downlevel-dts types/latest types/3.1",
"build": "npm run clean && tsc -p . && rollup -c 2>&1 && api-extractor run --local && npm run build:types",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",

Просмотреть файл

@ -1,164 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import nodeResolve from "@rollup/plugin-node-resolve";
import multiEntry from "@rollup/plugin-multi-entry";
import cjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import replace from "@rollup/plugin-replace";
import { terser } from "rollup-plugin-terser";
import sourcemaps from "rollup-plugin-sourcemaps";
import shim from "rollup-plugin-shim";
import inject from "@rollup/plugin-inject";
import { openTelemetryCommonJs } from "@azure/dev-tool/shared-config/rollup";
import path from "path";
const pkg = require("./package.json");
const depNames = Object.keys(pkg.dependencies);
const input = "dist-esm/src/index.js";
const production = process.env.NODE_ENV === "production";
export function nodeConfig(test = false) {
const externalNodeBuiltins = ["events", "util", "os", "url"];
const baseConfig = {
input: input,
external: depNames.concat(externalNodeBuiltins),
output: { file: "dist/index.js", format: "cjs", sourcemap: true },
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
// replace dynamic checks with if (true) since this is for node only.
// Allows rollup's dead code elimination to be more aggressive.
"if (isNode)": "if (true)"
}),
nodeResolve({ preferBuiltins: true }),
cjs(),
json()
]
};
baseConfig.external.push("crypto");
if (test) {
// entry point is every test file
baseConfig.input = ["dist-esm/test/internal/**/*.spec.js", "dist-esm/test/public/**/*.spec.js"];
baseConfig.plugins.unshift(multiEntry({ exports: false }));
// different output file
baseConfig.output.file = "dist-test/index.js";
// mark assert as external
baseConfig.external.push(
"assert",
"fs",
"path",
"os",
"tty",
"child_process",
"@azure/identity"
);
baseConfig.onwarn = (warning) => {
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;
}
console.error(`(!) ${warning.message}`);
};
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
} else if (production) {
baseConfig.plugins.push(terser());
}
return baseConfig;
}
export function browserConfig(test = false) {
const baseConfig = {
input: input,
external: ["ms-rest-js"],
output: {
file: "dist-browser/event-hubs.js",
format: "umd",
name: "Azure.Messaging.EventHubs",
sourcemap: true,
globals: { "ms-rest-js": "msRest" }
},
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace(
// ms-rest-js is externalized so users must include it prior to using this bundle.
{
delimiters: ["", ""],
// replace dynamic checks with if (false) since this is for
// browser only. Rollup's dead code elimination will remove
// any code guarded by if (isNode) { ... }
"if (isNode)": "if (false)"
}
),
...(!test
? []
: [
shim({
// dotenv doesn't work in the browser, so replace it with a no-op function
dotenv: `export function config() { }`
})
]),
nodeResolve({
mainFields: ["module", "browser"],
preferBuiltins: false
}),
cjs({
namedExports: {
...openTelemetryCommonJs(),
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()
]
};
if (test) {
baseConfig.input = [
"dist-esm/test/public/*.spec.js",
"dist-esm/test/internal/*.spec.js",
"dist-esm/test/internal/impl/*.spec.js"
];
baseConfig.plugins.unshift(multiEntry({ exports: false }));
baseConfig.output.file = "dist-test/index.browser.js";
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
} else if (production) {
baseConfig.plugins.push(terser());
}
return baseConfig;
}

Просмотреть файл

@ -1,16 +1,3 @@
// 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"));

Просмотреть файл

@ -1,16 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import * as base from "./rollup.base.config";
const inputs = [];
if (!process.env.ONLY_BROWSER) {
inputs.push(base.nodeConfig({ test: true }));
}
if (!process.env.ONLY_NODE) {
inputs.push(base.browserConfig({ test: true }));
}
export default inputs;

Просмотреть файл

@ -36,7 +36,7 @@
"build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
"build:samples": "dev-tool samples prep && cd dist-samples && tsc",
"build:test": "tsc -p . && cross-env ONLY_NODE=true rollup -c rollup.test.config.js 2>&1",
"build:test": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
"build": "npm run clean && tsc -p . && rollup -c 2>&1 && api-extractor run --local",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
"clean": "rimraf dist dist-* typings *.tgz *.log",
@ -88,11 +88,6 @@
"@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",
"@rollup/plugin-json": "^4.0.0",
"@rollup/plugin-multi-entry": "^3.0.0",
"@rollup/plugin-node-resolve": "^8.0.0",
"@rollup/plugin-replace": "^2.2.0",
"@types/async-lock": "^1.1.0",
"@types/chai": "^4.1.6",
"@types/chai-as-promised": "^7.1.0",
@ -116,7 +111,6 @@
"prettier": "^1.16.4",
"rimraf": "^3.0.0",
"rollup": "^1.16.3",
"rollup-plugin-sourcemaps": "^0.4.2",
"ts-node": "^10.0.0",
"typescript": "~4.2.0",
"ws": "^7.1.1",

Просмотреть файл

@ -1,119 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import nodeResolve from "@rollup/plugin-node-resolve";
import multiEntry from "@rollup/plugin-multi-entry";
import cjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import replace from "@rollup/plugin-replace";
import sourcemaps from "rollup-plugin-sourcemaps";
import path from "path";
const pkg = require("./package.json");
const depNames = Object.keys(pkg.dependencies);
const input = "dist-esm/src/index.js";
export function nodeConfig(test = false) {
const externalNodeBuiltins = ["events", "util"];
const baseConfig = {
input: input,
external: depNames.concat(externalNodeBuiltins),
output: { file: "dist/index.js", format: "cjs", sourcemap: true },
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
// replace dynamic checks with if (true) since this is for node only.
// Allows rollup's dead code elimination to be more aggressive.
"if (isNode)": "if (true)"
}),
nodeResolve({ preferBuiltins: true }),
cjs(),
json()
]
};
baseConfig.external.push("crypto", "path");
if (test) {
// entry point is every test file
baseConfig.input = "dist-esm/test/**/*.spec.js";
baseConfig.plugins.unshift(multiEntry({ exports: false }));
// different output file
baseConfig.output.file = "dist-test/index.js";
// mark assert as external
baseConfig.external.push("assert", "fs", "os", "tty", "child_process");
baseConfig.onwarn = (warning) => {
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;
}
console.error(`(!) ${warning.message}`);
};
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
}
return baseConfig;
}
export function browserConfig(test = false) {
const baseConfig = {
input: input,
external: ["ms-rest-js"],
output: {
file: "browser/index.js",
format: "umd",
name: "ExampleClient",
sourcemap: true,
globals: { "ms-rest-js": "msRest" }
},
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace(
// ms-rest-js is externalized so users must include it prior to using this bundle.
{
delimiters: ["", ""],
// replace dynamic checks with if (false) since this is for
// browser only. Rollup's dead code elimination will remove
// any code guarded by if (isNode) { ... }
"if (isNode)": "if (false)"
}
),
nodeResolve({
mainFields: ["module", "browser"],
preferBuiltins: false
}),
cjs({
namedExports: { events: ["EventEmitter"] }
}),
json()
]
};
if (test) {
baseConfig.input = "dist-esm/test/**/*.spec.js";
baseConfig.plugins.unshift(multiEntry({ exports: false }));
baseConfig.output.file = "dist-test/index.browser.js";
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
}
return baseConfig;
}

Просмотреть файл

@ -1,17 +1,3 @@
// 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());
}
// Disable this until we are ready to run rollup for the browser.
// if (!process.env.ONLY_NODE) {
// inputs.push(base.browserConfig());
// }
export default inputs;
export default makeConfig(require("./package.json"), { disableBrowserBundle: true });

Просмотреть файл

@ -1,6 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import * as base from "./rollup.base.config";
export default [base.nodeConfig(true) /*, base.browserConfig(true)*/];

Просмотреть файл

@ -35,8 +35,8 @@
"build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
"build:samples": "echo Obsolete",
"build:test:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c rollup.test.config.js 2>&1",
"build:test:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c rollup.test.config.js 2>&1",
"build:test:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:test:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
"build:test": "npm run build:test:node",
"build": "npm run clean && tsc -p . && rollup -c 2>&1 && api-extractor run --local",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
@ -70,12 +70,6 @@
"@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",
"@rollup/plugin-inject": "^4.0.0",
"@rollup/plugin-json": "^4.0.0",
"@rollup/plugin-multi-entry": "^3.0.0",
"@rollup/plugin-node-resolve": "^8.0.0",
"@rollup/plugin-replace": "^2.2.0",
"@types/chai": "^4.1.6",
"@types/chai-as-promised": "^7.1.0",
"@types/chai-string": "^1.4.1",
@ -109,10 +103,6 @@
"prettier": "^1.16.4",
"rimraf": "^3.0.0",
"rollup": "^1.16.3",
"rollup-plugin-shim": "^1.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-terser": "^5.1.1",
"rollup-plugin-visualizer": "^4.0.4",
"ts-node": "^10.0.0",
"typescript": "~4.2.0",
"util": "^0.12.1",

Просмотреть файл

@ -1,167 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import nodeResolve from "@rollup/plugin-node-resolve";
import multiEntry from "@rollup/plugin-multi-entry";
import cjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import replace from "@rollup/plugin-replace";
import { terser } from "rollup-plugin-terser";
import sourcemaps from "rollup-plugin-sourcemaps";
import shim from "rollup-plugin-shim";
import inject from "@rollup/plugin-inject";
import path from "path";
const pkg = require("./package.json");
const depNames = Object.keys(pkg.dependencies);
const input = "dist-esm/src/index.js";
const production = process.env.NODE_ENV === "production";
export function nodeConfig(test = false) {
const externalNodeBuiltins = ["events", "util", "os"];
const additionalExternals = ["keytar"];
const baseConfig = {
input: input,
external: depNames.concat(externalNodeBuiltins, additionalExternals),
output: { file: "dist/index.js", format: "cjs", sourcemap: true },
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
// replace dynamic checks with if (true) since this is for node only.
// Allows rollup's dead code elimination to be more aggressive.
"if (isNode)": "if (true)"
}),
nodeResolve({ preferBuiltins: true }),
cjs(),
json()
]
};
baseConfig.external.push("crypto");
if (test) {
// entry point is every test file
baseConfig.input = "dist-esm/test/**/*.spec.js";
baseConfig.plugins.unshift(multiEntry({ exports: false }));
// different output file
baseConfig.output.file = "dist-test/index.js";
// mark assert as external
baseConfig.external.push(
"assert",
"fs",
"path",
"os",
"tty",
"child_process",
"@azure/identity"
);
baseConfig.onwarn = (warning) => {
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;
}
console.error(`(!) ${warning.message}`);
};
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
} else if (production) {
baseConfig.plugins.push(terser());
}
return baseConfig;
}
export function browserConfig(test = false) {
const baseConfig = {
input: input,
external: ["ms-rest-js"],
output: {
file: "dist-browser/eventhubs-checkpointstore-blob.js",
format: "umd",
name: "Azure.Messaging.EventHubs.CheckpointStore.Blob",
sourcemap: true,
globals: { "ms-rest-js": "msRest" }
},
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace(
// ms-rest-js is externalized so users must include it prior to using this bundle.
{
delimiters: ["", ""],
// replace dynamic checks with if (false) since this is for
// browser only. Rollup's dead code elimination will remove
// any code guarded by if (isNode) { ... }
"if (isNode)": "if (false)"
}
),
// fs, net, and tls are used by rhea and need to be shimmed
// dotenv doesn't work in the browser, so replace it with a no-op function
shim({
fs: `export default {}`,
net: `export default {}`,
tls: `export default {}`,
dotenv: `export function config() { }`,
os: `
export function arch() { return "javascript" }
export function type() { return "Browser" }
export function release() { typeof navigator === 'undefined' ? '' : navigator.appVersion }
`,
path: `export default {}`,
dns: `export function resolve() { }`
}),
nodeResolve({
mainFields: ["module", "browser"],
preferBuiltins: false
}),
cjs({
namedExports: {
events: ["EventEmitter"]
}
}),
// 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()
]
};
if (test) {
baseConfig.input = "dist-esm/test/**/*.spec.js";
baseConfig.plugins.unshift(multiEntry({ exports: false }));
baseConfig.output.file = "dist-test/index.browser.js";
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
} else if (production) {
baseConfig.plugins.push(terser());
}
return baseConfig;
}

Просмотреть файл

@ -1,16 +1,3 @@
// 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"));

Просмотреть файл

@ -1,16 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import * as base from "./rollup.base.config";
const inputs = [];
if (!process.env.ONLY_BROWSER) {
inputs.push(base.nodeConfig({ test: true }));
}
if (!process.env.ONLY_NODE) {
inputs.push(base.browserConfig({ test: true }));
}
export default inputs;

Просмотреть файл

@ -35,8 +35,8 @@
"build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
"build:samples": "echo not implemented",
"build:test:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c rollup.test.config.js 2>&1",
"build:test:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c rollup.test.config.js 2>&1",
"build:test:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:test:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
"build:test": "npm run build:test:node",
"build": "npm run clean && tsc -p . && rollup -c 2>&1 && api-extractor run --local",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
@ -69,12 +69,6 @@
"@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",
"@rollup/plugin-inject": "^4.0.0",
"@rollup/plugin-json": "^4.0.0",
"@rollup/plugin-multi-entry": "^3.0.0",
"@rollup/plugin-node-resolve": "^8.0.0",
"@rollup/plugin-replace": "^2.2.0",
"@types/chai": "^4.1.6",
"@types/chai-as-promised": "^7.1.0",
"@types/chai-string": "^1.4.1",
@ -108,10 +102,6 @@
"prettier": "^1.16.4",
"rimraf": "^3.0.0",
"rollup": "^1.16.3",
"rollup-plugin-shim": "^1.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-terser": "^5.1.1",
"rollup-plugin-visualizer": "^4.0.4",
"ts-node": "^10.0.0",
"typescript": "~4.2.0",
"util": "^0.12.1",

Просмотреть файл

@ -1,167 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import nodeResolve from "@rollup/plugin-node-resolve";
import multiEntry from "@rollup/plugin-multi-entry";
import cjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import replace from "@rollup/plugin-replace";
import { terser } from "rollup-plugin-terser";
import sourcemaps from "rollup-plugin-sourcemaps";
import shim from "rollup-plugin-shim";
import inject from "@rollup/plugin-inject";
import path from "path";
const pkg = require("./package.json");
const depNames = Object.keys(pkg.dependencies);
const input = "dist-esm/src/index.js";
const production = process.env.NODE_ENV === "production";
export function nodeConfig(test = false) {
const externalNodeBuiltins = ["events", "util", "os"];
const additionalExternals = ["keytar"];
const baseConfig = {
input: input,
external: depNames.concat(externalNodeBuiltins, additionalExternals),
output: { file: "dist/index.js", format: "cjs", sourcemap: true },
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
// replace dynamic checks with if (true) since this is for node only.
// Allows rollup's dead code elimination to be more aggressive.
"if (isNode)": "if (true)"
}),
nodeResolve({ preferBuiltins: true }),
cjs(),
json()
]
};
baseConfig.external.push("crypto");
if (test) {
// entry point is every test file
baseConfig.input = "dist-esm/test/**/*.spec.js";
baseConfig.plugins.unshift(multiEntry({ exports: false }));
// different output file
baseConfig.output.file = "dist-test/index.js";
// mark assert as external
baseConfig.external.push(
"assert",
"fs",
"path",
"os",
"tty",
"child_process",
"@azure/identity"
);
baseConfig.onwarn = (warning) => {
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;
}
console.error(`(!) ${warning.message}`);
};
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
} else if (production) {
baseConfig.plugins.push(terser());
}
return baseConfig;
}
export function browserConfig(test = false) {
const baseConfig = {
input: input,
external: ["ms-rest-js"],
output: {
file: "dist-browser/eventhubs-checkpointstore-table.js",
format: "umd",
name: "Azure.Messaging.EventHubs.CheckpointStore.Table",
sourcemap: true,
globals: { "ms-rest-js": "msRest" }
},
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace(
// ms-rest-js is externalized so users must include it prior to using this bundle.
{
delimiters: ["", ""],
// replace dynamic checks with if (false) since this is for
// browser only. Rollup's dead code elimination will remove
// any code guarded by if (isNode) { ... }
"if (isNode)": "if (false)"
}
),
// fs, net, and tls are used by rhea and need to be shimmed
// dotenv doesn't work in the browser, so replace it with a no-op function
shim({
fs: `export default {}`,
net: `export default {}`,
tls: `export default {}`,
dotenv: `export function config() { }`,
os: `
export function arch() { return "javascript" }
export function type() { return "Browser" }
export function release() { typeof navigator === 'undefined' ? '' : navigator.appVersion }
`,
path: `export default {}`,
dns: `export function resolve() { }`
}),
nodeResolve({
mainFields: ["module", "browser"],
preferBuiltins: false
}),
cjs({
namedExports: {
events: ["EventEmitter"]
}
}),
// 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()
]
};
if (test) {
baseConfig.input = "dist-esm/test/**/*.spec.js";
baseConfig.plugins.unshift(multiEntry({ exports: false }));
baseConfig.output.file = "dist-test/index.browser.js";
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
} else if (production) {
baseConfig.plugins.push(terser());
}
return baseConfig;
}

Просмотреть файл

@ -1,16 +1,3 @@
// 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"));

Просмотреть файл

@ -1,16 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import * as base from "./rollup.base.config";
const inputs = [];
if (!process.env.ONLY_BROWSER) {
inputs.push(base.nodeConfig({ test: true }));
}
if (!process.env.ONLY_NODE) {
inputs.push(base.browserConfig({ test: true }));
}
export default inputs;

Просмотреть файл

@ -16,8 +16,8 @@
"build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1 && npm run extract-api",
"build": "npm run clean && npm run build:node && npm run build:browser",
"build:test:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c rollup.test.config.js 2>&1",
"build:test:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c rollup.test.config.js 2>&1",
"build:test:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:test:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
"build:test": "npm run build:test:node && npm run build:test:browser",
"build:samples": "echo Skipped.",
"check-format": "echo skip format check as this package has only auto generated code",
@ -28,7 +28,7 @@
"extract-api": "tsc -p . && api-extractor run --local",
"format": "echo skip format as this package has only auto generated code",
"integration-test:browser": "echo skipped",
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 180000 --full-trace \"dist-esm/test/*.spec.js\" \"dist-esm/test/**/*.spec.js\" --harmony",
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 180000 --full-trace \"dist-esm/test/{,!(browser)/**/}*.spec.js\"",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
"lint": "eslint package.json api-extractor.json src test --ext .ts -f html -o search-lintReport.html || exit 0",
@ -37,7 +37,7 @@
"test:browser": "npm run clean && npm run build:test:browser && npm run unit-test:browser",
"test": "npm run clean && npm run build:test && npm run unit-test",
"unit-test:browser": "echo skipped",
"unit-test:node": "mocha --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 180000 --full-trace \"dist-test/index.node.js\" --harmony",
"unit-test:node": "mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 180000 --full-trace \"test/{,!(browser)/**/}*.spec.ts\"",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src"
},
@ -75,11 +75,6 @@
"@azure/identity": "^2.0.1",
"@azure-tools/test-recorder": "^1.0.0",
"@microsoft/api-extractor": "^7.18.11",
"@rollup/plugin-commonjs": "11.0.2",
"@rollup/plugin-json": "^4.0.0",
"@rollup/plugin-multi-entry": "^3.0.0",
"@rollup/plugin-node-resolve": "^8.0.0",
"@rollup/plugin-replace": "^2.2.0",
"@types/chai": "^4.1.6",
"@types/mocha": "^7.0.2",
"@types/node": "^12.0.0",
@ -109,10 +104,6 @@
"prettier": "^1.16.4",
"rimraf": "^3.0.0",
"rollup": "^1.16.3",
"rollup-plugin-shim": "^1.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-terser": "^5.1.1",
"rollup-plugin-visualizer": "^4.0.4",
"sinon": "^9.0.2",
"typescript": "~4.2.0",
"util": "^0.12.1",

Просмотреть файл

@ -1,144 +0,0 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*/
import path from "path";
import nodeResolve from "@rollup/plugin-node-resolve";
import multiEntry from "@rollup/plugin-multi-entry";
import cjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import replace from "@rollup/plugin-replace";
import shim from "rollup-plugin-shim";
import { terser } from "rollup-plugin-terser";
import sourcemaps from "rollup-plugin-sourcemaps";
import viz from "rollup-plugin-visualizer";
import { openTelemetryCommonJs } from "@azure/dev-tool/shared-config/rollup";
const pkg = require("./package.json");
const depNames = Object.keys(pkg.dependencies);
const devDepNames = Object.keys(pkg.devDependencies);
const input = "dist-esm/src/index.js";
const production = process.env.NODE_ENV === "production";
export function nodeConfig(test = false) {
const externalNodeBuiltins = ["events", "path"];
const baseConfig = {
input: input,
external: depNames.concat(externalNodeBuiltins),
output: { file: "dist/index.js", format: "cjs", sourcemap: true },
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
// replace dynamic checks with if (true) since this is for node only.
// Allows rollup's dead code elimination to be more aggressive.
"if (isNode)": "if (true)"
}),
nodeResolve({ preferBuiltins: true }),
json(),
cjs()
]
};
if (test) {
// Entry points - test files under the `test` folder(common for both browser and node), node specific test files
baseConfig.input = [
"dist-esm/test/public/*.spec.js",
"dist-esm/test/internal/*.spec.js",
"dist-esm/test/public/node/*.spec.js",
"dist-esm/test/internal/node/*.spec.js"
];
baseConfig.plugins.unshift(multiEntry({ exports: false }));
// different output file
baseConfig.output.file = "dist-test/index.node.js";
// mark devdeps as external
baseConfig.external.push(...devDepNames);
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
} else if (production) {
baseConfig.plugins.push(terser());
}
return baseConfig;
}
export function browserConfig(test = false) {
const baseConfig = {
input: input,
output: {
file: "dist-browser/azure-quantum.js",
format: "umd",
name: "azquantumjobs",
sourcemap: true
},
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
// replace dynamic checks with if (false) since this is for
// browser only. Rollup's dead code elimination will remove
// any code guarded by if (isNode) { ... }
"if (isNode)": "if (false)"
}),
shim({
constants: `export default {}`,
fs: `export default {}`,
os: `export default {}`,
dotenv: `export function config() { }`,
path: `export default {}`
}),
nodeResolve({
mainFields: ["module", "browser"],
preferBuiltins: false
}),
json(),
cjs({
namedExports: {
events: ["EventEmitter"],
chai: ["assert"],
...openTelemetryCommonJs()
}
}),
// disable the plugin in the rollup config to cut-out errors
viz({ filename: "dist-browser/browser-stats.html", sourcemap: false })
]
};
if (test) {
// Entry points - test files under the `test` folder(common for both browser and node), browser specific test files
baseConfig.input = [
"dist-esm/test/public/*.spec.js",
"dist-esm/test/internal/*.spec.js",
"dist-esm/test/public/browser/*.spec.js",
"dist-esm/test/internal/browser/*.spec.js"
];
baseConfig.plugins.unshift(multiEntry({ exports: false }));
baseConfig.output.file = "dist-test/index.browser.js";
baseConfig.onwarn = (warning) => {
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;
}
console.error(`(!) ${warning.message}`);
};
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
}
return baseConfig;
}

Просмотреть файл

@ -1,17 +1,3 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*/
import * as base from "./rollup.base.config";
import { makeConfig } from "@azure/dev-tool/shared-config/rollup";
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"));

Просмотреть файл

@ -1,18 +0,0 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*/
import * as base from "./rollup.base.config";
const inputs = [];
if (!process.env.ONLY_BROWSER) {
inputs.push(base.nodeConfig(true));
}
if (!process.env.ONLY_NODE) {
inputs.push(base.browserConfig(true));
}
export default inputs;

Просмотреть файл

@ -12,7 +12,7 @@
"build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
"build:samples": "echo Obsolete.",
"execute:samples": "dev-tool samples run samples-dev",
"build:test": "tsc -p . && rollup -c rollup.test.config.js 2>&1",
"build:test": "tsc -p . && rollup -c 2>&1",
"build": "npm run clean && tsc -p . && rollup -c 2>&1 && api-extractor run --local",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"clean": "rimraf dist dist-* temp types *.tgz *.log",
@ -28,7 +28,7 @@
"test:node": "npm run build:test && npm run unit-test:node",
"test": "npm run build:test && npm run unit-test",
"unit-test:browser": "karma start --single-run",
"unit-test:node": "mocha --reporter ../../../common/tools/mocha-multi-reporter.js dist-test/index.node.js --harmony",
"unit-test:node": "mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/{,!(browser)/**/}*.spec.ts\"",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src"
},
@ -89,9 +89,6 @@
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@azure-tools/test-recorder": "^1.0.0",
"@microsoft/api-extractor": "^7.18.11",
"@rollup/plugin-json": "^4.0.0",
"@rollup/plugin-multi-entry": "^3.0.0",
"@rollup/plugin-replace": "^2.2.0",
"@types/chai": "^4.1.6",
"@types/mocha": "^7.0.2",
"@types/node": "^12.0.0",
@ -120,12 +117,6 @@
"prettier": "^1.16.4",
"rimraf": "^3.0.0",
"rollup": "^1.16.3",
"@rollup/plugin-commonjs": "11.0.2",
"@rollup/plugin-node-resolve": "^8.0.0",
"rollup-plugin-shim": "^1.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-terser": "^5.1.1",
"rollup-plugin-visualizer": "^4.0.4",
"sinon": "^9.0.2",
"ts-node": "^10.0.0",
"typescript": "~4.2.0",

Просмотреть файл

@ -1,138 +0,0 @@
import path from "path";
import nodeResolve from "@rollup/plugin-node-resolve";
import multiEntry from "@rollup/plugin-multi-entry";
import cjs from "@rollup/plugin-commonjs";
import replace from "@rollup/plugin-replace";
import shim from "rollup-plugin-shim";
import { terser } from "rollup-plugin-terser";
import sourcemaps from "rollup-plugin-sourcemaps";
import viz from "rollup-plugin-visualizer";
import { openTelemetryCommonJs } from "@azure/dev-tool/shared-config/rollup";
const pkg = require("./package.json");
const depNames = Object.keys(pkg.dependencies);
const devDepNames = Object.keys(pkg.devDependencies);
const input = "dist-esm/src/index.js";
const production = process.env.NODE_ENV === "production";
export function nodeConfig(test = false) {
const externalNodeBuiltins = ["events", "path"];
const baseConfig = {
input: input,
external: depNames.concat(externalNodeBuiltins),
output: { file: "dist/index.js", format: "cjs", sourcemap: true },
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
// replace dynamic checks with if (true) since this is for node only.
// Allows rollup's dead code elimination to be more aggressive.
"if (isNode)": "if (true)"
}),
nodeResolve({ preferBuiltins: true }),
cjs()
]
};
if (test) {
// Entry points - test files under the `test` folder(common for both browser and node), node specific test files
baseConfig.input = [
"dist-esm/test/public/*.spec.js",
"dist-esm/test/internal/*.spec.js",
"dist-esm/test/public/node/*.spec.js",
"dist-esm/test/internal/node/*.spec.js"
];
baseConfig.plugins.unshift(multiEntry({ exports: false }));
// different output file
baseConfig.output.file = "dist-test/index.node.js";
// mark devdeps as external
baseConfig.external.push(...devDepNames);
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
} else if (production) {
baseConfig.plugins.push(terser());
}
return baseConfig;
}
export function browserConfig(test = false) {
const baseConfig = {
input: input,
output: {
file: "dist-browser/azure-search.js",
format: "umd",
name: "SearchClient",
sourcemap: true,
globals: { "@azure/core-http": "Azure.Core.HTTP" }
},
preserveSymlinks: false,
external: ["fs-extra"],
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
// replace dynamic checks with if (false) since this is for
// browser only. Rollup's dead code elimination will remove
// any code guarded by if (isNode) { ... }
"if (isNode)": "if (false)"
}),
shim({
constants: `export default {}`,
fs: `export default {}`,
os: `export default {}`,
dotenv: `export function config() { }`,
path: `export default {}`
}),
nodeResolve({
mainFields: ["module", "browser"],
preferBuiltins: false
}),
cjs({
namedExports: {
chai: ["assert"],
...openTelemetryCommonJs()
}
}),
// disable the plugin in the rollup config to cut-out errors
viz({ filename: "dist-browser/browser-stats.html", sourcemap: false })
]
};
if (test) {
// Entry points - test files under the `test` folder(common for both browser and node), browser specific test files
baseConfig.input = [
"dist-esm/test/public/*.spec.js",
"dist-esm/test/internal/*.spec.js",
"dist-esm/test/public/browser/*.spec.js",
"dist-esm/test/internal/browser/*.spec.js"
];
baseConfig.plugins.unshift(multiEntry({ exports: false }));
baseConfig.output.file = "dist-test/index.browser.js";
baseConfig.onwarn = (warning) => {
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;
}
console.error(`(!) ${warning.message}`);
};
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
}
return baseConfig;
}

Просмотреть файл

@ -1,13 +1,3 @@
import * as base from "./rollup.base.config";
import { makeConfig } from "@azure/dev-tool/shared-config/rollup";
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"));

Просмотреть файл

@ -1,3 +0,0 @@
import * as base from "./rollup.base.config";
export default [base.nodeConfig(true), base.browserConfig(true)];

Просмотреть файл

@ -48,8 +48,8 @@
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
"build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
"build:test:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c rollup.test.config.js 2>&1",
"build:test:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c rollup.test.config.js 2>&1",
"build:test:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:test:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
"build:test": "npm run build:test:node && npm run build:test:browser",
"build:types": "downlevel-dts types/latest types/3.1",
"build": "npm run clean && tsc -p . && rollup -c 2>&1 && npm run extract-api && npm run build:types",
@ -70,7 +70,7 @@
"test:node": "npm run clean && npm run build:test:node && npm run integration-test:node",
"test": "npm run test:node && npm run test:browser",
"unit-test:browser": "echo skipped",
"unit-test:node": "mocha -r esm -r ts-node/register --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/internal/unit/*.spec.ts\" \"test/internal/node/*.spec.ts\"",
"unit-test:node": "mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/internal/unit/{,!(browser)/**/}*.spec.ts\"",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src"
},
@ -131,12 +131,6 @@
"@azure/test-utils": "^1.0.0",
"@azure/test-utils-perf": "^1.0.0",
"@microsoft/api-extractor": "^7.18.11",
"@rollup/plugin-commonjs": "11.0.2",
"@rollup/plugin-inject": "^4.0.0",
"@rollup/plugin-json": "^4.0.0",
"@rollup/plugin-multi-entry": "^3.0.0",
"@rollup/plugin-node-resolve": "^8.0.0",
"@rollup/plugin-replace": "^2.2.0",
"@types/chai": "^4.1.6",
"@types/chai-as-promised": "^7.1.0",
"@types/debug": "^4.1.4",
@ -175,9 +169,6 @@
"puppeteer": "^10.2.0",
"rimraf": "^3.0.0",
"rollup": "^1.16.3",
"rollup-plugin-shim": "^1.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-terser": "^5.1.1",
"ts-node": "^10.0.0",
"typescript": "~4.2.0",
"ws": "^7.1.1",

Просмотреть файл

@ -1,179 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import nodeResolve from "@rollup/plugin-node-resolve";
import multiEntry from "@rollup/plugin-multi-entry";
import cjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import replace from "@rollup/plugin-replace";
import { terser } from "rollup-plugin-terser";
import sourcemaps from "rollup-plugin-sourcemaps";
import shim from "rollup-plugin-shim";
import path from "path";
import inject from "@rollup/plugin-inject";
import { openTelemetryCommonJs } from "@azure/dev-tool/shared-config/rollup";
const pkg = require("./package.json");
const depNames = Object.keys(pkg.dependencies);
const input = "dist-esm/src/index.js";
const version = require("./package.json").version;
const banner = [
"/*!",
` * Azure Service Bus SDK for JavaScript, ${version}`,
" * Copyright (c) Microsoft and contributors. All rights reserved.",
" */"
].join("\n");
const ignoreKnownWarnings = (warning) => {
if (warning.code === "THIS_IS_UNDEFINED") {
// This error happens frequently due to TypeScript emitting `this` at the
// top-level of a module. In this case its fine if it gets rewritten to
// undefined, so ignore this error.
return;
}
if (
warning.code === "CIRCULAR_DEPENDENCY" &&
warning.importer.indexOf(path.normalize("node_modules/chai/lib") === 0)
) {
// Chai contains circular references, but they are not fatal and can be ignored.
return;
}
console.error(`(!) ${warning.message}`);
};
export function nodeConfig({ test = false, production = false } = {}) {
const externalNodeBuiltins = ["events", "util", "os"];
const baseConfig = {
input: input,
external: depNames.concat(externalNodeBuiltins),
output: { file: "dist/index.js", format: "cjs", sourcemap: true },
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
// replace dynamic checks with if (true) since this is for node only.
// Allows rollup's dead code elimination to be more aggressive.
"if (isNode)": "if (true)",
"if (!isNode)": "if (false)"
}),
nodeResolve({ preferBuiltins: true }),
cjs(),
json()
]
};
if (test) {
// entry point is every test file
baseConfig.input = [
"dist-esm/service-bus/test/internal/**/*.spec.js",
"dist-esm/service-bus/test/internal/node/*.spec.js",
"dist-esm/service-bus/test/public/**/*.spec.js"
];
baseConfig.plugins.unshift(multiEntry({ exports: false }));
// different output file
baseConfig.output.file = "dist-test/index.js";
// mark assert as external
baseConfig.external.push("assert", "fs", "path", "@azure/identity");
baseConfig.onwarn = ignoreKnownWarnings;
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
} else if (production) {
baseConfig.plugins.push(terser());
}
return baseConfig;
}
export function browserConfig(test = false) {
const baseConfig = {
input: input,
external: [],
output: {
file: "dist-browser/service-bus.js",
format: "umd",
name: "Azure.Messaging.ServiceBus",
sourcemap: true
},
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace(
// ms-rest-js is externalized so users must include it prior to using this bundle.
{
delimiters: ["", ""],
// replace dynamic checks with if (false) since this is for
// browser only. Rollup's dead code elimination will remove
// any code guarded by if (isNode) { ... }
"if (isNode)": "if (false)",
"if (!isNode)": "if (true)"
}
),
// fs, net, and tls are used by rhea and need to be shimmed
// dotenv doesn't work in the browser, so replace it with a no-op function
shim({
fs: `export default {}`,
net: `export default {}`,
tls: `export default {}`,
dotenv: `export function config() { }`,
path: `export default {}`,
dns: `export function resolve() { }`,
glob: `export default {}`
}),
nodeResolve({
mainFields: ["module", "browser"],
preferBuiltins: false
}),
cjs({
namedExports: {
events: ["EventEmitter"],
long: ["ZERO"],
...openTelemetryCommonJs(),
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()
]
};
baseConfig.onwarn = ignoreKnownWarnings;
if (test) {
baseConfig.input = [
"dist-esm/test/public/**/*.spec.js",
"dist-esm/test/internal/*.spec.js",
"dist-esm/test/internal/unit/*.spec.js"
];
baseConfig.plugins.unshift(multiEntry({ exports: false }));
baseConfig.output.file = "dist-test/index.browser.js";
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
}
return baseConfig;
}

Просмотреть файл

@ -1,16 +1,3 @@
// 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"));

Просмотреть файл

@ -1,16 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import * as base from "./rollup.base.config";
const inputs = [];
if (!process.env.ONLY_BROWSER) {
inputs.push(base.nodeConfig({ test: true }));
}
if (!process.env.ONLY_NODE) {
inputs.push(base.browserConfig({ test: true }));
}
export default inputs;