npm run generate breaks when import contains re-export `export { default as xxx } from 'ooo'`
Forwarded from downstream issue:
|
Environment
Nuxt project info:
- Operating System:
Darwin - Node Version:
v14.18.2 - Nuxt Version:
3.0.0-rc.3 - Package Manager:
[email protected] - Builder:
vite - User Config:
typescript,publicRuntimeConfig,buildModules,alias,vite - Runtime Modules:
- - Build Modules:
@pinia/[email protected]
Reproduction
https://codesandbox.io/s/angry-johnson-3h59db?file=/app.vue
Run npm run generate from the terminal.
<template>
<div>
<NuxtWelcome />
</div>
</template>
<script>
// the swiper js package has re-export in entry point
import { Pagination } from "swiper";
console.log(Pagination);
export default {};
</script>
Describe the bug
If package you used contains re-export syntex, then npm run generate didn't work.
Additional context
The import was incorrectly resolved to import Pagination from './modules/pagination/pagination.js'; in the /sandbox/.nuxt/prerender/chunks/app/server.mjs . and thus break the build
Logs
ERROR [nuxt] [request error] Cannot find module '/sandbox/.nuxt/prerender/chunks/app/modules/pagination/pagination.js' imported from /sandbox/.nuxt/prerender/chunks/app/server.mjs
at new NodeError (internal/errors.js:322:7)
at finalizeResolution (internal/modules/esm/resolve.js:308:11)
at moduleResolve (internal/modules/esm/resolve.js:731:10)
at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:842:11)
at Loader.resolve (internal/modules/esm/loader.js:89:40)
at Loader.getModuleJob (internal/modules/esm/loader.js:242:28)
at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:76:40)
at link (internal/modules/esm/module_job.js:75:36)
It is strange this issue is bubbling up to nitro. Is there an easier way to reproduce issue with nitro itself?
Good point. Will do my best to replicate in simpler form. Might be soluble in nuxt also.
@danielroe I'm pretty sure linked PR is something worth to consider but I cannot reproduce issue anymore with nuxt edge. Can you please help to make a reproduction for nitro? (Update: Neither with rc.8 and latest deps. both prod and dev log [Function: Pagination]...)
I can still reproduce the issue on rc9: https://stackblitz.com/edit/github-gaxgkz?file=app.vue. Sorry for the delay and thanks for the ping in attached PR; I'm looking again at this to get a nitro-only reproduction...
Here's a nitro-only reproduction: https://stackblitz.com/edit/github-y4xqiy
Issue with swiper on last reproduction at least seems fixed. If still can reproduce feel free to open new issue 🙏🏼