The CJS build of Vite's Node API is deprecated.
332lfgb6 opened this issue · comments
Environment
- Operating System: Windows_NT
- Node Version: v20.10.0
- Nuxt Version: 3.11.2
- CLI Version: 3.11.1
- Nitro Version: 2.9.6
- Package Manager: pnpm@8.12.0
- Builder: -
- User Config: devtools, css, devServer, modules, postcss, vite
- Runtime Modules: @vant/nuxt@1.0.4
- Build Modules: -
Reproduction
No repo needed
Describe the bug
When I use the official legacy plugin, I get this warning
import legacy from "@vitejs/plugin-legacy";
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
vite: {
plugins: [
legacy({
targets: ["Chrome 63", "ios 9"],
modernPolyfills: true,
}),
],
},
});
{
"dependencies": {
"nuxt": "^3.11.2",
},
"devDependencies": {
"@vitejs/plugin-legacy": "^5.4.0",
}
}
Additional context
No response
Logs
No response
This is because jiti
(which we use to transpile the nuxt.config
in c12
is loading the file in a CJS context.
@pi0 might have an idea about how to force ESM resolution of Vite, or a workaround here.
You can use VITE_CJS_IGNORE_WARNING=1
environment variable to hide this warning. Once vite completely drops CJS entrypoint OR when jiti v2 is landed and c12 (and nuxt) adopts it, it will be resolved.