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

[test-utils-recorder] Refactor to separate node/browser codepaths #12796

Merged
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
2 changes: 0 additions & 2 deletions common/tools/dev-tool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@
"mocha": "^7.1.1",
"rimraf": "^3.0.0",
"rollup": "^1.16.3",
"rollup-plugin-node-builtins": "~2.1.2",
"rollup-plugin-node-globals": "~1.4.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-visualizer": "^4.0.4"
}
Expand Down
30 changes: 15 additions & 15 deletions common/tools/dev-tool/src/config/rollup.base.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import cjs from "@rollup/plugin-commonjs";
import sourcemaps from "rollup-plugin-sourcemaps";
import multiEntry from "@rollup/plugin-multi-entry";
import json from "@rollup/plugin-json";
import nodeBuiltinsPlugin from "rollup-plugin-node-builtins";
import nodeGlobals from "rollup-plugin-node-globals";

import nodeBuiltins from "builtin-modules";

Expand All @@ -19,6 +17,12 @@ interface PackageJson {

// #region Warning Handler

/**
* A function that can determine whether a rollupwarning should be ignored. If
* the function returns `true`, then the warning will not be displayed.
*/
export type WarningInhibitor = (warning: RollupWarning) => boolean;

function ignoreNiseSinonEvalWarnings(warning: RollupWarning): boolean {
return (
warning.code === "EVAL" &&
Expand Down Expand Up @@ -58,33 +62,31 @@ function makeBrowserTestConfig() {
const config: RollupOptions = {
input: {
include: ["dist-esm/test/**/*.spec.js"],
exclude: ["dist-esm/test/**/node/*.spec.js"]
exclude: ["dist-esm/test/**/node/**"]
},
output: {
file: `dist-test/index.browser.js`,
format: "umd",
sourcemap: true,
globals: { "fs-extra": "undefined" }
sourcemap: true
},
preserveSymlinks: false,
// fs-extra must be marked as external in order to avoid an initialization error
external: ["fs-extra"],
plugins: [
multiEntry({ exports: false }),
nodeResolve({
mainFields: ["module", "browser"],
preferBuiltins: true
mainFields: ["module", "browser"]
}),
cjs({
namedExports: {
chai: ["assert", "use"],
// Chai's strange internal architecture makes it impossible to statically
// analyze its exports.
chai: ["version", "use", "util", "config", "expect", "should", "assert"],
// OpenTelemetry uses an __exportStar downleveled helper function to
// declare its exports, and so we have to add them here as well.
"@opentelemetry/api": ["CanonicalCode", "SpanKind", "TraceFlags"]
}
}),
json(),
sourcemaps(),
nodeGlobals(),
nodeBuiltinsPlugin()
sourcemaps()
//viz({ filename: "dist-test/browser-stats.html", sourcemap: true })
],
onwarn: makeOnWarnForTesting(),
Expand All @@ -95,8 +97,6 @@ function makeBrowserTestConfig() {
treeshake: false
};

// (config.external as string[]).push(...Object.keys(pkg.devDependencies));

return config;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license.

import { Context } from "mocha";
import * as dotenv from "dotenv";

import {
env,
Expand All @@ -16,8 +15,6 @@ import { AzureKeyCredential, FormTrainingClient, FormRecognizerClient } from "..
import { ClientSecretCredential } from "@azure/identity";
import { TokenCredential } from "@azure/core-auth";

dotenv.config();

export interface RecordedTrainingClient {
client: FormTrainingClient;
recorder: Recorder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

import { assert } from "chai";

import * as dotenv from "dotenv";
dotenv.config();

import {
AnomalyAlertConfiguration,
AnomalyDetectionConfiguration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

import { assert } from "chai";

import * as dotenv from "dotenv";
dotenv.config();

import {
MetricAnomalyFeedback,
MetricChangePointFeedback,
Expand Down
Loading