Skip to content

Add @vite-ignore to dynamic imports to silence Vite/Rollup warnings#409

Open
prawnsgupta wants to merge 1 commit into
root-project:masterfrom
prawnsgupta:fix/vite-ignore-dynamic-imports
Open

Add @vite-ignore to dynamic imports to silence Vite/Rollup warnings#409
prawnsgupta wants to merge 1 commit into
root-project:masterfrom
prawnsgupta:fix/vite-ignore-dynamic-imports

Conversation

@prawnsgupta

@prawnsgupta prawnsgupta commented Jul 17, 2026

Copy link
Copy Markdown

When JSROOT is bundled by Vite/Rollup-based tooling (e.g. the Angular 17+ dev server), the runtime-URL dynamic imports produce warnings like:

The above dynamic import cannot be analyzed by Vite.
See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations ...
If this is intended to be left as-is, you can use the /* @vite-ignore */ comment inside the import() call to suppress this warning.

These imports (in injectCode, loadModules, loadScript in modules/core.mjs, and the module loader in modules/gui/HierarchyPainter.mjs) are intentionally dynamic — the URL is only known at runtime — which is exactly the case the /* @vite-ignore */ comment exists for. This PR adds it alongside the existing /* webpackIgnore: true */ comment; the two coexist and each bundler reads its own.

No behavior change: node -e "import('./modules/core.mjs')" loads fine, and the comments are ignored by browsers/Node.

Reported downstream by the Phoenix event display (HSF/phoenix#902), which consumes jsroot through Angular's Vite-based builder.

Also added a line to changes.md.

Bundlers based on Vite/Rollup (e.g. Angular 17+ dev server) emit
'The above dynamic import cannot be analyzed by Vite' warnings for the
runtime-URL dynamic imports in core.mjs and HierarchyPainter.mjs.
Adding the /* @vite-ignore */ comment (alongside the existing
/* webpackIgnore: true */) tells Vite these imports are intentionally
dynamic, as recommended by the warning itself. No behavior change.

Seen downstream in HSF/phoenix#902.
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.

1 participant