Skip to content

fix(cd): adding path resolution plugin for scoped fallback#1197

Merged
ChronosSF merged 2 commits intovnextfrom
sstoychev/fix-astro-licensed-paths
Mar 25, 2026
Merged

fix(cd): adding path resolution plugin for scoped fallback#1197
ChronosSF merged 2 commits intovnextfrom
sstoychev/fix-astro-licensed-paths

Conversation

@ChronosSF
Copy link
Copy Markdown
Member

Fix: Resolve @infragistics/ scoped package aliases for Vite/Rollup

Problem

The project supports two package installation modes — unscoped (igniteui-dockmanager) and @infragistics/-scoped (@infragistics/igniteui-dockmanager). The tsconfig.json paths config handles this for the TypeScript language server via ordered fallback arrays, but Vite/Rollup is unaware of this fallback:

  • Astro only translates the first entry from each paths array into a Vite alias, so the @infragistics/ fallback was silently ignored.
  • When only the scoped packages are installed (e.g. in CI), Rollup failed at build time:
[vite]: Rollup failed to resolve import "igniteui-dockmanager" from "...src/index.ts"

Solution

Two changes to astro.config.mjs:

1. resolveIgniteUiScoped Vite plugin

Added a custom Vite plugin that mirrors the tsconfig paths fallback logic for Rollup. At startup it checks node_modules with existsSync and builds a redirect map — only for packages where the unscoped variant is absent. In the resolveId hook it delegates to this.resolve(..., { skipSelf: true }) so the scoped name goes through the full Node module resolution pipeline (respecting package.json exports, subpaths, etc.) rather than being treated as a raw file path.

A resolveId plugin was chosen over resolve.alias because Astro merges its own Vite config after user config and can overwrite alias arrays, whereas Rollup plugin hooks are always invoked regardless of config merging order.

2. Dynamic optimizeDeps.include

Added a small ig(pkg) helper that returns the unscoped or @infragistics/-scoped name based on which is installed. Used it to build the optimizeDeps.include list so esbuild's pre-bundling phase also resolves to the correct installed package. Previously the hardcoded unscoped names caused [WARN] Failed to resolve dependency warnings and a failed pre-bundle pass when only scoped packages were present.

Result

  • Build works with either unscoped or @infragistics/-scoped packages installed, matching the existing tsconfig.json fallback behaviour.
  • No new runtime dependencies added.

Copy link
Copy Markdown

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

This PR updates the Astro/Vite build configuration to correctly resolve Ignite UI packages when only the @infragistics/-scoped variants are installed, matching the existing TypeScript tsconfig.json paths fallback behavior.

Changes:

  • Added a custom Vite/Rollup resolveId plugin to redirect unscoped igniteui-* imports to @infragistics/igniteui-* when the unscoped package isn’t installed.
  • Made optimizeDeps.include dynamically choose the installed package name (unscoped vs scoped) to avoid pre-bundling failures/warnings in scoped-only installs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

dobromirts
dobromirts previously approved these changes Mar 25, 2026
Copy link
Copy Markdown

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ChronosSF ChronosSF merged commit 66f03eb into vnext Mar 25, 2026
8 checks passed
@ChronosSF ChronosSF deleted the sstoychev/fix-astro-licensed-paths branch March 25, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants