@datadog/esbuild-plugin 2.2.0-dev-1 → 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.
@@ -1,5 +1,4 @@
1
1
  import * as esbuild from 'esbuild';
2
- import * as src from 'src';
3
2
 
4
3
  declare const CONFIG_KEY$1: "rum";
5
4
 
@@ -73,13 +72,24 @@ type TelemetryOptions = {
73
72
  filters?: Filter[];
74
73
  };
75
74
 
75
+ declare const datadogEsbuildPlugin: (options: Options) => esbuild.Plugin;
76
+
76
77
  declare const helpers: {
77
78
  telemetry: {
78
79
  filters: ((metric: Metric) => Metric | null)[];
79
80
  };
80
81
  };
81
82
 
82
- declare const datadogEsbuildPlugin: (options: src.EsbuildPluginOptions) => esbuild.Plugin;
83
-
84
83
  export { type Options as EsbuildPluginOptions, type types$1 as RumTypes, type types as TelemetryTypes, datadogEsbuildPlugin, helpers };
84
+
85
+
86
+ if (typeof module !== 'undefined') {
87
+ module.exports = {
88
+ EsbuildPluginOptions,
89
+ RumTypes,
90
+ TelemetryTypes,
91
+ datadogEsbuildPlugin,
92
+ helpers
93
+ };
94
+ }
85
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) => {
@@ -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
  }
@@ -26957,7 +26959,7 @@ const buildPluginFactory = ({
26957
26959
 
26958
26960
  var name = "@datadog/esbuild-plugin";
26959
26961
  var packageManager = "yarn@4.0.2";
26960
- var version = "2.2.0-dev-1";
26962
+ var version = "2.2.1";
26961
26963
  var license = "MIT";
26962
26964
  var author = "Datadog";
26963
26965
  var description = "Datadog ESBuild Plugin";
@@ -27022,7 +27024,6 @@ var devDependencies = {
27022
27024
  var peerDependencies = {
27023
27025
  esbuild: ">=0.x"
27024
27026
  };
27025
- var stableVersion = "2.1.0";
27026
27027
  var pkg = {
27027
27028
  name: name,
27028
27029
  packageManager: packageManager,
@@ -27040,18 +27041,22 @@ var pkg = {
27040
27041
  files: files,
27041
27042
  scripts: scripts,
27042
27043
  devDependencies: devDependencies,
27043
- peerDependencies: peerDependencies,
27044
- stableVersion: stableVersion
27044
+ peerDependencies: peerDependencies
27045
27045
  };
27046
27046
 
27047
27047
  const datadogEsbuildPlugin = buildPluginFactory({
27048
27048
  version: pkg.version
27049
27049
  }).esbuild;
27050
- module.exports = {
27051
- helpers,
27052
- datadogEsbuildPlugin
27053
- };
27050
+ const helpers = helpers$1;
27054
27051
 
27055
27052
  exports.datadogEsbuildPlugin = datadogEsbuildPlugin;
27056
27053
  exports.helpers = helpers;
27054
+
27055
+
27056
+ if (typeof module !== 'undefined') {
27057
+ module.exports = {
27058
+ datadogEsbuildPlugin,
27059
+ helpers
27060
+ };
27061
+ }
27057
27062
  //# sourceMappingURL=index.js.map