Skip to content

fix(FR-2873): avoid esbuild glob analysis of plugin import path in LoginView#7377

Merged
yomybaby merged 1 commit into
mainfrom
05-12-fix_fr-2873_avoid_esbuild_glob_analysis_of_plugin_import_path_in_loginview
May 12, 2026
Merged

fix(FR-2873): avoid esbuild glob analysis of plugin import path in LoginView#7377
yomybaby merged 1 commit into
mainfrom
05-12-fix_fr-2873_avoid_esbuild_glob_analysis_of_plugin_import_path_in_loginview

Conversation

@yomybaby
Copy link
Copy Markdown
Member

@yomybaby yomybaby commented May 12, 2026

Resolves #7376(FR-2873)

Summary

pnpm dev started failing on main after #7332 (FR-2856) with:

✘ [ERROR] Could not resolve import("../../../src/plugins/**/*")

    src/components/LoginView.tsx:198:6:
      198 │       `../../../src/plugins/${sanitizedPlugin}`
          ╵       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Root cause

LoginView.tsx's dynamic import() was a template literal with a static prefix (`../../../src/plugins/${sanitizedPlugin}`). esbuild's optimizeDeps scanner treats this as a glob (../../../src/plugins/**/*) and fails because webui-ai/src/plugins/ only exists in production builds.

@vite-ignore suppresses Vite's static-analysis warning, but esbuild's scanner does not honor it — so the latent issue surfaced as soon as #7332 invalidated the install / Vite cache and the scanner re-ran.

The companion file PluginLoader.tsx already uses the correct pattern (assign to a variable first, then import(/* @vite-ignore */ pluginUrl)); only LoginView.tsx had the inline template literal.

Fix

Match PluginLoader.tsx: assign the path to a variable first so neither Vite nor esbuild can statically analyze the specifier.

const pluginUrl = `../../../src/plugins/${sanitizedPlugin}`;
import(/* @vite-ignore */ pluginUrl).catch(() => {
  setLoginError({ message: t('error.LoginFailed') });
});

Runtime behavior is unchanged — sanitization still happens before path interpolation, and the production loader (<base>/dist/plugins/<name>.js) is unaffected (different code path in PluginLoader.tsx).

Test plan

  • pnpm dev boots without the Could not resolve import("../../../src/plugins/**/*") esbuild error
  • Login page renders normally with no loginPlugin configured
  • With loginPlugin = "<some-plugin>" in config.toml, the dynamic import still resolves at runtime (path-traversal sanitization unchanged)

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 12, 2026 09:28
@github-actions github-actions Bot added the size:S 10~30 LoC label May 12, 2026
Copy link
Copy Markdown
Member Author

yomybaby commented May 12, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • flow:merge-queue - adds this PR to the back of the merge queue
  • flow:hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@yomybaby yomybaby added size:XS ~10 LoC type:fix Fix features that are not working labels May 12, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts LoginView’s login-plugin dynamic import to avoid Vite/esbuild dependency scanner (optimizeDeps) statically analyzing the import specifier as a glob during development.

Changes:

  • Refactors the dynamic import() call to use a runtime-computed pluginUrl variable instead of an inline template literal.
  • Adds inline documentation explaining why @vite-ignore alone is insufficient and why the specifier must not be statically analyzable.

Comment on lines +195 to +197
// is treated by esbuild as a glob and fails to resolve in dev because
// `webui-ai/src/plugins/` only exists in production builds. `@vite-ignore`
// alone is not enough — esbuild's scanner does not honor that comment.
/* @vite-ignore */
`../../../src/plugins/${sanitizedPlugin}`
).catch(() => {
// Build the plugin path at runtime, in a variable, so neither Vite nor
@yomybaby yomybaby merged commit f03bfb0 into main May 12, 2026
19 of 20 checks passed
@yomybaby yomybaby deleted the 05-12-fix_fr-2873_avoid_esbuild_glob_analysis_of_plugin_import_path_in_loginview branch May 12, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10~30 LoC size:XS ~10 LoC type:fix Fix features that are not working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix dev server failing to start due to esbuild scanning template-literal plugin import path

2 participants