sveltejs / kit

web development, streamlined
https://svelte.dev/docs/kit
MIT License
18.78k stars 1.96k forks source link

When issue npm run build get this error #12172

Closed RabbiIslamRony closed 7 months ago

RabbiIslamRony commented 7 months ago

Describe the bug

Warning: "The following packages have a svelte field in their package.json but no exports condition for svelte" in Vite Plugin Svelte and error build

Reproduction

npm run build

My svelte.config.js

import adapter from '@sveltejs/adapter-auto';
import preprocess from 'svelte-preprocess';
import path from 'path';

/** @type {import('@sveltejs/kit').Config} */
const config = {
    kit: {
        adapter: adapter(),
        alias: {
            '@components': path.resolve('./src/lib/components'),
            '@data': path.resolve('./src/demo-data'),
            '@store': path.resolve('./src/lib/store'),
            '@apps': path.resolve('./src/lib/view/apps'),
            '@view': path.resolve('./src/lib/view')
        },
        prerender: {
            crawl: true
        }
    },
    preprocess: preprocess(),
};

export default config;

My package.json

{
  "name": "hexadash-svelte",
  "version": "1.1.0",
  "private": true,
  "description": "HexaDash - Admin Dashbord Template",
  "author": "SovWare",
  "license": "ISC",
  "type": "module",
  "scripts": {
    "dev": "vite dev",
    "build": "vite build",
    "package": "svelte-kit package",
    "preview": "vite preview",
    "lint": "prettier --check --plugin-search-dir=. . && eslint .",
    "format": "prettier --write --plugin-search-dir=. .",
    "check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
        "check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch"
  },
  "devDependencies": {
    "@bulatdashiev/svelte-slider": "^1.0.3",
    "@ernane/svelte-star-rating": "^1.1.7",
    "@sveltejs/adapter-auto": "3.2.0",
    "@sveltejs/kit": "2.5.7",
    "eslint": "^9.1.1",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-svelte": "^2.38.0",
    "prettier": "^3.2.5",
    "prettier-plugin-svelte": "^3.2.3",
    "sass": "^1.75.0",
    "svelte": "^4.2.15",
    "svelte-feather-icons": "^4.1.0",
    "svelte-fullcalendar": "^3.0.0",
    "svelte-preprocess": "^5.1.4",
    "svelte-range-slider-pips": "^2.3.1",
    "vite": "^5.2.10"
  },
  "dependencies": {
    "@beyonk/svelte-datepicker": "^13.0.4",
    "@fortawesome/free-brands-svg-icons": "^6.5.2",
    "@fortawesome/free-regular-svg-icons": "^6.5.2",
    "@fortawesome/free-solid-svg-icons": "^6.5.2",
    "@fullcalendar/common": "^5.11.5",
    "@fullcalendar/core": "^6.1.11",
    "@fullcalendar/daygrid": "^6.1.11",
    "@fullcalendar/interaction": "^6.1.11",
    "@fullcalendar/list": "^6.1.11",
    "@fullcalendar/timegrid": "^6.1.11",
    "@sveltestrap/sveltestrap": "^6.2.7",
    "apexcharts": "^3.49.0",
    "axios": "^1.6.8",
    "bigger-picture": "^1.1.16",
    "bootstrap": "^5.3.3",
    "chart.js": "^4.4.2",
    "cl-editor": "^2.3.0",
    "file-saver": "^2.0.5",
    "js-cookie": "^3.0.5",
    "leaflet": "^1.9.4",
    "moment": "^2.30.1",
    "papaparse": "^5.4.1",
    "svelte-bootstrapjs-action": "^2.2.2",
    "svelte-chartjs": "^3.1.5",
    "svelte-countdown": "^1.1.2",
    "svelte-fa": "^4.0.2",
    "svelte-flatpickr": "^3.3.4",
    "svelte-forms-lib": "^2.0.1",
    "svelte-notifications": "^0.9.98",
    "svelte-select": "^5.8.3",
    "svgmap": "^2.10.1",
    "svrollbar": "^0.12.0",
    "swiper": "^11.1.1",
    "xlsx": "https://cdn.sheetjs.com/xlsx-0.19.1/xlsx-0.19.1.tgz",
    "yootils": "^0.3.1",
    "yup": "^1.4.0"
  }

}

Logs

$ npm run build

> hexadash-svelte@1.1.0 build
> vite build

11:41:47 AM [vite-plugin-svelte] WARNING: The following packages have a svelte field in their package.json but no exports condition for svelte.

