Angular 17使用pdfjs-dist遇Top-level await环境兼容错误
使用pdfjs-dist库时遭遇Top-level await环境兼容错误
我在使用pdfjs-dist库时遇到如下错误:
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);
我了解到有用户通过Vite解决过类似问题,但我的项目并未使用Vite。我已经尝试将tsconfig中的target从ES2022改为ESNext,不过问题依然存在。当前我的tsconfig配置如下:
{ "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 } }
内容的提问来源于stack exchange,提问作者f-accu
相关产品推荐
相关产品推荐

