You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vite executes the build process, async lib generates JS file in ES format, async package references this ES file of async lib package, but there are errors in the build process:
vite v2.3.8 building for production...
✓ 6 modules transformed.
Identifier '__vitePreload' has already been declared
file: /....../test-vite-async-import/packages/async-lib/dist/async-lib.es.js:3:6
1: let scriptRel;
2: const seen = {};
3: const __vitePreload = function preload(baseModule, deps) {
^
4: if (!deps) {
5: return baseModule();
error during build:
Error: Identifier '__vitePreload' has already been declared
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
This issue has been locked since it has been closed for more than 14 days.
If you have found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Vite version. If you have any other comments you should join the chat at Vite Land or create a new discussion.
Describe the bug
Vite library mode (format:es) generates
__vitePreload
function for async import.When the package is used as a dependency, an error will occur:
Error: Identifier '__vitePreload' has already been declared
I created a temporary project to verify the bug: https://github.com/xingxiuyi/test-vite-async-import
project:
async-lib
If
const value = await import ("some_package")
is used in the library package, vite will generateasync import
code similar to the following:project:
async-package
Then reference ES file (generated above) in another project,
An error will be triggered (vite build process).
question
I looked at the following files in vite project:
packages/vite/src/node/plugins/importAnalysisBuild.ts
Vite build process generates the following code:
Error: Identifier '__vitePreload' has already been declared
Reproduction
Example project url: https://github.com/xingxiuyi/test-vite-async-import
Vite executes the build process,
async lib
generates JS file in ES format,async package
references this ES file ofasync lib
package, but there are errors in the build process:System Info
Used Package Manager
yarn
Logs
Validations
The text was updated successfully, but these errors were encountered: