@datadog/webpack-plugin 2.1.0 → 2.2.0-dev-0

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.
@@ -5,7 +5,7 @@ import require$$0$1 from 'os';
5
5
  import { spawn } from 'child_process';
6
6
  import { EventEmitter as EventEmitter$1 } from 'node:events';
7
7
  import { URL as URL$1, fileURLToPath } from 'url';
8
- import require$$1$1, { resolve as resolve$1, extname, isAbsolute, normalize } from 'path';
8
+ import path$h, { resolve as resolve$1, extname, isAbsolute, normalize } from 'path';
9
9
  import { File, Buffer as Buffer$1 } from 'buffer';
10
10
  import require$$0$3, { Readable } from 'stream';
11
11
  import { createGzip } from 'zlib';
@@ -6765,6 +6765,12 @@ class TrackedFilesMatcher {
6765
6765
  }
6766
6766
  }
6767
6767
  }
6768
+ displaySource(src) {
6769
+ if (src.length <= 40) {
6770
+ return src;
6771
+ }
6772
+ return `[...]${src.slice(-35)}`;
6773
+ }
6768
6774
  // Looks up the sources declared in the sourcemap and return a list of related tracked files.
6769
6775
  matchSourcemap(srcmapPath, onSourcesNotFound) {
6770
6776
  const buff = fs$j.readFileSync(srcmapPath, "utf8");
@@ -6780,7 +6786,9 @@ class TrackedFilesMatcher {
6780
6786
  }
6781
6787
  const filtered = this.matchSources(sources);
6782
6788
  if (filtered.length === 0) {
6783
- onSourcesNotFound(`Sources not in the tracked files.`);
6789
+ onSourcesNotFound(
6790
+ `${sources.map(this.displaySource).join(", ")} not in the tracked files.`
6791
+ );
6784
6792
  return void 0;
6785
6793
  }
6786
6794
  return filtered;
@@ -8829,11 +8837,12 @@ const getLogger = (level = "warn", name) => (text, type = "debug") => log(text,
8829
8837
  const PLUGIN_NAME$2 = "global-context-plugin";
8830
8838
  const getGlobalContextPlugin = (opts, meta) => {
8831
8839
  const log = getLogger(opts.logLevel, "internal-global-context");
8840
+ const cwd = process.cwd();
8832
8841
  const globalContext = {
8833
8842
  auth: opts.auth,
8834
- cwd: process.cwd(),
8843
+ cwd,
8835
8844
  version: meta.version,
8836
- outputDir: process.cwd(),
8845
+ outputDir: cwd,
8837
8846
  bundler: {
8838
8847
  name: meta.framework
8839
8848
  }
@@ -8847,6 +8856,9 @@ const getGlobalContextPlugin = (opts, meta) => {
8847
8856
  if (build.initialOptions.outdir) {
8848
8857
  globalContext.outputDir = build.initialOptions.outdir;
8849
8858
  }
8859
+ if (build.initialOptions.outfile) {
8860
+ globalContext.outputDir = path$h.dirname(build.initialOptions.outfile);
8861
+ }
8850
8862
  build.initialOptions.metafile = true;
8851
8863
  build.onEnd((result) => {
8852
8864
  if (!result.metafile) {
@@ -8855,7 +8867,7 @@ const getGlobalContextPlugin = (opts, meta) => {
8855
8867
  }
8856
8868
  const files = [];
8857
8869
  for (const [output] of Object.entries(result.metafile.outputs)) {
8858
- files.push({ filepath: require$$1$1.join(globalContext.outputDir, output) });
8870
+ files.push({ filepath: path$h.join(cwd, output) });
8859
8871
  }
8860
8872
  globalContext.outputFiles = files;
8861
8873
  });
@@ -8869,7 +8881,7 @@ const getGlobalContextPlugin = (opts, meta) => {
8869
8881
  compiler.hooks.emit.tap(PLUGIN_NAME$2, (compilation) => {
8870
8882
  const files = [];
8871
8883
  for (const filename of Object.keys(compilation.assets)) {
8872
- files.push({ filepath: require$$1$1.join(globalContext.outputDir, filename) });
8884
+ files.push({ filepath: path$h.join(globalContext.outputDir, filename) });
8873
8885
  }
8874
8886
  globalContext.outputFiles = files;
8875
8887
  });
@@ -8877,11 +8889,35 @@ const getGlobalContextPlugin = (opts, meta) => {
8877
8889
  vite: {
8878
8890
  options(options) {
8879
8891
  globalContext.bundler.config = options;
8892
+ },
8893
+ outputOptions(options) {
8894
+ if (options.dir) {
8895
+ globalContext.outputDir = options.dir;
8896
+ }
8897
+ },
8898
+ writeBundle(options, bundle) {
8899
+ const files = [];
8900
+ for (const filename of Object.keys(bundle)) {
8901
+ files.push({ filepath: path$h.join(globalContext.outputDir, filename) });
8902
+ }
8903
+ globalContext.outputFiles = files;
8880
8904
  }
8881
8905
  },
8882
8906
  rollup: {
8883
8907
  options(options) {
8884
8908
  globalContext.bundler.config = options;
8909
+ },
8910
+ outputOptions(options) {
8911
+ if (options.dir) {
8912
+ globalContext.outputDir = options.dir;
8913
+ }
8914
+ },
8915
+ writeBundle(options, bundle) {
8916
+ const files = [];
8917
+ for (const filename of Object.keys(bundle)) {
8918
+ files.push({ filepath: path$h.join(globalContext.outputDir, filename) });
8919
+ }
8920
+ globalContext.outputFiles = files;
8885
8921
  }
8886
8922
  },
8887
8923
  rspack(compiler) {
@@ -9069,12 +9105,12 @@ if (typeof module !== "undefined") {
9069
9105
  }
9070
9106
 
9071
9107
  const decomposePath = (options, context, sourcemapFilePath) => {
9072
- if (require$$1$1.extname(sourcemapFilePath) !== ".map") {
9108
+ if (path$h.extname(sourcemapFilePath) !== ".map") {
9073
9109
  throw new Error(`The file ${chalk.green.bold(sourcemapFilePath)} is not a sourcemap.`);
9074
9110
  }
9075
9111
  const minifiedFilePath = sourcemapFilePath.replace(/\.map$/, "");
9076
9112
  const relativePath = minifiedFilePath.replace(context.outputDir, "");
9077
- const minifiedUrl = options.minifiedPathPrefix ? require$$1$1.join(options.minifiedPathPrefix, relativePath) : relativePath;
9113
+ const minifiedUrl = options.minifiedPathPrefix ? path$h.join(options.minifiedPathPrefix, relativePath) : relativePath;
9078
9114
  return {
9079
9115
  minifiedFilePath,
9080
9116
  minifiedUrl,
@@ -9096,6 +9132,17 @@ const getSourcemapsFiles = (options, context) => {
9096
9132
  return sourcemapFiles;
9097
9133
  };
9098
9134
 
9135
+ const formatDuration = (duration) => {
9136
+ const days = Math.floor(duration / 1e3 / 60 / 60 / 24);
9137
+ const usedDuration = duration - days * 24 * 60 * 60 * 1e3;
9138
+ const d = new Date(usedDuration);
9139
+ const hours = d.getUTCHours();
9140
+ const minutes = d.getUTCMinutes();
9141
+ const seconds = d.getUTCSeconds();
9142
+ const milliseconds = d.getUTCMilliseconds();
9143
+ return `${days ? `${days}d ` : ""}${hours ? `${hours}h ` : ""}${minutes ? `${minutes}m ` : ""}${seconds ? `${seconds}s ` : ""}${milliseconds}ms`.trim();
9144
+ };
9145
+
9099
9146
  var retry$4 = {};
9100
9147
 
9101
9148
  function RetryOperation(timeouts, options) {
@@ -10187,8 +10234,8 @@ var _default = dist.default = PQueue;
10187
10234
 
10188
10235
  const SLASH_RX = /[/]+|[\\]+/g;
10189
10236
  const SLASH_TRIM_RX = /^[/]+|^[\\]+|[/]+$|[\\]+$/g;
10190
- const prefixRepeat = (path, prefix) => {
10191
- const pathParts = path.replace(SLASH_TRIM_RX, "").split(SLASH_RX);
10237
+ const prefixRepeat = (filePath, prefix) => {
10238
+ const pathParts = filePath.replace(SLASH_TRIM_RX, "").split(SLASH_RX);
10192
10239
  const prefixParts = prefix.replace(SLASH_TRIM_RX, "").split(SLASH_RX);
10193
10240
  const normalizedPath = pathParts.join("/");
10194
10241
  let result = "";
@@ -10200,13 +10247,13 @@ const prefixRepeat = (path, prefix) => {
10200
10247
  }
10201
10248
  return result;
10202
10249
  };
10203
- const checkFile = async (path) => {
10250
+ const checkFile = async (filePath) => {
10204
10251
  const validity = {
10205
10252
  empty: false,
10206
10253
  exists: true
10207
10254
  };
10208
10255
  try {
10209
- const stats = await promises.stat(path);
10256
+ const stats = await promises.stat(filePath);
10210
10257
  if (stats.size === 0) {
10211
10258
  validity.empty = true;
10212
10259
  }
@@ -10281,7 +10328,7 @@ const getPayload = async (sourcemap, metadata, prefix, git) => {
10281
10328
  sourcemap.sourcemapFilePath,
10282
10329
  (reason) => {
10283
10330
  warnings.push(
10284
- `No tracked files found for sources contained in ${sourcemap.sourcemapFilePath}: "${reason}"`
10331
+ `${path$h.basename(sourcemap.sourcemapFilePath)}: "${reason}"`
10285
10332
  );
10286
10333
  }
10287
10334
  ),
@@ -10322,6 +10369,8 @@ const getPayload = async (sourcemap, metadata, prefix, git) => {
10322
10369
  const errorCodesNoRetry = [400, 403, 413];
10323
10370
  const nbRetries = 5;
10324
10371
  const green = chalk.green.bold;
10372
+ const yellow = chalk.yellow.bold;
10373
+ const red = chalk.red.bold;
10325
10374
  const doRequest = async (url, getData2, onRetry) => {
10326
10375
  return retry$2(
10327
10376
  async (bail, attempt) => {
@@ -10337,23 +10386,23 @@ const doRequest = async (url, getData2, onRetry) => {
10337
10386
  duplex: "half"
10338
10387
  });
10339
10388
  } catch (error) {
10340
- bail(new Error(error));
10389
+ bail(error);
10341
10390
  return;
10342
10391
  }
10343
10392
  if (!response.ok) {
10344
- const error = `HTTP ${response.status} ${response.statusText}`;
10393
+ const errorMessage = `HTTP ${response.status} ${response.statusText}`;
10345
10394
  if (errorCodesNoRetry.includes(response.status)) {
10346
- bail(new Error(error));
10395
+ bail(new Error(errorMessage));
10347
10396
  return;
10348
10397
  } else {
10349
- throw new Error(error);
10398
+ throw new Error(errorMessage);
10350
10399
  }
10351
10400
  }
10352
10401
  try {
10353
10402
  const result = await response.json();
10354
10403
  return result;
10355
10404
  } catch (error) {
10356
- bail(new Error(error));
10405
+ bail(error);
10357
10406
  }
10358
10407
  },
10359
10408
  {
@@ -10394,12 +10443,15 @@ const getData$1 = (payload, defaultHeaders = {}) => async () => {
10394
10443
  return { data, headers };
10395
10444
  };
10396
10445
  const upload = async (payloads, options, context, log) => {
10446
+ const errors = [];
10447
+ const warnings = [];
10397
10448
  if (!context.auth?.apiKey) {
10398
- throw new Error("No authentication token provided");
10449
+ errors.push({ error: new Error("No authentication token provided") });
10450
+ return { errors, warnings };
10399
10451
  }
10400
10452
  if (payloads.length === 0) {
10401
- log("No sourcemaps to upload", "warn");
10402
- return;
10453
+ warnings.push("No sourcemaps to upload");
10454
+ return { errors, warnings };
10403
10455
  }
10404
10456
  const queue = new _default({ concurrency: options.maxConcurrency });
10405
10457
  const defaultHeaders = {
@@ -10419,24 +10471,34 @@ const upload = async (payloads, options, context, log) => {
10419
10471
  )
10420
10472
  };
10421
10473
  log(`Queuing ${green(metadata.sourcemap)} | ${green(metadata.file)}`);
10422
- queue.add(async () => {
10423
- await doRequest(
10424
- options.intakeUrl,
10425
- getData$1(payload, defaultHeaders),
10426
- (error, attempt) => {
10427
- log(
10428
- `Failed to upload sourcemaps: ${error.message}
10429
- Retrying ${attempt}/${nbRetries}`,
10430
- "warn"
10431
- );
10474
+ await queue.add(async () => {
10475
+ try {
10476
+ await doRequest(
10477
+ options.intakeUrl,
10478
+ getData$1(payload, defaultHeaders),
10479
+ // On retry we store the error as a warning.
10480
+ (error, attempt) => {
10481
+ const warningMessage = `Failed to upload ${yellow(metadata.sourcemap)} | ${yellow(metadata.file)}:
10482
+ ${error.message}
10483
+ Retrying ${attempt}/${nbRetries}`;
10484
+ warnings.push(warningMessage);
10485
+ log(warningMessage, "warn");
10486
+ }
10487
+ );
10488
+ log(`Sent ${green(metadata.sourcemap)} | ${green(metadata.file)}`);
10489
+ } catch (e) {
10490
+ errors.push({ metadata, error: e });
10491
+ if (options.bailOnError === true) {
10492
+ throw e;
10432
10493
  }
10433
- );
10434
- log(`Sent ${green(metadata.sourcemap)} | ${green(metadata.file)}`);
10494
+ }
10435
10495
  });
10436
10496
  }
10437
- return queue.onIdle();
10497
+ await queue.onIdle();
10498
+ return { warnings, errors };
10438
10499
  };
10439
10500
  const sendSourcemaps = async (sourcemaps, options, context, log) => {
10501
+ const start = Date.now();
10440
10502
  const prefix = options.minifiedPathPrefix;
10441
10503
  const metadata = {
10442
10504
  git_repository_url: context.git?.remote,
@@ -10452,22 +10514,47 @@ const sendSourcemaps = async (sourcemaps, options, context, log) => {
10452
10514
  );
10453
10515
  const errors = payloads.map((payload) => payload.errors).flat();
10454
10516
  const warnings = payloads.map((payload) => payload.warnings).flat();
10517
+ if (warnings.length > 0) {
10518
+ log(`Warnings while preparing payloads:
10519
+ - ${warnings.join("\n - ")}`, "warn");
10520
+ }
10455
10521
  if (errors.length > 0) {
10456
- const errorMsg = `Failed to upload sourcemaps:
10522
+ const errorMsg = `Failed to prepare payloads, aborting upload :
10457
10523
  - ${errors.join("\n - ")}`;
10458
10524
  log(errorMsg, "error");
10459
- throw new Error(errorMsg);
10525
+ if (options.bailOnError === true) {
10526
+ throw new Error(errorMsg);
10527
+ }
10528
+ return;
10529
+ }
10530
+ const { errors: uploadErrors, warnings: uploadWarnings } = await upload(
10531
+ payloads,
10532
+ options,
10533
+ context,
10534
+ log
10535
+ );
10536
+ log(
10537
+ `Done uploading ${green(sourcemaps.length.toString())} sourcemaps in ${green(formatDuration(Date.now() - start))}.`,
10538
+ "info"
10539
+ );
10540
+ if (uploadErrors.length > 0) {
10541
+ const listOfErrors = ` - ${uploadErrors.map(({ metadata: fileMetadata, error }) => {
10542
+ if (fileMetadata) {
10543
+ return `${red(fileMetadata.file)} | ${red(fileMetadata.sourcemap)} : ${error.message}`;
10544
+ }
10545
+ return error.message;
10546
+ }).join("\n - ")}`;
10547
+ const errorMsg = `Failed to upload some sourcemaps:
10548
+ ${listOfErrors}`;
10549
+ log(errorMsg, "error");
10550
+ if (options.bailOnError === true) {
10551
+ throw new Error(errorMsg);
10552
+ }
10460
10553
  }
10461
- if (warnings.length > 0) {
10554
+ if (uploadWarnings.length > 0) {
10462
10555
  log(`Warnings while uploading sourcemaps:
10463
10556
  - ${warnings.join("\n - ")}`, "warn");
10464
10557
  }
10465
- try {
10466
- await upload(payloads, options, context, log);
10467
- } catch (error) {
10468
- log(`Failed to upload sourcemaps: ${error.message}`, "error");
10469
- throw error;
10470
- }
10471
10558
  };
10472
10559
 
10473
10560
  const uploadSourcemaps = async (options, context, log) => {
@@ -10483,13 +10570,14 @@ const uploadSourcemaps = async (options, context, log) => {
10483
10570
  };
10484
10571
 
10485
10572
  const defaultIntakeUrl = `https://sourcemap-intake.${process.env.DATADOG_SITE || "datadoghq.com"}/api/v2/srcmap`;
10486
- const validateOptions$1 = (config) => {
10573
+ const validateOptions$1 = (config, log) => {
10487
10574
  const errors = [];
10488
10575
  const sourcemapsResults = validateSourcemapsOptions(config);
10489
10576
  errors.push(...sourcemapsResults.errors);
10490
10577
  if (errors.length) {
10491
- throw new Error(`Invalid configuration for ${PLUGIN_NAME$1}:
10492
- - ${errors.join("\n - ")}`);
10578
+ log(`
10579
+ - ${errors.join("\n - ")}`, "error");
10580
+ throw new Error(`Invalid configuration for ${PLUGIN_NAME$1}.`);
10493
10581
  }
10494
10582
  const toReturn = {
10495
10583
  ...config[CONFIG_KEY$1],
@@ -10536,6 +10624,7 @@ const validateSourcemapsOptions = (config) => {
10536
10624
  }
10537
10625
  }
10538
10626
  const sourcemapsWithDefaults = {
10627
+ bailOnError: false,
10539
10628
  dryRun: false,
10540
10629
  maxConcurrency: 20,
10541
10630
  intakeUrl: process.env.DATADOG_SOURCEMAP_INTAKE_URL || validatedOptions.sourcemaps.intakeUrl || defaultIntakeUrl,
@@ -10546,11 +10635,9 @@ const validateSourcemapsOptions = (config) => {
10546
10635
  return toReturn;
10547
10636
  };
10548
10637
 
10549
- const helpers$2 = {
10550
- // Add the helpers you'd like to expose here.
10551
- };
10552
10638
  const getPlugins$2 = (opts, context) => {
10553
- const rumOptions = validateOptions$1(opts);
10639
+ const log = getLogger(opts.logLevel, PLUGIN_NAME$1);
10640
+ const rumOptions = validateOptions$1(opts, log);
10554
10641
  return [
10555
10642
  {
10556
10643
  name: PLUGIN_NAME$1,
@@ -10558,7 +10645,6 @@ const getPlugins$2 = (opts, context) => {
10558
10645
  if (rumOptions.disabled) {
10559
10646
  return;
10560
10647
  }
10561
- const log = getLogger(opts.logLevel, PLUGIN_NAME$1);
10562
10648
  if (rumOptions.sourcemaps) {
10563
10649
  await uploadSourcemaps(rumOptions, context, log);
10564
10650
  }
@@ -11695,7 +11781,7 @@ function retry () {
11695
11781
  };
11696
11782
  } (fs$i));
11697
11783
 
11698
- const path$g = require$$1$1;
11784
+ const path$g = path$h;
11699
11785
 
11700
11786
  // get drive on windows
11701
11787
  function getRootPath (p) {
@@ -11720,7 +11806,7 @@ var win32 = {
11720
11806
  };
11721
11807
 
11722
11808
  const fs$g = gracefulFs;
11723
- const path$f = require$$1$1;
11809
+ const path$f = path$h;
11724
11810
  const invalidWin32Path$1 = win32.invalidWin32Path;
11725
11811
 
11726
11812
  const o777$1 = parseInt('0777', 8);
@@ -11782,7 +11868,7 @@ function mkdirs$2 (p, opts, callback, made) {
11782
11868
  var mkdirs_1$1 = mkdirs$2;
11783
11869
 
11784
11870
  const fs$f = gracefulFs;
11785
- const path$e = require$$1$1;
11871
+ const path$e = path$h;
11786
11872
  const invalidWin32Path = win32.invalidWin32Path;
11787
11873
 
11788
11874
  const o777 = parseInt('0777', 8);
@@ -11850,7 +11936,7 @@ var mkdirs_1 = {
11850
11936
 
11851
11937
  const fs$e = gracefulFs;
11852
11938
  const os = require$$0$1;
11853
- const path$d = require$$1$1;
11939
+ const path$d = path$h;
11854
11940
 
11855
11941
  // HFS, ext{2,3}, FAT do not, Node.js v0.10 does not
11856
11942
  function hasMillisResSync () {
@@ -11939,7 +12025,7 @@ var buffer$1 = function (size) {
11939
12025
  };
11940
12026
 
11941
12027
  const fs$d = gracefulFs;
11942
- const path$c = require$$1$1;
12028
+ const path$c = path$h;
11943
12029
  const mkdirpSync$1 = mkdirs_1.mkdirsSync;
11944
12030
  const utimesSync = utimes$1.utimesMillisSync;
11945
12031
 
@@ -12147,7 +12233,7 @@ var pathExists_1 = {
12147
12233
  };
12148
12234
 
12149
12235
  const fs$b = gracefulFs;
12150
- const path$b = require$$1$1;
12236
+ const path$b = path$h;
12151
12237
  const mkdirp$1 = mkdirs_1.mkdirs;
12152
12238
  const pathExists$7 = pathExists_1.pathExists;
12153
12239
  const utimes = utimes$1.utimesMillis;
@@ -12397,7 +12483,7 @@ var copy$1 = {
12397
12483
  };
12398
12484
 
12399
12485
  const fs$a = gracefulFs;
12400
- const path$a = require$$1$1;
12486
+ const path$a = path$h;
12401
12487
  const assert = require$$5;
12402
12488
 
12403
12489
  const isWindows = (process.platform === 'win32');
@@ -12719,7 +12805,7 @@ var remove$3 = {
12719
12805
 
12720
12806
  const u$7 = universalify.fromCallback;
12721
12807
  const fs$9 = fs$j;
12722
- const path$9 = require$$1$1;
12808
+ const path$9 = path$h;
12723
12809
  const mkdir$5 = mkdirs_1;
12724
12810
  const remove$2 = remove$3;
12725
12811
 
@@ -12765,7 +12851,7 @@ var empty$2 = {
12765
12851
  };
12766
12852
 
12767
12853
  const u$6 = universalify.fromCallback;
12768
- const path$8 = require$$1$1;
12854
+ const path$8 = path$h;
12769
12855
  const fs$8 = gracefulFs;
12770
12856
  const mkdir$4 = mkdirs_1;
12771
12857
  const pathExists$6 = pathExists_1.pathExists;
@@ -12813,7 +12899,7 @@ var file$1 = {
12813
12899
  };
12814
12900
 
12815
12901
  const u$5 = universalify.fromCallback;
12816
- const path$7 = require$$1$1;
12902
+ const path$7 = path$h;
12817
12903
  const fs$7 = gracefulFs;
12818
12904
  const mkdir$3 = mkdirs_1;
12819
12905
  const pathExists$5 = pathExists_1.pathExists;
@@ -12872,7 +12958,7 @@ var link$1 = {
12872
12958
  createLinkSync
12873
12959
  };
12874
12960
 
12875
- const path$6 = require$$1$1;
12961
+ const path$6 = path$h;
12876
12962
  const fs$6 = gracefulFs;
12877
12963
  const pathExists$4 = pathExists_1.pathExists;
12878
12964
 
@@ -13001,7 +13087,7 @@ var symlinkType_1 = {
13001
13087
  };
13002
13088
 
13003
13089
  const u$4 = universalify.fromCallback;
13004
- const path$5 = require$$1$1;
13090
+ const path$5 = path$h;
13005
13091
  const fs$4 = gracefulFs;
13006
13092
  const _mkdirs = mkdirs_1;
13007
13093
  const mkdirs = _mkdirs.mkdirs;
@@ -13230,7 +13316,7 @@ var jsonfile = {
13230
13316
  writeJsonSync: jsonFile$3.writeFileSync
13231
13317
  };
13232
13318
 
13233
- const path$4 = require$$1$1;
13319
+ const path$4 = path$h;
13234
13320
  const mkdir$2 = mkdirs_1;
13235
13321
  const pathExists$2 = pathExists_1.pathExists;
13236
13322
  const jsonFile$2 = jsonfile;
@@ -13257,7 +13343,7 @@ function outputJson (file, data, options, callback) {
13257
13343
  var outputJson_1 = outputJson;
13258
13344
 
13259
13345
  const fs$3 = gracefulFs;
13260
- const path$3 = require$$1$1;
13346
+ const path$3 = path$h;
13261
13347
  const mkdir$1 = mkdirs_1;
13262
13348
  const jsonFile$1 = jsonfile;
13263
13349
 
@@ -13289,7 +13375,7 @@ jsonFile.readJSONSync = jsonFile.readJsonSync;
13289
13375
  var json = jsonFile;
13290
13376
 
13291
13377
  const fs$2 = gracefulFs;
13292
- const path$2 = require$$1$1;
13378
+ const path$2 = path$h;
13293
13379
  const copySync = copySync$1.copySync;
13294
13380
  const removeSync = remove$3.removeSync;
13295
13381
  const mkdirpSync = mkdirs_1.mkdirsSync;
@@ -13406,7 +13492,7 @@ var moveSync_1 = {
13406
13492
 
13407
13493
  const u$1 = universalify.fromCallback;
13408
13494
  const fs$1 = gracefulFs;
13409
- const path$1 = require$$1$1;
13495
+ const path$1 = path$h;
13410
13496
  const copy = copy$1.copy;
13411
13497
  const remove$1 = remove$3.remove;
13412
13498
  const mkdirp = mkdirs_1.mkdirp;
@@ -13487,7 +13573,7 @@ var move_1 = {
13487
13573
 
13488
13574
  const u = universalify.fromCallback;
13489
13575
  const fs = gracefulFs;
13490
- const path = require$$1$1;
13576
+ const path = path$h;
13491
13577
  const mkdir = mkdirs_1;
13492
13578
  const pathExists = pathExists_1.pathExists;
13493
13579
 
@@ -13636,17 +13722,6 @@ const getValueContext = (args) => {
13636
13722
  }));
13637
13723
  };
13638
13724
 
13639
- const formatDuration = (duration) => {
13640
- const days = Math.floor(duration / 1e3 / 60 / 60 / 24);
13641
- const usedDuration = duration - days * 24 * 60 * 60 * 1e3;
13642
- const d = new Date(usedDuration);
13643
- const hours = d.getUTCHours();
13644
- const minutes = d.getUTCMinutes();
13645
- const seconds = d.getUTCSeconds();
13646
- const milliseconds = d.getUTCMilliseconds();
13647
- return `${days ? `${days}d ` : ""}${hours ? `${hours}h ` : ""}${minutes ? `${minutes}m ` : ""}${seconds ? `${seconds}s ` : ""}${milliseconds}ms`.trim();
13648
- };
13649
-
13650
13725
  const outputFiles = async (context, outputOptions, log, cwd) => {
13651
13726
  const { report, metrics, bundler } = context;
13652
13727
  if (typeof outputOptions !== "string" && typeof outputOptions !== "object") {
@@ -13670,7 +13745,7 @@ const outputFiles = async (context, outputOptions, log, cwd) => {
13670
13745
  } else {
13671
13746
  destination = outputOptions;
13672
13747
  }
13673
- const outputPath = require$$1$1.resolve(cwd, destination);
13748
+ const outputPath = path$h.resolve(cwd, destination);
13674
13749
  try {
13675
13750
  const errors = {};
13676
13751
  const filesToWrite = {};
@@ -13700,7 +13775,7 @@ const outputFiles = async (context, outputOptions, log, cwd) => {
13700
13775
  const proms = Object.keys(filesToWrite).map((file) => {
13701
13776
  const start = Date.now();
13702
13777
  log(`Start writing ${file}.json.`);
13703
- return writeFile(require$$1$1.join(outputPath, `${file}.json`), filesToWrite[file].content).then(() => {
13778
+ return writeFile(path$h.join(outputPath, `${file}.json`), filesToWrite[file].content).then(() => {
13704
13779
  log(`Wrote ${file}.json in ${formatDuration(Date.now() - start)}`);
13705
13780
  }).catch((e) => {
13706
13781
  log(
@@ -13883,7 +13958,7 @@ const getInputsDependencies = (list, moduleName, deps = /* @__PURE__ */ new Set(
13883
13958
  };
13884
13959
  const getModulePath$1 = (fullPath, cwd) => {
13885
13960
  const filePath = fullPath.replace("pnp:", "").replace(cwd, "");
13886
- return getDisplayName(require$$1$1.resolve(cwd, filePath), cwd);
13961
+ return getDisplayName(path$h.resolve(cwd, filePath), cwd);
13887
13962
  };
13888
13963
  const getIndexed$1 = (stats, cwd) => {
13889
13964
  const inputsDependencies = {};
@@ -24686,7 +24761,7 @@ virtualStats.VirtualStats = VirtualStats;
24686
24761
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
24687
24762
  return (mod && mod.__esModule) ? mod : { "default": mod };
24688
24763
  };
24689
- const path_1 = __importDefault(require$$1$1);
24764
+ const path_1 = __importDefault(path$h);
24690
24765
  const virtual_stats_1 = virtualStats;
24691
24766
  let inode = 45000000;
24692
24767
  const ALL = 'all';
@@ -24970,7 +25045,7 @@ var VirtualModulesPlugin$1 = /*@__PURE__*/getDefaultExportFromCjs(lib);
24970
25045
 
24971
25046
  // node_modules/.pnpm/tsup@8.0.2_typescript@5.4.5/node_modules/tsup/assets/esm_shims.js
24972
25047
  var getFilename = () => fileURLToPath(import.meta.url);
24973
- var getDirname = () => require$$1$1.dirname(getFilename());
25048
+ var getDirname = () => path$h.dirname(getFilename());
24974
25049
  var __dirname = /* @__PURE__ */ getDirname();
24975
25050
 
24976
25051
  // node_modules/.pnpm/@jridgewell+sourcemap-codec@1.4.15/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
@@ -25771,7 +25846,7 @@ var ExtToLoader = {
25771
25846
  ".txt": "text"
25772
25847
  };
25773
25848
  function guessLoader(code, id) {
25774
- return ExtToLoader[require$$1$1.extname(id).toLowerCase()] || "js";
25849
+ return ExtToLoader[path$h.extname(id).toLowerCase()] || "js";
25775
25850
  }
25776
25851
  function unwrapLoader(loader, code, id) {
25777
25852
  if (typeof loader === "function")
@@ -25845,8 +25920,8 @@ function createBuildContext(initialOptions) {
25845
25920
  emitFile(emittedFile) {
25846
25921
  const outFileName = emittedFile.fileName || emittedFile.name;
25847
25922
  if (initialOptions.outdir && emittedFile.source && outFileName) {
25848
- const outPath = require$$1$1.resolve(initialOptions.outdir, outFileName);
25849
- const outDir = require$$1$1.dirname(outPath);
25923
+ const outPath = path$h.resolve(initialOptions.outdir, outFileName);
25924
+ const outDir = path$h.dirname(outPath);
25850
25925
  if (!fs$j.existsSync(outDir))
25851
25926
  fs$j.mkdirSync(outDir, { recursive: true });
25852
25927
  fs$j.writeFileSync(outPath, emittedFile.source);
@@ -26047,7 +26122,7 @@ function buildSetup(meta) {
26047
26122
  onLoad({ filter: onLoadFilter }, async (args) => {
26048
26123
  const id = args.path + args.suffix;
26049
26124
  const { errors, warnings, mixedContext } = createPluginContext(context);
26050
- const resolveDir = require$$1$1.dirname(args.path);
26125
+ const resolveDir = path$h.dirname(args.path);
26051
26126
  let code, map;
26052
26127
  if (plugin.load && (!plugin.loadInclude || plugin.loadInclude(id))) {
26053
26128
  const result = await plugin.load.call(mixedContext, id);
@@ -26078,7 +26153,7 @@ function buildSetup(meta) {
26078
26153
  if (plugin.transformInclude && !plugin.transformInclude(id))
26079
26154
  return;
26080
26155
  const { mixedContext, errors, warnings } = createPluginContext(context);
26081
- const resolveDir = require$$1$1.dirname(args.path);
26156
+ const resolveDir = path$h.dirname(args.path);
26082
26157
  let code = await args.getContents();
26083
26158
  let map;
26084
26159
  const result = await plugin.transform.call(mixedContext, code, id);
@@ -26170,7 +26245,7 @@ var ExtToLoader2 = {
26170
26245
  ".node": "napi"
26171
26246
  };
26172
26247
  function guessIdLoader(id) {
26173
- return ExtToLoader2[require$$1$1.extname(id).toLowerCase()] || "js";
26248
+ return ExtToLoader2[path$h.extname(id).toLowerCase()] || "js";
26174
26249
  }
26175
26250
  function transformQuery(context) {
26176
26251
  const queryParamsObject = {};
@@ -26260,7 +26335,7 @@ function toFarmPlugin(plugin, options) {
26260
26335
  farmPlugin.resolve = {
26261
26336
  filters: { sources: [".*", ...filters], importers: [".*"] },
26262
26337
  async executor(params, context) {
26263
- const resolvedIdPath = require$$1$1.resolve(
26338
+ const resolvedIdPath = path$h.resolve(
26264
26339
  process.cwd(),
26265
26340
  params.importer ?? ""
26266
26341
  );
@@ -26829,7 +26904,6 @@ function createUnplugin(factory) {
26829
26904
  const helpers = {
26830
26905
  // Each product should have a unique entry.
26831
26906
  // #helpers-injection-marker
26832
- [CONFIG_KEY$1]: helpers$2,
26833
26907
  [CONFIG_KEY]: helpers$1
26834
26908
  // #helpers-injection-marker
26835
26909
  };
@@ -26837,6 +26911,9 @@ const buildPluginFactory = ({
26837
26911
  version
26838
26912
  }) => {
26839
26913
  return createUnplugin((options, unpluginMetaContext) => {
26914
+ if ("esbuildHostName" in unpluginMetaContext) {
26915
+ unpluginMetaContext.esbuildHostName = "datadog-plugins";
26916
+ }
26840
26917
  const { globalContext, internalPlugins } = getInternalPlugins(options, {
26841
26918
  version,
26842
26919
  ...unpluginMetaContext
@@ -26854,7 +26931,7 @@ const buildPluginFactory = ({
26854
26931
 
26855
26932
  var name = "@datadog/webpack-plugin";
26856
26933
  var packageManager = "yarn@4.0.2";
26857
- var version = "2.1.0";
26934
+ var version = "2.2.0-dev-0";
26858
26935
  var license = "MIT";
26859
26936
  var author = "Datadog";
26860
26937
  var description = "Datadog Webpack Plugin";
@@ -26919,6 +26996,7 @@ var devDependencies = {
26919
26996
  var peerDependencies = {
26920
26997
  webpack: ">= 4.x < 6.x"
26921
26998
  };
26999
+ var stableVersion = "2.1.0";
26922
27000
  var pkg = {
26923
27001
  name: name,
26924
27002
  packageManager: packageManager,
@@ -26936,7 +27014,8 @@ var pkg = {
26936
27014
  files: files,
26937
27015
  scripts: scripts,
26938
27016
  devDependencies: devDependencies,
26939
- peerDependencies: peerDependencies
27017
+ peerDependencies: peerDependencies,
27018
+ stableVersion: stableVersion
26940
27019
  };
26941
27020
 
26942
27021
  const datadogWebpackPlugin = buildPluginFactory({