@datadog/webpack-plugin 2.2.0 → 2.2.1

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.
@@ -27,6 +27,27 @@ type types$1 = {
27
27
 
28
28
  declare const CONFIG_KEY: "telemetry";
29
29
 
30
+ type types = {
31
+ Filter: Filter;
32
+ Metric: Metric;
33
+ TelemetryOptions: TelemetryOptions;
34
+ };
35
+
36
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
37
+ type AuthOptions = {
38
+ apiKey?: string;
39
+ endPoint?: string;
40
+ };
41
+ interface GetPluginsOptions {
42
+ auth?: AuthOptions;
43
+ disableGit?: boolean;
44
+ logLevel?: LogLevel;
45
+ }
46
+ interface Options extends GetPluginsOptions {
47
+ [CONFIG_KEY$1]?: RumOptions;
48
+ [CONFIG_KEY]?: TelemetryOptions;
49
+ }
50
+
30
51
  interface Metric {
31
52
  metric: string;
32
53
  type: 'count' | 'size' | 'duration';
@@ -51,26 +72,7 @@ type TelemetryOptions = {
51
72
  filters?: Filter[];
52
73
  };
53
74
 
54
- type types = {
55
- Filter: Filter;
56
- Metric: Metric;
57
- TelemetryOptions: TelemetryOptions;
58
- };
59
-
60
- type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
61
- type AuthOptions = {
62
- apiKey?: string;
63
- endPoint?: string;
64
- };
65
- interface GetPluginsOptions {
66
- auth?: AuthOptions;
67
- disableGit?: boolean;
68
- logLevel?: LogLevel;
69
- }
70
- interface Options extends GetPluginsOptions {
71
- [CONFIG_KEY$1]?: RumOptions;
72
- [CONFIG_KEY]?: TelemetryOptions;
73
- }
75
+ declare const datadogWebpackPlugin: (options: Options) => webpack.WebpackPluginInstance;
74
76
 
75
77
  declare const helpers: {
76
78
  telemetry: {
@@ -78,7 +80,16 @@ declare const helpers: {
78
80
  };
79
81
  };
80
82
 
81
- declare const datadogWebpackPlugin: (options: Options) => webpack.WebpackPluginInstance;
82
-
83
83
  export { type types$1 as RumTypes, type types as TelemetryTypes, type Options as WebpackPluginOptions, datadogWebpackPlugin, helpers };
84
+
85
+
86
+ if (typeof module !== 'undefined') {
87
+ module.exports = {
88
+ RumTypes,
89
+ TelemetryTypes,
90
+ WebpackPluginOptions,
91
+ datadogWebpackPlugin,
92
+ helpers
93
+ };
94
+ }
84
95
  //# sourceMappingURL=index.d.ts.map
package/dist/src/index.js CHANGED
@@ -15,7 +15,6 @@ var require$$0$3 = require('constants');
15
15
  var require$$5 = require('assert');
16
16
  var https = require('https');
17
17
  var perf_hooks = require('perf_hooks');
18
- var webpack = require('webpack');
19
18
  var querystring = require('querystring');
20
19
  var process2 = require('process');
21
20
 
@@ -10596,7 +10595,7 @@ const uploadSourcemaps = async (options, context, log) => {
10596
10595
  };
10597
10596
 
10598
10597
  const defaultIntakeUrl = `https://sourcemap-intake.${process.env.DATADOG_SITE || "datadoghq.com"}/api/v2/srcmap`;
10599
- const validateOptions$1 = (config, log) => {
10598
+ const validateOptions$2 = (config, log) => {
10600
10599
  const errors = [];
10601
10600
  const sourcemapsResults = validateSourcemapsOptions(config);
10602
10601
  errors.push(...sourcemapsResults.errors);
@@ -10663,7 +10662,7 @@ const validateSourcemapsOptions = (config) => {
10663
10662
 
10664
10663
  const getPlugins$2 = (opts, context) => {
10665
10664
  const log = getLogger(opts.logLevel, PLUGIN_NAME$1);
10666
- const rumOptions = validateOptions$1(opts, log);
10665
+ const rumOptions = validateOptions$2(opts, log);
10667
10666
  return [
10668
10667
  {
10669
10668
  name: PLUGIN_NAME$1,
@@ -13668,7 +13667,7 @@ var output$1 = {
13668
13667
 
13669
13668
  var libExports = lib$2.exports;
13670
13669
 
13671
- const validateOptions = (options) => {
13670
+ const validateOptions$1 = (options) => {
13672
13671
  const validatedOptions = options[CONFIG_KEY] || { disabled: false };
13673
13672
  return validatedOptions;
13674
13673
  };
@@ -14905,7 +14904,7 @@ const getEsbuildPlugin$1 = (opt, ctx) => {
14905
14904
  setup: (build) => {
14906
14905
  const startBuild = Date.now();
14907
14906
  const logger = getLogger(opt.logLevel, "telemetry");
14908
- const telemetryOptions = validateOptions(opt);
14907
+ const telemetryOptions = validateOptions$1(opt);
14909
14908
  build.initialOptions.metafile = true;
14910
14909
  wrapPlugins(build, ctx.cwd);
14911
14910
  build.onEnd(async (result) => {
@@ -15216,14 +15215,24 @@ class Tapables {
15216
15215
  hook.tapAsync = this.newTap("async", hookName, hook.tapAsync, hook);
15217
15216
  hook.tapPromise = this.newTap("promise", hookName, hook.tapPromise, hook);
15218
15217
  }
15218
+ patchHook(tapableName, hookName, hook) {
15219
+ if (hook._fakeHook) {
15220
+ return;
15221
+ }
15222
+ if (!this.hooks[tapableName]) {
15223
+ this.hooks[tapableName] = [];
15224
+ }
15225
+ if (this.hooks[tapableName].includes(hookName)) {
15226
+ return;
15227
+ }
15228
+ this.hooks[tapableName].push(hookName);
15229
+ this.replaceTaps(hookName, hook);
15230
+ }
15219
15231
  checkHooks() {
15220
15232
  for (const tapable of this.tapables) {
15221
15233
  const name = tapable.constructor.name;
15222
15234
  for (const hookName of Object.keys(tapable.hooks)) {
15223
- if (!this.hooks[name].includes(hookName)) {
15224
- this.hooks[name].push(hookName);
15225
- this.replaceTaps(hookName, tapable.hooks[hookName]);
15226
- }
15235
+ this.patchHook(name, hookName, tapable.hooks[hookName]);
15227
15236
  }
15228
15237
  }
15229
15238
  }
@@ -15233,24 +15242,8 @@ class Tapables {
15233
15242
  if (!this.tapables.includes(tapable)) {
15234
15243
  this.tapables.push(tapable);
15235
15244
  }
15236
- if (!this.hooks[name]) {
15237
- this.hooks[name] = [];
15238
- }
15239
15245
  for (const hookName of Object.keys(tapable.hooks)) {
15240
- this.hooks[name].push(hookName);
15241
- try {
15242
- if (hookName === "normalModuleLoader" && typeof webpack.NormalModule.getCompilationHooks === "function") {
15243
- const NormalModule = webpack.NormalModule;
15244
- const compil = tapable;
15245
- this.replaceTaps(
15246
- hookName,
15247
- NormalModule.getCompilationHooks(compil).loader
15248
- );
15249
- } else {
15250
- this.replaceTaps(hookName, tapable.hooks[hookName]);
15251
- }
15252
- } catch (e) {
15253
- }
15246
+ this.patchHook(name, hookName, tapable.hooks[hookName]);
15254
15247
  }
15255
15248
  }
15256
15249
  }
@@ -15258,7 +15251,7 @@ class Tapables {
15258
15251
  const getWebpackPlugin$1 = (opt, ctx) => {
15259
15252
  return async (compiler) => {
15260
15253
  const HOOK_OPTIONS = { name: PLUGIN_NAME };
15261
- const options = validateOptions(opt);
15254
+ const options = validateOptions$1(opt);
15262
15255
  const logger = getLogger(opt.logLevel, "telemetry");
15263
15256
  const modules = new Modules(ctx.cwd, options);
15264
15257
  const tapables = new Tapables(ctx.cwd, options);
@@ -15300,7 +15293,7 @@ const getWebpackPlugin$1 = (opt, ctx) => {
15300
15293
  };
15301
15294
  };
15302
15295
 
15303
- const helpers$1 = {
15296
+ const helpers$2 = {
15304
15297
  filters: defaultFilters
15305
15298
  };
15306
15299
  const getPlugins = (options, context) => {
@@ -15442,14 +15435,14 @@ var beforeExpr = {beforeExpr: true}, startsExpr = {startsExpr: true};
15442
15435
 
15443
15436
  // Map keyword names to token types.
15444
15437
 
15445
- var keywords$2 = {};
15438
+ var keywords = {};
15446
15439
 
15447
15440
  // Succinct definitions of keyword token types
15448
15441
  function kw(name, options) {
15449
15442
  if ( options === void 0 ) options = {};
15450
15443
 
15451
15444
  options.keyword = name;
15452
- return keywords$2[name] = new TokenType(name, options)
15445
+ return keywords[name] = new TokenType(name, options)
15453
15446
  }
15454
15447
 
15455
15448
  var types$1 = {
@@ -21214,7 +21207,7 @@ pp.readWord = function() {
21214
21207
  var word = this.readWord1();
21215
21208
  var type = types$1.name;
21216
21209
  if (this.keywords.test(word)) {
21217
- type = keywords$2[word];
21210
+ type = keywords[word];
21218
21211
  }
21219
21212
  return this.finishToken(type, word)
21220
21213
  };
@@ -21248,7 +21241,7 @@ Parser.acorn = {
21248
21241
  Node: Node,
21249
21242
  TokenType: TokenType,
21250
21243
  tokTypes: types$1,
21251
- keywordTypes: keywords$2,
21244
+ keywordTypes: keywords,
21252
21245
  TokContext: TokContext,
21253
21246
  tokContexts: types,
21254
21247
  isIdentifierChar: isIdentifierChar,
@@ -26927,16 +26920,25 @@ function createUnplugin(factory) {
26927
26920
  };
26928
26921
  }
26929
26922
 
26930
- const helpers = {
26923
+ const helpers$1 = {
26931
26924
  // Each product should have a unique entry.
26932
26925
  // #helpers-injection-marker
26933
- [CONFIG_KEY]: helpers$1
26926
+ [CONFIG_KEY]: helpers$2
26934
26927
  // #helpers-injection-marker
26935
26928
  };
26929
+ const validateOptions = (options = {}) => {
26930
+ return {
26931
+ auth: {},
26932
+ disableGit: false,
26933
+ logLevel: "warn",
26934
+ ...options
26935
+ };
26936
+ };
26936
26937
  const buildPluginFactory = ({
26937
26938
  version
26938
26939
  }) => {
26939
- return createUnplugin((options, unpluginMetaContext) => {
26940
+ return createUnplugin((opts, unpluginMetaContext) => {
26941
+ const options = validateOptions(opts);
26940
26942
  if ("esbuildHostName" in unpluginMetaContext) {
26941
26943
  unpluginMetaContext.esbuildHostName = "datadog-plugins";
26942
26944
  }
@@ -26955,101 +26957,21 @@ const buildPluginFactory = ({
26955
26957
  });
26956
26958
  };
26957
26959
 
26958
- var name = "@datadog/webpack-plugin";
26959
- var packageManager = "yarn@4.0.2";
26960
- var version = "2.2.0";
26961
- var license = "MIT";
26962
- var author = "Datadog";
26963
- var description = "Datadog Webpack Plugin";
26964
- var keywords = [
26965
- "datadog",
26966
- "webpack",
26967
- "bundler",
26968
- "plugin",
26969
- "unplugin"
26970
- ];
26971
- var homepage = "https://github.com/DataDog/build-plugins#readme";
26972
- var repository = {
26973
- type: "git",
26974
- url: "https://github.com/DataDog/build-plugins",
26975
- directory: "packages/webpack-plugin"
26976
- };
26977
- var main = "./dist/src/index.js";
26978
- var module$1 = "./dist/src/index.mjs";
26979
- var exports$1 = {
26980
- ".": "./src/index.ts"
26981
- };
26982
- var publishConfig = {
26983
- access: "public",
26984
- types: "./dist/src/index.d.ts",
26985
- exports: {
26986
- "./package.json": "./package.json",
26987
- ".": {
26988
- "import": "./dist/src/index.mjs",
26989
- require: "./dist/src/index.js",
26990
- types: "./dist/src/index.d.ts"
26991
- }
26992
- }
26993
- };
26994
- var files = [
26995
- "dist"
26996
- ];
26997
- var scripts = {
26998
- build: "yarn clean && rollup --config rollup.config.mjs",
26999
- clean: "rm -rf dist",
27000
- prepack: "yarn build",
27001
- typecheck: "tsc --noEmit",
27002
- watch: "yarn clean && rollup --config rollup.config.mjs --watch"
27003
- };
27004
- var devDependencies = {
27005
- "@babel/core": "7.24.5",
27006
- "@babel/preset-env": "7.24.5",
27007
- "@babel/preset-typescript": "7.24.1",
27008
- "@dd/factory": "workspace:*",
27009
- "@dd/tools": "workspace:*",
27010
- "@rollup/plugin-babel": "6.0.4",
27011
- "@rollup/plugin-commonjs": "25.0.7",
27012
- "@rollup/plugin-json": "6.1.0",
27013
- "@rollup/plugin-node-resolve": "15.2.3",
27014
- "@types/babel__core": "^7",
27015
- "@types/babel__preset-env": "^7",
27016
- esbuild: "0.21.5",
27017
- rollup: "4.18.0",
27018
- "rollup-plugin-dts": "6.1.0",
27019
- "rollup-plugin-esbuild": "6.1.1",
27020
- typescript: "5.4.3"
27021
- };
27022
- var peerDependencies = {
27023
- webpack: ">= 4.x < 6.x"
27024
- };
27025
- var pkg = {
27026
- name: name,
27027
- packageManager: packageManager,
27028
- version: version,
27029
- license: license,
27030
- author: author,
27031
- description: description,
27032
- keywords: keywords,
27033
- homepage: homepage,
27034
- repository: repository,
27035
- main: main,
27036
- module: module$1,
27037
- exports: exports$1,
27038
- publishConfig: publishConfig,
27039
- files: files,
27040
- scripts: scripts,
27041
- devDependencies: devDependencies,
27042
- peerDependencies: peerDependencies
27043
- };
26960
+ var version = "2.2.1";
27044
26961
 
27045
26962
  const datadogWebpackPlugin = buildPluginFactory({
27046
- version: pkg.version
26963
+ version
27047
26964
  }).webpack;
27048
- module.exports = {
27049
- helpers,
27050
- datadogWebpackPlugin
27051
- };
26965
+ const helpers = helpers$1;
27052
26966
 
27053
26967
  exports.datadogWebpackPlugin = datadogWebpackPlugin;
27054
26968
  exports.helpers = helpers;
26969
+
26970
+
26971
+ if (typeof module !== 'undefined') {
26972
+ module.exports = {
26973
+ datadogWebpackPlugin,
26974
+ helpers
26975
+ };
26976
+ }
27055
26977
  //# sourceMappingURL=index.js.map