question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using @vitejs/plugin-legacy within Astro project: Build fails with Error

See original GitHub issue

Describe 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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
tncrazvancommented, Jan 14, 2022

Having a similar error message in plain Svelte using "@sveltejs/vite-plugin-svelte": "^1.0.0-next.34" and "vite": "^2.7.12":

✓ 216 modules transformed.
rendering chunks (1)...[!] Error: unfinished hook action(s) on exit:
(vite:css-post) renderChunk

Does this belong into a separate issue?

1reaction
cselliscommented, Feb 13, 2022

Experiencing it as well

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found