@datadog/esbuild-plugin 2.3.1-dev-10 → 2.3.1-dev-13
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.js +33 -13
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +33 -13
- package/dist/src/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -2296,7 +2296,6 @@ var retry$2 = /*@__PURE__*/getDefaultExportFromCjs(lib$3);
|
|
|
2296
2296
|
const PREPARATION_PLUGIN_NAME = "datadog-injection-preparation-plugin";
|
|
2297
2297
|
const PLUGIN_NAME$4 = "datadog-injection-plugin";
|
|
2298
2298
|
const INJECTED_FILE = "__datadog-helper-file";
|
|
2299
|
-
const INJECTED_FILE_PATH = `${INJECTED_FILE}.js`;
|
|
2300
2299
|
const DISTANT_FILE_RX = /^https?:\/\//;
|
|
2301
2300
|
|
|
2302
2301
|
const formatDuration = (duration) => {
|
|
@@ -11827,7 +11826,7 @@ const getWebpackPlugin$2 = (context, PLUGIN_NAME, log) => (compiler) => {
|
|
|
11827
11826
|
const isModuleSupported = (moduleIdentifier) => {
|
|
11828
11827
|
return (
|
|
11829
11828
|
// Ignore unidentified modules and runtimes.
|
|
11830
|
-
!!moduleIdentifier && !moduleIdentifier.startsWith("webpack/runtime") && !moduleIdentifier.includes("/webpack4/buildin/")
|
|
11829
|
+
!!moduleIdentifier && !moduleIdentifier.startsWith("webpack/runtime") && !moduleIdentifier.includes("/webpack4/buildin/") && !moduleIdentifier.startsWith("multi ")
|
|
11831
11830
|
);
|
|
11832
11831
|
};
|
|
11833
11832
|
const warn = (warning) => {
|
|
@@ -11854,6 +11853,9 @@ const getWebpackPlugin$2 = (context, PLUGIN_NAME, log) => (compiler) => {
|
|
|
11854
11853
|
return getModuleFromDep(dep)?.identifier();
|
|
11855
11854
|
}).filter(Boolean)
|
|
11856
11855
|
);
|
|
11856
|
+
if (!isModuleSupported(moduleIdentifier)) {
|
|
11857
|
+
continue;
|
|
11858
|
+
}
|
|
11857
11859
|
for (const depIdentifier of dependencies) {
|
|
11858
11860
|
const depDeps = tempDeps.get(depIdentifier) || {
|
|
11859
11861
|
dependencies: /* @__PURE__ */ new Set(),
|
|
@@ -11862,9 +11864,6 @@ const getWebpackPlugin$2 = (context, PLUGIN_NAME, log) => (compiler) => {
|
|
|
11862
11864
|
depDeps.dependents.add(moduleIdentifier);
|
|
11863
11865
|
tempDeps.set(depIdentifier, depDeps);
|
|
11864
11866
|
}
|
|
11865
|
-
if (!isModuleSupported(moduleIdentifier)) {
|
|
11866
|
-
continue;
|
|
11867
|
-
}
|
|
11868
11867
|
const moduleDeps = tempDeps.get(moduleIdentifier) || {
|
|
11869
11868
|
dependents: /* @__PURE__ */ new Set(),
|
|
11870
11869
|
dependencies: /* @__PURE__ */ new Set()
|
|
@@ -11917,9 +11916,10 @@ const getWebpackPlugin$2 = (context, PLUGIN_NAME, log) => (compiler) => {
|
|
|
11917
11916
|
(f) => getAbsolutePath(context.bundler.outDir, f)
|
|
11918
11917
|
);
|
|
11919
11918
|
};
|
|
11919
|
+
const chunkGraph = result.chunkGraph;
|
|
11920
11920
|
for (const chunk of chunks) {
|
|
11921
11921
|
const files = getChunkFiles(chunk);
|
|
11922
|
-
const chunkModules = chunk.getModules().flatMap((m) => {
|
|
11922
|
+
const chunkModules = (chunkGraph ? chunkGraph?.getChunkModules(chunk) : chunk.getModules()).flatMap((m) => {
|
|
11923
11923
|
return "modules" in m && Array.isArray(m.modules) ? m.modules.map((m2) => m2.identifier()) : m.identifier();
|
|
11924
11924
|
}).filter(isModuleSupported);
|
|
11925
11925
|
for (const file of files) {
|
|
@@ -11973,7 +11973,12 @@ const getWebpackPlugin$2 = (context, PLUGIN_NAME, log) => (compiler) => {
|
|
|
11973
11973
|
const entryInputs = [];
|
|
11974
11974
|
let size = 0;
|
|
11975
11975
|
const entryFiles = entrypoint.chunks.flatMap(getChunkFiles);
|
|
11976
|
-
const entryFilename = entrypoint.chunks.filter(
|
|
11976
|
+
const entryFilename = entrypoint.chunks.filter(
|
|
11977
|
+
(c) => (
|
|
11978
|
+
// Webpack5 forces you to use the chunkGraph to get the modules.
|
|
11979
|
+
chunkGraph ? chunkGraph.getNumberOfEntryModules(c) > 0 : c.hasEntryModule()
|
|
11980
|
+
)
|
|
11981
|
+
).flatMap((c) => Array.from(c.files))[0];
|
|
11977
11982
|
for (const file2 of entryFiles) {
|
|
11978
11983
|
const outputFound = reportOutputsIndexed.get(file2);
|
|
11979
11984
|
if (!file2 || !outputFound) {
|
|
@@ -19046,6 +19051,7 @@ ${after}`;
|
|
|
19046
19051
|
return "";
|
|
19047
19052
|
}
|
|
19048
19053
|
};
|
|
19054
|
+
const INJECTED_FILE_PATH = `${Math.random().toString().replace("0.", "")}_${INJECTED_FILE}.js`;
|
|
19049
19055
|
const plugins = [
|
|
19050
19056
|
// Prepare and fetch the content to inject for all bundlers.
|
|
19051
19057
|
{
|
|
@@ -19103,22 +19109,36 @@ ${after}`;
|
|
|
19103
19109
|
},
|
|
19104
19110
|
webpack: (compiler) => {
|
|
19105
19111
|
const BannerPlugin = compiler?.webpack?.BannerPlugin || bundler?.BannerPlugin || bundler?.default?.BannerPlugin;
|
|
19112
|
+
compiler?.webpack?.ChunkGraph || bundler?.ChunkGraph || bundler?.default?.ChunkGraph;
|
|
19106
19113
|
if (!BannerPlugin) {
|
|
19107
19114
|
log("Missing BannerPlugin", "error");
|
|
19108
19115
|
}
|
|
19116
|
+
let chunkGraph;
|
|
19117
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME$4, (compilation) => {
|
|
19118
|
+
compilation.hooks.afterChunks.tap(PLUGIN_NAME$4, () => {
|
|
19119
|
+
chunkGraph = compilation.chunkGraph;
|
|
19120
|
+
});
|
|
19121
|
+
});
|
|
19109
19122
|
compiler.options.plugins = compiler.options.plugins || [];
|
|
19110
19123
|
compiler.options.plugins.push(
|
|
19111
19124
|
new BannerPlugin({
|
|
19112
19125
|
// Not wrapped in comments.
|
|
19113
19126
|
raw: true,
|
|
19114
|
-
//
|
|
19127
|
+
// Doesn't seem to work, but it's supposed to only add
|
|
19115
19128
|
// the banner to entry modules.
|
|
19116
19129
|
entryOnly: true,
|
|
19117
|
-
banner(
|
|
19118
|
-
if (
|
|
19119
|
-
|
|
19130
|
+
banner(data) {
|
|
19131
|
+
if (context.bundler.variant === "5") {
|
|
19132
|
+
if (!chunkGraph || chunkGraph.getNumberOfEntryModules(data.chunk) === 0) {
|
|
19133
|
+
return "";
|
|
19134
|
+
}
|
|
19135
|
+
return getContentToInject();
|
|
19136
|
+
} else {
|
|
19137
|
+
if (!data.chunk?.hasEntryModule()) {
|
|
19138
|
+
return "";
|
|
19139
|
+
}
|
|
19140
|
+
return getContentToInject();
|
|
19120
19141
|
}
|
|
19121
|
-
return getContentToInject();
|
|
19122
19142
|
}
|
|
19123
19143
|
})
|
|
19124
19144
|
);
|
|
@@ -36422,7 +36442,7 @@ const buildPluginFactory = ({
|
|
|
36422
36442
|
|
|
36423
36443
|
var name = "@datadog/esbuild-plugin";
|
|
36424
36444
|
var packageManager = "yarn@4.0.2";
|
|
36425
|
-
var version$1 = "2.3.1-dev-
|
|
36445
|
+
var version$1 = "2.3.1-dev-13";
|
|
36426
36446
|
var license = "MIT";
|
|
36427
36447
|
var author = "Datadog";
|
|
36428
36448
|
var description = "Datadog ESBuild Plugin";
|