ng2-pdf-viewer
ng2-pdf-viewer copied to clipboard
Dynamic import cannot be analyzed by Vite
On angular's dev-server start getting the following warning in the console:
Watch mode enabled. Watching for file changes...
NOTE: Raw file sizes do not reflect development server per-request transformations.
➜ Local: http://localhost:4200/
➜ press h + enter to show help
10:22:02 AM [vite] warning:
.../src/frontend/.angular/cache/18.2.2/vite/deps/ng2-pdf-viewer.js
11940| const worker = yield import(
11941| /*webpackIgnore: true*/
11942| this.workerSrc
| ^^^^^^^^^^^^^^
11943| );
11944| return worker.WorkerMessageHandler;
The above dynamic import cannot be analyzed by Vite.
See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations for supported dynamic import formats. If this is intended to be left as-is, you can use the /* @vite-ignore */ comment inside the import() call to suppress this warning.
Plugin: vite:import-analysis
File: .../src/frontend/.angular/cache/18.2.2/vite/deps/ng2-pdf-viewer.js?v=c66f4614
10:22:02 AM [vite] warning:
.../src/frontend/.angular/cache/18.2.2/vite/deps/ng2-pdf-viewer.js
25819| const sandbox = import(
25820| /*webpackIgnore: true*/
25821| sandboxBundleSrc
| ^^^^^^^^^^^^^^^^
25822| );
25823| sandbox.then((pdfjsSandbox) => {
The above dynamic import cannot be analyzed by Vite.
See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations for supported dynamic import formats. If this is intended to be left as-is, you can use the /* @vite-ignore */ comment inside the import() call to suppress this warning.
Plugin: vite:import-analysis
File: .../src/frontend/.angular/cache/18.2.2/vite/deps/ng2-pdf-viewer.js?v=c66f4614
rm -rf node-modules package-lock.json .angular && npm install did not help.
Everything else seems to work fine, the production build completes without any warnings, and the PDF preview works as expected.
- Angular 18.2.2
- ng2-pdf-viewer 10.3.0
- Node.js 20.16.0
- MacOS 14.6.1
same problem here... thks.
I have the same issue. Wouldn't be possible to add /vite-ignore/ where there is /webpack-ignore/? This solves the issue
relevant for this topic: https://github.com/mozilla/pdf.js/pull/18395
ng2-pdf-viewer can't do anything helpful here.
It’s unfortunate that this error can’t be resolved at the moment. Does anyone have suggestions on how to instruct the compiler to safely ignore this issue?
Thanks in advance for any insights!
This issue does not belong here, the error comes from pdfjs. See https://github.com/mozilla/pdf.js/issues/19077
This should be closed
@tehdb - Just to confirm, while you get this error in the local dev server, you are not getting it in a production build? We just upgraded to Angular v.19 and started seeing this error...
Also getting this error when upgraded to V18. So frustrating!!!!!
Hi, I use "ng2-pdf-viewer": "9.1.0", with Angular 18.2.13, and I receive this error with vite:
any update about this problems?
I am using ng2-pdf-viewer: 10.0.0 and angular 19.1.17 and have same issue... Any other ideas?
The above dynamic import cannot be analyzed by Vite. See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations for supported dynamic import formats. If this is intended to be left as-is, you can use the /* @vite-ignore */ comment inside the import() call to suppress this warning.
Plugin: vite:import-analysis File: /Users/darwinraj/Documents/SODISYS/Projects/sodisys-saas/projects/ng-sodisys/.angular/vite-root/sodisys/chunk-77QDKOY6.js
You should close the duplicate issue you opened for this #1184, then you can refer back to my other comment https://github.com/VadimDez/ng2-pdf-viewer/issues/1130#issuecomment-2522293084 and research why this is not a bug to report here (aka, google it)
This bug is not related to Firefox. On my side the bug appears after I run ng serve, I open Chrome and when I come back to the terminal I see the warning. I use angular 19.1.7 and tested with ng2-pdf-viewer v10.0.0 and 10.0.4
The issue was resolved in the newest version of pdfjs-dist (released 2 days ago). I created the following PR to update the version of the aforementioned lib in ng2-pdf-viewer: https://github.com/VadimDez/ng2-pdf-viewer/pull/1188
2 months later and still no new release for the fix
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Commenting so that this issue doesn't get closed for no valid reason