Reputation: 1805
I have this very simple component in a brand new Sveltekit project:
<script context="module" lang="ts">
import type { Load } from '@sveltejs/kit';
export const load: Load = ({ url }) => {
const company = url.searchParams.get('company');
return {
props: {
company
}
};
}
</script>
<script type="ts">
export let company: string;
</script>
<h1>{company}</h1>
However, I always get an error at the import line:
This also happens when I run the app outside VSCode, so it's not just a problem with the IDE.
My package.json:
{
"name": "testapp",
"version": "0.0.1",
"scripts": {
"dev": "svelte-kit dev",
"build": "svelte-kit build",
"package": "svelte-kit package",
"preview": "svelte-kit preview",
"prepare": "svelte-kit sync",
"check": "svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check --plugin-search-dir=. . && eslint .",
"format": "prettier --write --plugin-search-dir=. ."
},
"devDependencies": {
"@sveltejs/adapter-static": "^1.0.0-next.34",
"@sveltejs/kit": "next",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-svelte3": "^4.0.0",
"prettier": "^2.6.2",
"prettier-plugin-svelte": "^2.7.0",
"svelte": "^3.44.0",
"svelte-check": "^2.7.1",
"svelte-preprocess": "^4.10.6",
"tslib": "^2.3.1",
"typescript": "^4.7.2"
},
"type": "module"
}
Does anybody have an idea what's going wrong here?
Upvotes: 3
Views: 3975
Reputation: 1805
Found the solution: when changing the adpater, I accidently removed svelte preprocess from svelte.config.js. Doing it like this, and it works perfcetly fine:
import adapter from '@sveltejs/adapter-static';
import preprocess from 'svelte-preprocess';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: preprocess(),
kit: {
adapter: adapter()
}
};
export default config;
Upvotes: 7