Dynamic import cannot be analyzed by Vite
tehdb opened this issue · 6 comments
tehdb commented
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
mateogo commented
same problem here... thks.
alfmosmq commented
I have the same issue. Wouldn't be possible to add /vite-ignore/ where there is /webpack-ignore/?
This solves the issue
ftaffelt commented
relevant for this topic:
mozilla/pdf.js#18395
ng2-pdf-viewer can't do anything helpful here.