Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev-tool] Remove the openTelemetryCommonJs() export #19866

Merged
merged 1 commit into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions common/tools/dev-tool/src/config/rollup.base.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,6 @@ interface PackageJson {
devDependencies: Record<string, string>;
}

/**
* Gets the proper configuration needed for rollup's commonJS plugin for @opentelemetry/api.
*
* NOTE: this manual configuration is only needed because OpenTelemetry uses an
* __exportStar downleveled helper function to declare its exports which confuses
* rollup's automatic discovery mechanism.
*
* @returns an object reference that can be `...`'d into your cjs() configuration.
*/
export function openTelemetryCommonJs(): Record<string, string[]> {
const namedExports: Record<string, string[]> = {};

for (const key of ["@opentelemetry/api", "@azure/core-tracing/node_modules/@opentelemetry/api"]) {
namedExports[key] = [
"SpanKind",
"TraceFlags",
"getSpan",
"setSpan",
"SpanStatusCode",
"getSpanContext",
"setSpanContext",
];
}

const releasedOpenTelemetryVersions = ["0.10.2", "1.0.0-rc.0"];

for (const version of releasedOpenTelemetryVersions) {
namedExports[
// working around a limitation in the rollup common.js plugin - it's not able to resolve these modules so the named exports listed above will not get applied. We have to drill down to the actual path.
`../../../common/temp/node_modules/.pnpm/@opentelemetry+api@${version}/node_modules/@opentelemetry/api/build/src/index.js`
] = [
"SpanKind",
"TraceFlags",
"getSpan",
"setSpan",
"StatusCode",
"CanonicalCode",
"getSpanContext",
"setSpanContext",
];
}

return namedExports;
}

// #region Warning Handler

/**
Expand Down
47 changes: 46 additions & 1 deletion sdk/communication/communication-chat/rollup.test.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,52 @@ import multiEntry from "@rollup/plugin-multi-entry";
import replace from "@rollup/plugin-replace";
import sourcemaps from "rollup-plugin-sourcemaps";
import shim from "rollup-plugin-shim";
import { makeBrowserTestConfig, openTelemetryCommonJs } from "@azure/dev-tool/shared-config/rollup";
import { makeBrowserTestConfig } from "@azure/dev-tool/shared-config/rollup";

/**
* Gets the proper configuration needed for rollup's commonJS plugin for @opentelemetry/api.
*
* NOTE: this manual configuration is only needed because OpenTelemetry uses an
* __exportStar downleveled helper function to declare its exports which confuses
* rollup's automatic discovery mechanism.
*
* @returns an object reference that can be `...`'d into your cjs() configuration.
*/
export function openTelemetryCommonJs() {
const namedExports = {};

for (const key of ["@opentelemetry/api", "@azure/core-tracing/node_modules/@opentelemetry/api"]) {
namedExports[key] = [
"SpanKind",
"TraceFlags",
"getSpan",
"setSpan",
"SpanStatusCode",
"getSpanContext",
"setSpanContext",
];
}

const releasedOpenTelemetryVersions = ["0.10.2", "1.0.0-rc.0"];

for (const version of releasedOpenTelemetryVersions) {
namedExports[
// working around a limitation in the rollup common.js plugin - it's not able to resolve these modules so the named exports listed above will not get applied. We have to drill down to the actual path.
`../../../common/temp/node_modules/.pnpm/@opentelemetry+api@${version}/node_modules/@opentelemetry/api/build/src/index.js`
] = [
"SpanKind",
"TraceFlags",
"getSpan",
"setSpan",
"StatusCode",
"CanonicalCode",
"getSpanContext",
"setSpanContext",
];
}

return namedExports;
}

function makeBrowserTestConfigPatch() {
const config = { ...makeBrowserTestConfig(require("./package.json")) };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,52 @@ import multiEntry from "@rollup/plugin-multi-entry";
import replace from "@rollup/plugin-replace";
import sourcemaps from "rollup-plugin-sourcemaps";
import shim from "rollup-plugin-shim";
import { makeBrowserTestConfig, openTelemetryCommonJs } from "@azure/dev-tool/shared-config/rollup";
import { makeBrowserTestConfig } from "@azure/dev-tool/shared-config/rollup";

/**
* Gets the proper configuration needed for rollup's commonJS plugin for @opentelemetry/api.
*
* NOTE: this manual configuration is only needed because OpenTelemetry uses an
* __exportStar downleveled helper function to declare its exports which confuses
* rollup's automatic discovery mechanism.
*
* @returns an object reference that can be `...`'d into your cjs() configuration.
*/
export function openTelemetryCommonJs() {
const namedExports = {};

for (const key of ["@opentelemetry/api", "@azure/core-tracing/node_modules/@opentelemetry/api"]) {
namedExports[key] = [
"SpanKind",
"TraceFlags",
"getSpan",
"setSpan",
"SpanStatusCode",
"getSpanContext",
"setSpanContext",
];
}

const releasedOpenTelemetryVersions = ["0.10.2", "1.0.0-rc.0"];

for (const version of releasedOpenTelemetryVersions) {
namedExports[
// working around a limitation in the rollup common.js plugin - it's not able to resolve these modules so the named exports listed above will not get applied. We have to drill down to the actual path.
`../../../common/temp/node_modules/.pnpm/@opentelemetry+api@${version}/node_modules/@opentelemetry/api/build/src/index.js`
] = [
"SpanKind",
"TraceFlags",
"getSpan",
"setSpan",
"StatusCode",
"CanonicalCode",
"getSpanContext",
"setSpanContext",
];
}

return namedExports;
}

function makeBrowserTestConfigPatch() {
const config = { ...makeBrowserTestConfig(require("./package.json")) };
Expand Down