Closed TxcA closed 5 months ago
npm install vite-plugin-top-level-await -D
vite 配置 optimizeDeps: { esbuildOptions: { target: 'esnext', }, },
try this
optimizeDeps: {
include: ['pdfjs-dist'], // optionally specify dependency name
esbuildOptions: {
supported: {
'top-level-await': true,
},
},
},
this is an issue with pdfjs and esbuild https://github.com/mozilla/pdf.js/issues/17245 https://github.com/evanw/esbuild/issues/253
try this
optimizeDeps: { include: ['pdfjs-dist'], // optionally specify dependency name esbuildOptions: { supported: { 'top-level-await': true, }, }, },
This method works during development, but yarn build
still throws an error. Currently, we are still using the vite-plugin-top-level-await plugin to resolve this issue.
ERROR: Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)
@lhiro Thanks~
try this
optimizeDeps: { include: ['pdfjs-dist'], // optionally specify dependency name esbuildOptions: { supported: { 'top-level-await': true, }, }, },
This method works during development, but
yarn build
still throws an error. Currently, we are still using the vite-plugin-top-level-await plugin to resolve this issue.ERROR: Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)
@lhiro Thanks~
Try this, it's not recommend to change the build target, we just add top-level-await
to support list
optimizeDeps: {
esbuildOptions: {
supported: {
'top-level-await': true,
},
},
},
esbuild: {
supported: {
'top-level-await': true,
},
},
try this
optimizeDeps: { include: ['pdfjs-dist'], // optionally specify dependency name esbuildOptions: { supported: { 'top-level-await': true, }, }, },
This method works during development, but still throws an error. Currently, we are still using the vite-plugin-top-level-await plugin to resolve this issue.
yarn build
ERROR: Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)
@lhiro Thanks~
Try this, it's not recommend to change the build target, we just add to support list
top-level-await
optimizeDeps: { esbuildOptions: { supported: { 'top-level-await': true, }, }, }, esbuild: { supported: { 'top-level-await': true, }, },
🎉 @lhiro Thank you. After removing the vite-plugin-top-level-await
plugin, I am now also able to run and build successfully.
error log:
After upgrading to
1.10.0
, the use of top await inpdfjs-dist
v4+ caused compilation errors on my end. I tried downgrading to1.9.7
, which resolved the issue. Then, I used the@tato30/vue-pdf@1.10.0
+ vite-plugin-top-level-await plugin to fix the error.I submitted this issue in order to alert other users about how to resolve this problem.