@datadog/esbuild-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.
- package/dist/src/index.d.ts +33 -22
- package/dist/src/index.js +43 -36
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +43 -36
- package/dist/src/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -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
|
-
|
|
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 datadogEsbuildPlugin: (options: Options) => esbuild.Plugin;
|
|
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 datadogEsbuildPlugin: (options: Options) => esbuild.Plugin;
|
|
82
|
-
|
|
83
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
|
+
}
|
|
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$
|
|
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$
|
|
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
|
-
|
|
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[
|
|
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$
|
|
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$
|
|
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((
|
|
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.
|
|
26962
|
+
var version = "2.2.1";
|
|
26961
26963
|
var license = "MIT";
|
|
26962
26964
|
var author = "Datadog";
|
|
26963
26965
|
var description = "Datadog ESBuild Plugin";
|
|
@@ -27045,11 +27047,16 @@ var pkg = {
|
|
|
27045
27047
|
const datadogEsbuildPlugin = buildPluginFactory({
|
|
27046
27048
|
version: pkg.version
|
|
27047
27049
|
}).esbuild;
|
|
27048
|
-
|
|
27049
|
-
helpers,
|
|
27050
|
-
datadogEsbuildPlugin
|
|
27051
|
-
};
|
|
27050
|
+
const helpers = helpers$1;
|
|
27052
27051
|
|
|
27053
27052
|
exports.datadogEsbuildPlugin = datadogEsbuildPlugin;
|
|
27054
27053
|
exports.helpers = helpers;
|
|
27054
|
+
|
|
27055
|
+
|
|
27056
|
+
if (typeof module !== 'undefined') {
|
|
27057
|
+
module.exports = {
|
|
27058
|
+
datadogEsbuildPlugin,
|
|
27059
|
+
helpers
|
|
27060
|
+
};
|
|
27061
|
+
}
|
|
27055
27062
|
//# sourceMappingURL=index.js.map
|