Nuxt fails to preserve a side-effect only import in server build
Forwarded from downstream issue:
|
Environment
Nuxi 3.4.3 RootDir: /home/projects/nuxt-starter-hpuww7 Nuxt project info:
- Operating System: Linux
- Node Version: v16.14.2
- Nuxt Version: 3.4.3
- Nitro Version: 2.4.0
- Package Manager: [email protected]
- Builder: vite
- User Config: -
- Runtime Modules: -
- Build Modules: -
Reproduction
- Install
@vintl/compact-number - Import
@vintl/compact-number/locale-data/enwithout any specifiers (side-effect only import)
https://stackblitz.com/edit/nuxt-starter-hpuww7?file=app.vue
Describe the bug
Nuxt successfully preserves the import in both .nuxt/dist/client (search thousand in .nuxt/dist/client/_nuxt/entry.xxxxxx.js) and .nuxt/dist/server (.nuxt/dist/server/server.mjs has the import line), however the Nitro server build in .output fails to preserve the import, which causes an error in real applications. In @vintl/compact-number case it's a locale data required for the package to function properly.
Additional context
N/D
Logs
N/A
Per https://github.com/nuxt/nuxt/issues/20707, Nitro-only reproduction: https://stackblitz.com/edit/github-afydgr?file=package.json (npm run build to build normally, npm run build:workraround to apply manual workaround).