antfu-collective / vite-ssg

Static site generation for Vue 3 on Vite
MIT License
1.36k stars 137 forks source link

Vite-ssg build error in SSR step #404

Open ademtonay opened 6 months ago

ademtonay commented 6 months ago

Describe the bug

I'm using vue3-carousel in my project and getting following error while building with build script.

[vite-ssg] Build for server...
vite v5.2.11 building SSR bundle for production...
Ambiguous external namespace resolution: "virtual:vue-router/auto" re-exports "useRouter" from one of the external modules "vue-router" and "unplugin-vue-router/data-loaders/basic", guessing "vue-router".
"useRouter" is imported from external module "unplugin-vue-router/data-loaders/basic" but never used in "virtual:vue-router/auto".
✓ 66 modules transformed.
✓ 0 webfont css downloaded. (0 ms, cache hit: NaN%)
.vite-ssg-temp/7un0o79hrz/manifest.webmanifest                         0.39 kB
.vite-ssg-temp/7un0o79hrz/assets/style-EG92fjKA.css                   35.60 kB
.vite-ssg-temp/7un0o79hrz/assets/route-block-mFfs_uHM.js               0.05 kB
.vite-ssg-temp/7un0o79hrz/assets/en-DrlAedJ-.js                        1.14 kB
.vite-ssg-temp/7un0o79hrz/assets/tr-BgRAO5hH.js                        1.16 kB
.vite-ssg-temp/7un0o79hrz/assets/_...all_-Emgd7hKA.js                  1.19 kB
.vite-ssg-temp/7un0o79hrz/assets/virtual_pwa-register-MFElTJ3Z.js      1.45 kB
.vite-ssg-temp/7un0o79hrz/assets/workbox-window.prod.es5-BZWEBaKl.js   8.18 kB
.vite-ssg-temp/7un0o79hrz/assets/index-BkKP3A0x.js                    43.61 kB
.vite-ssg-temp/7un0o79hrz/main.mjs                                    78.91 kB
✓ built in 452ms
file:///Users/ademtonay/Projects/kt-dent/.vite-ssg-temp/7un0o79hrz/assets/index-BkKP3A0x.js:4
import { Carousel, Navigation, Pagination, Slide } from "vue3-carousel";
         ^^^^^^^^
SyntaxError: The requested module 'vue3-carousel' does not provide an export named 'Carousel'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)

[vite-ssg] An internal error occurred.
[vite-ssg] Please report an issue, if none already exists: https://github.com/antfu/vite-ssg/issues
file:///Users/ademtonay/Projects/kt-dent/.vite-ssg-temp/7un0o79hrz/assets/index-BkKP3A0x.js:4
import { Carousel, Navigation, Pagination, Slide } from "vue3-carousel";
         ^^^^^^^^
SyntaxError: The requested module 'vue3-carousel' does not provide an export named 'Carousel'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)

Node.js v20.13.1
 ELIFECYCLE  Command failed with exit code 1.

Reproduction

none

System Info

System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M2 Pro
    Memory: 619.52 MB / 16.00 GB
    Shell: 3.6.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 20.13.1 - /opt/homebrew/opt/node@20/bin/node
    npm: 10.2.5 - /usr/local/bin/npm
    pnpm: 9.1.1 - ~/Projects/kt-dent/node_modules/.bin/pnpm
  Browsers:
    Chrome: 124.0.6367.209
    Safari: 17.4.1

Used Package Manager

pnpm

Validations

Contributions

ninaismail commented 6 months ago

same error here.

ademtonay commented 5 months ago

I solved the issue by downgrade vite packages from:

   "vite": "^5.2.11",
    "vite-bundle-visualizer": "^1.2.1",
    "vite-plugin-inspect": "^0.8.4",
    "vite-plugin-pwa": "^0.20.0",
    "vite-plugin-vue-devtools": "^7.1.3",
    "vite-plugin-vue-layouts": "^0.11.0",
    "vite-plugin-webfont-dl": "^3.9.4",
    "vite-ssg": "^0.23.7",
    "vite-ssg-sitemap": "^0.6.1",
    "vitest": "^1.6.0",

to:

    "vite": "5.0.3",
    "vite-bundle-visualizer": "0.11.0",
    "vite-plugin-inspect": "0.7.42",
    "vite-plugin-pwa": "0.17.2",
    "vite-plugin-vue-devtools": "1.0.0-rc.5",
    "vite-plugin-vue-layouts": "0.8.0",
    "vite-plugin-webfont-dl": "3.9.1",
    "vite-ssg": "0.23.5",
    "vite-ssg-sitemap": "0.6.1",
    "vitest": "1.0.0-beta.6"

Note: It's just a workaround

ninaismail commented 5 months ago

Thank you so much it worked! @ademtonay

jasonconsumerdirect commented 4 months ago

I am running into the same issue except downgrading packages is not fixing it for me.

pzj01 commented 3 months ago

I also encountered the same problem, my vite version is 5.3.1。

muckch commented 3 months ago

I solved the problem for me by downgrading "vue3-carousel" (from 0.3.3) by adding the following dependency:

"vue3-carousel": "0.3.1"

ninaismail commented 3 months ago

Hey @muckch , I'm gonna try this too thanks.