@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.
package/dist/src/index.js CHANGED
@@ -7,7 +7,7 @@ var require$$0$1 = require('os');
7
7
  var child_process = require('child_process');
8
8
  var node_events = require('node:events');
9
9
  var url = require('url');
10
- var require$$1$1 = require('path');
10
+ var path$h = require('path');
11
11
  var buffer$2 = require('buffer');
12
12
  var require$$0$2 = require('stream');
13
13
  var zlib = require('zlib');
@@ -6787,6 +6787,12 @@ class TrackedFilesMatcher {
6787
6787
  }
6788
6788
  }
6789
6789
  }
6790
+ displaySource(src) {
6791
+ if (src.length <= 40) {
6792
+ return src;
6793
+ }
6794
+ return `[...]${src.slice(-35)}`;
6795
+ }
6790
6796
  // Looks up the sources declared in the sourcemap and return a list of related tracked files.
6791
6797
  matchSourcemap(srcmapPath, onSourcesNotFound) {
6792
6798
  const buff = fs$j.readFileSync(srcmapPath, "utf8");
@@ -6802,7 +6808,9 @@ class TrackedFilesMatcher {
6802
6808
  }
6803
6809
  const filtered = this.matchSources(sources);
6804
6810
  if (filtered.length === 0) {
6805
- onSourcesNotFound(`Sources not in the tracked files.`);
6811
+ onSourcesNotFound(
6812
+ `${sources.map(this.displaySource).join(", ")} not in the tracked files.`
6813
+ );
6806
6814
  return void 0;
6807
6815
  }
6808
6816
  return filtered;
@@ -8851,11 +8859,12 @@ const getLogger = (level = "warn", name) => (text, type = "debug") => log(text,
8851
8859
  const PLUGIN_NAME$2 = "global-context-plugin";
8852
8860
  const getGlobalContextPlugin = (opts, meta) => {
8853
8861
  const log = getLogger(opts.logLevel, "internal-global-context");
8862
+ const cwd = process.cwd();
8854
8863
  const globalContext = {
8855
8864
  auth: opts.auth,
8856
- cwd: process.cwd(),
8865
+ cwd,
8857
8866
  version: meta.version,
8858
- outputDir: process.cwd(),
8867
+ outputDir: cwd,
8859
8868
  bundler: {
8860
8869
  name: meta.framework
8861
8870
  }
@@ -8869,6 +8878,9 @@ const getGlobalContextPlugin = (opts, meta) => {
8869
8878
  if (build.initialOptions.outdir) {
8870
8879
  globalContext.outputDir = build.initialOptions.outdir;
8871
8880
  }
8881
+ if (build.initialOptions.outfile) {
8882
+ globalContext.outputDir = path$h.dirname(build.initialOptions.outfile);
8883
+ }
8872
8884
  build.initialOptions.metafile = true;
8873
8885
  build.onEnd((result) => {
8874
8886
  if (!result.metafile) {
@@ -8877,7 +8889,7 @@ const getGlobalContextPlugin = (opts, meta) => {
8877
8889
  }
8878
8890
  const files = [];
8879
8891
  for (const [output] of Object.entries(result.metafile.outputs)) {
8880
- files.push({ filepath: require$$1$1.join(globalContext.outputDir, output) });
8892
+ files.push({ filepath: path$h.join(cwd, output) });
8881
8893
  }
8882
8894
  globalContext.outputFiles = files;
8883
8895
  });
@@ -8891,7 +8903,7 @@ const getGlobalContextPlugin = (opts, meta) => {
8891
8903
  compiler.hooks.emit.tap(PLUGIN_NAME$2, (compilation) => {
8892
8904
  const files = [];
8893
8905
  for (const filename of Object.keys(compilation.assets)) {
8894
- files.push({ filepath: require$$1$1.join(globalContext.outputDir, filename) });
8906
+ files.push({ filepath: path$h.join(globalContext.outputDir, filename) });
8895
8907
  }
8896
8908
  globalContext.outputFiles = files;
8897
8909
  });
@@ -8899,11 +8911,35 @@ const getGlobalContextPlugin = (opts, meta) => {
8899
8911
  vite: {
8900
8912
  options(options) {
8901
8913
  globalContext.bundler.config = options;
8914
+ },
8915
+ outputOptions(options) {
8916
+ if (options.dir) {
8917
+ globalContext.outputDir = options.dir;
8918
+ }
8919
+ },
8920
+ writeBundle(options, bundle) {
8921
+ const files = [];
8922
+ for (const filename of Object.keys(bundle)) {
8923
+ files.push({ filepath: path$h.join(globalContext.outputDir, filename) });
8924
+ }
8925
+ globalContext.outputFiles = files;
8902
8926
  }
8903
8927
  },
8904
8928
  rollup: {
8905
8929
  options(options) {
8906
8930
  globalContext.bundler.config = options;
8931
+ },
8932
+ outputOptions(options) {
8933
+ if (options.dir) {
8934
+ globalContext.outputDir = options.dir;
8935
+ }
8936
+ },
8937
+ writeBundle(options, bundle) {
8938
+ const files = [];
8939
+ for (const filename of Object.keys(bundle)) {
8940
+ files.push({ filepath: path$h.join(globalContext.outputDir, filename) });
8941
+ }
8942
+ globalContext.outputFiles = files;
8907
8943
  }
8908
8944
  },
8909
8945
  rspack(compiler) {
@@ -9091,12 +9127,12 @@ if (typeof module !== "undefined") {
9091
9127
  }
9092
9128
 
9093
9129
  const decomposePath = (options, context, sourcemapFilePath) => {
9094
- if (require$$1$1.extname(sourcemapFilePath) !== ".map") {
9130
+ if (path$h.extname(sourcemapFilePath) !== ".map") {
9095
9131
  throw new Error(`The file ${chalk.green.bold(sourcemapFilePath)} is not a sourcemap.`);
9096
9132
  }
9097
9133
  const minifiedFilePath = sourcemapFilePath.replace(/\.map$/, "");
9098
9134
  const relativePath = minifiedFilePath.replace(context.outputDir, "");
9099
- const minifiedUrl = options.minifiedPathPrefix ? require$$1$1.join(options.minifiedPathPrefix, relativePath) : relativePath;
9135
+ const minifiedUrl = options.minifiedPathPrefix ? path$h.join(options.minifiedPathPrefix, relativePath) : relativePath;
9100
9136
  return {
9101
9137
  minifiedFilePath,
9102
9138
  minifiedUrl,
@@ -9118,6 +9154,17 @@ const getSourcemapsFiles = (options, context) => {
9118
9154
  return sourcemapFiles;
9119
9155
  };
9120
9156
 
9157
+ const formatDuration = (duration) => {
9158
+ const days = Math.floor(duration / 1e3 / 60 / 60 / 24);
9159
+ const usedDuration = duration - days * 24 * 60 * 60 * 1e3;
9160
+ const d = new Date(usedDuration);
9161
+ const hours = d.getUTCHours();
9162
+ const minutes = d.getUTCMinutes();
9163
+ const seconds = d.getUTCSeconds();
9164
+ const milliseconds = d.getUTCMilliseconds();
9165
+ return `${days ? `${days}d ` : ""}${hours ? `${hours}h ` : ""}${minutes ? `${minutes}m ` : ""}${seconds ? `${seconds}s ` : ""}${milliseconds}ms`.trim();
9166
+ };
9167
+
9121
9168
  var retry$4 = {};
9122
9169
 
9123
9170
  function RetryOperation(timeouts, options) {
@@ -10209,8 +10256,8 @@ var _default = dist.default = PQueue;
10209
10256
 
10210
10257
  const SLASH_RX = /[/]+|[\\]+/g;
10211
10258
  const SLASH_TRIM_RX = /^[/]+|^[\\]+|[/]+$|[\\]+$/g;
10212
- const prefixRepeat = (path, prefix) => {
10213
- const pathParts = path.replace(SLASH_TRIM_RX, "").split(SLASH_RX);
10259
+ const prefixRepeat = (filePath, prefix) => {
10260
+ const pathParts = filePath.replace(SLASH_TRIM_RX, "").split(SLASH_RX);
10214
10261
  const prefixParts = prefix.replace(SLASH_TRIM_RX, "").split(SLASH_RX);
10215
10262
  const normalizedPath = pathParts.join("/");
10216
10263
  let result = "";
@@ -10222,13 +10269,13 @@ const prefixRepeat = (path, prefix) => {
10222
10269
  }
10223
10270
  return result;
10224
10271
  };
10225
- const checkFile = async (path) => {
10272
+ const checkFile = async (filePath) => {
10226
10273
  const validity = {
10227
10274
  empty: false,
10228
10275
  exists: true
10229
10276
  };
10230
10277
  try {
10231
- const stats = await fs$j.promises.stat(path);
10278
+ const stats = await fs$j.promises.stat(filePath);
10232
10279
  if (stats.size === 0) {
10233
10280
  validity.empty = true;
10234
10281
  }
@@ -10303,7 +10350,7 @@ const getPayload = async (sourcemap, metadata, prefix, git) => {
10303
10350
  sourcemap.sourcemapFilePath,
10304
10351
  (reason) => {
10305
10352
  warnings.push(
10306
- `No tracked files found for sources contained in ${sourcemap.sourcemapFilePath}: "${reason}"`
10353
+ `${path$h.basename(sourcemap.sourcemapFilePath)}: "${reason}"`
10307
10354
  );
10308
10355
  }
10309
10356
  ),
@@ -10344,6 +10391,8 @@ const getPayload = async (sourcemap, metadata, prefix, git) => {
10344
10391
  const errorCodesNoRetry = [400, 403, 413];
10345
10392
  const nbRetries = 5;
10346
10393
  const green = chalk.green.bold;
10394
+ const yellow = chalk.yellow.bold;
10395
+ const red = chalk.red.bold;
10347
10396
  const doRequest = async (url, getData2, onRetry) => {
10348
10397
  return retry$2(
10349
10398
  async (bail, attempt) => {
@@ -10359,23 +10408,23 @@ const doRequest = async (url, getData2, onRetry) => {
10359
10408
  duplex: "half"
10360
10409
  });
10361
10410
  } catch (error) {
10362
- bail(new Error(error));
10411
+ bail(error);
10363
10412
  return;
10364
10413
  }
10365
10414
  if (!response.ok) {
10366
- const error = `HTTP ${response.status} ${response.statusText}`;
10415
+ const errorMessage = `HTTP ${response.status} ${response.statusText}`;
10367
10416
  if (errorCodesNoRetry.includes(response.status)) {
10368
- bail(new Error(error));
10417
+ bail(new Error(errorMessage));
10369
10418
  return;
10370
10419
  } else {
10371
- throw new Error(error);
10420
+ throw new Error(errorMessage);
10372
10421
  }
10373
10422
  }
10374
10423
  try {
10375
10424
  const result = await response.json();
10376
10425
  return result;
10377
10426
  } catch (error) {
10378
- bail(new Error(error));
10427
+ bail(error);
10379
10428
  }
10380
10429
  },
10381
10430
  {
@@ -10416,12 +10465,15 @@ const getData$1 = (payload, defaultHeaders = {}) => async () => {
10416
10465
  return { data, headers };
10417
10466
  };
10418
10467
  const upload = async (payloads, options, context, log) => {
10468
+ const errors = [];
10469
+ const warnings = [];
10419
10470
  if (!context.auth?.apiKey) {
10420
- throw new Error("No authentication token provided");
10471
+ errors.push({ error: new Error("No authentication token provided") });
10472
+ return { errors, warnings };
10421
10473
  }
10422
10474
  if (payloads.length === 0) {
10423
- log("No sourcemaps to upload", "warn");
10424
- return;
10475
+ warnings.push("No sourcemaps to upload");
10476
+ return { errors, warnings };
10425
10477
  }
10426
10478
  const queue = new _default({ concurrency: options.maxConcurrency });
10427
10479
  const defaultHeaders = {
@@ -10441,24 +10493,34 @@ const upload = async (payloads, options, context, log) => {
10441
10493
  )
10442
10494
  };
10443
10495
  log(`Queuing ${green(metadata.sourcemap)} | ${green(metadata.file)}`);
10444
- queue.add(async () => {
10445
- await doRequest(
10446
- options.intakeUrl,
10447
- getData$1(payload, defaultHeaders),
10448
- (error, attempt) => {
10449
- log(
10450
- `Failed to upload sourcemaps: ${error.message}
10451
- Retrying ${attempt}/${nbRetries}`,
10452
- "warn"
10453
- );
10496
+ await queue.add(async () => {
10497
+ try {
10498
+ await doRequest(
10499
+ options.intakeUrl,
10500
+ getData$1(payload, defaultHeaders),
10501
+ // On retry we store the error as a warning.
10502
+ (error, attempt) => {
10503
+ const warningMessage = `Failed to upload ${yellow(metadata.sourcemap)} | ${yellow(metadata.file)}:
10504
+ ${error.message}
10505
+ Retrying ${attempt}/${nbRetries}`;
10506
+ warnings.push(warningMessage);
10507
+ log(warningMessage, "warn");
10508
+ }
10509
+ );
10510
+ log(`Sent ${green(metadata.sourcemap)} | ${green(metadata.file)}`);
10511
+ } catch (e) {
10512
+ errors.push({ metadata, error: e });
10513
+ if (options.bailOnError === true) {
10514
+ throw e;
10454
10515
  }
10455
- );
10456
- log(`Sent ${green(metadata.sourcemap)} | ${green(metadata.file)}`);
10516
+ }
10457
10517
  });
10458
10518
  }
10459
- return queue.onIdle();
10519
+ await queue.onIdle();
10520
+ return { warnings, errors };
10460
10521
  };
10461
10522
  const sendSourcemaps = async (sourcemaps, options, context, log) => {
10523
+ const start = Date.now();
10462
10524
  const prefix = options.minifiedPathPrefix;
10463
10525
  const metadata = {
10464
10526
  git_repository_url: context.git?.remote,
@@ -10474,22 +10536,47 @@ const sendSourcemaps = async (sourcemaps, options, context, log) => {
10474
10536
  );
10475
10537
  const errors = payloads.map((payload) => payload.errors).flat();
10476
10538
  const warnings = payloads.map((payload) => payload.warnings).flat();
10539
+ if (warnings.length > 0) {
10540
+ log(`Warnings while preparing payloads:
10541
+ - ${warnings.join("\n - ")}`, "warn");
10542
+ }
10477
10543
  if (errors.length > 0) {
10478
- const errorMsg = `Failed to upload sourcemaps:
10544
+ const errorMsg = `Failed to prepare payloads, aborting upload :
10479
10545
  - ${errors.join("\n - ")}`;
10480
10546
  log(errorMsg, "error");
10481
- throw new Error(errorMsg);
10547
+ if (options.bailOnError === true) {
10548
+ throw new Error(errorMsg);
10549
+ }
10550
+ return;
10551
+ }
10552
+ const { errors: uploadErrors, warnings: uploadWarnings } = await upload(
10553
+ payloads,
10554
+ options,
10555
+ context,
10556
+ log
10557
+ );
10558
+ log(
10559
+ `Done uploading ${green(sourcemaps.length.toString())} sourcemaps in ${green(formatDuration(Date.now() - start))}.`,
10560
+ "info"
10561
+ );
10562
+ if (uploadErrors.length > 0) {
10563
+ const listOfErrors = ` - ${uploadErrors.map(({ metadata: fileMetadata, error }) => {
10564
+ if (fileMetadata) {
10565
+ return `${red(fileMetadata.file)} | ${red(fileMetadata.sourcemap)} : ${error.message}`;
10566
+ }
10567
+ return error.message;
10568
+ }).join("\n - ")}`;
10569
+ const errorMsg = `Failed to upload some sourcemaps:
10570
+ ${listOfErrors}`;
10571
+ log(errorMsg, "error");
10572
+ if (options.bailOnError === true) {
10573
+ throw new Error(errorMsg);
10574
+ }
10482
10575
  }
10483
- if (warnings.length > 0) {
10576
+ if (uploadWarnings.length > 0) {
10484
10577
  log(`Warnings while uploading sourcemaps:
10485
10578
  - ${warnings.join("\n - ")}`, "warn");
10486
10579
  }
10487
- try {
10488
- await upload(payloads, options, context, log);
10489
- } catch (error) {
10490
- log(`Failed to upload sourcemaps: ${error.message}`, "error");
10491
- throw error;
10492
- }
10493
10580
  };
10494
10581
 
10495
10582
  const uploadSourcemaps = async (options, context, log) => {
@@ -10505,13 +10592,14 @@ const uploadSourcemaps = async (options, context, log) => {
10505
10592
  };
10506
10593
 
10507
10594
  const defaultIntakeUrl = `https://sourcemap-intake.${process.env.DATADOG_SITE || "datadoghq.com"}/api/v2/srcmap`;
10508
- const validateOptions$1 = (config) => {
10595
+ const validateOptions$1 = (config, log) => {
10509
10596
  const errors = [];
10510
10597
  const sourcemapsResults = validateSourcemapsOptions(config);
10511
10598
  errors.push(...sourcemapsResults.errors);
10512
10599
  if (errors.length) {
10513
- throw new Error(`Invalid configuration for ${PLUGIN_NAME$1}:
10514
- - ${errors.join("\n - ")}`);
10600
+ log(`
10601
+ - ${errors.join("\n - ")}`, "error");
10602
+ throw new Error(`Invalid configuration for ${PLUGIN_NAME$1}.`);
10515
10603
  }
10516
10604
  const toReturn = {
10517
10605
  ...config[CONFIG_KEY$1],
@@ -10558,6 +10646,7 @@ const validateSourcemapsOptions = (config) => {
10558
10646
  }
10559
10647
  }
10560
10648
  const sourcemapsWithDefaults = {
10649
+ bailOnError: false,
10561
10650
  dryRun: false,
10562
10651
  maxConcurrency: 20,
10563
10652
  intakeUrl: process.env.DATADOG_SOURCEMAP_INTAKE_URL || validatedOptions.sourcemaps.intakeUrl || defaultIntakeUrl,
@@ -10568,11 +10657,9 @@ const validateSourcemapsOptions = (config) => {
10568
10657
  return toReturn;
10569
10658
  };
10570
10659
 
10571
- const helpers$2 = {
10572
- // Add the helpers you'd like to expose here.
10573
- };
10574
10660
  const getPlugins$2 = (opts, context) => {
10575
- const rumOptions = validateOptions$1(opts);
10661
+ const log = getLogger(opts.logLevel, PLUGIN_NAME$1);
10662
+ const rumOptions = validateOptions$1(opts, log);
10576
10663
  return [
10577
10664
  {
10578
10665
  name: PLUGIN_NAME$1,
@@ -10580,7 +10667,6 @@ const getPlugins$2 = (opts, context) => {
10580
10667
  if (rumOptions.disabled) {
10581
10668
  return;
10582
10669
  }
10583
- const log = getLogger(opts.logLevel, PLUGIN_NAME$1);
10584
10670
  if (rumOptions.sourcemaps) {
10585
10671
  await uploadSourcemaps(rumOptions, context, log);
10586
10672
  }
@@ -11717,7 +11803,7 @@ function retry () {
11717
11803
  };
11718
11804
  } (fs$i));
11719
11805
 
11720
- const path$g = require$$1$1;
11806
+ const path$g = path$h;
11721
11807
 
11722
11808
  // get drive on windows
11723
11809
  function getRootPath (p) {
@@ -11742,7 +11828,7 @@ var win32 = {
11742
11828
  };
11743
11829
 
11744
11830
  const fs$g = gracefulFs;
11745
- const path$f = require$$1$1;
11831
+ const path$f = path$h;
11746
11832
  const invalidWin32Path$1 = win32.invalidWin32Path;
11747
11833
 
11748
11834
  const o777$1 = parseInt('0777', 8);
@@ -11804,7 +11890,7 @@ function mkdirs$2 (p, opts, callback, made) {
11804
11890
  var mkdirs_1$1 = mkdirs$2;
11805
11891
 
11806
11892
  const fs$f = gracefulFs;
11807
- const path$e = require$$1$1;
11893
+ const path$e = path$h;
11808
11894
  const invalidWin32Path = win32.invalidWin32Path;
11809
11895
 
11810
11896
  const o777 = parseInt('0777', 8);
@@ -11872,7 +11958,7 @@ var mkdirs_1 = {
11872
11958
 
11873
11959
  const fs$e = gracefulFs;
11874
11960
  const os = require$$0$1;
11875
- const path$d = require$$1$1;
11961
+ const path$d = path$h;
11876
11962
 
11877
11963
  // HFS, ext{2,3}, FAT do not, Node.js v0.10 does not
11878
11964
  function hasMillisResSync () {
@@ -11961,7 +12047,7 @@ var buffer$1 = function (size) {
11961
12047
  };
11962
12048
 
11963
12049
  const fs$d = gracefulFs;
11964
- const path$c = require$$1$1;
12050
+ const path$c = path$h;
11965
12051
  const mkdirpSync$1 = mkdirs_1.mkdirsSync;
11966
12052
  const utimesSync = utimes$1.utimesMillisSync;
11967
12053
 
@@ -12169,7 +12255,7 @@ var pathExists_1 = {
12169
12255
  };
12170
12256
 
12171
12257
  const fs$b = gracefulFs;
12172
- const path$b = require$$1$1;
12258
+ const path$b = path$h;
12173
12259
  const mkdirp$1 = mkdirs_1.mkdirs;
12174
12260
  const pathExists$7 = pathExists_1.pathExists;
12175
12261
  const utimes = utimes$1.utimesMillis;
@@ -12419,7 +12505,7 @@ var copy$1 = {
12419
12505
  };
12420
12506
 
12421
12507
  const fs$a = gracefulFs;
12422
- const path$a = require$$1$1;
12508
+ const path$a = path$h;
12423
12509
  const assert = require$$5;
12424
12510
 
12425
12511
  const isWindows = (process.platform === 'win32');
@@ -12741,7 +12827,7 @@ var remove$3 = {
12741
12827
 
12742
12828
  const u$7 = universalify.fromCallback;
12743
12829
  const fs$9 = fs$j;
12744
- const path$9 = require$$1$1;
12830
+ const path$9 = path$h;
12745
12831
  const mkdir$5 = mkdirs_1;
12746
12832
  const remove$2 = remove$3;
12747
12833
 
@@ -12787,7 +12873,7 @@ var empty$2 = {
12787
12873
  };
12788
12874
 
12789
12875
  const u$6 = universalify.fromCallback;
12790
- const path$8 = require$$1$1;
12876
+ const path$8 = path$h;
12791
12877
  const fs$8 = gracefulFs;
12792
12878
  const mkdir$4 = mkdirs_1;
12793
12879
  const pathExists$6 = pathExists_1.pathExists;
@@ -12835,7 +12921,7 @@ var file$1 = {
12835
12921
  };
12836
12922
 
12837
12923
  const u$5 = universalify.fromCallback;
12838
- const path$7 = require$$1$1;
12924
+ const path$7 = path$h;
12839
12925
  const fs$7 = gracefulFs;
12840
12926
  const mkdir$3 = mkdirs_1;
12841
12927
  const pathExists$5 = pathExists_1.pathExists;
@@ -12894,7 +12980,7 @@ var link$1 = {
12894
12980
  createLinkSync
12895
12981
  };
12896
12982
 
12897
- const path$6 = require$$1$1;
12983
+ const path$6 = path$h;
12898
12984
  const fs$6 = gracefulFs;
12899
12985
  const pathExists$4 = pathExists_1.pathExists;
12900
12986
 
@@ -13023,7 +13109,7 @@ var symlinkType_1 = {
13023
13109
  };
13024
13110
 
13025
13111
  const u$4 = universalify.fromCallback;
13026
- const path$5 = require$$1$1;
13112
+ const path$5 = path$h;
13027
13113
  const fs$4 = gracefulFs;
13028
13114
  const _mkdirs = mkdirs_1;
13029
13115
  const mkdirs = _mkdirs.mkdirs;
@@ -13252,7 +13338,7 @@ var jsonfile = {
13252
13338
  writeJsonSync: jsonFile$3.writeFileSync
13253
13339
  };
13254
13340
 
13255
- const path$4 = require$$1$1;
13341
+ const path$4 = path$h;
13256
13342
  const mkdir$2 = mkdirs_1;
13257
13343
  const pathExists$2 = pathExists_1.pathExists;
13258
13344
  const jsonFile$2 = jsonfile;
@@ -13279,7 +13365,7 @@ function outputJson (file, data, options, callback) {
13279
13365
  var outputJson_1 = outputJson;
13280
13366
 
13281
13367
  const fs$3 = gracefulFs;
13282
- const path$3 = require$$1$1;
13368
+ const path$3 = path$h;
13283
13369
  const mkdir$1 = mkdirs_1;
13284
13370
  const jsonFile$1 = jsonfile;
13285
13371
 
@@ -13311,7 +13397,7 @@ jsonFile.readJSONSync = jsonFile.readJsonSync;
13311
13397
  var json = jsonFile;
13312
13398
 
13313
13399
  const fs$2 = gracefulFs;
13314
- const path$2 = require$$1$1;
13400
+ const path$2 = path$h;
13315
13401
  const copySync = copySync$1.copySync;
13316
13402
  const removeSync = remove$3.removeSync;
13317
13403
  const mkdirpSync = mkdirs_1.mkdirsSync;
@@ -13428,7 +13514,7 @@ var moveSync_1 = {
13428
13514
 
13429
13515
  const u$1 = universalify.fromCallback;
13430
13516
  const fs$1 = gracefulFs;
13431
- const path$1 = require$$1$1;
13517
+ const path$1 = path$h;
13432
13518
  const copy = copy$1.copy;
13433
13519
  const remove$1 = remove$3.remove;
13434
13520
  const mkdirp = mkdirs_1.mkdirp;
@@ -13509,7 +13595,7 @@ var move_1 = {
13509
13595
 
13510
13596
  const u = universalify.fromCallback;
13511
13597
  const fs = gracefulFs;
13512
- const path = require$$1$1;
13598
+ const path = path$h;
13513
13599
  const mkdir = mkdirs_1;
13514
13600
  const pathExists = pathExists_1.pathExists;
13515
13601
 
@@ -13658,17 +13744,6 @@ const getValueContext = (args) => {
13658
13744
  }));
13659
13745
  };
13660
13746
 
13661
- const formatDuration = (duration) => {
13662
- const days = Math.floor(duration / 1e3 / 60 / 60 / 24);
13663
- const usedDuration = duration - days * 24 * 60 * 60 * 1e3;
13664
- const d = new Date(usedDuration);
13665
- const hours = d.getUTCHours();
13666
- const minutes = d.getUTCMinutes();
13667
- const seconds = d.getUTCSeconds();
13668
- const milliseconds = d.getUTCMilliseconds();
13669
- return `${days ? `${days}d ` : ""}${hours ? `${hours}h ` : ""}${minutes ? `${minutes}m ` : ""}${seconds ? `${seconds}s ` : ""}${milliseconds}ms`.trim();
13670
- };
13671
-
13672
13747
  const outputFiles = async (context, outputOptions, log, cwd) => {
13673
13748
  const { report, metrics, bundler } = context;
13674
13749
  if (typeof outputOptions !== "string" && typeof outputOptions !== "object") {
@@ -13692,7 +13767,7 @@ const outputFiles = async (context, outputOptions, log, cwd) => {
13692
13767
  } else {
13693
13768
  destination = outputOptions;
13694
13769
  }
13695
- const outputPath = require$$1$1.resolve(cwd, destination);
13770
+ const outputPath = path$h.resolve(cwd, destination);
13696
13771
  try {
13697
13772
  const errors = {};
13698
13773
  const filesToWrite = {};
@@ -13722,7 +13797,7 @@ const outputFiles = async (context, outputOptions, log, cwd) => {
13722
13797
  const proms = Object.keys(filesToWrite).map((file) => {
13723
13798
  const start = Date.now();
13724
13799
  log(`Start writing ${file}.json.`);
13725
- return writeFile(require$$1$1.join(outputPath, `${file}.json`), filesToWrite[file].content).then(() => {
13800
+ return writeFile(path$h.join(outputPath, `${file}.json`), filesToWrite[file].content).then(() => {
13726
13801
  log(`Wrote ${file}.json in ${formatDuration(Date.now() - start)}`);
13727
13802
  }).catch((e) => {
13728
13803
  log(
@@ -13905,7 +13980,7 @@ const getInputsDependencies = (list, moduleName, deps = /* @__PURE__ */ new Set(
13905
13980
  };
13906
13981
  const getModulePath$1 = (fullPath, cwd) => {
13907
13982
  const filePath = fullPath.replace("pnp:", "").replace(cwd, "");
13908
- return getDisplayName(require$$1$1.resolve(cwd, filePath), cwd);
13983
+ return getDisplayName(path$h.resolve(cwd, filePath), cwd);
13909
13984
  };
13910
13985
  const getIndexed$1 = (stats, cwd) => {
13911
13986
  const inputsDependencies = {};
@@ -24708,7 +24783,7 @@ virtualStats.VirtualStats = VirtualStats;
24708
24783
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
24709
24784
  return (mod && mod.__esModule) ? mod : { "default": mod };
24710
24785
  };
24711
- const path_1 = __importDefault(require$$1$1);
24786
+ const path_1 = __importDefault(path$h);
24712
24787
  const virtual_stats_1 = virtualStats;
24713
24788
  let inode = 45000000;
24714
24789
  const ALL = 'all';
@@ -24992,7 +25067,7 @@ var VirtualModulesPlugin$1 = /*@__PURE__*/getDefaultExportFromCjs(lib);
24992
25067
 
24993
25068
  // node_modules/.pnpm/tsup@8.0.2_typescript@5.4.5/node_modules/tsup/assets/esm_shims.js
24994
25069
  var getFilename = () => url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
24995
- var getDirname = () => require$$1$1.dirname(getFilename());
25070
+ var getDirname = () => path$h.dirname(getFilename());
24996
25071
  var __dirname$1 = /* @__PURE__ */ getDirname();
24997
25072
 
24998
25073
  // node_modules/.pnpm/@jridgewell+sourcemap-codec@1.4.15/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
@@ -25744,8 +25819,8 @@ function remapping(input, loader, options) {
25744
25819
  return new SourceMap(traceMappings(tree), opts);
25745
25820
  }
25746
25821
  function normalizeAbsolutePath(path6) {
25747
- if (require$$1$1.isAbsolute(path6))
25748
- return require$$1$1.normalize(path6);
25822
+ if (path$h.isAbsolute(path6))
25823
+ return path$h.normalize(path6);
25749
25824
  else
25750
25825
  return path6;
25751
25826
  }
@@ -25793,7 +25868,7 @@ var ExtToLoader = {
25793
25868
  ".txt": "text"
25794
25869
  };
25795
25870
  function guessLoader(code, id) {
25796
- return ExtToLoader[require$$1$1.extname(id).toLowerCase()] || "js";
25871
+ return ExtToLoader[path$h.extname(id).toLowerCase()] || "js";
25797
25872
  }
25798
25873
  function unwrapLoader(loader, code, id) {
25799
25874
  if (typeof loader === "function")
@@ -25867,8 +25942,8 @@ function createBuildContext(initialOptions) {
25867
25942
  emitFile(emittedFile) {
25868
25943
  const outFileName = emittedFile.fileName || emittedFile.name;
25869
25944
  if (initialOptions.outdir && emittedFile.source && outFileName) {
25870
- const outPath = require$$1$1.resolve(initialOptions.outdir, outFileName);
25871
- const outDir = require$$1$1.dirname(outPath);
25945
+ const outPath = path$h.resolve(initialOptions.outdir, outFileName);
25946
+ const outDir = path$h.dirname(outPath);
25872
25947
  if (!fs$j.existsSync(outDir))
25873
25948
  fs$j.mkdirSync(outDir, { recursive: true });
25874
25949
  fs$j.writeFileSync(outPath, emittedFile.source);
@@ -26069,7 +26144,7 @@ function buildSetup(meta) {
26069
26144
  onLoad({ filter: onLoadFilter }, async (args) => {
26070
26145
  const id = args.path + args.suffix;
26071
26146
  const { errors, warnings, mixedContext } = createPluginContext(context);
26072
- const resolveDir = require$$1$1.dirname(args.path);
26147
+ const resolveDir = path$h.dirname(args.path);
26073
26148
  let code, map;
26074
26149
  if (plugin.load && (!plugin.loadInclude || plugin.loadInclude(id))) {
26075
26150
  const result = await plugin.load.call(mixedContext, id);
@@ -26100,7 +26175,7 @@ function buildSetup(meta) {
26100
26175
  if (plugin.transformInclude && !plugin.transformInclude(id))
26101
26176
  return;
26102
26177
  const { mixedContext, errors, warnings } = createPluginContext(context);
26103
- const resolveDir = require$$1$1.dirname(args.path);
26178
+ const resolveDir = path$h.dirname(args.path);
26104
26179
  let code = await args.getContents();
26105
26180
  let map;
26106
26181
  const result = await plugin.transform.call(mixedContext, code, id);
@@ -26158,7 +26233,7 @@ function createFarmContext(context, currentResolveId) {
26158
26233
  resolvedPath: outFileName,
26159
26234
  name: outFileName,
26160
26235
  content: [...buffer$2.Buffer.from(emittedFile.source)],
26161
- resourceType: require$$1$1.extname(outFileName)
26236
+ resourceType: path$h.extname(outFileName)
26162
26237
  });
26163
26238
  }
26164
26239
  },
@@ -26192,7 +26267,7 @@ var ExtToLoader2 = {
26192
26267
  ".node": "napi"
26193
26268
  };
26194
26269
  function guessIdLoader(id) {
26195
- return ExtToLoader2[require$$1$1.extname(id).toLowerCase()] || "js";
26270
+ return ExtToLoader2[path$h.extname(id).toLowerCase()] || "js";
26196
26271
  }
26197
26272
  function transformQuery(context) {
26198
26273
  const queryParamsObject = {};
@@ -26282,7 +26357,7 @@ function toFarmPlugin(plugin, options) {
26282
26357
  farmPlugin.resolve = {
26283
26358
  filters: { sources: [".*", ...filters], importers: [".*"] },
26284
26359
  async executor(params, context) {
26285
- const resolvedIdPath = require$$1$1.resolve(
26360
+ const resolvedIdPath = path$h.resolve(
26286
26361
  process.cwd(),
26287
26362
  params.importer ?? ""
26288
26363
  );
@@ -26489,11 +26564,11 @@ function createBuildContext2(compilation) {
26489
26564
  }
26490
26565
 
26491
26566
  // src/rspack/index.ts
26492
- var TRANSFORM_LOADER = require$$1$1.resolve(
26567
+ var TRANSFORM_LOADER = path$h.resolve(
26493
26568
  __dirname$1,
26494
26569
  "rspack/loaders/transform"
26495
26570
  );
26496
- var LOAD_LOADER = require$$1$1.resolve(
26571
+ var LOAD_LOADER = path$h.resolve(
26497
26572
  __dirname$1,
26498
26573
  "rspack/loaders/load"
26499
26574
  );
@@ -26501,7 +26576,7 @@ function getRspackPlugin(factory) {
26501
26576
  return (userOptions) => {
26502
26577
  return {
26503
26578
  apply(compiler) {
26504
- const VIRTUAL_MODULE_PREFIX = require$$1$1.resolve(compiler.options.context ?? process.cwd(), "_virtual_");
26579
+ const VIRTUAL_MODULE_PREFIX = path$h.resolve(compiler.options.context ?? process.cwd(), "_virtual_");
26505
26580
  const injected = compiler.$unpluginContext || {};
26506
26581
  compiler.$unpluginContext = injected;
26507
26582
  const meta = {
@@ -26611,7 +26686,7 @@ function createBuildContext3(options, compilation) {
26611
26686
  });
26612
26687
  },
26613
26688
  addWatchFile(id) {
26614
- options.addWatchFile(require$$1$1.resolve(process2.cwd(), id));
26689
+ options.addWatchFile(path$h.resolve(process2.cwd(), id));
26615
26690
  },
26616
26691
  emitFile(emittedFile) {
26617
26692
  const outFileName = emittedFile.fileName || emittedFile.name;
@@ -26645,11 +26720,11 @@ function normalizeMessage(error) {
26645
26720
  }
26646
26721
 
26647
26722
  // src/webpack/index.ts
26648
- var TRANSFORM_LOADER2 = require$$1$1.resolve(
26723
+ var TRANSFORM_LOADER2 = path$h.resolve(
26649
26724
  __dirname$1,
26650
26725
  "webpack/loaders/transform"
26651
26726
  );
26652
- var LOAD_LOADER2 = require$$1$1.resolve(
26727
+ var LOAD_LOADER2 = path$h.resolve(
26653
26728
  __dirname$1,
26654
26729
  "webpack/loaders/load"
26655
26730
  );
@@ -26657,7 +26732,7 @@ function getWebpackPlugin(factory) {
26657
26732
  return (userOptions) => {
26658
26733
  return {
26659
26734
  apply(compiler) {
26660
- const VIRTUAL_MODULE_PREFIX = require$$1$1.resolve(compiler.options.context ?? process2.cwd(), "_virtual_");
26735
+ const VIRTUAL_MODULE_PREFIX = path$h.resolve(compiler.options.context ?? process2.cwd(), "_virtual_");
26661
26736
  const injected = compiler.$unpluginContext || {};
26662
26737
  compiler.$unpluginContext = injected;
26663
26738
  const meta = {
@@ -26851,7 +26926,6 @@ function createUnplugin(factory) {
26851
26926
  const helpers = {
26852
26927
  // Each product should have a unique entry.
26853
26928
  // #helpers-injection-marker
26854
- [CONFIG_KEY$1]: helpers$2,
26855
26929
  [CONFIG_KEY]: helpers$1
26856
26930
  // #helpers-injection-marker
26857
26931
  };
@@ -26859,6 +26933,9 @@ const buildPluginFactory = ({
26859
26933
  version
26860
26934
  }) => {
26861
26935
  return createUnplugin((options, unpluginMetaContext) => {
26936
+ if ("esbuildHostName" in unpluginMetaContext) {
26937
+ unpluginMetaContext.esbuildHostName = "datadog-plugins";
26938
+ }
26862
26939
  const { globalContext, internalPlugins } = getInternalPlugins(options, {
26863
26940
  version,
26864
26941
  ...unpluginMetaContext
@@ -26876,7 +26953,7 @@ const buildPluginFactory = ({
26876
26953
 
26877
26954
  var name = "@datadog/webpack-plugin";
26878
26955
  var packageManager = "yarn@4.0.2";
26879
- var version = "2.1.0";
26956
+ var version = "2.2.0-dev-0";
26880
26957
  var license = "MIT";
26881
26958
  var author = "Datadog";
26882
26959
  var description = "Datadog Webpack Plugin";
@@ -26941,6 +27018,7 @@ var devDependencies = {
26941
27018
  var peerDependencies = {
26942
27019
  webpack: ">= 4.x < 6.x"
26943
27020
  };
27021
+ var stableVersion = "2.1.0";
26944
27022
  var pkg = {
26945
27023
  name: name,
26946
27024
  packageManager: packageManager,
@@ -26958,7 +27036,8 @@ var pkg = {
26958
27036
  files: files,
26959
27037
  scripts: scripts,
26960
27038
  devDependencies: devDependencies,
26961
- peerDependencies: peerDependencies
27039
+ peerDependencies: peerDependencies,
27040
+ stableVersion: stableVersion
26962
27041
  };
26963
27042
 
26964
27043
  const datadogWebpackPlugin = buildPluginFactory({