-
Notifications
You must be signed in to change notification settings - Fork 138
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
Top-level await is not supported #1948
Comments
pdf.js. is using top-level await. We can't make that work until we do emberjs/rfcs#938. A workaround until then is to access pdf.js via dynamic import only: diff --git a/app/routes/application.js b/app/routes/application.js
index 1c602d9..9555db4 100644
--- a/app/routes/application.js
+++ b/app/routes/application.js
@@ -1,10 +1,10 @@
import Route from '@ember/routing/route';
-import { getDocument } from 'pdfjs-dist/webpack.mjs';
const url = '/fw4.pdf';
export default class ApplicationRoute extends Route {
async model() {
+ const { getDocument } = await import('pdfjs-dist/webpack.mjs');
const loadingTask = getDocument({ url });
return await loadingTask.promise;
} This worked for me in your reproduction app. |
PDF.js 4.3.136 just released and they no longer use top-level await, so it works now without the dynamic import. Related issue mozilla/pdf.js#17245 and fix mozilla/pdf.js#18051 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reproduction here: https://github.com/dwickern/ember-pdfjs-reproduction/tree/embroider
The module which imports PDF.js will have its own exports broken. In the reproduction, the application route imports pdf.js. Its export resolves to a promise instead of the route class:
This results in an error:
If you import PDF.js in a service instead, all
@service
injections for that service will resolve to aPromise<Service>
instead of the service.There's a related problem with ember-auto-import embroider-build/ember-auto-import#614
The text was updated successfully, but these errors were encountered: