@datadog/webpack-plugin 0.0.3-dev → 0.0.5-dev

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.
@@ -0,0 +1,48 @@
1
+ import * as webpack from 'webpack';
2
+
3
+ interface GetPluginsOptions {
4
+ auth: {
5
+ apiKey: string;
6
+ appKey: string;
7
+ };
8
+ }
9
+
10
+ declare const CONFIG_KEY: "telemetry";
11
+
12
+ interface Metric {
13
+ metric: string;
14
+ type: 'count' | 'size' | 'duration';
15
+ value: number;
16
+ tags: string[];
17
+ }
18
+ type Filter = (metric: Metric) => Metric | null;
19
+ interface DatadogOptions {
20
+ apiKey?: string;
21
+ endPoint?: string;
22
+ prefix?: string;
23
+ tags?: string[];
24
+ timestamp?: number;
25
+ filters?: Filter[];
26
+ }
27
+ type OutputOptions = boolean | string | {
28
+ destination: string;
29
+ timings?: boolean;
30
+ dependencies?: boolean;
31
+ bundler?: boolean;
32
+ metrics?: boolean;
33
+ };
34
+ type TelemetryOptions = {
35
+ disabled?: boolean;
36
+ output?: OutputOptions;
37
+ hooks?: string[];
38
+ datadog?: DatadogOptions;
39
+ };
40
+
41
+ interface Options extends GetPluginsOptions {
42
+ [CONFIG_KEY]?: TelemetryOptions;
43
+ }
44
+
45
+ declare const datadogWebpackPlugin: (options: Options) => webpack.WebpackPluginInstance;
46
+
47
+ export { datadogWebpackPlugin, datadogWebpackPlugin as default };
48
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/src/index.js CHANGED
@@ -1,41 +1,17 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var fs$j = require('fs');
6
- var require$$0 = require('constants');
7
- var require$$0$1 = require('stream');
8
- var require$$4 = require('util');
9
- var require$$5 = require('assert');
10
- var require$$1 = require('path');
11
- var require$$1$1 = require('os');
12
- var https = require('https');
13
- var perf_hooks = require('perf_hooks');
14
- var webpack = require('webpack');
15
- var url = require('url');
16
- var buffer$2 = require('buffer');
17
- var querystring = require('querystring');
18
- var process2 = require('process');
19
-
20
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
21
- function _interopNamespaceDefault(e) {
22
- var n = Object.create(null);
23
- if (e) {
24
- Object.keys(e).forEach(function (k) {
25
- if (k !== 'default') {
26
- var d = Object.getOwnPropertyDescriptor(e, k);
27
- Object.defineProperty(n, k, d.get ? d : {
28
- enumerable: true,
29
- get: function () { return e[k]; }
30
- });
31
- }
32
- });
33
- }
34
- n.default = e;
35
- return Object.freeze(n);
36
- }
37
-
38
- var querystring__namespace = /*#__PURE__*/_interopNamespaceDefault(querystring);
1
+ import fs$j from 'fs';
2
+ import require$$0 from 'constants';
3
+ import require$$0$1 from 'stream';
4
+ import require$$4 from 'util';
5
+ import require$$5 from 'assert';
6
+ import require$$1, { resolve as resolve$1, extname, isAbsolute, normalize } from 'path';
7
+ import require$$1$1 from 'os';
8
+ import { request } from 'https';
9
+ import { performance } from 'perf_hooks';
10
+ import webpack from 'webpack';
11
+ import { fileURLToPath } from 'url';
12
+ import { Buffer as Buffer$1 } from 'buffer';
13
+ import * as querystring from 'querystring';
14
+ import process2 from 'process';
39
15
 
40
16
  const CONFIG_KEY = "telemetry";
41
17
  const PLUGIN_NAME = `${CONFIG_KEY}-plugin`;
@@ -5647,7 +5623,7 @@ Sending ${metrics.length} metrics.
5647
5623
  Metrics:
