nitro icon indicating copy to clipboard operation
nitro copied to clipboard

Nuxt fails to preserve a side-effect only import in server build

Open issue-up[bot] opened this issue 2 years ago • 1 comments

   Forwarded from downstream issue:

  • https://github.com/nuxt/nuxt/issues/20707 by @brawaru

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

  1. Install @vintl/compact-number
  2. Import @vintl/compact-number/locale-data/en without 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

issue-up[bot] avatar May 06 '23 18:05 issue-up[bot]

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).

brawaru avatar Jun 17 '24 02:06 brawaru