@datadog/esbuild-plugin 2.3.1-dev-9 → 2.3.1-dev-10

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.
@@ -7,9 +7,9 @@ import { lstat, readdir as readdir$1, readlink, realpath } from 'node:fs/promise
7
7
  import { EventEmitter as EventEmitter$1 } from 'node:events';
8
8
  import Stream$1 from 'node:stream';
9
9
  import { StringDecoder } from 'node:string_decoder';
10
- import require$$1, { resolve as resolve$1, extname, isAbsolute, normalize as normalize$1 } from 'path';
10
+ import path$i, { resolve as resolve$1, extname, isAbsolute, normalize as normalize$1 } from 'path';
11
11
  import require$$0$1 from 'tty';
12
- import require$$1$1 from 'util';
12
+ import require$$1 from 'util';
13
13
  import { spawn } from 'child_process';
14
14
  import { URL as URL$1, fileURLToPath as fileURLToPath$1 } from 'url';
15
15
  import { readFile as readFile$1 } from 'fs/promises';
@@ -21,6 +21,7 @@ import require$$5 from 'assert';
21
21
  import { performance as performance$1 } from 'perf_hooks';
22
22
  import * as querystring from 'querystring';
23
23
  import process2 from 'process';
24
+ import esbuild from 'esbuild';
24
25
 
25
26
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
26
27
 
@@ -2271,8 +2272,8 @@ var retry$2 = /*@__PURE__*/getDefaultExportFromCjs(lib$3);
2271
2272
 
2272
2273
  const PREPARATION_PLUGIN_NAME = "datadog-injection-preparation-plugin";
2273
2274
  const PLUGIN_NAME$4 = "datadog-injection-plugin";
2274
- const RESOLUTION_PLUGIN_NAME = "datadog-injection-resolution-plugin";
2275
- const INJECTED_FILE = "__DATADOG_INJECTION_STUB";
2275
+ const INJECTED_FILE = "__datadog-helper-file";
2276
+ const INJECTED_FILE_PATH = `${INJECTED_FILE}.js`;
2276
2277
  const DISTANT_FILE_RX = /^https?:\/\//;
2277
2278
 
