@datadog/esbuild-plugin 0.0.13-5 → 0.0.13-6

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.
@@ -1,4 +1,5 @@
1
1
  import * as esbuild from 'esbuild';
2
+ import * as src from 'src';
2
3
 
3
4
  type LogLevel = 'debug' | 'warn' | 'error' | 'none';
4
5
  interface GetPluginsOptions {
@@ -43,7 +44,7 @@ declare const helpers: {
43
44
  };
44
45
  };
45
46
 
46
- declare const datadogEsbuildPlugin: (options: Options) => esbuild.Plugin;
47
+ declare const datadogEsbuildPlugin: (options: src.EsbuildPluginOptions) => esbuild.Plugin;
47
48
 
48
49
  export { type Options as EsbuildPluginOptions, datadogEsbuildPlugin, helpers };
49
50
  //# sourceMappingURL=index.d.ts.map
package/dist/src/index.js CHANGED
@@ -5876,37 +5876,37 @@ const sortDesc = (attr) => (a, b) => {
5876
5876
  }
5877
5877
  };
5878
5878
  const getOutput = (values, renderValue) => {
5879
- let st = "";
5879
+ let output = "";
5880
5880
  for (const val of values.slice(0, TOP)) {
5881
- st += `[${numColor(renderValue(val))}] ${nameColor(val.name)}
5881
+ output += `[${numColor(renderValue(val))}] ${nameColor(val.name)}
5882
5882
  `;
5883
5883
  }
5884
- return st;
5884
+ return output;
5885
5885
  };
5886
5886
  const outputTapables = (timings) => {
5887
- let st = "";
5887
+ let output = "";
5888
5888
  if (!timings) {
5889
- return st;
5889
+ return output;
5890
5890
  }
5891
5891
  const times = Array.from(timings.values());
5892
5892
  if (!times.length) {
5893
- return st;
5893
+ return output;
5894
5894
  }
5895
- st += "\n===== Tapables =====\n";
5896
- st += `
5895
+ output += "\n===== Tapables =====\n";
5896
+ output += `
5897
5897
  === Top ${TOP} duration ===
5898
5898
  `;
5899
5899
  times.sort(sortDesc("duration"));
5900
- st += getOutput(times, (time) => formatDuration(time.duration));
5901
- st += `
5900
+ output += getOutput(times, (time) => formatDuration(time.duration));
5901
+ output += `
5902
5902
  === Top ${TOP} hits ===
5903
5903
  `;
5904
5904
  times.sort(sortDesc("increment"));
5905
- st += getOutput(times, (plugin) => plugin.increment);
5906
- return st;
5905
+ output += getOutput(times, (plugin) => plugin.increment);
5906
+ return output;
5907
5907
  };
5908
5908
  const outputWebpack = (stats) => {
5909
- let st = "\n===== General =====\n";
5909
+ let output = "\n===== General =====\n";
5910
5910
  const duration = stats.endTime - stats.startTime;
5911
5911
  const nbDeps = stats.compilation.fileDependencies.size;
5912
5912
  const nbFiles = stats.compilation.assets ? Object.keys(stats.compilation.assets).length : stats.compilation.emittedAssets.size;
@@ -5914,7 +5914,7 @@ const outputWebpack = (stats) => {
5914
5914
  const nbModules = "size" in stats.compilation.modules ? stats.compilation.modules.size : stats.compilation.modules.length;
5915
5915
  const nbChunks = "size" in stats.compilation.chunks ? stats.compilation.chunks.size : stats.compilation.chunks.length;
5916
5916
  const nbEntries = "size" in stats.compilation.entries ? stats.compilation.entries.size : stats.compilation.entries.length;
5917
- st += `duration: ${chalk.bold(formatDuration(duration))}
5917
+ output += `duration: ${chalk.bold(formatDuration(duration))}
5918
5918
  nbDeps: ${chalk.bold(nbDeps.toString())}
5919
5919
  nbFiles: ${chalk.bold(nbFiles.toString())}
5920
5920
  nbWarnings: ${chalk.bold(nbWarnings.toString())}
@@ -5922,94 +5922,94 @@ nbModules: ${chalk.bold(nbModules.toString())}
5922
5922
  nbChunks: ${chalk.bold(nbChunks.toString())}
5923
5923
  nbEntries: ${chalk.bold(nbEntries.toString())}
5924
5924
  `;
5925
- return st;
5925
+ return output;
5926
5926
  };
5927
5927
  const outputEsbuild = (stats) => {
5928
- let st = "\n===== General =====\n";
5928
+ let output = "\n===== General =====\n";
5929
5929
  const nbDeps = stats.inputs ? Object.keys(stats.inputs).length : 0;
5930
5930
  const nbFiles = stats.outputs ? Object.keys(stats.outputs).length : 0;
5931
5931
  const nbWarnings = stats.warnings.length;
5932
5932
  const nbErrors = stats.errors.length;
5933
5933
  const nbEntries = stats.entrypoints ? Object.keys(stats.entrypoints).length : 0;
5934
- st += `
5934
+ output += `
5935
5935
  nbDeps: ${chalk.bold(nbDeps.toString())}
5936
5936
  nbFiles: ${chalk.bold(nbFiles.toString())}
5937
5937
  nbWarnings: ${chalk.bold(nbWarnings.toString())}
5938
5938
  nbErrors: ${chalk.bold(nbErrors.toString())}
5939
5939
  nbEntries: ${chalk.bold(nbEntries.toString())}
5940
5940
  `;
5941
- return st;
5941
+ return output;
5942
5942
  };
5943
5943
  const outputLoaders = (timings) => {
5944
- let st = "";
5944
+ let output = "";
5945
5945
  if (!timings) {
5946
- return st;
5946
+ return output;
5947
5947
  }
5948
5948
  const times = Array.from(timings.values());
5949
5949
  if (!times.length) {
5950
- return st;
5950
+ return output;
5951
5951
  }
5952
- st += "\n===== Loaders =====\n";
5953
- st += `
5952
+ output += "\n===== Loaders =====\n";
5953
+ output += `
5954
5954
  === Top ${TOP} duration ===
5955
5955
  `;
5956
5956
  times.sort(sortDesc("duration"));
5957
- st += getOutput(times, (loader) => formatDuration(loader.duration));
5958
- st += `
5957
+ output += getOutput(times, (loader) => formatDuration(loader.duration));
5958
+ output += `
5959
5959
  === Top ${TOP} hits ===
5960
5960
  `;
5961
5961
  times.sort(sortDesc("increment"));
5962
- st += getOutput(times, (loader) => loader.increment);
5963
- return st;
5962
+ output += getOutput(times, (loader) => loader.increment);
5963
+ return output;
5964
5964
  };
5965
5965
  const outputModulesDependencies = (deps) => {
5966
- let st = "";
5966
+ let output = "";
5967
5967
  if (!deps) {
5968
- return st;
5968
+ return output;
5969
5969
  }
5970
5970
  const dependencies = Object.values(deps);
5971
5971
  if (!dependencies.length) {
5972
- return st;
5972
+ return output;
5973
5973
  }
5974
- st += "\n===== Modules =====\n";
5974
+ output += "\n===== Modules =====\n";
5975
5975
  dependencies.sort(sortDesc((mod) => mod.dependents.length));
5976
- st += `
5976
+ output += `
5977
5977
  === Top ${TOP} dependents ===
5978
5978
  `;
5979
- st += getOutput(dependencies, (module) => module.dependents.length);
5979
+ output += getOutput(dependencies, (module) => module.dependents.length);
5980
5980
  dependencies.sort(sortDesc((mod) => mod.dependencies.length));
5981
- st += `
5981
+ output += `
5982
5982
  === Top ${TOP} dependencies ===
5983
5983
  `;
5984
- st += getOutput(dependencies, (module) => module.dependencies.length);
5984
+ output += getOutput(dependencies, (module) => module.dependencies.length);
5985
5985
  dependencies.sort(sortDesc("size"));
5986
- st += `
5986
+ output += `
5987
5987
  === Top ${TOP} size ===
5988
5988
  `;
5989
- st += getOutput(dependencies, (module) => prettyBytes$1(module.size));
5990
- return st;
5989
+ output += getOutput(dependencies, (module) => prettyBytes$1(module.size));
5990
+ return output;
5991
5991
  };
5992
5992
  const outputModulesTimings = (timings) => {
5993
- let st = "";
5993
+ let output = "";
5994
5994
  if (!timings) {
5995
- return st;
5995
+ return output;
5996
5996
  }
5997
5997
  const times = Array.from(timings.values());
5998
5998
  if (!times.length) {
5999
- return st;
5999
+ return output;
6000
6000
  }
6001
- st += "\n===== Modules =====\n";
6001
+ output += "\n===== Modules =====\n";
6002
6002
  times.sort(sortDesc("duration"));
6003
- st += `
6003
+ output += `
6004
6004
  === Top ${TOP} duration ===
6005
6005
  `;
6006
- st += getOutput(times, (module) => formatDuration(module.duration));
6006
+ output += getOutput(times, (module) => formatDuration(module.duration));
6007
6007
  times.sort(sortDesc("increment"));
6008
- st += `
6008
+ output += `
6009
6009
  === Top ${TOP} hits ===
6010
6010
  `;
6011
- st += getOutput(times, (module) => module.increment);
6012
- return st;
6011
+ output += getOutput(times, (module) => module.increment);
6012
+ return output;
6013
6013
  };
6014
6014
  const outputTexts = (context, options) => {
6015
6015
  const { output } = options[CONFIG_KEY];
@@ -6018,20 +6018,20 @@ const outputTexts = (context, options) => {
6018
6018
  if (output === false) {
6019
6019
  return;
6020
6020
  }
6021
- let st = "";
6021
+ let outputString = "";
6022
6022
  if (report) {
6023
- st += outputTapables(report.timings.tapables);
6024
- st += outputLoaders(report.timings.loaders);
6025
- st += outputModulesDependencies(report.dependencies);
6026
- st += outputModulesTimings(report.timings.modules);
6023
+ outputString += outputTapables(report.timings.tapables);
6024
+ outputString += outputLoaders(report.timings.loaders);
6025
+ outputString += outputModulesDependencies(report.dependencies);
6026
+ outputString += outputModulesTimings(report.timings.modules);
6027
6027
  }
6028
6028
  if (bundler.webpack) {
6029
- st += outputWebpack(bundler.webpack);
6029
+ outputString += outputWebpack(bundler.webpack);
6030
6030
  }
6031
6031
  if (bundler.esbuild) {
6032
- st += outputEsbuild(bundler.esbuild);
6032
+ outputString += outputEsbuild(bundler.esbuild);
6033
6033
  }
6034
- log(st);
6034
+ log(outputString);
6035
6035
  };
6036
6036
 
6037
6037
  const output = async (context, options) => {