ghenry
Importing pdf.mjs into app.js
Hi all,
I’m trying to use pdf.js and importing it like so:
import PDFJS from "../vendor/pdf.mjs"
so I can use it in a Hook to render the 1st page of a PDF, but I’m getting:
✘ [ERROR] Top-level await is not available in the configured target environment ("es2018")
vendor/pdf.mjs:16837:53:
16837 │ ...ck_exports__ = globalThis.pdfjsLib = await __webpack_exports__;
╵ ~~~~~
I’ve tried incrementing the es version in config.exs to no avail.
Anyone else using .mjs files? They are from https://github.com/mozilla/pdf.js/releases/download/v4.0.189/pdfjs-4.0.189-dist.zip
Thanks.
First Post!
ghenry
Actually:
https://caniuse.com/?search=top%20level%20await
es2022 is OK and now giving me:
✘ [ERROR] Top-level await is currently not supported with the "iife" output format
vendor/pdf.mjs:16837:53:
16837 │ ...ck_exports__ = globalThis.pdfjsLib = await __webpack_exports__;
╵ ~~~~~
so I don’t think I’m doing this right.
0
Last Post!
ghenry
I kept with v3, but my github dependabot upgraded it to v4 and it still seemed to work. I’m watching that issue though.
0
Popular in Questions
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
Hi everyone,
I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
Other popular topics
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
Lets say I have map like this fetching from my database
%{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










