Skip to content

fix(FR-2903): align login plugin loader with page plugin runtime fetch pattern#7433

Open
nowgnuesLee wants to merge 1 commit into
mainfrom
05-15-fix_fr-2903_use_import.meta.glob_to_avoid_esbuild_glob_scan_on_src_plugins
Open

fix(FR-2903): align login plugin loader with page plugin runtime fetch pattern#7433
nowgnuesLee wants to merge 1 commit into
mainfrom
05-15-fix_fr-2903_use_import.meta.glob_to_avoid_esbuild_glob_scan_on_src_plugins

Conversation

@nowgnuesLee
Copy link
Copy Markdown
Contributor

@nowgnuesLee nowgnuesLee commented May 15, 2026

Resolves #7432(FR-2903)

Summary

Realign the login-screen plugin.login slot with the existing page plugin loading model (PluginLoader.tsx): runtime URL fetch from /dist/plugins/<name>.js (or ${apiEndpoint}/dist/plugins/<name>.js in Electron). Replaces the original import('../../../src/plugins/${name}') flow that crashed Vite's dev server when <repo>/src/plugins/ was missing — because esbuild's optimizeDeps scanner treated the static prefix as a glob and tried to walk an absent directory.

Why runtime fetch instead of import.meta.glob?

import.meta.glob enumerates at build time — fine when the build machine has plugins, but breaks the deployment model where customer-specific plugins are deployed to the running WebServer's static dir after the WebUI bundle ships. Runtime URL fetch matches the page-plugin convention and decouples plugin distribution from the WebUI release cadence.

Changes

  • react/src/components/LoginView.tsx — replace the relative-prefixed dynamic import with import(/* @vite-ignore */ pluginUrl) where pluginUrl mirrors PluginLoader.tsx's URL resolution.
  • i18n — add error.LoginPluginLoadFailed ("Failed to load login plugin." / "로그인 플러그인을 가져오지 못했습니다.") to 21 locales. Used by the plugin-load .catch so users see a deployment-issue-specific message instead of the generic LoginFailed.
  • e2e/plugin/login-plugin.spec.ts + e2e/plugin/backend-ai-homepage-link.js — first regression test for the slot. Mirrors the existing page-plugin test pattern (modifyConfigToml + page.route interception). The fixture (a side-effect IIFE appending a "Visit backend.ai" link to the login form) doubles as a living plugin-contract reference for future authors.
  • config.toml.sample — annotate #login with an inline comment: Inject a JavaScript file into the login page. so the slot's purpose is discoverable without reading source.
  • Deprecate plugin.sidebar — remove the #sidebar = "report-cloud.js" fossil line from configs/{default,main,debug}.toml. The slot was briefly wired up in 2020 (PR Plugin architecture for menus #315) but the handler was merged into the page system within the same PR (commit 20c3e15b9); no code has read this key in any era since. Keeping the line in samples misled future readers into thinking it was a live extension surface.
  • AGENTS.md (= CLAUDE.md symlink) — update stale Craco/Webpack/Jest references to Vite 6 + vite-plugin-pwa + Vitest 4 so the agent guidance reflects the current stack.

Test plan

  • bash scripts/verify.sh passes
  • e2e/plugin/login-plugin.spec.ts passes (2/2, ~3s) — positive injection + negative-when-slot-unset cases
  • pnpm dev boots cleanly when <repo>/src/plugins/ is empty or missing
  • Verify in connected backend: set [plugin] login = "...", deploy plugin file to WebServer's /dist/plugins/, confirm link injection
  • No regression in existing page plugin tests (e2e/plugin/plugin-system.spec.ts)

Notes

  • Commit subject still mentions import.meta.glob from the initial direction. Scope grew during review to the architectural realignment above.
  • <repo>/src/plugins/ directory is now unused by any code path. Follow-up cleanup PR could remove the directory + the .gitignore entries that reserved it.
  • The react/src/diagnostics/rules/configRules.ts validator still has a plugin.sidebar entry that validates the (now-removed) sample line's filename format. Candidate for the same follow-up cleanup PR.

CleanShot 2026-05-18 at 19.43.13@2x.png

CleanShot 2026-05-18 at 19.09.18@2x.png

Copy link
Copy Markdown
Contributor Author


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.

@github-actions github-actions Bot added the size:M 30~100 LoC label May 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Coverage Report for react-coverage (./react)

Status Category Percentage Covered / Total
🔵 Lines 6.52% 1785 / 27369
🔵 Statements 5.36% 1980 / 36901
🔵 Functions 5.25% 296 / 5630
🔵 Branches 3.74% 1293 / 34498
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
react/src/components/LoginView.tsx 0% 0% 0% 0% 55-1105
Generated in workflow #787 for commit 7b39d86 by the Vitest Coverage Report Action

@nowgnuesLee nowgnuesLee marked this pull request as ready for review May 18, 2026 05:43
Copilot AI review requested due to automatic review settings May 18, 2026 05:43
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

Replaces the dynamic import() in LoginView.tsx with Vite's import.meta.glob to prevent esbuild's optimizeDeps scanner from glob-scanning the src/plugins/ directory, which is .gitignored and often absent in dev trees. Also updates AGENTS.md to reflect the current Vite/Vitest stack instead of stale Craco/Webpack/Jest references.

Changes:

  • Use import.meta.glob('../../../src/plugins/*.js') to build a static loader map at compile time, falling back gracefully when the plugin file is missing.
  • Update AGENTS.md to document the current Vite 6 + vite-plugin-pwa + Vitest 4 stack.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
react/src/components/LoginView.tsx Switches login plugin loading from dynamic import() to import.meta.glob, with explicit .js key lookup and missing-loader fallback.
AGENTS.md Updates build/test/tooling references from Craco/Webpack/Jest to Vite/Vitest.

@nowgnuesLee nowgnuesLee force-pushed the 05-15-fix_fr-2903_use_import.meta.glob_to_avoid_esbuild_glob_scan_on_src_plugins branch from 7b39d86 to 976098e Compare May 18, 2026 10:07
@github-actions github-actions Bot added quick-capture size:L 100~500 LoC and removed size:M 30~100 LoC labels May 18, 2026
@nowgnuesLee nowgnuesLee force-pushed the 05-15-fix_fr-2903_use_import.meta.glob_to_avoid_esbuild_glob_scan_on_src_plugins branch from 976098e to 9869e4e Compare May 18, 2026 10:42
@github-actions github-actions Bot added area:ux UI / UX issue. area:i18n Localization labels May 18, 2026
@nowgnuesLee nowgnuesLee changed the title fix(FR-2903): use import.meta.glob to avoid esbuild glob scan on src/plugins fix(FR-2903): align login plugin loader with page plugin runtime fetch pattern May 18, 2026
@nowgnuesLee nowgnuesLee force-pushed the 05-15-fix_fr-2903_use_import.meta.glob_to_avoid_esbuild_glob_scan_on_src_plugins branch from 9869e4e to cbd6ff2 Compare May 18, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:i18n Localization area:ux UI / UX issue. quick-capture size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use import.meta.glob for login plugin loader to bypass esbuild glob scan

2 participants