@datadog/esbuild-plugin 2.3.1-dev-6 → 2.3.1-dev-8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -96,6 +96,7 @@ type GlobalContext = {
96
96
  build: BuildReport;
97
97
  cwd: string;
98
98
  git?: RepositoryData;
99
+ pluginNames: string[];
99
100
  start: number;
100
101
  version: string;
101
102
  };
package/dist/src/index.js CHANGED
@@ -2377,6 +2377,14 @@ const truncateString = (str, maxLength = 60, placeholder = "[...]") => {
2377
2377
  return `${str.slice(0, leftStop)}${placeholder}${str.slice(-rightStop)}`;
2378
2378
  };
2379
2379
  const isInjection = (filename) => filename.includes(INJECTED_FILE);
2380
+ const isInternalPlugin = (pluginName, context) => {
2381
+ for (const internalPluginName of context.pluginNames) {
2382
+ if (pluginName.includes(internalPluginName)) {
2383
+ return true;
2384
+ }
2385
+ }
2386
+ return false;
2387
+ };
2380
2388
 
2381
2389
  var balancedMatch = balanced$1;
2382
2390
  function balanced$1(a, b, str) {
@@ -12066,7 +12074,7 @@ const getBuildReportPlugin = (opts, context) => {
12066
12074
  };
12067
12075
  };
12068
12076
 
12069
- const PLUGIN_NAME$2 = "datadog-context-plugin";
12077
+ const PLUGIN_NAME$2 = "datadog-bundler-report-plugin";
12070
12078
  const rollupPlugin = (context) => ({
12071
12079
  options(options) {
12072
12080
  context.bundler.rawConfig = options;
@@ -19133,8 +19141,20 @@ const getInjectionPlugins = (opts, context, toInject) => {
19133
19141
  esbuild: {
19134
19142
  setup(build) {
19135
19143
  const { initialOptions } = build;
19144
+ const initialInject = initialOptions.inject ? [...initialOptions.inject] : [];
19145
+ const plugins = initialOptions.plugins || [];
19136
19146
  initialOptions.inject = initialOptions.inject || [];
19137
19147
  initialOptions.inject.push(INJECTED_FILE);
19148
+ for (const plugin of plugins) {
19149
+ const oldSetup = plugin.setup;
19150
+ if (isInternalPlugin(plugin.name, context)) {
19151
+ continue;
19152
+ }
19153
+ plugin.setup = async (esbuild) => {
19154
+ esbuild.initialOptions.inject = initialInject;
19155
+ await oldSetup(esbuild);
19156
+ };
19157
+ }
19138
19158
  }
19139
19159
  },
19140
19160
  webpack: (compiler) => {
@@ -19190,6 +19210,7 @@ const getInternalPlugins = (options, meta) => {
19190
19210
  const toInject = [];
19191
19211
  const globalContext = {
19192
19212
  auth: options.auth,
19213
+ pluginNames: [],
19193
19214
  bundler: {
19194
19215
  name: meta.framework,
19195
19216
  fullName: `${meta.framework}${variant}`,
@@ -23542,15 +23563,16 @@ const defaultFilters = [
23542
23563
 
23543
23564
  const validateOptions$1 = (opts) => {
23544
23565
  const options = opts[CONFIG_KEY] || {};
23566
+ const endPoint = options.endPoint || "https://app.datadoghq.com";
23545
23567
  return {
23546
23568
  disabled: false,
23547
23569
  enableTracing: false,
23548
- endPoint: "app.datadoghq.com",
23549
23570
  filters: defaultFilters,
23550
23571
  output: false,
23551
23572
  prefix: "",
23552
23573
  tags: [],
23553
- ...options
23574
+ ...options,
23575
+ endPoint: endPoint.startsWith("http") ? endPoint : `https://${endPoint}`
23554
23576
  };
23555
23577
  };
23556
23578
  const getMetric = (metric, opts) => ({
@@ -36439,18 +36461,20 @@ const validateOptions = (options = {}) => {
36439
36461
  ...options
36440
36462
  };
36441
36463
  };
36464
+ const HOST_NAME = "datadog-build-plugins";
36442
36465
  const buildPluginFactory = ({
36443
36466
  version
36444
36467
  }) => {
36445
36468
  return createUnplugin((opts, unpluginMetaContext) => {
36446
36469
  const options = validateOptions(opts);
36447
- if ("esbuildHostName" in unpluginMetaContext) {
36448
- unpluginMetaContext.esbuildHostName = "datadog-plugins";
36470
+ if (unpluginMetaContext.framework === "esbuild") {
36471
+ unpluginMetaContext.esbuildHostName = HOST_NAME;
36449
36472
  }
36450
36473
  const { globalContext, internalPlugins } = getInternalPlugins(options, {
36451
36474
  version,
36452
36475
  ...unpluginMetaContext
36453
36476
  });
36477
+ globalContext.pluginNames.push(HOST_NAME);
36454
36478
  const plugins = [...internalPlugins];
36455
36479
  if (options.customPlugins) {
36456
36480
  const customPlugins = options.customPlugins(options, globalContext);
@@ -36462,13 +36486,14 @@ const buildPluginFactory = ({
36462
36486
  if (options[CONFIG_KEY] && options[CONFIG_KEY].disabled !== true) {
36463
36487
  plugins.push(...getPlugins(options, globalContext));
36464
36488
  }
36489
+ globalContext.pluginNames.push(...plugins.map((plugin) => plugin.name));
36465
36490
  return plugins;
36466
36491
  });
36467
36492
  };
36468
36493
 
36469
36494
  var name = "@datadog/esbuild-plugin";
36470
36495
  var packageManager = "yarn@4.0.2";
36471
- var version$1 = "2.3.1-dev-6";
36496
+ var version$1 = "2.3.1-dev-8";
36472
36497
  var license = "MIT";
36473
36498
  var author = "Datadog";
36474
36499
  var description = "Datadog ESBuild Plugin";