Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing "./ssr" export in "svelte" package #2181

Closed
gigitalz opened this issue Aug 12, 2021 · 4 comments · Fixed by #2182
Closed

Missing "./ssr" export in "svelte" package #2181

gigitalz opened this issue Aug 12, 2021 · 4 comments · Fixed by #2182

Comments

@gigitalz
Copy link

gigitalz commented Aug 12, 2021

Describe the bug

I am running svelte-kit dev with the most recent version 1.0.0-146 and I get a weird error which I was not having before.
For some reason i cleared node_modules and reinstalled all of them with "npm i" but now it doesn't run anymore.

Reproduction

run "npm run reproduce"

my package.json file:

{
  "name": "bot",
  "scripts": {
    "prestart": "nvm on && nvm use 14.17.3",
    "reproduce": "svelte-kit dev",
    "start": "npm run clean && concurrently -kill-others \"npm run watch:tailwind\" \"svelte-kit dev\"",
    "watch:tailwind": "postcss src/app.css -o tailwind.css --verbose -w",
    "build:tailwind": "cross-env NODE_ENV=production postcss src/app.css -o tailwind.css",
    "build": "npm run clean && npm run build:tailwind && npm run copy:tailwind && svelte-kit build",
    "clean": "npx shx rm -rf .svelte-kit && npx shx rm -rf build tailwind.css static/tailwind.css && npx shx rm -rf ../release/web",
    "clean:deep": "npm run clean && npx shx rm -rf node_modules",
    "release": "npm run build && shx cp -R build/ ../_stage/web",
    "copy:tailwind": "shx cp tailwind.css static/"
  },
  "devDependencies": {
    "@sveltejs/adapter-static": "next",
    "@sveltejs/kit": "next",
    "autoprefixer": "10.2.6",
    "concurrently": "6.2.0",
    "cross-env": "7.0.3",
    "postcss": "8.3.1",
    "postcss-cli": "8.3.1",
    "shx": "0.3.3",
    "svelte": "3.34.0",
    "tailwindcss": "2.1.4"
  },
  "type": "module",
  "dependencies": {
    "sockette": "2.0.6",
    "svelte-hero-icons": "2.2.0",
    "svelte-notifications": "0.9.91"
  }
}

svelte config:

/** @type {import('@sveltejs/kit').Config} */
import adapter from '@sveltejs/adapter-static';

const config = {
	kit: {
		// hydrate the <div id="svelte"> element in src/app.html
		ssr: false,
		target: '#svelte',
		// prerender: {
		// 	enabled: false
		// },
		adapter: adapter({
			pages: 'build',
			assets: 'build',
			fallback: null
		}),

		trailingSlash: 'ignore',
		paths: {
			assets: '',
			base: '/bot'
		},

		vite: () => ({
			ssr: {
				noExternal: ['svelte-hero-icons']
			},
			optimizeDeps: {
				include: ['svelte-hero-icons']
			},
			base: "/bot",
			server: {
				watch: {
					usePolling: true,
					interval: 500
				}
			}
		})
	}
};

export default config;

Logs

> Missing "./ssr" export in "svelte" package
Error: Missing "./ssr" export in "svelte" package
    at bail (...\frontend\node_modules\vite\dist\node\chunks\dep-c1a9de64.js:38264:8)
    at resolve$1 (...\frontend\node_modules\vite\dist\node\chunks\dep-c1a9de64.js:38340:10)
    at resolveExports (...\frontend\node_modules\vite\dist\node\chunks\dep-c1a9de64.js:38769:12)
    at resolveDeepImport (...\frontend\node_modules\vite\dist\node\chunks\dep-c1a9de64.js:38786:26)
    at tryNodeResolve (...\frontend\node_modules\vite\dist\node\chunks\dep-c1a9de64.js:38575:11)
    at Context.resolveId (...\frontend\node_modules\vite\dist\node\chunks\dep-c1a9de64.js:38459:28)
    at Object.resolveId (...\frontend\node_modules\vite\dist\node\chunks\dep-c1a9de64.js:50882:55)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async ...\frontend\node_modules\vite\dist\node\chunks\dep-c1a9de64.js:75199:27
    at async optimizeDeps (...\frontend\node_modules\vite\dist\node\chunks\dep-c1a9de64.js:73162:31)

System Info

Windows 10
svelte kit "next" (which at current time is 146)

Severity

blocking all usage of SvelteKit

Additional Information

No response

@dominikg
Copy link
Member

svelte/ssr was added in svelte v3.39.0 via sveltejs/svelte#6416

the latest version of vite-plugin-svelte adds that to vite.optimizeDeps config which leads to the bug you're seeing.
If you're able to update svelte, this bug should go away. The next version of vite-plugin-svelte is going to include a fix.
Give me a couple of minutes...

@dominikg
Copy link
Member

should be fixed in vite-plugin-svelte@1.0.0-next.17 please try again

@benmccann benmccann linked a pull request Aug 12, 2021 that will close this issue
5 tasks
@gigitalz
Copy link
Author

It picked your changes and it works now, wiped reinstalled all again.

@gigitalz
Copy link
Author

If I add -H to svelte kit to the try with https it returns me this error. I thought it should work anyway with a self signed certificate but it doesn't. Do I need to provide my own certificate in the vite config?

[1] > Cannot read property 'key' of undefined
[1] TypeError: Cannot read property 'key' of undefined
[1]     at get_server (.../frontend/node_modules/@sveltejs/kit/dist/chunks/index3.js:19:19)
[1]     at Watcher.init_server (.../node_modules/@sveltejs/kit/dist/chunks/index.js:3252:23)
[1]     at Watcher.init (.../node_modules/@sveltejs/kit/dist/chunks/index.js:3211:14)
[1]     at async .../node_modules/@sveltejs/kit/dist/cli.js:891:20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants