Vite entry-legacy.js is not ES5 compatible
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 285
- Forks
- 33
- Avg merge
- 22h 38m
- Merged PRs (30d)
- 3
Description
Environment
- Operating System:
Darwin - Node Version:
v16.13.0 - Nuxt Version:
2.16.0-27358576.777a4b7f - Package Manager:
pnpm@6.32.4 - Builder:
vite - User Config:
bridge,hooks,buildModules - Runtime Modules:
- - Build Modules:
@nuxt/bridge@3.0.0-27530716.c4f8671
Reproduction
Create empty project with this nuxt.config.js:
import { defineNuxtConfig } from '@nuxt/bridge'
import legacy from '@vitejs/plugin-legacy'
export default defineNuxtConfig({
bridge: {
vite: true,
},
hooks: {
'vite:extendConfig': config => {
config.plugins.forEach((plugin, i) => {
if (Array.isArray(plugin) && plugin[0].name === 'vite:legacy-config') {
config.plugins[i] = legacy({
targets: ['ie 9'],
})
}
})
},
},
})
Then run nuxi build.
.output/public/_nuxt/entry-legacy.c81f3a42.js will include code that does not run in IE 9:
var appConfig = window?.__NUXT__?.config.app || {}
Describe the bug
nuxi build generates ES5-incompatible javascript even if @vitejs/plugin-legacy is configured with IE 9 target. The plugin itself works fine, the problem is apparently that Nuxt-injected code is not processed with that plugin.
Additional context
No response
Logs
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Vite integration involved in the vite:extendConfig hook and trace how Nuxt-injected code reaches .output/public/_nuxt/entry-legacy.c81f3a42.js. Run nuxi build using the reported configuration and inspect the generated legacy entry. Done means the Nuxt-injected output is processed for the configured IE 9 target and no optional-chaining syntax remains.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vite
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100