2278
2279
  const formatDuration = (duration) => {
@@ -2283,7 +2284,7 @@ const formatDuration = (duration) => {
2283
2284
  const minutes = d.getUTCMinutes();
2284
2285
  const seconds = d.getUTCSeconds();
2285
2286
  const milliseconds = d.getUTCMilliseconds();
2286
- return `${days ? `${days}d ` : ""}${hours ? `${hours}h ` : ""}${minutes ? `${minutes}m ` : ""}${seconds ? `${seconds}s ` : ""}${milliseconds}ms`.trim();
2287
+ return `${days ? `${days}d ` : ""}${hours ? `${hours}h ` : ""}${minutes ? `${minutes}m ` : ""}${seconds ? `${seconds}s ` : ""}${milliseconds ? `${milliseconds}ms` : ""}`.trim();
2287
2288
  };
2288
2289
  const getResolvedPath = (filepath) => {
2289
2290
  try {
@@ -2353,7 +2354,7 @@ const truncateString = (str, maxLength = 60, placeholder = "[...]") => {
2353
2354
  const rightStop = stringLength - leftStop;
2354
2355
  return `${str.slice(0, leftStop)}${placeholder}${str.slice(-rightStop)}`;
2355
2356
  };
2356
- const isInjection = (filename) => filename.includes(INJECTED_FILE);
2357
+ const isInjectionFile = (filename) => filename.includes(INJECTED_FILE);
2357
2358
 
2358
2359
  var balancedMatch = balanced$1;
2359
2360
  function balanced$1(a, b, str) {
@@ -11309,18 +11310,13 @@ const cleanReport = (report, filepath, filter) => {
11309
11310
  const cleanedPath = cleanPath(reportFilepath);
11310
11311
  if (
11311
11312
  // Don't add injections.
11312
- isInjection(reportFilepath) || // Don't add itself into it.
11313
+ isInjectionFile(reportFilepath) || // Don't add itself into it.
11313
11314
  cleanedPath === filepath || // Remove common specific files injected by bundlers.
11314
11315
  BUNDLER_SPECIFICS.includes(cleanedPath)
11315
11316
  ) {
11316
11317
  continue;
11317
11318
  }
11318
- if (filter) {
11319
- const filteredValue = filter(cleanedPath);
11320
- if (filteredValue) {
11321
- cleanedReport.add(filteredValue);
11322
- }
11323
- } else {
11319
+ {
11324
11320
  cleanedReport.add(cleanedPath);
11325
11321
  }
11326
11322
  }
@@ -11330,16 +11326,16 @@ const cleanPath = (filepath) => {
11330
11326
  return filepath.split("!").pop().split(QUERY_RX).shift().replace(/^[^\w\s.,!@#$%^&*()=+~`\-/]+/, "");
11331
11327
  };
11332
11328
  const getAbsolutePath = (cwd, filepath) => {
11333
- if (isInjection(filepath)) {
11329
+ if (isInjectionFile(filepath)) {
11334
11330
  return INJECTED_FILE;
11335
11331
  }
11336
11332
  if (filepath.startsWith(cwd)) {
11337
11333
  return filepath;
11338
11334
  }
11339
- return require$$1.resolve(cwd, filepath);
11335
+ return path$i.resolve(cwd, filepath);
11340
11336
  };
11341
11337
  const cleanName = (context, filepath) => {
11342
- if (isInjection(filepath)) {
11338
+ if (isInjectionFile(filepath)) {
11343
11339
  return INJECTED_FILE;
11344
11340
  }
11345
11341
  if (filepath === "unknown") {
@@ -11413,8 +11409,24 @@ const getEsbuildPlugin$2 = (context, log) => {
11413
11409
  const reportOutputsIndexed = {};
11414
11410
  const metaInputsIndexed = reIndexMeta(result.metafile.inputs, cwd);
11415
11411
  const metaOutputsIndexed = reIndexMeta(result.metafile.outputs, cwd);
11412
+ const getRealPathFromInjectionProxy = (entryPoint) => {
11413
+ if (!isInjectionFile(entryPoint)) {
11414
+ return entryPoint;
11415
+ }
11416
+ const metaInput = metaInputsIndexed[getAbsolutePath(cwd, entryPoint)];
11417
+ if (!metaInput) {
11418
+ return entryPoint;
11419
+ }
11420
+ const actualImport = metaInput.imports.find(
11421
+ (imp) => !isInjectionFile(imp.path)
11422
+ );
11423
+ if (!actualImport) {
11424
+ return entryPoint;
11425
+ }
11426
+ return actualImport.path;
11427
+ };
11416
11428
  for (const [filename, input] of Object.entries(result.metafile.inputs)) {
11417
- if (isInjection(filename)) {
11429
+ if (isInjectionFile(filename)) {
11418
11430
  continue;
11419
11431
  }
11420
11432
  const filepath = getAbsolutePath(cwd, filename);
@@ -11435,7 +11447,7 @@ const getEsbuildPlugin$2 = (context, log) => {
11435
11447
  const cleanedName = cleanName(context, fullPath);
11436
11448
  const inputFiles = [];
11437
11449
  for (const inputName of Object.keys(output.inputs)) {
11438
- if (isInjection(inputName)) {
11450
+ if (isInjectionFile(inputName)) {
11439
11451
  continue;
11440
11452
  }
11441
11453
  const inputFound = reportInputsIndexed[getAbsolutePath(cwd, inputName)];
@@ -11468,7 +11480,7 @@ const getEsbuildPlugin$2 = (context, log) => {
11468
11480
  if (!output.entryPoint) {
11469
11481
  continue;
11470
11482
  }
11471
- const inputFile = reportInputsIndexed[getAbsolutePath(cwd, output.entryPoint)];
11483
+ const inputFile = reportInputsIndexed[getAbsolutePath(cwd, getRealPathFromInjectionProxy(output.entryPoint))];
11472
11484
  if (inputFile) {
11473
11485
  if (!entryNames.get(inputFile.name)) {
11474
11486
  continue;
@@ -11503,7 +11515,7 @@ const getEsbuildPlugin$2 = (context, log) => {
11503
11515
  };
11504
11516
  const FILE_EXCEPTIONS_RX = /(<runtime>|https:|file:|data:|#)/g;
11505
11517
  const isFileSupported = (filePath) => {
11506
- if (isInjection(filePath) || filePath.match(FILE_EXCEPTIONS_RX)) {
11518
+ if (isInjectionFile(filePath) || filePath.match(FILE_EXCEPTIONS_RX)) {
11507
11519
  return false;
11508
11520
  }
11509
11521
  return true;
@@ -11780,239 +11792,177 @@ const getRollupPlugin$1 = (context, log) => {
11780
11792
  };
11781
11793
 
11782
11794
  const getWebpackPlugin$2 = (context, PLUGIN_NAME, log) => (compiler) => {
11783
- compiler.hooks.afterEmit.tap(PLUGIN_NAME, (compilation) => {
11784
- const inputs = [];
11785
- const outputs = [];
11786
- const entries = [];
11787
- context.build.errors = compilation.errors.map((err) => err.message) || [];
11788
- context.build.warnings = compilation.warnings.map((err) => err.message) || [];
11789
- const warn = (warning) => {
11790
- context.build.warnings.push(warning);
11791
- log(warning, "warn");
11792
- };
11793
- const stats = compilation.getStats().toJson({
11794
- all: false,
11795
- assets: true,
11796
- children: true,
11797
- chunks: true,
11798
- chunkGroupAuxiliary: true,
11799
- chunkGroupChildren: true,
11800
- chunkGroups: true,
11801
- chunkModules: true,
11802
- chunkRelations: true,
11803
- entrypoints: true,
11804
- errors: true,
11805
- ids: true,
11806
- modules: true,
11807
- nestedModules: true,
11808
- reasons: true,
11809
- relatedAssets: true,
11810
- warnings: true
11811
- });
11812
- const chunks = stats.chunks || [];
11813
- const assets = compilation.getAssets();
11814
- const modules = [];
11815
- const entrypoints = stats.entrypoints || [];
11816
- const tempSourcemaps = [];
11817
- const tempDeps = {};
11818
- const reportInputsIndexed = {};
11819
- const reportOutputsIndexed = {};
11820
- const modulePerId = /* @__PURE__ */ new Map();
11821
- const modulePerIdentifier = /* @__PURE__ */ new Map();
11822
- const concatModulesPerId = /* @__PURE__ */ new Map();
11823
- const concatModulesPerIdentifier = /* @__PURE__ */ new Map();
11824
- for (const module of stats.modules || []) {
11825
- if (module.modules) {
11826
- if (module.id) {
11827
- concatModulesPerId.set(module.id, module.modules);
11828
- }
11829
- if (module.identifier) {
11830
- concatModulesPerIdentifier.set(module.identifier, module.modules);
11831
- }
11832
- for (const subModule of module.modules) {
11833
- modules.push(subModule);
11834
- if (subModule.id) {
11835
- modulePerId.set(subModule.id, subModule);
11836
- }
11837
- if (subModule.identifier) {
11838
- modulePerIdentifier.set(subModule.identifier, subModule);
11795
+ const inputs = [];
11796
+ const outputs = [];
11797
+ const entries = [];
11798
+ const warnings = [];
11799
+ const reportInputsIndexed = /* @__PURE__ */ new Map();
11800
+ const reportOutputsIndexed = /* @__PURE__ */ new Map();
11801
+ const modulesPerFile = /* @__PURE__ */ new Map();
11802
+ const tempSourcemaps = [];
11803
+ const tempDeps = /* @__PURE__ */ new Map();
11804
+ const isModuleSupported = (moduleIdentifier) => {
11805
+ return (
11806
+ // Ignore unidentified modules and runtimes.
11807
+ !!moduleIdentifier && !moduleIdentifier.startsWith("webpack/runtime") && !moduleIdentifier.includes("/webpack4/buildin/")
11808
+ );
11809
+ };
11810
+ const warn = (warning) => {
11811
+ warnings.push(warning);
11812
+ log(warning, "warn");
11813
+ };
11814
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
11815
+ compilation.hooks.finishModules.tap(PLUGIN_NAME, (finishedModules) => {
11816
+ const getModuleFromDep = (dep) => {
11817
+ return compilation.moduleGraph ? compilation.moduleGraph.getModule(dep) : dep.module;
11818
+ };
11819
+ for (const module of finishedModules) {
11820
+ const moduleIdentifier = module.identifier();
11821
+ const dependencies = new Set(
11822
+ [...module.dependencies, ...module.blocks.flatMap((b) => b.dependencies)].filter(
11823
+ (dep) => (
11824
+ // Ignore side effects.
11825
+ dep.type !== "harmony side effect evaluation" && // Ignore those we can't identify.
11826
+ getModuleFromDep(dep)?.identifier() && // Only what we support.
11827
+ isModuleSupported(getModuleFromDep(dep)?.identifier()) && // Don't add itself as a dependency.
11828
+ getModuleFromDep(dep)?.identifier() !== moduleIdentifier
11829
+ )
11830
+ ).map((dep) => {
11831
+ return getModuleFromDep(dep)?.identifier();
11832
+ }).filter(Boolean)
11833
+ );
11834
+ for (const depIdentifier of dependencies) {
11835
+ const depDeps = tempDeps.get(depIdentifier) || {
11836
+ dependencies: /* @__PURE__ */ new Set(),
11837
+ dependents: /* @__PURE__ */ new Set()
11838
+ };
11839
+ depDeps.dependents.add(moduleIdentifier);
11840
+ tempDeps.set(depIdentifier, depDeps);
11841
+ }
11842
+ if (!isModuleSupported(moduleIdentifier)) {
11843
+ continue;
11844
+ }
11845
+ const moduleDeps = tempDeps.get(moduleIdentifier) || {
11846
+ dependents: /* @__PURE__ */ new Set(),
11847
+ dependencies: /* @__PURE__ */ new Set()
11848
+ };
11849
+ for (const moduleDep of dependencies) {
11850
+ moduleDeps.dependencies.add(moduleDep);
11851
+ }
11852
+ tempDeps.set(moduleIdentifier, moduleDeps);
11853
+ const file = {
11854
+ size: module.size() || 0,
11855
+ name: cleanName(context, moduleIdentifier),
11856
+ dependencies: /* @__PURE__ */ new Set(),
11857
+ dependents: /* @__PURE__ */ new Set(),
11858
+ filepath: moduleIdentifier,
11859
+ type: getType(moduleIdentifier)
11860
+ };
11861
+ inputs.push(file);
11862
+ reportInputsIndexed.set(moduleIdentifier, file);
11863
+ }
11864
+ for (const input of inputs) {
11865
+ const depsReport = tempDeps.get(input.filepath);
11866
+ if (!depsReport) {
11867
+ warn(`Could not find dependency report for ${input.name}`);
11868
+ continue;
11869
+ }
11870
+ for (const dependency of depsReport.dependencies) {
11871
+ const depInput = reportInputsIndexed.get(dependency);
11872
+ if (!depInput) {
11873
+ warn(`Could not find input of dependency ${dependency}`);
11874
+ continue;
11839
11875
  }
11876
+ input.dependencies.add(depInput);
11840
11877
  }
11841
- } else {
11842
- modules.push(module);
11843
- if (module.id) {
11844
- modulePerId.set(module.id, module);
11878
+ for (const dependent of depsReport.dependents) {
11879
+ const depInput = reportInputsIndexed.get(dependent);
11880
+ if (!depInput) {
11881
+ warn(`Could not find input of dependent ${dependent}`);
11882
+ continue;
11883
+ }
11884
+ input.dependents.add(depInput);
11845
11885
  }
11846
- if (module.identifier) {
11847
- modulePerIdentifier.set(module.identifier, module);
11886
+ }
11887
+ });
11888
+ });
11889
+ compiler.hooks.afterEmit.tap(PLUGIN_NAME, (result) => {
11890
+ const chunks = result.chunks;
11891
+ const assets = result.getAssets();
11892
+ const getChunkFiles = (chunk) => {
11893
+ return [...chunk.files || [], ...chunk.auxiliaryFiles || []].map(
11894
+ (f) => getAbsolutePath(context.bundler.outDir, f)
11895
+ );
11896
+ };
11897
+ for (const chunk of chunks) {
11898
+ const files = getChunkFiles(chunk);
11899
+ const chunkModules = chunk.getModules().flatMap((m) => {
11900
+ return "modules" in m && Array.isArray(m.modules) ? m.modules.map((m2) => m2.identifier()) : m.identifier();
11901
+ }).filter(isModuleSupported);
11902
+ for (const file of files) {
11903
+ if (getType(file) === "map") {
11904
+ continue;
11848
11905
  }
11906
+ const fileModules = modulesPerFile.get(file) || [];
11907
+ modulesPerFile.set(file, [...fileModules, ...chunkModules]);
11849
11908
  }
11850
11909
  }
11851
11910
  for (const asset of assets) {
11852
11911
  const file = {
11853
- size: asset.info.size || 0,
11912
+ size: asset.source.size() || 0,
11854
11913
  name: asset.name,
11855
11914
  inputs: [],
11856
11915
  filepath: getAbsolutePath(context.bundler.outDir, asset.name),
11857
11916
  type: getType(asset.name)
11858
11917
  };
11859
- reportOutputsIndexed[file.filepath] = file;
11918
+ reportOutputsIndexed.set(file.filepath, file);
11860
11919
  outputs.push(file);
11861
11920
  if (file.type === "map") {
11862
11921
  tempSourcemaps.push(file);
11863
- }
11864
- }
11865
- for (const sourcemap of tempSourcemaps) {
11866
- const outputFound = reportOutputsIndexed[sourcemap.filepath.replace(/\.map$/, "")];
11867
- if (!outputFound) {
11868
- warn(`Output not found for sourcemap ${sourcemap.name}`);
11869
- continue;
11870
- }
11871
- sourcemap.inputs.push(outputFound);
11872
- }
11873
- const getModulePath = (module) => {
11874
- return module.nameForCondition ? module.nameForCondition : module.name ? getAbsolutePath(context.cwd, module.name) : module.identifier ? module.identifier : "unknown";
11875
- };
11876
- const isModuleSupported = (module) => {
11877
- if (isInjection(getModulePath(module)) || // Do not report runtime modules as they are very specific to webpack.
11878
- module.moduleType === "runtime" || module.name?.startsWith("(webpack)") || // Also ignore orphan modules
11879
- module.type === "orphan modules") {
11880
- return false;
11881
- }
11882
- return true;
11883
- };
11884
- const getModules = (reason) => {
11885
- const { moduleIdentifier, moduleId } = reason;
11886
- if (!moduleIdentifier && !moduleId) {
11887
- return [];
11888
- }
11889
- const modulesFound = [];
11890
- if (moduleId) {
11891
- const module = modulePerId.get(moduleId);
11892
- if (module) {
11893
- modulesFound.push(module);
11894
- }
11895
- const concatModules = concatModulesPerId.get(moduleId);
11896
- if (concatModules) {
11897
- modulesFound.push(...concatModules);
11898
- }
11899
- }
11900
- if (moduleIdentifier) {
11901
- const module = modulePerIdentifier.get(moduleIdentifier);
11902
- if (module) {
11903
- modulesFound.push(module);
11904
- }
11905
- const concatModules = concatModulesPerIdentifier.get(moduleIdentifier);
11906
- if (concatModules) {
11907
- modulesFound.push(...concatModules);
11908
- }
11909
- }
11910
- return Array.from(new Set(modulesFound.map(getModulePath)));
11911
- };
11912
- const modulesDone = /* @__PURE__ */ new Set();
11913
- for (const module of modules) {
11914
- if (!isModuleSupported(module)) {
11915
11922
  continue;
11916
11923
  }
11917
- const modulePath = getModulePath(module);
11918
- if (modulesDone.has(modulePath)) {
11924
+ const fileModules = modulesPerFile.get(file.filepath);
11925
+ if (!fileModules) {
11926
+ warn(`Could not find modules for ${file.name}`);
11919
11927
  continue;
11920
11928
  }
11921
- modulesDone.add(modulePath);
11922
- if (modulePath === "unknown") {
11923
- warn(`Unknown module: ${JSON.stringify(module)}`);
11924
- }
11925
- if (module.reasons) {
11926
- const moduleDeps = tempDeps[modulePath] || {
11927
- dependencies: /* @__PURE__ */ new Set(),
11928
- dependents: /* @__PURE__ */ new Set()
11929
- };
11930
- const dependents = module.reasons.flatMap(getModules);
11931
- for (const dependent of dependents) {
11932
- const reasonDeps = tempDeps[dependent] || {
11933
- dependencies: /* @__PURE__ */ new Set(),
11934
- dependents: /* @__PURE__ */ new Set()
11935
- };
11936
- reasonDeps.dependencies.add(modulePath);
11937
- tempDeps[dependent] = reasonDeps;
11938
- moduleDeps.dependents.add(dependent);
11939
- }
11940
- tempDeps[modulePath] = moduleDeps;
11941
- }
11942
- const file = {
11943
- size: module.size || 0,
11944
- name: cleanName(context, modulePath),
11945
- dependencies: /* @__PURE__ */ new Set(),
11946
- dependents: /* @__PURE__ */ new Set(),
11947
- filepath: modulePath,
11948
- type: getType(modulePath)
11949
- };
11950
- for (const chunkId of module.chunks || []) {
11951
- const chunkFound = chunks.find((chunk) => chunk.id === chunkId);
11952
- if (!chunkFound) {
11929
+ for (const moduleIdentifier of fileModules) {
11930
+ const inputFound = reportInputsIndexed.get(moduleIdentifier);
11931
+ if (!inputFound) {
11932
+ warn(`Could not find input of ${moduleIdentifier}`);
11953
11933
  continue;
11954
11934
  }
11955
- const chunkFiles = chunkFound.files || [];
11956
- if (chunkFound.auxiliaryFiles) {
11957
- chunkFiles.push(...chunkFound.auxiliaryFiles);
11958
- }
11959
- const outputFound = outputs.find((output) => chunkFiles.includes(output.name));
11960
- if (!outputFound) {
11961
- warn(`Output not found for ${file.name}`);
11962
- continue;
11963
- }
11964
- if (!outputFound.inputs.includes(file)) {
11965
- outputFound.inputs.push(file);
11966
- }
11935
+ file.inputs.push(inputFound);
11967
11936
  }
11968
- reportInputsIndexed[modulePath] = file;
11969
- inputs.push(file);
11970
11937
  }
11971
- const getInput = (filepath) => {
11972
- const inputFound = reportInputsIndexed[filepath];
11973
- if (!inputFound) {
11974
- warn(`Could not find input of ${filepath}`);
11975
- }
11976
- return inputFound;
11977
- };
11978
- for (const input of inputs) {
11979
- const depsReport = tempDeps[input.filepath];
11980
- if (!depsReport) {
11981
- warn(`Could not find dependency report for ${input.name}`);
11938
+ for (const sourcemap of tempSourcemaps) {
11939
+ const outputFound = reportOutputsIndexed.get(
11940
+ sourcemap.filepath.replace(/\.map$/, "")
11941
+ );
11942
+ if (!outputFound) {
11943
+ warn(`Output not found for sourcemap ${sourcemap.name}`);
11982
11944
  continue;
11983
11945
  }
11984
- input.dependencies = cleanReport(depsReport.dependencies, input.filepath, getInput);
11985
- input.dependents = cleanReport(depsReport.dependents, input.filepath, getInput);
11946
+ sourcemap.inputs.push(outputFound);
11986
11947
  }
11987
- for (const [name, entry] of Object.entries(entrypoints)) {
11948
+ for (const [name, entrypoint] of result.entrypoints) {
11988
11949
  const entryOutputs = [];
11989
11950
  const entryInputs = [];
11990
11951
  let size = 0;
11991
- const entryAssets = entry.assets || [];
11992
- if (entry.auxiliaryAssets) {
11993
- entryAssets.push(...entry.auxiliaryAssets);
11994
- }
11995
- for (const asset of entryAssets) {
11996
- let assetPath;
11997
- if (typeof asset === "string") {
11998
- assetPath = getAbsolutePath(context.bundler.outDir, asset);
11999
- } else if (typeof asset.name === "string") {
12000
- assetPath = getAbsolutePath(context.bundler.outDir, asset.name);
12001
- }
12002
- if (!assetPath || !reportOutputsIndexed[assetPath]) {
12003
- warn(`Could not find output of ${JSON.stringify(asset)}`);
11952
+ const entryFiles = entrypoint.chunks.flatMap(getChunkFiles);
11953
+ const entryFilename = entrypoint.chunks.filter((c) => c.entryModule).flatMap((c) => Array.from(c.files))[0];
11954
+ for (const file2 of entryFiles) {
11955
+ const outputFound = reportOutputsIndexed.get(file2);
11956
+ if (!file2 || !outputFound) {
11957
+ warn(`Could not find output of ${JSON.stringify(file2)}`);
12004
11958
  continue;
12005
11959
  }
12006
- const outputFound = reportOutputsIndexed[assetPath];
12007
- if (outputFound) {
12008
- if (outputFound.type !== "map" && !entryOutputs.includes(outputFound)) {
12009
- entryOutputs.push(outputFound);
12010
- entryInputs.push(...outputFound.inputs);
12011
- size += outputFound.size;
12012
- }
11960
+ if (outputFound.type !== "map" && !entryOutputs.includes(outputFound)) {
11961
+ entryOutputs.push(outputFound);
11962
+ entryInputs.push(...outputFound.inputs);
11963
+ size += outputFound.size;
12013
11964
  }
12014
11965
  }
12015
- const entryFilename = stats.assetsByChunkName?.[name]?.[0];
12016
11966
  const file = {
12017
11967
  name,
12018
11968
  filepath: entryFilename ? getAbsolutePath(context.bundler.outDir, entryFilename) : "unknown",
@@ -12023,6 +11973,8 @@ const getWebpackPlugin$2 = (context, PLUGIN_NAME, log) => (compiler) => {
12023
11973
  };
12024
11974
  entries.push(file);
12025
11975
  }
11976
+ context.build.errors = result.errors.map((err) => err.message);
11977
+ context.build.warnings = [...warnings, ...result.warnings.map((err) => err.message)];
12026
11978
  context.build.inputs = inputs;
12027
11979
  context.build.outputs = outputs;
12028
11980
  context.build.entries = entries;
@@ -12069,7 +12021,7 @@ const getBundlerReportPlugin = (opts, globalContext) => {
12069
12021
  globalContext.bundler.outDir = build.initialOptions.outdir;
12070
12022
  }
12071
12023
  if (build.initialOptions.outfile) {
12072
- globalContext.bundler.outDir = require$$1.dirname(build.initialOptions.outfile);
12024
+ globalContext.bundler.outDir = path$i.dirname(build.initialOptions.outfile);
12073
12025
  }
12074
12026
  build.initialOptions.metafile = true;
12075
12027
  }
@@ -12990,7 +12942,7 @@ function requireNode$1 () {
12990
12942
  hasRequiredNode$1 = 1;
12991
12943
  (function (module, exports) {
12992
12944
  const tty = require$$0$1;
12993
- const util = require$$1$1;
12945
+ const util = require$$1;
12994
12946
 
12995
12947
  /**
12996
12948
  * This is the Node.js implementation of `debug()`.
@@ -13903,7 +13855,7 @@ function requireNode () {
13903
13855
  hasRequiredNode = 1;
13904
13856
  (function (module, exports) {
13905
13857
  const tty = require$$0$1;
13906
- const util = require$$1$1;
13858
+ const util = require$$1;
13907
13859
 
13908
13860
  /**
13909
13861
  * This is the Node.js implementation of `debug()`.
@@ -19049,7 +19001,7 @@ const processInjections = async (toInject, log) => {
19049
19001
  return results.filter(Boolean);
19050
19002
  };
19051
19003
 
19052
- const getInjectionPlugins = (opts, context, toInject) => {
19004
+ const getInjectionPlugins = (bundler, opts, context, toInject) => {
19053
19005
  const log = getLogger(opts.logLevel, PLUGIN_NAME$4);
19054
19006
  const contentToInject = [];
19055
19007
  const getContentToInject = () => {
@@ -19071,27 +19023,7 @@ ${after}`;
19071
19023
  return "";
19072
19024
  }
19073
19025
  };
19074
- return [
19075
- // Resolve the injected file for all bundlers.
19076
- {
19077
- name: RESOLUTION_PLUGIN_NAME,
19078
- enforce: "pre",
19079
- async resolveId(id) {
19080
- if (isInjection(id)) {
19081
- return { id, moduleSideEffects: true };
19082
- }
19083
- },
19084
- loadInclude(id) {
19085
- if (isInjection(id)) {
19086
- return true;
19087
- }
19088
- },
19089
- load(id) {
19090
- if (isInjection(id)) {
19091
- return getContentToInject();
19092
- }
19093
- }
19094
- },
19026
+ const plugins = [
19095
19027
  // Prepare and fetch the content to inject for all bundlers.
19096
19028
  {
19097
19029
  name: PREPARATION_PLUGIN_NAME,
@@ -19100,103 +19032,79 @@ ${after}`;
19100
19032
  async buildStart() {
19101
19033
  const results = await processInjections(toInject, log);
19102
19034
  contentToInject.push(...results);
19035
+ if (context.bundler.name !== "esbuild") {
19036
+ return;
19037
+ }
19038
+ const absolutePathInjectFile = path$i.resolve(
19039
+ context.bundler.outDir,
19040
+ INJECTED_FILE_PATH
19041
+ );
19042
+ try {
19043
+ await fs$j.promises.mkdir(path$i.dirname(absolutePathInjectFile), {
19044
+ recursive: true
19045
+ });
19046
+ await fs$j.promises.writeFile(absolutePathInjectFile, getContentToInject());
19047
+ } catch (e) {
19048
+ log(`Could not create the file: ${e.message}`, "error");
19049
+ }
19050
+ },
19051
+ async buildEnd() {
19052
+ if (context.bundler.name !== "esbuild") {
19053
+ return;
19054
+ }
19055
+ const absolutePathInjectFile = path$i.resolve(
19056
+ context.bundler.outDir,
19057
+ INJECTED_FILE_PATH
19058
+ );
19059
+ await fs$j.promises.rm(absolutePathInjectFile, {
19060
+ force: true,
19061
+ maxRetries: 3,
19062
+ recursive: true
19063
+ });
19103
19064
  }
19104
19065
  },
19105
- // Inject the virtual file that will be home of all injected content.
19066
+ // Inject the file that will be home of all injected content.
19106
19067
  // Each bundler has its own way to inject a file.
19107
19068
  {
19108
19069
  name: PLUGIN_NAME$4,
19109
19070
  esbuild: {
19110
19071
  setup(build) {
19111
19072
  const { initialOptions } = build;
19112
- build.onResolve({ filter: /.*/ }, async (args) => {
19113
- if (args.kind !== "entry-point") {
19114
- return null;
19115
- }
19116
- if (initialOptions.inject?.includes(args.path)) {
19117
- return null;
19118
- }
19119
- return {
19120
- pluginName: PLUGIN_NAME$4,
19121
- path: require$$1.isAbsolute(args.path) ? args.path : require$$1.join(args.resolveDir, args.path),
19122
- pluginData: {
19123
- isInjectionResolver: true,
19124
- originalPath: args.path,
19125
- originalResolveDir: args.resolveDir
19126
- },
19127
- // Adding a suffix prevents esbuild from marking the entrypoint as resolved,
19128
- // avoiding a dependency loop with the proxy module.
19129
- // This ensures esbuild continues to traverse the module tree
19130
- // and re-resolves the entrypoint when imported from the proxy module.
19131
- suffix: "?datadogInjected=true"
19132
- };
19133
- });
19134
- build.onLoad({ filter: /.*/ }, async (args) => {
19135
- if (!args.pluginData?.isInjectionResolver) {
19136
- return null;
19137
- }
19138
- const originalPath = args.pluginData.originalPath;
19139
- const originalResolveDir = args.pluginData.originalResolveDir;
19140
- const contents = `
19141
- import ${JSON.stringify(INJECTED_FILE)};
19142
- import * as OriginalModule from ${JSON.stringify(originalPath)};
19143
- export default OriginalModule['default'.toString()];
19144
- export * from ${JSON.stringify(originalPath)};
19145
- `;
19146
- return {
19147
- loader: "js",
19148
- pluginName: PLUGIN_NAME$4,
19149
- contents,
19150
- resolveDir: originalResolveDir
19151
- };
19152
- });
19073
+ const absolutePathInjectFile = path$i.resolve(
19074
+ context.bundler.outDir,
19075
+ INJECTED_FILE_PATH
19076
+ );
19077
+ initialOptions.inject = initialOptions.inject || [];
19078
+ initialOptions.inject.push(absolutePathInjectFile);
19153
19079
  }
19154
19080
  },
19155
19081
  webpack: (compiler) => {
19156
- const injectEntry = (originalEntry) => {
19157
- if (!originalEntry) {
19158
- return [INJECTED_FILE];
19159
- }
19160
- if (Array.isArray(originalEntry)) {
19161
- return [INJECTED_FILE, ...originalEntry];
19162
- }
19163
- if (typeof originalEntry === "function") {
19164
- return async () => {
19165
- const originEntry = await originalEntry();
19166
- return [INJECTED_FILE, originEntry];
19167
- };
19168
- }
19169
- if (typeof originalEntry === "string") {
19170
- return [INJECTED_FILE, originalEntry];
19171
- }
19172
- if (typeof originalEntry === "object") {
19173
- const newEntry = {};
19174
- if (Object.keys(originalEntry).length === 0) {
19175
- newEntry[INJECTED_FILE] = // Webpack 4 and 5 have different entry formats.
19176
- context.bundler.variant === "5" ? { import: [INJECTED_FILE] } : INJECTED_FILE;
19177
- return newEntry;
19178
- }
19179
- for (const entryName in originalEntry) {
19180
- if (!Object.hasOwn(originalEntry, entryName)) {
19181
- continue;
19082
+ const BannerPlugin = compiler?.webpack?.BannerPlugin || bundler?.BannerPlugin || bundler?.default?.BannerPlugin;
19083
+ if (!BannerPlugin) {
19084
+ log("Missing BannerPlugin", "error");
19085
+ }
19086
+ compiler.options.plugins = compiler.options.plugins || [];
19087
+ compiler.options.plugins.push(
19088
+ new BannerPlugin({
19089
+ // Not wrapped in comments.
19090
+ raw: true,
19091
+ // Not sure this is actually working, but it's supposed to only add
19092
+ // the banner to entry modules.
19093
+ entryOnly: true,
19094
+ banner({ chunk }) {
19095
+ if (!chunk?.entryModule) {
19096
+ return "";
19182
19097
  }
19183
- const entry = originalEntry[entryName];
19184
- newEntry[entryName] = // Webpack 4 and 5 have different entry formats.
19185
- typeof entry === "string" ? [INJECTED_FILE, entry] : {
19186
- ...entry,
19187
- import: [INJECTED_FILE, ...entry.import]
19188
- };
19098
+ return getContentToInject();
19189
19099
  }
19190
- return newEntry;
19191
- }
19192
- return [INJECTED_FILE, originalEntry];
19193
- };
19194
- compiler.options.entry = injectEntry(compiler.options.entry);
19100
+ })
19101
+ );
19195
19102
  },
19196
19103
  rollup: rollupInjectionPlugin,
19197
19104
  vite: rollupInjectionPlugin
19198
19105
  }
19199
19106
  ];
19107
+ return plugins;
19200
19108
  };
19201
19109
 
19202
19110
  const getInternalPlugins = (options, meta) => {
@@ -19210,7 +19118,8 @@ const getInternalPlugins = (options, meta) => {
19210
19118
  name: meta.framework,
19211
19119
  fullName: `${meta.framework}${variant}`,
19212
19120
  variant,
19213
- outDir: cwd
19121
+ outDir: cwd,
19122
+ version: meta.bundler.version || meta.bundler.VERSION
19214
19123
  },
19215
19124
  build: {
19216
19125
  errors: [],
@@ -19226,7 +19135,7 @@ const getInternalPlugins = (options, meta) => {
19226
19135
  const bundlerReportPlugin = getBundlerReportPlugin(options, globalContext);
19227
19136
  const buildReportPlugin = getBuildReportPlugin(options, globalContext);
19228
19137
  const gitPlugin = getGitPlugin(options, globalContext);
19229
- const injectionPlugins = getInjectionPlugins(options, globalContext, toInject);
19138
+ const injectionPlugins = getInjectionPlugins(meta.bundler, options, globalContext, toInject);
19230
19139
  return {
19231
19140
  globalContext,
19232
19141
  internalPlugins: [bundlerReportPlugin, buildReportPlugin, gitPlugin, ...injectionPlugins]
@@ -19400,12 +19309,12 @@ if (typeof module !== "undefined") {
19400
19309
  }
19401
19310
 
19402
19311
  const decomposePath = (options, context, sourcemapFilePath) => {
19403
- if (require$$1.extname(sourcemapFilePath) !== ".map") {
19312
+ if (path$i.extname(sourcemapFilePath) !== ".map") {
19404
19313
  throw new Error(`The file ${chalk.green.bold(sourcemapFilePath)} is not a sourcemap.`);
19405
19314
  }
19406
19315
  const minifiedFilePath = sourcemapFilePath.replace(/\.map$/, "");
19407
19316
  const relativePath = minifiedFilePath.replace(context.bundler.outDir, "");
19408
- const minifiedUrl = options.minifiedPathPrefix ? require$$1.join(options.minifiedPathPrefix, relativePath) : relativePath;
19317
+ const minifiedUrl = options.minifiedPathPrefix ? path$i.join(options.minifiedPathPrefix, relativePath) : relativePath;
19409
19318
  return {
19410
19319
  minifiedFilePath,
19411
19320
  minifiedUrl,
@@ -20278,7 +20187,7 @@ const getPayload = async (sourcemap, metadata, prefix, git) => {
20278
20187
  sourcemap.sourcemapFilePath,
20279
20188
  (reason) => {
20280
20189
  warnings.push(
20281
- `${require$$1.basename(sourcemap.sourcemapFilePath)}: "${reason}"`
20190
+ `${path$i.basename(sourcemap.sourcemapFilePath)}: "${reason}"`
20282
20191
  );
20283
20192
  }
20284
20193
  ),
@@ -21099,7 +21008,7 @@ var polyfills = polyfills$1;
21099
21008
  var legacy = legacyStreams;
21100
21009
  var clone = clone_1;
21101
21010
 
21102
- var util = require$$1$1;
21011
+ var util = require$$1;
21103
21012
 
21104
21013
  /* istanbul ignore next - node 0.x polyfill */
21105
21014
  var gracefulQueue;
@@ -21649,7 +21558,7 @@ function retry () {
21649
21558
  };
21650
21559
  } (fs$i));
21651
21560
 
21652
- const path$g = require$$1;
21561
+ const path$g = path$i;
21653
21562
 
21654
21563
  // get drive on windows
21655
21564
  function getRootPath (p) {
@@ -21674,7 +21583,7 @@ var win32 = {
21674
21583
  };
21675
21584
 
21676
21585
  const fs$g = gracefulFs;
21677
- const path$f = require$$1;
21586
+ const path$f = path$i;
21678
21587
  const invalidWin32Path$1 = win32.invalidWin32Path;
21679
21588
 
21680
21589
  const o777$1 = parseInt('0777', 8);
@@ -21736,7 +21645,7 @@ function mkdirs$2 (p, opts, callback, made) {
21736
21645
  var mkdirs_1$1 = mkdirs$2;
21737
21646
 
21738
21647
  const fs$f = gracefulFs;
21739
- const path$e = require$$1;
21648
+ const path$e = path$i;
21740
21649
  const invalidWin32Path = win32.invalidWin32Path;
21741
21650
 
21742
21651
  const o777 = parseInt('0777', 8);
@@ -21804,7 +21713,7 @@ var mkdirs_1 = {
21804
21713
 
21805
21714
  const fs$e = gracefulFs;
21806
21715
  const os = require$$0;
21807
- const path$d = require$$1;
21716
+ const path$d = path$i;
21808
21717
 
21809
21718
  // HFS, ext{2,3}, FAT do not, Node.js v0.10 does not
21810
21719
  function hasMillisResSync () {
@@ -21893,7 +21802,7 @@ var buffer$1 = function (size) {
21893
21802
  };
21894
21803
 
21895
21804
  const fs$d = gracefulFs;
21896
- const path$c = require$$1;
21805
+ const path$c = path$i;
21897
21806
  const mkdirpSync$1 = mkdirs_1.mkdirsSync;
21898
21807
  const utimesSync = utimes$1.utimesMillisSync;
21899
21808
 
@@ -22101,7 +22010,7 @@ var pathExists_1 = {
22101
22010
  };
22102
22011
 
22103
22012
  const fs$b = gracefulFs;
22104
- const path$b = require$$1;
22013
+ const path$b = path$i;
22105
22014
  const mkdirp$1 = mkdirs_1.mkdirs;
22106
22015
  const pathExists$7 = pathExists_1.pathExists;
22107
22016
  const utimes = utimes$1.utimesMillis;
@@ -22351,7 +22260,7 @@ var copy$1 = {
22351
22260
  };
22352
22261
 
22353
22262
  const fs$a = gracefulFs;
22354
- const path$a = require$$1;
22263
+ const path$a = path$i;
22355
22264
  const assert = require$$5;
22356
22265
 
22357
22266
  const isWindows = (process.platform === 'win32');
@@ -22673,7 +22582,7 @@ var remove$3 = {
22673
22582
 
22674
22583
  const u$7 = universalify.fromCallback;
22675
22584
  const fs$9 = fs$j;
22676
- const path$9 = require$$1;
22585
+ const path$9 = path$i;
22677
22586
  const mkdir$5 = mkdirs_1;
22678
22587
  const remove$2 = remove$3;
22679
22588
 
@@ -22719,7 +22628,7 @@ var empty$2 = {
22719
22628
  };
22720
22629
 
22721
22630
  const u$6 = universalify.fromCallback;
22722
- const path$8 = require$$1;
22631
+ const path$8 = path$i;
22723
22632
  const fs$8 = gracefulFs;
22724
22633
  const mkdir$4 = mkdirs_1;
22725
22634
  const pathExists$6 = pathExists_1.pathExists;
@@ -22767,7 +22676,7 @@ var file$1 = {
22767
22676
  };
22768
22677
 
22769
22678
  const u$5 = universalify.fromCallback;
22770
- const path$7 = require$$1;
22679
+ const path$7 = path$i;
22771
22680
  const fs$7 = gracefulFs;
22772
22681
  const mkdir$3 = mkdirs_1;
22773
22682
  const pathExists$5 = pathExists_1.pathExists;
@@ -22826,7 +22735,7 @@ var link$1 = {
22826
22735
  createLinkSync
22827
22736
  };
22828
22737
 
22829
- const path$6 = require$$1;
22738
+ const path$6 = path$i;
22830
22739
  const fs$6 = gracefulFs;
22831
22740
  const pathExists$4 = pathExists_1.pathExists;
22832
22741
 
@@ -22955,7 +22864,7 @@ var symlinkType_1 = {
22955
22864
  };
22956
22865
 
22957
22866
  const u$4 = universalify.fromCallback;
22958
- const path$5 = require$$1;
22867
+ const path$5 = path$i;
22959
22868
  const fs$4 = gracefulFs;
22960
22869
  const _mkdirs = mkdirs_1;
22961
22870
  const mkdirs = _mkdirs.mkdirs;
@@ -23184,7 +23093,7 @@ var jsonfile = {
23184
23093
  writeJsonSync: jsonFile$3.writeFileSync
23185
23094
  };
23186
23095
 
23187
- const path$4 = require$$1;
23096
+ const path$4 = path$i;
23188
23097
  const mkdir$2 = mkdirs_1;
23189
23098
  const pathExists$2 = pathExists_1.pathExists;
23190
23099
  const jsonFile$2 = jsonfile;
@@ -23211,7 +23120,7 @@ function outputJson (file, data, options, callback) {
23211
23120
  var outputJson_1 = outputJson;
23212
23121
 
23213
23122
  const fs$3 = gracefulFs;
23214
- const path$3 = require$$1;
23123
+ const path$3 = path$i;
23215
23124
  const mkdir$1 = mkdirs_1;
23216
23125
  const jsonFile$1 = jsonfile;
23217
23126
 
@@ -23243,7 +23152,7 @@ jsonFile.readJSONSync = jsonFile.readJsonSync;
23243
23152
  var json = jsonFile;
23244
23153
 
23245
23154
  const fs$2 = gracefulFs;
23246
- const path$2 = require$$1;
23155
+ const path$2 = path$i;
23247
23156
  const copySync = copySync$1.copySync;
23248
23157
  const removeSync = remove$3.removeSync;
23249
23158
  const mkdirpSync = mkdirs_1.mkdirsSync;
@@ -23360,7 +23269,7 @@ var moveSync_1 = {
23360
23269
 
23361
23270
  const u$1 = universalify.fromCallback;
23362
23271
  const fs$1 = gracefulFs;
23363
- const path$1 = require$$1;
23272
+ const path$1 = path$i;
23364
23273
  const copy = copy$1.copy;
23365
23274
  const remove$1 = remove$3.remove;
23366
23275
  const mkdirp = mkdirs_1.mkdirp;
@@ -23441,7 +23350,7 @@ var move_1 = {
23441
23350
 
23442
23351
  const u = universalify.fromCallback;
23443
23352
  const fs = gracefulFs;
23444
- const path = require$$1;
23353
+ const path = path$i;
23445
23354
  const mkdir = mkdirs_1;
23446
23355
  const pathExists = pathExists_1.pathExists;
23447
23356
 
@@ -23911,7 +23820,7 @@ const outputFiles = async (data, outputOptions, log, cwd) => {
23911
23820
  } else if (typeof outputOptions === "string") {
23912
23821
  destination = outputOptions;
23913
23822
  }
23914
- const outputPath = require$$1.resolve(cwd, destination);
23823
+ const outputPath = path$i.resolve(cwd, destination);
23915
23824
  try {
23916
23825
  const errors = {};
23917
23826
  const filesToWrite = {};
@@ -23930,7 +23839,7 @@ const outputFiles = async (data, outputOptions, log, cwd) => {
23930
23839
  const proms = Object.keys(filesToWrite).map((file) => {
23931
23840
  const start = Date.now();
23932
23841
  log(`Start writing ${file}.json.`);
23933
- return writeFile(require$$1.join(outputPath, `${file}.json`), filesToWrite[file].content).then(() => {
23842
+ return writeFile(path$i.join(outputPath, `${file}.json`), filesToWrite[file].content).then(() => {
23934
23843
  log(`Wrote ${file}.json in ${formatDuration(Date.now() - start)}`);
23935
23844
  }).catch((e) => {
23936
23845
  log(
@@ -34302,7 +34211,7 @@ virtualStats.VirtualStats = VirtualStats;
34302
34211
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
34303
34212
  return (mod && mod.__esModule) ? mod : { "default": mod };
34304
34213
  };
34305
- const path_1 = __importDefault(require$$1);
34214
+ const path_1 = __importDefault(path$i);
34306
34215
  const virtual_stats_1 = virtualStats;
34307
34216
  let inode = 45000000;
34308
34217
  const ALL = 'all';
@@ -34586,7 +34495,7 @@ var VirtualModulesPlugin$1 = /*@__PURE__*/getDefaultExportFromCjs(lib);
34586
34495
 
34587
34496
  // node_modules/.pnpm/tsup@8.0.2_typescript@5.4.5/node_modules/tsup/assets/esm_shims.js
34588
34497
  var getFilename = () => fileURLToPath$1(import.meta.url);
34589
- var getDirname = () => require$$1.dirname(getFilename());
34498
+ var getDirname = () => path$i.dirname(getFilename());
34590
34499
  var __dirname = /* @__PURE__ */ getDirname();
34591
34500
 
34592
34501
  // node_modules/.pnpm/@jridgewell+sourcemap-codec@1.4.15/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
@@ -35387,7 +35296,7 @@ var ExtToLoader = {
35387
35296
  ".txt": "text"
35388
35297
  };
35389
35298
  function guessLoader(code, id) {
35390
- return ExtToLoader[require$$1.extname(id).toLowerCase()] || "js";
35299
+ return ExtToLoader[path$i.extname(id).toLowerCase()] || "js";
35391
35300
  }
35392
35301
  function unwrapLoader(loader, code, id) {
35393
35302
  if (typeof loader === "function")
@@ -35461,8 +35370,8 @@ function createBuildContext(initialOptions) {
35461
35370
  emitFile(emittedFile) {
35462
35371
  const outFileName = emittedFile.fileName || emittedFile.name;
35463
35372
  if (initialOptions.outdir && emittedFile.source && outFileName) {
35464
- const outPath = require$$1.resolve(initialOptions.outdir, outFileName);
35465
- const outDir = require$$1.dirname(outPath);
35373
+ const outPath = path$i.resolve(initialOptions.outdir, outFileName);
35374
+ const outDir = path$i.dirname(outPath);
35466
35375
  if (!fs$j.existsSync(outDir))
35467
35376
  fs$j.mkdirSync(outDir, { recursive: true });
35468
35377
  fs$j.writeFileSync(outPath, emittedFile.source);
@@ -35663,7 +35572,7 @@ function buildSetup(meta) {
35663
35572
  onLoad({ filter: onLoadFilter }, async (args) => {
35664
35573
  const id = args.path + args.suffix;
35665
35574
  const { errors, warnings, mixedContext } = createPluginContext(context);
35666
- const resolveDir = require$$1.dirname(args.path);
35575
+ const resolveDir = path$i.dirname(args.path);
35667
35576
  let code, map;
35668
35577
  if (plugin.load && (!plugin.loadInclude || plugin.loadInclude(id))) {
35669
35578
  const result = await plugin.load.call(mixedContext, id);
@@ -35694,7 +35603,7 @@ function buildSetup(meta) {
35694
35603
  if (plugin.transformInclude && !plugin.transformInclude(id))
35695
35604
  return;
35696
35605
  const { mixedContext, errors, warnings } = createPluginContext(context);
35697
- const resolveDir = require$$1.dirname(args.path);
35606
+ const resolveDir = path$i.dirname(args.path);
35698
35607
  let code = await args.getContents();
35699
35608
  let map;
35700
35609
  const result = await plugin.transform.call(mixedContext, code, id);
@@ -35786,7 +35695,7 @@ var ExtToLoader2 = {
35786
35695
  ".node": "napi"
35787
35696
  };
35788
35697
  function guessIdLoader(id) {
35789
- return ExtToLoader2[require$$1.extname(id).toLowerCase()] || "js";
35698
+ return ExtToLoader2[path$i.extname(id).toLowerCase()] || "js";
35790
35699
  }
35791
35700
  function transformQuery(context) {
35792
35701
  const queryParamsObject = {};
@@ -35876,7 +35785,7 @@ function toFarmPlugin(plugin, options) {
35876
35785
  farmPlugin.resolve = {
35877
35786
  filters: { sources: [".*", ...filters], importers: [".*"] },
35878
35787
  async executor(params, context) {
35879
- const resolvedIdPath = require$$1.resolve(
35788
+ const resolvedIdPath = path$i.resolve(
35880
35789
  process.cwd(),
35881
35790
  params.importer ?? ""
35882
35791
  );
@@ -36458,6 +36367,7 @@ const validateOptions = (options = {}) => {
36458
36367
  };
36459
36368
  const HOST_NAME = "datadog-build-plugins";
36460
36369
  const buildPluginFactory = ({
36370
+ bundler,
36461
36371
  version
36462
36372
  }) => {
36463
36373
  return createUnplugin((opts, unpluginMetaContext) => {
@@ -36466,6 +36376,7 @@ const buildPluginFactory = ({
36466
36376
  unpluginMetaContext.esbuildHostName = HOST_NAME;
36467
36377
  }
36468
36378
  const { globalContext, internalPlugins } = getInternalPlugins(options, {
36379
+ bundler,
36469
36380
  version,
36470
36381
  ...unpluginMetaContext
36471
36382
  });
@@ -36488,7 +36399,7 @@ const buildPluginFactory = ({
36488
36399
 
36489
36400
  var name = "@datadog/esbuild-plugin";
36490
36401
  var packageManager = "yarn@4.0.2";
36491
- var version$1 = "2.3.1-dev-9";
36402
+ var version$1 = "2.3.1-dev-10";
36492
36403
  var license = "MIT";
36493
36404
  var author = "Datadog";
36494
36405
  var description = "Datadog ESBuild Plugin";
@@ -36576,6 +36487,7 @@ var pkg = {
36576
36487
  };
36577
36488
 
36578
36489
  const datadogEsbuildPlugin = buildPluginFactory({
36490
+ bundler: esbuild,
36579
36491
  version: pkg.version
36580
36492
  }).esbuild;
36581
36493
  const version = pkg.version;