@datadog/esbuild-plugin 2.3.1-dev-10 → 2.3.1-dev-12

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.
@@ -11804,7 +11804,7 @@ const getWebpackPlugin$2 = (context, PLUGIN_NAME, log) => (compiler) => {
11804
11804
  const isModuleSupported = (moduleIdentifier) => {
11805
11805
  return (
11806
11806
  // Ignore unidentified modules and runtimes.
11807
- !!moduleIdentifier && !moduleIdentifier.startsWith("webpack/runtime") && !moduleIdentifier.includes("/webpack4/buildin/")
11807
+ !!moduleIdentifier && !moduleIdentifier.startsWith("webpack/runtime") && !moduleIdentifier.includes("/webpack4/buildin/") && !moduleIdentifier.startsWith("multi ")
11808
11808
  );
11809
11809
  };
11810
11810
  const warn = (warning) => {
@@ -11831,6 +11831,9 @@ const getWebpackPlugin$2 = (context, PLUGIN_NAME, log) => (compiler) => {
11831
11831
  return getModuleFromDep(dep)?.identifier();
11832
11832
  }).filter(Boolean)
11833
11833
  );
11834
+ if (!isModuleSupported(moduleIdentifier)) {
11835
+ continue;
11836
+ }
11834
11837
  for (const depIdentifier of dependencies) {
11835
11838
  const depDeps = tempDeps.get(depIdentifier) || {
11836
11839
  dependencies: /* @__PURE__ */ new Set(),
@@ -11839,9 +11842,6 @@ const getWebpackPlugin$2 = (context, PLUGIN_NAME, log) => (compiler) => {
11839
11842
  depDeps.dependents.add(moduleIdentifier);
11840
11843
  tempDeps.set(depIdentifier, depDeps);
11841
11844
  }
11842
- if (!isModuleSupported(moduleIdentifier)) {
11843
- continue;
11844
- }
11845
11845
  const moduleDeps = tempDeps.get(moduleIdentifier) || {
11846
11846
  dependents: /* @__PURE__ */ new Set(),
11847
11847
  dependencies: /* @__PURE__ */ new Set()
@@ -11894,9 +11894,10 @@ const getWebpackPlugin$2 = (context, PLUGIN_NAME, log) => (compiler) => {
11894
11894
  (f) => getAbsolutePath(context.bundler.outDir, f)
11895
11895
  );
11896
11896
  };
11897
+ const chunkGraph = result.chunkGraph;
11897
11898
  for (const chunk of chunks) {
11898
11899
  const files = getChunkFiles(chunk);
11899
- const chunkModules = chunk.getModules().flatMap((m) => {
11900
+ const chunkModules = (chunkGraph ? chunkGraph?.getChunkModules(chunk) : chunk.getModules()).flatMap((m) => {
11900
11901
  return "modules" in m && Array.isArray(m.modules) ? m.modules.map((m2) => m2.identifier()) : m.identifier();
11901
11902
  }).filter(isModuleSupported);
11902
11903
  for (const file of files) {
@@ -11950,7 +11951,12 @@ const getWebpackPlugin$2 = (context, PLUGIN_NAME, log) => (compiler) => {
11950
11951
  const entryInputs = [];
11951
11952
  let size = 0;
11952
11953
  const entryFiles = entrypoint.chunks.flatMap(getChunkFiles);
11953
- const entryFilename = entrypoint.chunks.filter((c) => c.entryModule).flatMap((c) => Array.from(c.files))[0];
11954
+ const entryFilename = entrypoint.chunks.filter(
11955
+ (c) => (
11956
+ // Webpack5 forces you to use the chunkGraph to get the modules.
11957
+ chunkGraph ? chunkGraph.getNumberOfEntryModules(c) > 0 : c.hasEntryModule()
11958
+ )
11959
+ ).flatMap((c) => Array.from(c.files))[0];
11954
11960
  for (const file2 of entryFiles) {
11955
11961
  const outputFound = reportOutputsIndexed.get(file2);
11956
11962
  if (!file2 || !outputFound) {
@@ -19080,22 +19086,36 @@ ${after}`;
19080
19086
  },
19081
19087
  webpack: (compiler) => {
19082
19088
  const BannerPlugin = compiler?.webpack?.BannerPlugin || bundler?.BannerPlugin || bundler?.default?.BannerPlugin;
19089
+ compiler?.webpack?.ChunkGraph || bundler?.ChunkGraph || bundler?.default?.ChunkGraph;
19083
19090
  if (!BannerPlugin) {
19084
19091
  log("Missing BannerPlugin", "error");
19085
19092
  }
19093
+ let chunkGraph;
19094
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME$4, (compilation) => {
19095
+ compilation.hooks.afterChunks.tap(PLUGIN_NAME$4, () => {
19096
+ chunkGraph = compilation.chunkGraph;
19097
+ });
19098
+ });
19086
19099
  compiler.options.plugins = compiler.options.plugins || [];
19087
19100
  compiler.options.plugins.push(
19088
19101
  new BannerPlugin({
19089
19102
  // Not wrapped in comments.
19090
19103
  raw: true,
19091
- // Not sure this is actually working, but it's supposed to only add
19104
+ // Doesn't seem to work, but it's supposed to only add
19092
19105
  // the banner to entry modules.
19093
19106
  entryOnly: true,
19094
- banner({ chunk }) {
19095
- if (!chunk?.entryModule) {
19096
- return "";
19107
+ banner(data) {
19108
+ if (context.bundler.variant === "5") {
19109
+ if (!chunkGraph || chunkGraph.getNumberOfEntryModules(data.chunk) === 0) {
19110
+ return "";
19111
+ }
19112
+ return getContentToInject();
19113
+ } else {
19114
+ if (!data.chunk?.hasEntryModule()) {
19115
+ return "";
19116
+ }
19117
+ return getContentToInject();
19097
19118
  }
19098
- return getContentToInject();
19099
19119
  }
19100
19120
  })
19101
19121
  );
@@ -36399,7 +36419,7 @@ const buildPluginFactory = ({
36399
36419
 
36400
36420
  var name = "@datadog/esbuild-plugin";
36401
36421
  var packageManager = "yarn@4.0.2";
36402
- var version$1 = "2.3.1-dev-10";
36422
+ var version$1 = "2.3.1-dev-12";
36403
36423
  var license = "MIT";
36404
36424
  var author = "Datadog";
36405
36425
  var description = "Datadog ESBuild Plugin";