@beyonk/svelte-datepicker@13.0.4
cl-editor@2.3.0
svelte-bootstrapjs-action@2.2.2
svelte-countdown@1.1.2
svelte-forms-lib@2.0.1
svelte-notifications@0.9.98
svrollbar@0.12.0
@bulatdashiev/svelte-slider@1.0.3
@ernane/svelte-star-rating@1.1.7
svelte-fullcalendar@3.0.0
svelte-range-slider-pips@2.3.1

Please see https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#missing-exports-condition for details.
vite v5.2.10 building SSR bundle for production...
transforming (1) .svelte-kit\generated\server\internal.js11:41:49 AM [vite-plugin-svelte] F:/2 Write CODE/5 Svelte/ninjadash-svelte/src/routes/+error.svelte svelte.preprocess depends on more than 10 external files which can cause slow builds and poor DX, try to reduce them. Found: F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\style.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\mixins\mixins.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\mixins\_variables.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\mixins\_helpers.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\mixins\_rfs.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\mixins\_media-queries.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\mixins\_utility-classes.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\mixins\_functions.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\common.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\components\components.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\components\button.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\components\_cards.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\components\_dropdown.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\components\_navbar.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\components\_badges.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\components\_alert.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\components\_dark-mode.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\apps\app.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\apps\_email.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\pages\blog.scss    
11:41:50 AM [vite-plugin-svelte] F:/2 Write CODE/5 Svelte/ninjadash-svelte/src/routes/(common-layout)/+layout.svelte svelte.preprocess depends on more than 10 external files which can cause slow builds and poor DX, try to reduce them. Found: F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\style.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\mixins\mixins.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\mixins\_variables.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\mixins\_helpers.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\mixins\_rfs.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\mixins\_media-queries.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\mixins\_utility-classes.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\mixins\_functions.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\common.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\components\components.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\components\button.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\components\_cards.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\components\_dropdown.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\components\_navbar.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\components\_badges.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\components\_alert.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\components\_dark-mode.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\apps\app.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\apps\_email.scss, F:\2 Write CODE\5 Svelte\ninjadash-svelte\src\assets\sass\pages\blog.scss
✓ 40 modules transformed.
x Build failed in 5.27s
error during build:
Error: [commonjs--resolver] Missing "./svelte" specifier in "swiper" package
    at e (file:///F:/2%20Write%20CODE/5%20Svelte/ninjadash-svelte/node_modules/vite/dist/node/chunks/dep-DkOS1hkm.js:47596:25)
    at n (file:///F:/2%20Write%20CODE/5%20Svelte/ninjadash-svelte/node_modules/vite/dist/node/chunks/dep-DkOS1hkm.js:47596:627)
    at o (file:///F:/2%20Write%20CODE/5%20Svelte/ninjadash-svelte/node_modules/vite/dist/node/chunks/dep-DkOS1hkm.js:47596:1297)
    at resolveExportsOrImports (file:///F:/2%20Write%20CODE/5%20Svelte/ninjadash-svelte/node_modules/vite/dist/node/chunks/dep-DkOS1hkm.js:48286:20)
    at resolveDeepImport (file:///F:/2%20Write%20CODE/5%20Svelte/ninjadash-svelte/node_modules/vite/dist/node/chunks/dep-DkOS1hkm.js:48305:31)
    at tryNodeResolve (file:///F:/2%20Write%20CODE/5%20Svelte/ninjadash-svelte/node_modules/vite/dist/node/chunks/dep-DkOS1hkm.js:48030:20)
    at Object.resolveId (file:///F:/2%20Write%20CODE/5%20Svelte/ninjadash-svelte/node_modules/vite/dist/node/chunks/dep-DkOS1hkm.js:47780:28)
    at Object.handler (file:///F:/2%20Write%20CODE/5%20Svelte/ninjadash-svelte/node_modules/vite/dist/node/chunks/dep-DkOS1hkm.js:67684:19)
    at file:///F:/2%20Write%20CODE/5%20Svelte/ninjadash-svelte/node_modules/rollup/dist/es/shared/node-entry.js:19830:40
    at async PluginDriver.hookFirstAndGetPlugin (file:///F:/2%20Write%20CODE/5%20Svelte/ninjadash-svelte/node_modules/rollup/dist/es/shared/node-entry.js:19730:28)

System Info

node version: v20.12.0

Severity

serious, but I can work around it

Additional Information

No response

dominikg commented 7 months ago

The warning you put in the title is just a warning, it does not cause the build error.

Error: [commonjs--resolver] Missing "./svelte" specifier in "swiper" package seems to be the cause for that.

Please update the description and include a link to a repository with a minimal reproduction with using that package.

benmccann commented 7 months ago

I'm guessing you're trying to import from swiper/svelte someplace. However, you're using Swiper 11 and Swiper Svelte components were removed in v9: https://swiperjs.com/svelte

Closing this since it appears to be a mistake in your usage rather than any bug in SvelteKit