@datadog/vite-plugin 2.3.1-dev-7 → 2.3.1-dev-8

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.
@@ -96,6 +96,7 @@ type GlobalContext = {
96
96
  build: BuildReport;
97
97
  cwd: string;
98
98
  git?: RepositoryData;
99
+ pluginNames: string[];
99
100
  start: number;
100
101
  version: string;
101
102
  };
package/dist/src/index.js CHANGED
@@ -2377,6 +2377,14 @@ const truncateString = (str, maxLength = 60, placeholder = "[...]") => {
2377
2377
  return `${str.slice(0, leftStop)}${placeholder}${str.slice(-rightStop)}`;
2378
2378
  };
2379
2379
  const isInjection = (filename) => filename.includes(INJECTED_FILE);
2380
+ const isInternalPlugin = (pluginName, context) => {
2381
+ for (const internalPluginName of context.pluginNames) {
2382
+ if (pluginName.includes(internalPluginName)) {
2383
+ return true;
2384
+ }
2385
+ }
2386
+ return false;
2387
+ };
2380
2388
 
2381
2389
  var balancedMatch = balanced$1;
2382
2390
  function balanced$1(a, b, str) {
@@ -12066,7 +12074,7 @@ const getBuildReportPlugin = (opts, context) => {
12066
12074
  };
12067
12075
  };
12068
12076
 
12069
- const PLUGIN_NAME$2 = "datadog-context-plugin";
12077
+ const PLUGIN_NAME$2 = "datadog-bundler-report-plugin";
12070
12078
  const rollupPlugin = (context) => ({
12071
12079
  options(options) {
12072
12080
  context.bundler.rawConfig = options;
@@ -19133,8 +19141,20 @@ const getInjectionPlugins = (opts, context, toInject) => {
19133
19141
  esbuild: {
19134
19142
  setup(build) {
19135
19143
  const { initialOptions } = build;
19144
+ const initialInject = initialOptions.inject ? [...initialOptions.inject] : [];
19145
+ const plugins = initialOptions.plugins || [];
19136
19146
  initialOptions.inject = initialOptions.inject || [];
19137
19147
  initialOptions.inject.push(INJECTED_FILE);
19148
+ for (const plugin of plugins) {
19149
+ const oldSetup = plugin.setup;
19150
+ if (isInternalPlugin(plugin.name, context)) {
19151
+ continue;
19152
+ }
19153
+ plugin.setup = async (esbuild) => {
19154
+ esbuild.initialOptions.inject = initialInject;
19155
+ await oldSetup(esbuild);
19156
+ };
19157
+ }
19138
19158
  }
19139
19159
  },
19140
19160
  webpack: (compiler) => {
@@ -19190,6 +19210,7 @@ const getInternalPlugins = (options, meta) => {
19190
19210
  const toInject = [];
19191
19211
  const globalContext = {
19192
19212
  auth: options.auth,
19213
+ pluginNames: [],
19193
19214
  bundler: {
19194
19215
  name: meta.framework,
19195
19216
  fullName: `${meta.framework}${variant}`,
@@ -36440,18 +36461,20 @@ const validateOptions = (options = {}) => {
36440
36461
  ...options
36441
36462
  };
36442
36463
  };
36464
+ const HOST_NAME = "datadog-build-plugins";
36443
36465
  const buildPluginFactory = ({
36444
36466
  version
36445
36467
  }) => {
36446
36468
  return createUnplugin((opts, unpluginMetaContext) => {
36447
36469
  const options = validateOptions(opts);
36448
- if ("esbuildHostName" in unpluginMetaContext) {
36449
- unpluginMetaContext.esbuildHostName = "datadog-plugins";
36470
+ if (unpluginMetaContext.framework === "esbuild") {
36471
+ unpluginMetaContext.esbuildHostName = HOST_NAME;
36450
36472
  }
36451
36473
  const { globalContext, internalPlugins } = getInternalPlugins(options, {
36452
36474
  version,
36453
36475
  ...unpluginMetaContext
36454
36476
  });
36477
+ globalContext.pluginNames.push(HOST_NAME);
36455
36478
  const plugins = [...internalPlugins];
36456
36479
  if (options.customPlugins) {
36457
36480
  const customPlugins = options.customPlugins(options, globalContext);
@@ -36463,13 +36486,14 @@ const buildPluginFactory = ({
36463
36486
  if (options[CONFIG_KEY] && options[CONFIG_KEY].disabled !== true) {
36464
36487
  plugins.push(...getPlugins(options, globalContext));
36465
36488
  }
36489
+ globalContext.pluginNames.push(...plugins.map((plugin) => plugin.name));
36466
36490
  return plugins;
36467
36491
  });
36468
36492
  };
36469
36493
 
36470
36494
  var name = "@datadog/vite-plugin";
36471
36495
  var packageManager = "yarn@4.0.2";
36472
- var version$1 = "2.3.1-dev-7";
36496
+ var version$1 = "2.3.1-dev-8";
36473
36497
  var license = "MIT";
36474
36498
  var author = "Datadog";
36475
36499
  var description = "Datadog Vite Plugin";