From 5b4eac348e4db7afed67ee203d74a1b2a048ea90 Mon Sep 17 00:00:00 2001 From: Maor Leger Date: Mon, 28 Jun 2021 15:14:01 -0700 Subject: [PATCH] [synapse] - Ignore known rollup warnings (#15948) ## What - Adds warning filter to ignore known rollup warnings that are safe to ignore - Ignore `this has been rewritten to undefined` in synapse - Ignore circular dependencies in synapse ## Why These are both known warnings, are safe to ignore, and add noise to the build output unnecessarily. The first is totally safe to ignore: ``` var __spreadArray = (this && this.__spreadArray) || function (to, from) { ``` Is emitted from TypeScript in the OTel ESM and is safe to use. The second is a known issue in OTel 1.0.0 that is not harmful at runtime. Finally, we have precedent for doing the exact same thing in other packages like service-bus. --- .../synapse-access-control/rollup.config.js | 18 ++++++++++++++++++ .../rollup.config.js | 17 +++++++++++++++++ .../synapse-monitoring/rollup.config.js | 18 ++++++++++++++++++ sdk/synapse/synapse-spark/rollup.config.js | 18 ++++++++++++++++++ 4 files changed, 71 insertions(+) diff --git a/sdk/synapse/synapse-access-control/rollup.config.js b/sdk/synapse/synapse-access-control/rollup.config.js index 1225dc56b8b3..afd0dd19a25c 100644 --- a/sdk/synapse/synapse-access-control/rollup.config.js +++ b/sdk/synapse/synapse-access-control/rollup.config.js @@ -4,12 +4,30 @@ import sourcemaps from "rollup-plugin-sourcemaps"; import cjs from "@rollup/plugin-commonjs"; import { openTelemetryCommonJs } from "@azure/dev-tool/shared-config/rollup"; + +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("@opentelemetry/api") >= 0) { + // OpenTelemetry contains circular references as of 1.0.0, but they are not fatal and can be ignored. + return; + } + + console.error(`(!) ${warning.message}`); +} + /** * @type {rollup.RollupFileOptions} */ const config = { input: "./dist-esm/accessControlClient.js", external: ["@azure/core-http", "@azure/core-arm"], + onwarn: ignoreKnownWarnings, output: { file: "./dist/index.js", format: "cjs", diff --git a/sdk/synapse/synapse-managed-private-endpoints/rollup.config.js b/sdk/synapse/synapse-managed-private-endpoints/rollup.config.js index 71e18098501b..1bd733ecc291 100644 --- a/sdk/synapse/synapse-managed-private-endpoints/rollup.config.js +++ b/sdk/synapse/synapse-managed-private-endpoints/rollup.config.js @@ -4,12 +4,29 @@ import sourcemaps from "rollup-plugin-sourcemaps"; import cjs from "@rollup/plugin-commonjs"; import { openTelemetryCommonJs } from "@azure/dev-tool/shared-config/rollup"; +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("@opentelemetry/api") >= 0) { + // OpenTelemetry contains circular references as of 1.0.0, but they are not fatal and can be ignored. + return; + } + + console.error(`(!) ${warning.message}`); +} + /** * @type {rollup.RollupFileOptions} */ const config = { input: "./dist-esm/managedPrivateEndpointsClient.js", external: ["@azure/core-http", "@azure/core-arm"], + onwarn: ignoreKnownWarnings, output: { file: "./dist/index.js", format: "cjs", diff --git a/sdk/synapse/synapse-monitoring/rollup.config.js b/sdk/synapse/synapse-monitoring/rollup.config.js index 1e1c8628373a..c1d24e737128 100644 --- a/sdk/synapse/synapse-monitoring/rollup.config.js +++ b/sdk/synapse/synapse-monitoring/rollup.config.js @@ -4,12 +4,30 @@ import sourcemaps from "rollup-plugin-sourcemaps"; import cjs from "@rollup/plugin-commonjs"; import { openTelemetryCommonJs } from "@azure/dev-tool/shared-config/rollup"; + +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("@opentelemetry/api") >= 0) { + // OpenTelemetry contains circular references as of 1.0.0, but they are not fatal and can be ignored. + return; + } + + console.error(`(!) ${warning.message}`); +} + /** * @type {rollup.RollupFileOptions} */ const config = { input: "./dist-esm/monitoringClient.js", external: ["@azure/core-http", "@azure/core-arm"], + onwarn: ignoreKnownWarnings, output: { file: "./dist/index.js", format: "cjs", diff --git a/sdk/synapse/synapse-spark/rollup.config.js b/sdk/synapse/synapse-spark/rollup.config.js index fa85bbbc8812..8cdd0e5c0c18 100644 --- a/sdk/synapse/synapse-spark/rollup.config.js +++ b/sdk/synapse/synapse-spark/rollup.config.js @@ -4,12 +4,30 @@ import sourcemaps from "rollup-plugin-sourcemaps"; import cjs from "@rollup/plugin-commonjs"; import { openTelemetryCommonJs } from "@azure/dev-tool/shared-config/rollup"; + +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("@opentelemetry/api") >= 0) { + // OpenTelemetry contains circular references as of 1.0.0, but they are not fatal and can be ignored. + return; + } + + console.error(`(!) ${warning.message}`); +} + /** * @type {rollup.RollupFileOptions} */ const config = { input: "./dist-esm/sparkClient.js", external: ["@azure/core-http", "@azure/core-arm"], + onwarn: ignoreKnownWarnings, output: { file: "./dist/index.js", format: "cjs",