5648
5624
  - ${metricsNames.join("\n - ")}`);
5649
5625
  return new Promise((resolve, reject) => {
5650
- const req = https.request({
5626
+ const req = request({
5651
5627
  method: "POST",
5652
5628
  hostname: opts.endPoint,
5653
5629
  path: `/api/v1/series?api_key=${opts.apiKey}`
@@ -6096,11 +6072,11 @@ const getNewBuildObject = (build, pluginName, context) => {
6096
6072
  name: fn,
6097
6073
  values: []
6098
6074
  };
6099
- const start = perf_hooks.performance.now();
6075
+ const start = performance.now();
6100
6076
  try {
6101
6077
  return await cb(...args);
6102
6078
  } finally {
6103
- const end = perf_hooks.performance.now();
6079
+ const end = performance.now();
6104
6080
  const duration = end - start;
6105
6081
  const statsObject = {
6106
6082
  start,
@@ -6175,7 +6151,7 @@ class Loaders {
6175
6151
  this.started[moduleName] = {
6176
6152
  module: getDisplayName(moduleName),
6177
6153
  timings: {
6178
- start: perf_hooks.performance.now(),
6154
+ start: performance.now(),
6179
6155
  duration: 0,
6180
6156
  end: 0
6181
6157
  },
@@ -6188,7 +6164,7 @@ class Loaders {
6188
6164
  if (!event) {
6189
6165
  return;
6190
6166
  }
6191
- event.timings.end = perf_hooks.performance.now();
6167
+ event.timings.end = performance.now();
6192
6168
  event.timings.duration = event.timings.end - event.timings.start;
6193
6169
  this.finished.push(event);
6194
6170
  delete this.started[moduleName];
@@ -6357,7 +6333,7 @@ class Tapables {
6357
6333
  getPromiseTapPatch(type, fn, pluginName, hookName) {
6358
6334
  return (...args) => {
6359
6335
  this.checkHooks();
6360
- const startTime = perf_hooks.performance.now();
6336
+ const startTime = performance.now();
6361
6337
  const returnValue = fn.apply(this, args);
6362
6338
  const cb = () => {
6363
6339
  this.saveResult(
@@ -6366,7 +6342,7 @@ class Tapables {
6366
6342
  hookName,
6367
6343
  getContext(args),
6368
6344
  startTime,
6369
- perf_hooks.performance.now()
6345
+ performance.now()
6370
6346
  );
6371
6347
  };
6372
6348
  returnValue.then(cb, cb);
@@ -6376,7 +6352,7 @@ class Tapables {
6376
6352
  getAsyncTapPatch(type, fn, pluginName, hookName) {
6377
6353
  return (...args) => {
6378
6354
  this.checkHooks();
6379
- const startTime = perf_hooks.performance.now();
6355
+ const startTime = performance.now();
6380
6356
  const originalCB = args.pop();
6381
6357
  const newCB = (...a) => {
6382
6358
  this.saveResult(
@@ -6385,7 +6361,7 @@ class Tapables {
6385
6361
  hookName,
6386
6362
  getContext(args),
6387
6363
  startTime,
6388
- perf_hooks.performance.now()
6364
+ performance.now()
6389
6365
  );
6390
6366
  return originalCB(...a);
6391
6367
  };
@@ -6395,7 +6371,7 @@ class Tapables {
6395
6371
  getDefaultTapPatch(type, fn, pluginName, hookName) {
6396
6372
  return (...args) => {
6397
6373
  this.checkHooks();
6398
- const startTime = perf_hooks.performance.now();
6374
+ const startTime = performance.now();
6399
6375
  const returnValue = fn.apply(this, args);
6400
6376
  this.saveResult(
6401
6377
  type,
@@ -6403,7 +6379,7 @@ class Tapables {
6403
6379
  hookName,
6404
6380
  getContext(args),
6405
6381
  startTime,
6406
- perf_hooks.performance.now()
6382
+ performance.now()
6407
6383
  );
6408
6384
  return returnValue;
6409
6385
  };
@@ -16287,9 +16263,9 @@ var lib = VirtualModulesPlugin;
16287
16263
  var VirtualModulesPlugin$1 = /*@__PURE__*/getDefaultExportFromCjs(lib);
16288
16264
 
16289
16265
  // node_modules/.pnpm/tsup@8.0.2_typescript@5.4.3/node_modules/tsup/assets/esm_shims.js
16290
- var getFilename = () => url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
16266
+ var getFilename = () => fileURLToPath(import.meta.url);
16291
16267
  var getDirname = () => require$$1.dirname(getFilename());
16292
- var __dirname$1 = /* @__PURE__ */ getDirname();
16268
+ var __dirname = /* @__PURE__ */ getDirname();
16293
16269
 
16294
16270
  // node_modules/.pnpm/@jridgewell+sourcemap-codec@1.4.15/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
16295
16271
  var comma = ",".charCodeAt(0);
@@ -17040,8 +17016,8 @@ function remapping(input, loader, options) {
17040
17016
  return new SourceMap(traceMappings(tree), opts);
17041
17017
  }
17042
17018
  function normalizeAbsolutePath(path6) {
17043
- if (require$$1.isAbsolute(path6))
17044
- return require$$1.normalize(path6);
17019
+ if (isAbsolute(path6))
17020
+ return normalize(path6);
17045
17021
  else
17046
17022
  return path6;
17047
17023
  }
@@ -17109,7 +17085,7 @@ function fixSourceMap(map) {
17109
17085
  Object.defineProperty(map, "toUrl", {
17110
17086
  enumerable: false,
17111
17087
  value: function toUrl() {
17112
- return `data:application/json;charset=utf-8;base64,${buffer$2.Buffer.from(this.toString()).toString("base64")}`;
17088
+ return `data:application/json;charset=utf-8;base64,${Buffer$1.from(this.toString()).toString("base64")}`;
17113
17089
  }
17114
17090
  });
17115
17091
  }
@@ -17453,8 +17429,8 @@ function createFarmContext(context, currentResolveId) {
17453
17429
  context.emitFile({
17454
17430
  resolvedPath: outFileName,
17455
17431
  name: outFileName,
17456
- content: [...buffer$2.Buffer.from(emittedFile.source)],
17457
- resourceType: require$$1.extname(outFileName)
17432
+ content: [...Buffer$1.from(emittedFile.source)],
17433
+ resourceType: extname(outFileName)
17458
17434
  });
17459
17435
  }
17460
17436
  },
@@ -17495,7 +17471,7 @@ function transformQuery(context) {
17495
17471
  context.query.forEach(([param, value]) => {
17496
17472
  queryParamsObject[param] = value;
17497
17473
  });
17498
- const transformQuery2 = querystring__namespace.stringify(queryParamsObject);
17474
+ const transformQuery2 = querystring.stringify(queryParamsObject);
17499
17475
  context.resolvedPath = `${context.resolvedPath}?${transformQuery2}`;
17500
17476
  }
17501
17477
  function convertEnforceToPriority(value) {
@@ -17527,7 +17503,7 @@ function customParseQueryString(url) {
17527
17503
  if (!url)
17528
17504
  return [];
17529
17505
  const queryString = url.split("?")[1];
17530
- const parsedParams = querystring__namespace.parse(queryString);
17506
+ const parsedParams = querystring.parse(queryString);
17531
17507
  const paramsArray = [];
17532
17508
  for (const key in parsedParams)
17533
17509
  paramsArray.push([key, parsedParams[key]]);
@@ -17773,7 +17749,7 @@ function createBuildContext2(compilation) {
17773
17749
  outFileName,
17774
17750
  new sources2.RawSource(
17775
17751
  // @ts-expect-error types mismatch
17776
- typeof emittedFile.source === "string" ? emittedFile.source : buffer$2.Buffer.from(emittedFile.source)
17752
+ typeof emittedFile.source === "string" ? emittedFile.source : Buffer$1.from(emittedFile.source)
17777
17753
  )
17778
17754
  );
17779
17755
  }
@@ -17785,19 +17761,19 @@ function createBuildContext2(compilation) {
17785
17761
  }
17786
17762
 
17787
17763
  // src/rspack/index.ts
17788
- var TRANSFORM_LOADER = require$$1.resolve(
17789
- __dirname$1,
17764
+ var TRANSFORM_LOADER = resolve$1(
17765
+ __dirname,
17790
17766
  "rspack/loaders/transform"
17791
17767
  );
17792
- var LOAD_LOADER = require$$1.resolve(
17793
- __dirname$1,
17768
+ var LOAD_LOADER = resolve$1(
17769
+ __dirname,
17794
17770
  "rspack/loaders/load"
17795
17771
  );
17796
17772
  function getRspackPlugin(factory) {
17797
17773
  return (userOptions) => {
17798
17774
  return {
17799
17775
  apply(compiler) {
17800
- const VIRTUAL_MODULE_PREFIX = require$$1.resolve(compiler.options.context ?? process.cwd(), "_virtual_");
17776
+ const VIRTUAL_MODULE_PREFIX = resolve$1(compiler.options.context ?? process.cwd(), "_virtual_");
17801
17777
  const injected = compiler.$unpluginContext || {};
17802
17778
  compiler.$unpluginContext = injected;
17803
17779
  const meta = {
@@ -17907,7 +17883,7 @@ function createBuildContext3(options, compilation) {
17907
17883
  });
17908
17884
  },
17909
17885
  addWatchFile(id) {
17910
- options.addWatchFile(require$$1.resolve(process2.cwd(), id));
17886
+ options.addWatchFile(resolve$1(process2.cwd(), id));
17911
17887
  },
17912
17888
  emitFile(emittedFile) {
17913
17889
  const outFileName = emittedFile.fileName || emittedFile.name;
@@ -17918,7 +17894,7 @@ function createBuildContext3(options, compilation) {
17918
17894
  outFileName,
17919
17895
  sources2 ? new sources2.RawSource(
17920
17896
  // @ts-expect-error types mismatch
17921
- typeof emittedFile.source === "string" ? emittedFile.source : buffer$2.Buffer.from(emittedFile.source)
17897
+ typeof emittedFile.source === "string" ? emittedFile.source : Buffer$1.from(emittedFile.source)
17922
17898
  ) : {
17923
17899
  source: () => emittedFile.source,
17924
17900
  size: () => emittedFile.source.length
@@ -17941,19 +17917,19 @@ function normalizeMessage(error) {
17941
17917
  }
17942
17918
 
17943
17919
  // src/webpack/index.ts
17944
- var TRANSFORM_LOADER2 = require$$1.resolve(
17945
- __dirname$1,
17920
+ var TRANSFORM_LOADER2 = resolve$1(
17921
+ __dirname,
17946
17922
  "webpack/loaders/transform"
17947
17923
  );
17948
- var LOAD_LOADER2 = require$$1.resolve(
17949
- __dirname$1,
17924
+ var LOAD_LOADER2 = resolve$1(
17925
+ __dirname,
17950
17926
  "webpack/loaders/load"
17951
17927
  );
17952
17928
  function getWebpackPlugin(factory) {
17953
17929
  return (userOptions) => {
17954
17930
  return {
17955
17931
  apply(compiler) {
17956
- const VIRTUAL_MODULE_PREFIX = require$$1.resolve(compiler.options.context ?? process2.cwd(), "_virtual_");
17932
+ const VIRTUAL_MODULE_PREFIX = resolve$1(compiler.options.context ?? process2.cwd(), "_virtual_");
17957
17933
  const injected = compiler.$unpluginContext || {};
17958
17934
  compiler.$unpluginContext = injected;
17959
17935
  const meta = {
@@ -18161,6 +18137,5 @@ const buildPluginFactory = () => {
18161
18137
  const datadogWebpackPlugin = buildPluginFactory().webpack;
18162
18138
  module.exports = datadogWebpackPlugin;
18163
18139
 
18164
- exports.datadogWebpackPlugin = datadogWebpackPlugin;
18165
- exports.default = datadogWebpackPlugin;
18140
+ export { datadogWebpackPlugin, datadogWebpackPlugin as default };
18166
18141
  //# sourceMappingURL=index.js.map