Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic import cannot be analyzed by Vite #1130

Open
tehdb opened this issue Sep 2, 2024 · 6 comments
Open

Dynamic import cannot be analyzed by Vite #1130

tehdb opened this issue Sep 2, 2024 · 6 comments

Comments

@tehdb
Copy link

tehdb commented Sep 2, 2024

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
Copy link

mateogo commented Sep 5, 2024

same problem here... thks.

@alfmosmq
Copy link

I have the same issue. Wouldn't be possible to add /vite-ignore/ where there is /webpack-ignore/?
This solves the issue

@ftaffelt
Copy link
Contributor

relevant for this topic:
mozilla/pdf.js#18395

ng2-pdf-viewer can't do anything helpful here.

@D-Abdi
Copy link

D-Abdi commented Oct 18, 2024

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!

Repository owner deleted a comment Oct 24, 2024
@shamoon
Copy link
Contributor

shamoon commented Dec 6, 2024

This issue does not belong here, the error comes from pdfjs. See mozilla/pdf.js#19077

This should be closed

@joewIST
Copy link

joewIST commented Dec 19, 2024

@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...

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

No branches or pull requests

12 participants
@mateogo @tehdb @shamoon @ftaffelt @D-Abdi @joewIST @alfmosmq and others