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

Strange import behavior with pdfjs v4 #614

Open
dwickern opened this issue Mar 13, 2024 · 2 comments
Open

Strange import behavior with pdfjs v4 #614

dwickern opened this issue Mar 13, 2024 · 2 comments

Comments

@dwickern
Copy link

dwickern commented Mar 13, 2024

Repro here: https://github.com/dwickern/ember-pdfjs-reproduction

In pdfjs v4 the project was converted to ESM. After upgrading pdfjs from v3 to v4, its default export is an unresolved promise:

Screenshot 2024-03-13 at 3 07 21 PM

To get it working, you actually have to await the imported module:
dwickern/ember-pdfjs-reproduction@f8aa137

Expected behavior: importing a module should resolve it

@dwickern
Copy link
Author

dwickern commented Mar 13, 2024

There's a similar issue building with embroider, where the application route class is an unresolved promise:

Screenshot 2024-03-13 at 3 32 56 PM

Which manifests as an error:

Uncaught Error: Assertion Failed: Failed to create an instance of 'route:application'. Most likely an improperly defined class or an invalid module export.
    at assert (index.js:118:1)
    at InternalFactoryManager.create (index.js:372:1)
    at Proxy.create (index.js:204:1)
    at instantiateFactory (index.js:276:1)
    at lookup (index.js:223:1)
    at Container.lookup (index.js:121:1)
    at ApplicationInstance.lookup (container_proxy.js:19:1)
    at PrivateRouter.getRoute (router.js:183:1)
    at UnresolvedRouteInfoByParam.fetchRoute (router_js.js:714:1)
    at get route (router_js.js:648:1)

It seems that any module importing pdfjs will have its own exports broken. For example, in my app, a service imports pdfjs and all @service injections for that service are broken (they resolve to a Promise<Service> instead of the service).

Reproduction is on the embroider branch: https://github.com/dwickern/ember-pdfjs-reproduction/tree/embroider

@ef4
Copy link
Collaborator

ef4 commented May 28, 2024

The commentary in embroider-build/embroider#1948 (comment) also applies here.

And the same workaround should apply. The only difference is that for ember-auto-import you must make sure you opted in to dynamic import support.

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

2 participants