@vitejs/plugin-legacy does not build
See original GitHub issueEnvironment
- Operating System:
Linux
- Node Version:
v16.14.2
- Nuxt Version:
3.0.0-rc.8
- Package Manager:
npm@7.17.0
- Builder:
vite
- User Config:
vite
- Runtime Modules:
-
- Build Modules:
-
Reproduction
https://stackblitz.com/edit/github-qzrpnn?file=nuxt.config.ts
Describe the bug
When adding the Vite plugin @vitejs/plugin-legacy
and trying to build using nuxt build
I get an error.
The error does not happen when using a clean Vite project, so I guess it is related to Nuxt.
Additional context
No response
Logs
ERROR [vite:terser] _require2 is not defined 11:12:21
ERROR [vite:legacy-generate-polyfill-chunk] _require2 is not defined 11:12:21
ERROR _require2 is not defined 11:12:21
at doWork (eval at __global_eval__ (https://github-qzrpnn.w.staticblitz.com/blitz.1f021b18268b32e6c6b2095e039ac8c9f88b0d52.js:8:32190), <anonymous>:5:20)
at _0x51acfb.eval (eval at __global_eval__ (https://github-qzrpnn.w.staticblitz.com/blitz.1f021b18268b32e6c6b2095e039ac8c9f88b0d52.js:8:32190), <anonymous>:12:21)
at [nodejs.internal.kHybridDispatch] (https://github-qzrpnn.w.staticblitz.com/blitz.1f021b18268b32e6c6b2095e039ac8c9f88b0d52.js:6:353083)
at t.emitMessage (https://github-qzrpnn.w.staticblitz.com/blitz.1f021b18268b32e6c6b2095e039ac8c9f88b0d52.js:6:1031392)
at _started.<computed>._source.<computed> (https://github-qzrpnn.w.staticblitz.com/blitz.1f021b18268b32e6c6b2095e039ac8c9f88b0d52.js:15:103757)
Issue Analytics
- State:
- Created a year ago
- Reactions:7
- Comments:8 (5 by maintainers)
Top Results From Across the Web
About @vitejs/plugin-legacy does not support library mode
I have successfully built these components with Vite (with dynamic import and everything) and they work juts fine on modern browser. Describe ...
Read more >@vitejs/plugin-legacy - npm
This plugin provides support for legacy browsers that do not support those features when building for production. By default, this plugin ...
Read more >React app created with VITE does not work in IE 11
I have tried the @vitejs/plugin-react and added it in the ... which says "@vite/plugin-legacy only affects build mode, not dev mode".
Read more >Migration from v3 | Vite (main branch)
If you need to support older browsers, you can add @vitejs/plugin-legacy as usual. ... In part of this change, vite dev and vite...
Read more >@vitejs/plugin-legacy examples - CodeSandbox
Learn how to use @vitejs/plugin-legacy by viewing and forking ... by viewing and forking example apps that make use of @vitejs/plugin-legacy on CodeSandbox....
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
This is caused by the following code, inlined in
@vite/legacy-vue
:The problem is that
jiti
, which transpilesnuxt.config
and anything used within it, is manglingrequire(terserPath)
=>require2(terserPath)
because this is an ES module and Babel doesn’t understand that this is meant to run within a CJS context.I have same problem, need to help 😢