@datadog/esbuild-plugin 0.0.13-8 → 2.0.0
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 +2 -2
- package/dist/src/index.js +21 -8
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +21 -8
- package/dist/src/index.mjs.map +1 -1
- package/package.json +7 -6
package/dist/src/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as esbuild from 'esbuild';
|
|
2
|
-
import * as src from 'src';
|
|
3
2
|
|
|
4
3
|
type LogLevel = 'debug' | 'warn' | 'error' | 'none';
|
|
5
4
|
interface GetPluginsOptions {
|
|
@@ -28,6 +27,7 @@ type OutputOptions = boolean | string | {
|
|
|
28
27
|
dependencies?: boolean;
|
|
29
28
|
bundler?: boolean;
|
|
30
29
|
metrics?: boolean;
|
|
30
|
+
logs?: boolean;
|
|
31
31
|
};
|
|
32
32
|
type TelemetryOptions = {
|
|
33
33
|
disabled?: boolean;
|
|
@@ -59,7 +59,7 @@ declare const helpers: {
|
|
|
59
59
|
};
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
declare const datadogEsbuildPlugin: (options:
|
|
62
|
+
declare const datadogEsbuildPlugin: (options: Options) => esbuild.Plugin;
|
|
63
63
|
|
|
64
64
|
export { type Options as EsbuildPluginOptions, type types as TelemetryTypes, datadogEsbuildPlugin, helpers };
|
|
65
65
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.js
CHANGED
|
@@ -36,7 +36,7 @@ function _interopNamespaceDefault(e) {
|
|
|
36
36
|
var querystring__namespace = /*#__PURE__*/_interopNamespaceDefault(querystring);
|
|
37
37
|
|
|
38
38
|
const CONFIG_KEY = "telemetry";
|
|
39
|
-
const PLUGIN_NAME =
|
|
39
|
+
const PLUGIN_NAME = `datadog-${CONFIG_KEY}-plugin`;
|
|
40
40
|
|
|
41
41
|
const filterTreeMetrics = (metric) => (
|
|
42
42
|
// Remove tree metrics because way too verbose
|
|
@@ -6011,11 +6011,22 @@ const outputModulesTimings = (timings) => {
|
|
|
6011
6011
|
output += getOutput(times, (module) => module.increment);
|
|
6012
6012
|
return output;
|
|
6013
6013
|
};
|
|
6014
|
+
const shouldShowOutput = (output) => {
|
|
6015
|
+
if (typeof output === "boolean") {
|
|
6016
|
+
return output;
|
|
6017
|
+
}
|
|
6018
|
+
if (typeof output === "string") {
|
|
6019
|
+
return true;
|
|
6020
|
+
}
|
|
6021
|
+
if (!output) {
|
|
6022
|
+
return true;
|
|
6023
|
+
}
|
|
6024
|
+
return output.logs !== false;
|
|
6025
|
+
};
|
|
6014
6026
|
const outputTexts = (context, options) => {
|
|
6015
6027
|
const { output } = options[CONFIG_KEY];
|
|
6016
6028
|
const { report, bundler } = context;
|
|
6017
|
-
|
|
6018
|
-
if (output === false) {
|
|
6029
|
+
if (!shouldShowOutput(output)) {
|
|
6019
6030
|
return;
|
|
6020
6031
|
}
|
|
6021
6032
|
let outputString = "";
|
|
@@ -6031,7 +6042,7 @@ const outputTexts = (context, options) => {
|
|
|
6031
6042
|
if (bundler.esbuild) {
|
|
6032
6043
|
outputString += outputEsbuild(bundler.esbuild);
|
|
6033
6044
|
}
|
|
6034
|
-
log(outputString);
|
|
6045
|
+
console.log(outputString);
|
|
6035
6046
|
};
|
|
6036
6047
|
|
|
6037
6048
|
const output = async (context, options) => {
|
|
@@ -6102,10 +6113,13 @@ const wrapPlugins = (build, context) => {
|
|
|
6102
6113
|
};
|
|
6103
6114
|
});
|
|
6104
6115
|
for (const plugin of plugins) {
|
|
6105
|
-
|
|
6116
|
+
if (plugin.name === PLUGIN_NAME) {
|
|
6117
|
+
continue;
|
|
6118
|
+
}
|
|
6106
6119
|
const oldSetup = plugin.setup;
|
|
6107
|
-
plugin.setup = () => {
|
|
6108
|
-
|
|
6120
|
+
plugin.setup = async (esbuild) => {
|
|
6121
|
+
const newBuildObject = getNewBuildObject(esbuild, plugin.name, context);
|
|
6122
|
+
await oldSetup({
|
|
6109
6123
|
...newBuildObject,
|
|
6110
6124
|
// Use non-modified plugins for other plugins
|
|
6111
6125
|
initialOptions: { ...newBuildObject.initialOptions, plugins: initialPlugins }
|
|
@@ -6571,7 +6585,6 @@ const getPlugins = (opt) => {
|
|
|
6571
6585
|
return [
|
|
6572
6586
|
{
|
|
6573
6587
|
name: PLUGIN_NAME,
|
|
6574
|
-
enforce: "pre",
|
|
6575
6588
|
esbuild: getEsbuildPlugin$1(opt),
|
|
6576
6589
|
webpack: getWebpackPlugin$1(opt)
|
|
6577
6590
|
}
|