@datadog/esbuild-plugin 2.3.1-dev-8 → 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,15 +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 isInternalPlugin = (pluginName, context) => {
2358
- for (const internalPluginName of context.pluginNames) {
2359
- if (pluginName.includes(internalPluginName)) {
2360
- return true;
2361
- }
2362
- }
2363
- return false;
2364
- };
2357
+ const isInjectionFile = (filename) => filename.includes(INJECTED_FILE);
2365
2358
 
2366
2359
  var balancedMatch = balanced$1;
2367
2360
  function balanced$1(a, b, str) {
@@ -11317,18 +11310,13 @@ const cleanReport = (report, filepath, filter) => {
11317
11310
  const cleanedPath = cleanPath(reportFilepath);
11318
11311
  if (
11319
11312
  // Don't add injections.
11320
- isInjection(reportFilepath) || // Don't add itself into it.
11313
+ isInjectionFile(reportFilepath) || // Don't add itself into it.
11321
11314
  cleanedPath === filepath || // Remove common specific files injected by bundlers.
11322
11315
  BUNDLER_SPECIFICS.includes(cleanedPath)
11323
11316
  ) {
11324
11317
  continue;
11325
11318
  }
11326
- if (filter) {
11327
- const filteredValue = filter(cleanedPath);
11328
- if (filteredValue) {
11329
- cleanedReport.add(filteredValue);
11330
- }
11331
- } else {
11319
+ {
11332
11320
  cleanedReport.add(cleanedPath);
11333
11321
  }
11334
11322
  }
@@ -11338,16 +11326,16 @@ const cleanPath = (filepath) => {
11338
11326
  return filepath.split("!").pop().split(QUERY_RX).shift().replace(/^[^\w\s.,!@#$%^&*()=+~`\-/]+/, "");
11339
11327
  };
11340
11328
  const getAbsolutePath = (cwd, filepath) => {
11341
- if (isInjection(filepath)) {
11329
+ if (isInjectionFile(filepath)) {
11342
11330
  return INJECTED_FILE;
11343
11331
  }
11344
11332
  if (filepath.startsWith(cwd)) {
11345
11333
  return filepath;
11346
11334
  }
11347
- return require$$1.resolve(cwd, filepath);
11335
+ return path$i.resolve(cwd, filepath);
11348
11336
  };
11349
11337
  const cleanName = (context, filepath) => {
11350
- if (isInjection(filepath)) {
11338
+ if (isInjectionFile(filepath)) {
11351
11339
  return INJECTED_FILE;
11352
11340
  }
11353
11341
  if (filepath === "unknown") {
@@ -11421,8 +11409,24 @@ const getEsbuildPlugin$2 = (context, log) => {
11421
11409
  const reportOutputsIndexed = {};
11422
11410
  const metaInputsIndexed = reIndexMeta(result.metafile.inputs, cwd);
11423
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
+ };
11424
11428
  for (const [filename, input] of Object.entries(result.metafile.inputs)) {
11425
- if (isInjection(filename)) {
11429
+ if (isInjectionFile(filename)) {
11426
11430
  continue;
11427
11431
  }
11428
11432
  const filepath = getAbsolutePath(cwd, filename);
@@ -11443,7 +11447,7 @@ const getEsbuildPlugin$2 = (context, log) => {
11443
11447
  const cleanedName = cleanName(context, fullPath);
11444
11448
  const inputFiles = [];
11445
11449
  for (const inputName of Object.keys(output.inputs)) {
11446
- if (isInjection(inputName)) {
11450
+ if (isInjectionFile(inputName)) {
11447
11451
  continue;
11448
11452
  }
11449
11453
  const inputFound = reportInputsIndexed[getAbsolutePath(cwd, inputName)];
@@ -11476,7 +11480,7 @@ const getEsbuildPlugin$2 = (context, log) => {
11476
11480
  if (!output.entryPoint) {
11477
11481
  continue;
11478
11482
  }
11479
- const inputFile = reportInputsIndexed[getAbsolutePath(cwd, output.entryPoint)];
11483
+ const inputFile = reportInputsIndexed[getAbsolutePath(cwd, getRealPathFromInjectionProxy(output.entryPoint))];
11480
11484
  if (inputFile) {
11481
11485
  if (!entryNames.get(inputFile.name)) {
11482
11486
  continue;
@@ -11511,7 +11515,7 @@ const getEsbuildPlugin$2 = (context, log) => {
11511
11515
  };
11512
11516
  const FILE_EXCEPTIONS_RX = /(<runtime>|https:|file:|data:|#)/g;
11513
11517
  const isFileSupported = (filePath) => {
11514
- if (isInjection(filePath) || filePath.match(FILE_EXCEPTIONS_RX)) {
11518
+ if (isInjectionFile(filePath) || filePath.match(FILE_EXCEPTIONS_RX)) {
11515
11519
  return false;
11516
11520
  }
11517
11521
  return true;
@@ -11788,239 +11792,177 @@ const getRollupPlugin$1 = (context, log) => {
11788
11792
  };
11789
11793
 
11790
11794
  const getWebpackPlugin$2 = (context, PLUGIN_NAME, log) => (compiler) => {
11791
- compiler.hooks.afterEmit.tap(PLUGIN_NAME, (compilation) => {
11792
- const inputs = [];
11793
- const outputs = [];
11794
- const entries = [];
11795
- context.build.errors = compilation.errors.map((err) => err.message) || [];
11796
- context.build.warnings = compilation.warnings.map((err) => err.message) || [];
11797
- const warn = (warning) => {
11798
- context.build.warnings.push(warning);
11799
- log(warning, "warn");
11800
- };
11801
- const stats = compilation.getStats().toJson({
11802
- all: false,
11803
- assets: true,
11804
- children: true,
11805
- chunks: true,
11806
- chunkGroupAuxiliary: true,
11807
- chunkGroupChildren: true,
11808
- chunkGroups: true,
11809
- chunkModules: true,
11810
- chunkRelations: true,
11811
- entrypoints: true,
11812
- errors: true,
11813
- ids: true,
11814
- modules: true,
11815
- nestedModules: true,
11816
- reasons: true,
11817
- relatedAssets: true,
11818
- warnings: true
11819
- });
11820
- const chunks = stats.chunks || [];
11821
- const assets = compilation.getAssets();
11822
- const modules = [];
11823
- const entrypoints = stats.entrypoints || [];
11824
- const tempSourcemaps = [];
11825
- const tempDeps = {};
11826
- const reportInputsIndexed = {};
11827
- const reportOutputsIndexed = {};
11828
- const modulePerId = /* @__PURE__ */ new Map();
11829
- const modulePerIdentifier = /* @__PURE__ */ new Map();
11830
- const concatModulesPerId = /* @__PURE__ */ new Map();
11831
- const concatModulesPerIdentifier = /* @__PURE__ */ new Map();
11832
- for (const module of stats.modules || []) {
11833
- if (module.modules) {
11834
- if (module.id) {
11835
- concatModulesPerId.set(module.id, module.modules);
11836
- }
11837
- if (module.identifier) {
11838
- concatModulesPerIdentifier.set(module.identifier, module.modules);
11839
- }
11840
- for (const subModule of module.modules) {
11841
- modules.push(subModule);
11842
- if (subModule.id) {
11843
- modulePerId.set(subModule.id, subModule);
11844
- }
11845
- if (subModule.identifier) {
11846
- 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;
11847
11875
  }
11876
+ input.dependencies.add(depInput);
11848
11877
  }
11849
- } else {
11850
- modules.push(module);
11851
- if (module.id) {
11852
- 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);
11853
11885
  }
11854
- if (module.identifier) {
11855
- 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;
11856
11905
  }
11906
+ const fileModules = modulesPerFile.get(file) || [];
11907
+ modulesPerFile.set(file, [...fileModules, ...chunkModules]);
11857
11908
  }
11858
11909
  }
11859
11910
  for (const asset of assets) {
11860
11911
  const file = {
11861
- size: asset.info.size || 0,
11912
+ size: asset.source.size() || 0,
11862
11913
  name: asset.name,
11863
11914
  inputs: [],
11864
11915
  filepath: getAbsolutePath(context.bundler.outDir, asset.name),
11865
11916
  type: getType(asset.name)
11866
11917
  };
11867
- reportOutputsIndexed[file.filepath] = file;
11918
+ reportOutputsIndexed.set(file.filepath, file);
11868
11919
  outputs.push(file);
11869
11920
  if (file.type === "map") {
11870
11921
  tempSourcemaps.push(file);
11871
- }
11872
- }
11873
- for (const sourcemap of tempSourcemaps) {
11874
- const outputFound = reportOutputsIndexed[sourcemap.filepath.replace(/\.map$/, "")];
11875
- if (!outputFound) {
11876
- warn(`Output not found for sourcemap ${sourcemap.name}`);
11877
11922
  continue;
11878
11923
  }
11879
- sourcemap.inputs.push(outputFound);
11880
- }
11881
- const getModulePath = (module) => {
11882
- return module.nameForCondition ? module.nameForCondition : module.name ? getAbsolutePath(context.cwd, module.name) : module.identifier ? module.identifier : "unknown";
11883
- };
11884
- const isModuleSupported = (module) => {
11885
- if (isInjection(getModulePath(module)) || // Do not report runtime modules as they are very specific to webpack.
11886
- module.moduleType === "runtime" || module.name?.startsWith("(webpack)") || // Also ignore orphan modules
11887
- module.type === "orphan modules") {
11888
- return false;
11889
- }
11890
- return true;
11891
- };
11892
- const getModules = (reason) => {
11893
- const { moduleIdentifier, moduleId } = reason;
11894
- if (!moduleIdentifier && !moduleId) {
11895
- return [];
11896
- }
11897
- const modulesFound = [];
11898
- if (moduleId) {
11899
- const module = modulePerId.get(moduleId);
11900
- if (module) {
11901
- modulesFound.push(module);
11902
- }
11903
- const concatModules = concatModulesPerId.get(moduleId);
11904
- if (concatModules) {
11905
- modulesFound.push(...concatModules);
11906
- }
11907
- }
11908
- if (moduleIdentifier) {
11909
- const module = modulePerIdentifier.get(moduleIdentifier);
11910
- if (module) {
11911
- modulesFound.push(module);
11912
- }
11913
- const concatModules = concatModulesPerIdentifier.get(moduleIdentifier);
11914
- if (concatModules) {
11915
- modulesFound.push(...concatModules);
11916
- }
11917
- }
11918
- return Array.from(new Set(modulesFound.map(getModulePath)));
11919
- };
11920
- const modulesDone = /* @__PURE__ */ new Set();
11921
- for (const module of modules) {
11922
- if (!isModuleSupported(module)) {
11924
+ const fileModules = modulesPerFile.get(file.filepath);
11925
+ if (!fileModules) {
11926
+ warn(`Could not find modules for ${file.name}`);
11923
11927
  continue;
11924
11928
  }
11925
- const modulePath = getModulePath(module);
11926
- if (modulesDone.has(modulePath)) {
11927
- continue;
11928
- }
11929
- modulesDone.add(modulePath);
11930
- if (modulePath === "unknown") {
11931
- warn(`Unknown module: ${JSON.stringify(module)}`);
11932
- }
11933
- if (module.reasons) {
11934
- const moduleDeps = tempDeps[modulePath] || {
11935
- dependencies: /* @__PURE__ */ new Set(),
11936
- dependents: /* @__PURE__ */ new Set()
11937
- };
11938
- const dependents = module.reasons.flatMap(getModules);
11939
- for (const dependent of dependents) {
11940
- const reasonDeps = tempDeps[dependent] || {
11941
- dependencies: /* @__PURE__ */ new Set(),
11942
- dependents: /* @__PURE__ */ new Set()
11943
- };
11944
- reasonDeps.dependencies.add(modulePath);
11945
- tempDeps[dependent] = reasonDeps;
11946
- moduleDeps.dependents.add(dependent);
11947
- }
11948
- tempDeps[modulePath] = moduleDeps;
11949
- }
11950
- const file = {
11951
- size: module.size || 0,
11952
- name: cleanName(context, modulePath),
11953
- dependencies: /* @__PURE__ */ new Set(),
11954
- dependents: /* @__PURE__ */ new Set(),
11955
- filepath: modulePath,
11956
- type: getType(modulePath)
11957
- };
11958
- for (const chunkId of module.chunks || []) {
11959
- const chunkFound = chunks.find((chunk) => chunk.id === chunkId);
11960
- 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}`);
11961
11933
  continue;
11962
11934
  }
11963
- const chunkFiles = chunkFound.files || [];
11964
- if (chunkFound.auxiliaryFiles) {
11965
- chunkFiles.push(...chunkFound.auxiliaryFiles);
11966
- }
11967
- const outputFound = outputs.find((output) => chunkFiles.includes(output.name));
11968
- if (!outputFound) {
11969
- warn(`Output not found for ${file.name}`);
11970
- continue;
11971
- }
11972
- if (!outputFound.inputs.includes(file)) {
11973
- outputFound.inputs.push(file);
11974
- }
11935
+ file.inputs.push(inputFound);
11975
11936
  }
11976
- reportInputsIndexed[modulePath] = file;
11977
- inputs.push(file);
11978
11937
  }
11979
- const getInput = (filepath) => {
11980
- const inputFound = reportInputsIndexed[filepath];
11981
- if (!inputFound) {
11982
- warn(`Could not find input of ${filepath}`);
11983
- }
11984
- return inputFound;
11985
- };
11986
- for (const input of inputs) {
11987
- const depsReport = tempDeps[input.filepath];
11988
- if (!depsReport) {
11989
- 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}`);
11990
11944
  continue;
11991
11945
  }
11992
- input.dependencies = cleanReport(depsReport.dependencies, input.filepath, getInput);
11993
- input.dependents = cleanReport(depsReport.dependents, input.filepath, getInput);
11946
+ sourcemap.inputs.push(outputFound);
11994
11947
  }
11995
- for (const [name, entry] of Object.entries(entrypoints)) {
11948
+ for (const [name, entrypoint] of result.entrypoints) {
11996
11949
  const entryOutputs = [];
11997
11950
  const entryInputs = [];
11998
11951
  let size = 0;
11999
- const entryAssets = entry.assets || [];
12000
- if (entry.auxiliaryAssets) {
12001
- entryAssets.push(...entry.auxiliaryAssets);
12002
- }
12003
- for (const asset of entryAssets) {
12004
- let assetPath;
12005
- if (typeof asset === "string") {
12006
- assetPath = getAbsolutePath(context.bundler.outDir, asset);
12007
- } else if (typeof asset.name === "string") {
12008
- assetPath = getAbsolutePath(context.bundler.outDir, asset.name);
12009
- }
12010
- if (!assetPath || !reportOutputsIndexed[assetPath]) {
12011
- 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)}`);
12012
11958
  continue;
12013
11959
  }
12014
- const outputFound = reportOutputsIndexed[assetPath];
12015
- if (outputFound) {
12016
- if (outputFound.type !== "map" && !entryOutputs.includes(outputFound)) {
12017
- entryOutputs.push(outputFound);
12018
- entryInputs.push(...outputFound.inputs);
12019
- size += outputFound.size;
12020
- }
11960
+ if (outputFound.type !== "map" && !entryOutputs.includes(outputFound)) {
11961
+ entryOutputs.push(outputFound);
11962
+ entryInputs.push(...outputFound.inputs);
11963
+ size += outputFound.size;
12021
11964
  }
12022
11965
  }
12023
- const entryFilename = stats.assetsByChunkName?.[name]?.[0];
12024
11966
  const file = {
12025
11967
  name,
12026
11968
  filepath: entryFilename ? getAbsolutePath(context.bundler.outDir, entryFilename) : "unknown",
@@ -12031,6 +11973,8 @@ const getWebpackPlugin$2 = (context, PLUGIN_NAME, log) => (compiler) => {
12031
11973
  };
12032
11974
  entries.push(file);
12033
11975
  }
11976
+ context.build.errors = result.errors.map((err) => err.message);
11977
+ context.build.warnings = [...warnings, ...result.warnings.map((err) => err.message)];
12034
11978
  context.build.inputs = inputs;
12035
11979
  context.build.outputs = outputs;
12036
11980
  context.build.entries = entries;
@@ -12077,7 +12021,7 @@ const getBundlerReportPlugin = (opts, globalContext) => {
12077
12021
  globalContext.bundler.outDir = build.initialOptions.outdir;
12078
12022
  }
12079
12023
  if (build.initialOptions.outfile) {
12080
- globalContext.bundler.outDir = require$$1.dirname(build.initialOptions.outfile);
12024
+ globalContext.bundler.outDir = path$i.dirname(build.initialOptions.outfile);
12081
12025
  }
12082
12026
  build.initialOptions.metafile = true;
12083
12027
  }
@@ -12998,7 +12942,7 @@ function requireNode$1 () {
12998
12942
  hasRequiredNode$1 = 1;
12999
12943
  (function (module, exports) {
13000
12944
  const tty = require$$0$1;
13001
- const util = require$$1$1;
12945
+ const util = require$$1;
13002
12946
 
13003
12947
  /**
13004
12948
  * This is the Node.js implementation of `debug()`.
@@ -13911,7 +13855,7 @@ function requireNode () {
13911
13855
  hasRequiredNode = 1;
13912
13856
  (function (module, exports) {
13913
13857
  const tty = require$$0$1;
13914
- const util = require$$1$1;
13858
+ const util = require$$1;
13915
13859
 
13916
13860
  /**
13917
13861
  * This is the Node.js implementation of `debug()`.
@@ -19057,21 +19001,19 @@ const processInjections = async (toInject, log) => {
19057
19001
  return results.filter(Boolean);
19058
19002
  };
19059
19003
 
19060
- const getInjectionPlugins = (opts, context, toInject) => {
19004
+ const getInjectionPlugins = (bundler, opts, context, toInject) => {
19061
19005
  const log = getLogger(opts.logLevel, PLUGIN_NAME$4);
19062
19006
  const contentToInject = [];
19063
19007
  const getContentToInject = () => {
19064
- contentToInject.unshift(
19065
- // Needs at least one element otherwise ESBuild will throw 'Do not know how to load path'.
19066
- // Most likely because it tries to generate an empty file.
19067
- `
19008
+ const before = `
19068
19009
  /********************************************/
19069
- /* BEGIN INJECTION BY DATADOG BUILD PLUGINS */`
19070
- );
19071
- contentToInject.push(`
19010
+ /* BEGIN INJECTION BY DATADOG BUILD PLUGINS */`;
19011
+ const after = `
19072
19012
  /* END INJECTION BY DATADOG BUILD PLUGINS */
19073
- /********************************************/`);
19074
- return contentToInject.join("\n\n");
19013
+ /********************************************/`;
19014
+ return `${before}
19015
+ ${contentToInject.join("\n\n")}
19016
+ ${after}`;
19075
19017
  };
19076
19018
  const rollupInjectionPlugin = {
19077
19019
  banner(chunk) {
@@ -19081,28 +19023,8 @@ const getInjectionPlugins = (opts, context, toInject) => {
19081
19023
  return "";
19082
19024
  }
19083
19025
  };
19084
- return [
19085
- // Resolve the injected file.
19086
- {
19087
- name: RESOLUTION_PLUGIN_NAME,
19088
- enforce: "pre",
19089
- resolveId(id) {
19090
- if (isInjection(id)) {
19091
- return { id, moduleSideEffects: true };
19092
- }
19093
- },
19094
- loadInclude(id) {
19095
- if (isInjection(id)) {
19096
- return true;
19097
- }
19098
- },
19099
- load(id) {
19100
- if (isInjection(id)) {
19101
- return getContentToInject();
19102
- }
19103
- }
19104
- },
19105
- // Prepare and fetch the content to inject.
19026
+ const plugins = [
19027
+ // Prepare and fetch the content to inject for all bundlers.
19106
19028
  {
19107
19029
  name: PREPARATION_PLUGIN_NAME,
19108
19030
  enforce: "pre",
@@ -19110,75 +19032,79 @@ const getInjectionPlugins = (opts, context, toInject) => {
19110
19032
  async buildStart() {
19111
19033
  const results = await processInjections(toInject, log);
19112
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
+ });
19113
19064
  }
19114
19065
  },
19115
- // Inject the virtual file that will be home of all injected content.
19066
+ // Inject the file that will be home of all injected content.
19067
+ // Each bundler has its own way to inject a file.
19116
19068
  {
19117
19069
  name: PLUGIN_NAME$4,
19118
19070
  esbuild: {
19119
19071
  setup(build) {
19120
19072
  const { initialOptions } = build;
19121
- const initialInject = initialOptions.inject ? [...initialOptions.inject] : [];
19122
- const plugins = initialOptions.plugins || [];
19073
+ const absolutePathInjectFile = path$i.resolve(
19074
+ context.bundler.outDir,
19075
+ INJECTED_FILE_PATH
19076
+ );
19123
19077
  initialOptions.inject = initialOptions.inject || [];
19124
- initialOptions.inject.push(INJECTED_FILE);
19125
- for (const plugin of plugins) {
19126
- const oldSetup = plugin.setup;
19127
- if (isInternalPlugin(plugin.name, context)) {
19128
- continue;
19129
- }
19130
- plugin.setup = async (esbuild) => {
19131
- esbuild.initialOptions.inject = initialInject;
19132
- await oldSetup(esbuild);
19133
- };
19134
- }
19078
+ initialOptions.inject.push(absolutePathInjectFile);
19135
19079
  }
19136
19080
  },
19137
19081
  webpack: (compiler) => {
19138
- const injectEntry = (originalEntry) => {
19139
- if (!originalEntry) {
19140
- return [INJECTED_FILE];
19141
- }
19142
- if (Array.isArray(originalEntry)) {
19143
- return [INJECTED_FILE, ...originalEntry];
19144
- }
19145
- if (typeof originalEntry === "function") {
19146
- return async () => {
19147
- const originEntry = await originalEntry();
19148
- return [INJECTED_FILE, originEntry];
19149
- };
19150
- }
19151
- if (typeof originalEntry === "string") {
19152
- return [INJECTED_FILE, originalEntry];
19153
- }
19154
- if (typeof originalEntry === "object") {
19155
- const newEntry = {};
19156
- if (Object.keys(originalEntry).length === 0) {
19157
- newEntry[INJECTED_FILE] = // Webpack 4 and 5 have different entry formats.
19158
- context.bundler.variant === "5" ? { import: [INJECTED_FILE] } : INJECTED_FILE;
19159
- return newEntry;
19160
- }
19161
- for (const entryName in originalEntry) {
19162
- if (!Object.hasOwn(originalEntry, entryName)) {
19163
- 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 "";
19164
19097
  }
19165
- const entry = originalEntry[entryName];
19166
- newEntry[entryName] = // Webpack 4 and 5 have different entry formats.
19167
- typeof entry === "string" ? [INJECTED_FILE, entry] : {
19168
- ...entry,
19169
- import: [INJECTED_FILE, ...entry.import]
19170
- };
19098
+ return getContentToInject();
19171
19099
  }
19172
- return newEntry;
19173
- }
19174
- return [INJECTED_FILE, originalEntry];
19175
- };
19176
- compiler.options.entry = injectEntry(compiler.options.entry);
19100
+ })
19101
+ );
19177
19102
  },
19178
19103
  rollup: rollupInjectionPlugin,
19179
19104
  vite: rollupInjectionPlugin
19180
19105
  }
19181
19106
  ];
19107
+ return plugins;
19182
19108
  };
19183
19109
 
19184
19110
  const getInternalPlugins = (options, meta) => {
@@ -19192,7 +19118,8 @@ const getInternalPlugins = (options, meta) => {
19192
19118
  name: meta.framework,
19193
19119
  fullName: `${meta.framework}${variant}`,
19194
19120
  variant,
19195
- outDir: cwd
19121
+ outDir: cwd,
19122
+ version: meta.bundler.version || meta.bundler.VERSION
19196
19123
  },
19197
19124
  build: {
19198
19125
  errors: [],
@@ -19208,7 +19135,7 @@ const getInternalPlugins = (options, meta) => {
19208
19135
  const bundlerReportPlugin = getBundlerReportPlugin(options, globalContext);
19209
19136
  const buildReportPlugin = getBuildReportPlugin(options, globalContext);
19210
19137
  const gitPlugin = getGitPlugin(options, globalContext);
19211
- const injectionPlugins = getInjectionPlugins(options, globalContext, toInject);
19138
+ const injectionPlugins = getInjectionPlugins(meta.bundler, options, globalContext, toInject);
19212
19139
  return {
19213
19140
  globalContext,
19214
19141
  internalPlugins: [bundlerReportPlugin, buildReportPlugin, gitPlugin, ...injectionPlugins]
@@ -19382,12 +19309,12 @@ if (typeof module !== "undefined") {
19382
19309
  }
19383
19310
 
19384
19311
  const decomposePath = (options, context, sourcemapFilePath) => {
19385
- if (require$$1.extname(sourcemapFilePath) !== ".map") {
19312
+ if (path$i.extname(sourcemapFilePath) !== ".map") {
19386
19313
  throw new Error(`The file ${chalk.green.bold(sourcemapFilePath)} is not a sourcemap.`);
19387
19314
  }
19388
19315
  const minifiedFilePath = sourcemapFilePath.replace(/\.map$/, "");
19389
19316
  const relativePath = minifiedFilePath.replace(context.bundler.outDir, "");
19390
- const minifiedUrl = options.minifiedPathPrefix ? require$$1.join(options.minifiedPathPrefix, relativePath) : relativePath;
19317
+ const minifiedUrl = options.minifiedPathPrefix ? path$i.join(options.minifiedPathPrefix, relativePath) : relativePath;
19391
19318
  return {
19392
19319
  minifiedFilePath,
19393
19320
  minifiedUrl,
@@ -20260,7 +20187,7 @@ const getPayload = async (sourcemap, metadata, prefix, git) => {
20260
20187
  sourcemap.sourcemapFilePath,
20261
20188
  (reason) => {
20262
20189
  warnings.push(
20263
- `${require$$1.basename(sourcemap.sourcemapFilePath)}: "${reason}"`
20190
+ `${path$i.basename(sourcemap.sourcemapFilePath)}: "${reason}"`
20264
20191
  );
20265
20192
  }
20266
20193
  ),
@@ -21081,7 +21008,7 @@ var polyfills = polyfills$1;
21081
21008
  var legacy = legacyStreams;
21082
21009
  var clone = clone_1;
21083
21010
 
21084
- var util = require$$1$1;
21011
+ var util = require$$1;
21085
21012
 
21086
21013
  /* istanbul ignore next - node 0.x polyfill */
21087
21014
  var gracefulQueue;
@@ -21631,7 +21558,7 @@ function retry () {
21631
21558
  };
21632
21559
  } (fs$i));
21633
21560
 
21634
- const path$g = require$$1;
21561
+ const path$g = path$i;
21635
21562
 
21636
21563
  // get drive on windows
21637
21564
  function getRootPath (p) {
@@ -21656,7 +21583,7 @@ var win32 = {
21656
21583
  };
21657
21584
 
21658
21585
  const fs$g = gracefulFs;
21659
- const path$f = require$$1;
21586
+ const path$f = path$i;
21660
21587
  const invalidWin32Path$1 = win32.invalidWin32Path;
21661
21588
 
21662
21589
  const o777$1 = parseInt('0777', 8);
@@ -21718,7 +21645,7 @@ function mkdirs$2 (p, opts, callback, made) {
21718
21645
  var mkdirs_1$1 = mkdirs$2;
21719
21646
 
21720
21647
  const fs$f = gracefulFs;
21721
- const path$e = require$$1;
21648
+ const path$e = path$i;
21722
21649
  const invalidWin32Path = win32.invalidWin32Path;
21723
21650
 
21724
21651
  const o777 = parseInt('0777', 8);
@@ -21786,7 +21713,7 @@ var mkdirs_1 = {
21786
21713
 
21787
21714
  const fs$e = gracefulFs;
21788
21715
  const os = require$$0;
21789
- const path$d = require$$1;
21716
+ const path$d = path$i;
21790
21717
 
21791
21718
  // HFS, ext{2,3}, FAT do not, Node.js v0.10 does not
21792
21719
  function hasMillisResSync () {
@@ -21875,7 +21802,7 @@ var buffer$1 = function (size) {
21875
21802
  };
21876
21803
 
21877
21804
  const fs$d = gracefulFs;
21878
- const path$c = require$$1;
21805
+ const path$c = path$i;
21879
21806
  const mkdirpSync$1 = mkdirs_1.mkdirsSync;
21880
21807
  const utimesSync = utimes$1.utimesMillisSync;
21881
21808
 
@@ -22083,7 +22010,7 @@ var pathExists_1 = {
22083
22010
  };
22084
22011
 
22085
22012
  const fs$b = gracefulFs;
22086
- const path$b = require$$1;
22013
+ const path$b = path$i;
22087
22014
  const mkdirp$1 = mkdirs_1.mkdirs;
22088
22015
  const pathExists$7 = pathExists_1.pathExists;
22089
22016
  const utimes = utimes$1.utimesMillis;
@@ -22333,7 +22260,7 @@ var copy$1 = {
22333
22260
  };
22334
22261
 
22335
22262
  const fs$a = gracefulFs;
22336
- const path$a = require$$1;
22263
+ const path$a = path$i;
22337
22264
  const assert = require$$5;
22338
22265
 
22339
22266
  const isWindows = (process.platform === 'win32');
@@ -22655,7 +22582,7 @@ var remove$3 = {
22655
22582
 
22656
22583
  const u$7 = universalify.fromCallback;
22657
22584
  const fs$9 = fs$j;
22658
- const path$9 = require$$1;
22585
+ const path$9 = path$i;
22659
22586
  const mkdir$5 = mkdirs_1;
22660
22587
  const remove$2 = remove$3;
22661
22588
 
@@ -22701,7 +22628,7 @@ var empty$2 = {
22701
22628
  };
22702
22629
 
22703
22630
  const u$6 = universalify.fromCallback;
22704
- const path$8 = require$$1;
22631
+ const path$8 = path$i;
22705
22632
  const fs$8 = gracefulFs;
22706
22633
  const mkdir$4 = mkdirs_1;
22707
22634
  const pathExists$6 = pathExists_1.pathExists;
@@ -22749,7 +22676,7 @@ var file$1 = {
22749
22676
  };
22750
22677
 
22751
22678
  const u$5 = universalify.fromCallback;
22752
- const path$7 = require$$1;
22679
+ const path$7 = path$i;
22753
22680
  const fs$7 = gracefulFs;
22754
22681
  const mkdir$3 = mkdirs_1;
22755
22682
  const pathExists$5 = pathExists_1.pathExists;
@@ -22808,7 +22735,7 @@ var link$1 = {
22808
22735
  createLinkSync
22809
22736
  };
22810
22737
 
22811
- const path$6 = require$$1;
22738
+ const path$6 = path$i;
22812
22739
  const fs$6 = gracefulFs;
22813
22740
  const pathExists$4 = pathExists_1.pathExists;
22814
22741
 
@@ -22937,7 +22864,7 @@ var symlinkType_1 = {
22937
22864
  };
22938
22865
 
22939
22866
  const u$4 = universalify.fromCallback;
22940
- const path$5 = require$$1;
22867
+ const path$5 = path$i;
22941
22868
  const fs$4 = gracefulFs;
22942
22869
  const _mkdirs = mkdirs_1;
22943
22870
  const mkdirs = _mkdirs.mkdirs;
@@ -23166,7 +23093,7 @@ var jsonfile = {
23166
23093
  writeJsonSync: jsonFile$3.writeFileSync
23167
23094
  };
23168
23095
 
23169
- const path$4 = require$$1;
23096
+ const path$4 = path$i;
23170
23097
  const mkdir$2 = mkdirs_1;
23171
23098
  const pathExists$2 = pathExists_1.pathExists;
23172
23099
  const jsonFile$2 = jsonfile;
@@ -23193,7 +23120,7 @@ function outputJson (file, data, options, callback) {
23193
23120
  var outputJson_1 = outputJson;
23194
23121
 
23195
23122
  const fs$3 = gracefulFs;
23196
- const path$3 = require$$1;
23123
+ const path$3 = path$i;
23197
23124
  const mkdir$1 = mkdirs_1;
23198
23125
  const jsonFile$1 = jsonfile;
23199
23126
 
@@ -23225,7 +23152,7 @@ jsonFile.readJSONSync = jsonFile.readJsonSync;
23225
23152
  var json = jsonFile;
23226
23153
 
23227
23154
  const fs$2 = gracefulFs;
23228
- const path$2 = require$$1;
23155
+ const path$2 = path$i;
23229
23156
  const copySync = copySync$1.copySync;
23230
23157
  const removeSync = remove$3.removeSync;
23231
23158
  const mkdirpSync = mkdirs_1.mkdirsSync;
@@ -23342,7 +23269,7 @@ var moveSync_1 = {
23342
23269
 
23343
23270
  const u$1 = universalify.fromCallback;
23344
23271
  const fs$1 = gracefulFs;
23345
- const path$1 = require$$1;
23272
+ const path$1 = path$i;
23346
23273
  const copy = copy$1.copy;
23347
23274
  const remove$1 = remove$3.remove;
23348
23275
  const mkdirp = mkdirs_1.mkdirp;
@@ -23423,7 +23350,7 @@ var move_1 = {
23423
23350
 
23424
23351
  const u = universalify.fromCallback;
23425
23352
  const fs = gracefulFs;
23426
- const path = require$$1;
23353
+ const path = path$i;
23427
23354
  const mkdir = mkdirs_1;
23428
23355
  const pathExists = pathExists_1.pathExists;
23429
23356
 
@@ -23893,7 +23820,7 @@ const outputFiles = async (data, outputOptions, log, cwd) => {
23893
23820
  } else if (typeof outputOptions === "string") {
23894
23821
  destination = outputOptions;
23895
23822
  }
23896
- const outputPath = require$$1.resolve(cwd, destination);
23823
+ const outputPath = path$i.resolve(cwd, destination);
23897
23824
  try {
23898
23825
  const errors = {};
23899
23826
  const filesToWrite = {};
@@ -23912,7 +23839,7 @@ const outputFiles = async (data, outputOptions, log, cwd) => {
23912
23839
  const proms = Object.keys(filesToWrite).map((file) => {
23913
23840
  const start = Date.now();
23914
23841
  log(`Start writing ${file}.json.`);
23915
- 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(() => {
23916
23843
  log(`Wrote ${file}.json in ${formatDuration(Date.now() - start)}`);
23917
23844
  }).catch((e) => {
23918
23845
  log(
@@ -34284,7 +34211,7 @@ virtualStats.VirtualStats = VirtualStats;
34284
34211
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
34285
34212
  return (mod && mod.__esModule) ? mod : { "default": mod };
34286
34213
  };
34287
- const path_1 = __importDefault(require$$1);
34214
+ const path_1 = __importDefault(path$i);
34288
34215
  const virtual_stats_1 = virtualStats;
34289
34216
  let inode = 45000000;
34290
34217
  const ALL = 'all';
@@ -34568,7 +34495,7 @@ var VirtualModulesPlugin$1 = /*@__PURE__*/getDefaultExportFromCjs(lib);
34568
34495
 
34569
34496
  // node_modules/.pnpm/tsup@8.0.2_typescript@5.4.5/node_modules/tsup/assets/esm_shims.js
34570
34497
  var getFilename = () => fileURLToPath$1(import.meta.url);
34571
- var getDirname = () => require$$1.dirname(getFilename());
34498
+ var getDirname = () => path$i.dirname(getFilename());
34572
34499
  var __dirname = /* @__PURE__ */ getDirname();
34573
34500
 
34574
34501
  // node_modules/.pnpm/@jridgewell+sourcemap-codec@1.4.15/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
@@ -35369,7 +35296,7 @@ var ExtToLoader = {
35369
35296
  ".txt": "text"
35370
35297
  };
35371
35298
  function guessLoader(code, id) {
35372
- return ExtToLoader[require$$1.extname(id).toLowerCase()] || "js";
35299
+ return ExtToLoader[path$i.extname(id).toLowerCase()] || "js";
35373
35300
  }
35374
35301
  function unwrapLoader(loader, code, id) {
35375
35302
  if (typeof loader === "function")
@@ -35443,8 +35370,8 @@ function createBuildContext(initialOptions) {
35443
35370
  emitFile(emittedFile) {
35444
35371
  const outFileName = emittedFile.fileName || emittedFile.name;
35445
35372
  if (initialOptions.outdir && emittedFile.source && outFileName) {
35446
- const outPath = require$$1.resolve(initialOptions.outdir, outFileName);
35447
- const outDir = require$$1.dirname(outPath);
35373
+ const outPath = path$i.resolve(initialOptions.outdir, outFileName);
35374
+ const outDir = path$i.dirname(outPath);
35448
35375
  if (!fs$j.existsSync(outDir))
35449
35376
  fs$j.mkdirSync(outDir, { recursive: true });
35450
35377
  fs$j.writeFileSync(outPath, emittedFile.source);
@@ -35645,7 +35572,7 @@ function buildSetup(meta) {
35645
35572
  onLoad({ filter: onLoadFilter }, async (args) => {
35646
35573
  const id = args.path + args.suffix;
35647
35574
  const { errors, warnings, mixedContext } = createPluginContext(context);
35648
- const resolveDir = require$$1.dirname(args.path);
35575
+ const resolveDir = path$i.dirname(args.path);
35649
35576
  let code, map;
35650
35577
  if (plugin.load && (!plugin.loadInclude || plugin.loadInclude(id))) {
35651
35578
  const result = await plugin.load.call(mixedContext, id);
@@ -35676,7 +35603,7 @@ function buildSetup(meta) {
35676
35603
  if (plugin.transformInclude && !plugin.transformInclude(id))
35677
35604
  return;
35678
35605
  const { mixedContext, errors, warnings } = createPluginContext(context);
35679
- const resolveDir = require$$1.dirname(args.path);
35606
+ const resolveDir = path$i.dirname(args.path);
35680
35607
  let code = await args.getContents();
35681
35608
  let map;
35682
35609
  const result = await plugin.transform.call(mixedContext, code, id);
@@ -35768,7 +35695,7 @@ var ExtToLoader2 = {
35768
35695
  ".node": "napi"
35769
35696
  };
35770
35697
  function guessIdLoader(id) {
35771
- return ExtToLoader2[require$$1.extname(id).toLowerCase()] || "js";
35698
+ return ExtToLoader2[path$i.extname(id).toLowerCase()] || "js";
35772
35699
  }
35773
35700
  function transformQuery(context) {
35774
35701
  const queryParamsObject = {};
@@ -35858,7 +35785,7 @@ function toFarmPlugin(plugin, options) {
35858
35785
  farmPlugin.resolve = {
35859
35786
  filters: { sources: [".*", ...filters], importers: [".*"] },
35860
35787
  async executor(params, context) {
35861
- const resolvedIdPath = require$$1.resolve(
35788
+ const resolvedIdPath = path$i.resolve(
35862
35789
  process.cwd(),
35863
35790
  params.importer ?? ""
35864
35791
  );
@@ -36440,6 +36367,7 @@ const validateOptions = (options = {}) => {
36440
36367
  };
36441
36368
  const HOST_NAME = "datadog-build-plugins";
36442
36369
  const buildPluginFactory = ({
36370
+ bundler,
36443
36371
  version
36444
36372
  }) => {
36445
36373
  return createUnplugin((opts, unpluginMetaContext) => {
@@ -36448,6 +36376,7 @@ const buildPluginFactory = ({
36448
36376
  unpluginMetaContext.esbuildHostName = HOST_NAME;
36449
36377
  }
36450
36378
  const { globalContext, internalPlugins } = getInternalPlugins(options, {
36379
+ bundler,
36451
36380
  version,
36452
36381
  ...unpluginMetaContext
36453
36382
  });
@@ -36470,7 +36399,7 @@ const buildPluginFactory = ({
36470
36399
 
36471
36400
  var name = "@datadog/esbuild-plugin";
36472
36401
  var packageManager = "yarn@4.0.2";
36473
- var version$1 = "2.3.1-dev-8";
36402
+ var version$1 = "2.3.1-dev-10";
36474
36403
  var license = "MIT";
36475
36404
  var author = "Datadog";
36476
36405
  var description = "Datadog ESBuild Plugin";
@@ -36558,6 +36487,7 @@ var pkg = {
36558
36487
  };
36559
36488
 
36560
36489
  const datadogEsbuildPlugin = buildPluginFactory({
36490
+ bundler: esbuild,
36561
36491
  version: pkg.version
36562
36492
  }).esbuild;
36563
36493
  const version = pkg.version;