Using @vitejs/plugin-legacy within Astro project: Build fails with Error
See original GitHub issueDescribe the bug
I am using the @vitejs/plugin-legacy
package within an Astro project. When building the production bundle the build fails with the following error message shown below.
Tried Node versions 17, 16 and 14. Same error.
Reproduction
https://github.com/moritzlaube/astro-svelte-legacy-test
System Info
System:
OS: macOS 12.1
CPU: (10) arm64 Apple M1 Max
Memory: 2.32 GB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 17.2.0 - ~/.nvm/versions/node/v17.2.0/bin/node
npm: 8.1.4 - ~/.nvm/versions/node/v17.2.0/bin/npm
Browsers:
Chrome: 96.0.4664.110
Safari: 15.2
npmPackages:
@vitejs/plugin-legacy: ^1.6.4 => 1.6.4
Used Package Manager
npm
Logs
[vite:esbuild-transpile] Transform failed with 1 error:
assets/index.9a1f8e01.js:1:87: error: Multiple exports with the same name "__vite_legacy_guard"
Multiple exports with the same name "__vite_legacy_guard"
1 | export function __vite_legacy_guard(){import('data:text/javascript,')};export function __vite_legacy_guard(){import('data:text/javascript,')};var _1 = '';
| ^
2 |
3 | var _2 = '';
Error: Transform failed with 1 error:
assets/index.9a1f8e01.js:1:87: error: Multiple exports with the same name "__vite_legacy_guard"
[!] Error: unfinished hook action(s) on exit:
(vite:esbuild-transpile) renderChunk
(vite:esbuild-transpile) renderChunk
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- 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.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Troubleshooting - Vite
Vite cannot handle and does not support code that only runs on non-strict mode (sloppy mode). This is because Vite uses ESM and...
Read more >vite build - patak-dev
To support legacy browsers, Vite offers @vite_js/plugin-legacy. Vite can also be used to build libraries and watch mode. You can learn more ...
Read more >Imports - Astro Documentation
Even if a package was published using a legacy format, Astro will convert the package to ESM so that import statements work. Some...
Read more >A deep-dive on Vite featuring Evan You (JS Party #212)
So in WebPack, if you want to really consistently cache your dependency build result, you'll have to use something like the DLL plugin,...
Read more >Troubleshooting | Vite Ruby
Missing executable error # ... Verify that both vite and vite-plugin-ruby are in devDependencies in your package.json and have been installed by running...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Having a similar error message in plain Svelte using
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.34"
and"vite": "^2.7.12"
:Does this belong into a separate issue?
Experiencing it as well