Issue
I'm using Pdfjs library and i'm facing this error
Top-level await is not available in the configured target environment ("chrome119.0", "edge119.0", "firefox115.0", "ios16.0", "safari16.0" + 7 overrides)
/****/ webpack_exports = globalThis.pdfjsLib = await (globalThis.pdfjsLibPromise = webpack_exports);**
I saw an issue at github saying that i can fix this with vite but i'm not using vite at all in my project..
This is my tsconfig file
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true,
"esModuleInterop": true,
"sourceMap": true,
"declaration": false,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "ESNext",
"module": "ESNext",
"useDefineForClassFields": false,
"lib": ["ESNext", "dom"]
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
I tried to change the target in tsconfig from ES2022 to ESNext but nothing works
Solution
I ran into the same problem, I ended up downgrading pdfjs-dist to the latest 3 version
npm i pdfjs-dist@3.11.174
This works as I suppose it is before they changed the package to use top level await.
Unsuccessful fix attempts
I tried several other solutions which didn't work. The Angular CLI issues suggested editing vite.config.ts, which isn't actually accessible. This is also referenced in pdf.js issues.
I also tried with the vite-plugin-top-level-await package, it did not work.
Answered By - Tri42
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.