-
Notifications
You must be signed in to change notification settings - Fork 6
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
"svelte-persistent-store/dist/local" not found #15
Comments
I'm having this same issue, just using Rollup. However, I did try to convert to Snowpack last week but reverted. Also, for some reason Rollup is trying to find this module via a double/nested |
Yes, I also noticed the double dist path with snowpack. Couldn't reproduce consistently though. |
I added all the non-test root files in |
I'm having the same issue: |
We replace `rollup` with `webpack` to make our builds faster. While webpack is not faster without a cache it supports persistent caches in the file system which makes it significantly faster in development. Webpack is also significantly faster in watch mode. On my machine a rollup build and a webpack build without a cache take about 60 seconds. If a cache is present webpack builds the project in 8-9 seconds. When updating a file in watch mode rollup takes 7-8 seconds to rebuild. Webpack rebuilds the project in under a second. Another thing to note is that in the past I spent multiple hours investigating issues with rollup and tweaking the config. None of this was necessary for webpack. We also gain more functionality, for example we can now leverage templating in the HTML document. Some implementation notes: * We patch `package.json` of `svelte-persistent-store` because of [this issue][sps-issue]. This only worked before because rollup itself was buggy. * We add some dependencies that are used in our source code but were not explicitly specified. * We use `html-webpack-plugin` to dynamically build `public/index.html` and configure it for different environments. * We remove `bundle.css`. CSS is now injected during runtime via JS. Follup-up: * We still need to leverage the webpack cache on CI [sps-issue]: andsala/svelte-persistent-store#15 Signed-off-by: Thomas Scholtes <thomas@monadic.xyz>
We replace `rollup` with `webpack` to make our builds faster. While webpack is not faster without a cache it supports persistent caches in the file system which makes it significantly faster in development. Webpack is also significantly faster in watch mode. On my machine a rollup build and a webpack build without a cache take about 60 seconds. If a cache is present webpack builds the project in 8-9 seconds. When updating a file in watch mode rollup takes 7-8 seconds to rebuild. Webpack rebuilds the project in under a second. Another thing to note is that in the past I spent multiple hours investigating issues with rollup and tweaking the config. None of this was necessary for webpack. We also gain more functionality, for example we can now leverage templating in the HTML document. Some implementation notes: * We patch `package.json` of `svelte-persistent-store` because of [this issue][sps-issue]. This only worked before because rollup itself was buggy. * We add some dependencies that are used in our source code but were not explicitly specified. * We use `html-webpack-plugin` to dynamically build `public/index.html` and configure it for different environments. * We remove `bundle.css`. CSS is now injected during runtime via JS. Follup-up: * We still need to leverage the webpack cache on CI [sps-issue]: andsala/svelte-persistent-store#15 Signed-off-by: Thomas Scholtes <thomas@monadic.xyz>
We replace `rollup` with `webpack` to make our builds faster. While webpack is not faster without a cache it supports persistent caches in the file system which makes it significantly faster in development. Webpack is also significantly faster in watch mode. On my machine a rollup build and a webpack build without a cache take about 60 seconds. If a cache is present webpack builds the project in 8-9 seconds. When updating a file in watch mode rollup takes 7-8 seconds to rebuild. Webpack rebuilds the project in under a second. Another thing to note is that in the past I spent multiple hours investigating issues with rollup and tweaking the config. None of this was necessary for webpack. We also gain more functionality, for example we can now leverage templating in the HTML document. Some implementation notes: * We patch `package.json` of `svelte-persistent-store` because of [this issue][sps-issue]. This only worked before because rollup itself was buggy. * We add some dependencies that are used in our source code but were not explicitly specified. * We use `html-webpack-plugin` to dynamically build `public/index.html` and configure it for different environments. * We remove `bundle.css`. CSS is now injected during runtime via JS. Follup-up: * We still need to leverage the webpack cache on CI [sps-issue]: andsala/svelte-persistent-store#15 Signed-off-by: Thomas Scholtes <thomas@monadic.xyz>
We replace `rollup` with `webpack` to make our builds faster. While webpack is not faster without a cache it supports persistent caches in the file system which makes it significantly faster in development. Webpack is also significantly faster in watch mode. On my machine a rollup build and a webpack build without a cache take about 60 seconds. If a cache is present webpack builds the project in 8-9 seconds. When updating a file in watch mode rollup takes 7-8 seconds to rebuild. Webpack rebuilds the project in under a second. Another thing to note is that in the past I spent multiple hours investigating issues with rollup and tweaking the config. None of this was necessary for webpack. We also gain more functionality, for example we can now leverage templating in the HTML document. Some implementation notes: * We patch `package.json` of `svelte-persistent-store` because of [this issue][sps-issue]. This only worked before because rollup itself was buggy. * We add some dependencies that are used in our source code but were not explicitly specified. * We use `html-webpack-plugin` to dynamically build `public/index.html` and configure it for different environments. * We remove `bundle.css`. CSS is now injected during runtime via JS. Follup-up: * We still need to leverage the webpack cache on CI [sps-issue]: andsala/svelte-persistent-store#15 Signed-off-by: Thomas Scholtes <thomas@monadic.xyz>
We replace `rollup` with `webpack` to make our builds faster. While webpack is not faster without a cache it supports persistent caches in the file system which makes it significantly faster in development. Webpack is also significantly faster in watch mode. On my machine a rollup build and a webpack build without a cache take about 60 seconds. If a cache is present webpack builds the project in 8-9 seconds. When updating a file in watch mode rollup takes 7-8 seconds to rebuild. Webpack rebuilds the project in under a second. Another thing to note is that in the past I spent multiple hours investigating issues with rollup and tweaking the config. None of this was necessary for webpack. We also gain more functionality, for example we can now leverage templating in the HTML document. Some implementation notes: * We patch `package.json` of `svelte-persistent-store` because of [this issue][sps-issue]. This only worked before because rollup itself was buggy. * We add some dependencies that are used in our source code but were not explicitly specified. * We use `html-webpack-plugin` to dynamically build `public/index.html` and configure it for different environments. * We remove `bundle.css`. CSS is now injected during runtime via JS. Follup-up: * We still need to leverage the webpack cache on CI [sps-issue]: andsala/svelte-persistent-store#15 Signed-off-by: Thomas Scholtes <thomas@monadic.xyz>
We replace `rollup` with `webpack` to make our builds faster. While webpack is not faster without a cache it supports persistent caches in the file system which makes it significantly faster in development. Webpack is also significantly faster in watch mode. On my machine a rollup build and a webpack build without a cache take about 60 seconds. If a cache is present webpack builds the project in 8-9 seconds. When updating a file in watch mode rollup takes 7-8 seconds to rebuild. Webpack rebuilds the project in under a second. Another thing to note is that in the past I spent multiple hours investigating issues with rollup and tweaking the config. None of this was necessary for webpack. We also gain more functionality, for example we can now leverage templating in the HTML document. Some implementation notes: * We patch `package.json` of `svelte-persistent-store` because of [this issue][sps-issue]. This only worked before because rollup itself was buggy. * We add some dependencies that are used in our source code but were not explicitly specified. * We use `html-webpack-plugin` to dynamically build `public/index.html` and configure it for different environments. * We remove `bundle.css`. CSS is now injected during runtime via JS. Follup-up: * We still need to leverage the webpack cache on CI [sps-issue]: andsala/svelte-persistent-store#15 Signed-off-by: Thomas Scholtes <thomas@monadic.xyz>
I had the same issue with rollup and resolve this with import { writable } from "svelte-persistent-store/local.js"; |
this is due to the path mapping given by the exports field of the "exports": {
".": "./dist/index.js",
"./": "./dist/"
}, any import with "svelte-persistent-store/[something]" is rewritten into "./node-modules/svelte-persistent-store/dist/[something]". this "exports": {
".": "./dist/index.js",
"./*": "./dist/*"
}, subpath folder mappings is deprecated
or exports field is it necessary?
|
I'm trying to run this with SvelteKit and run into the same issue. import { writable, readable, derived } from 'svelte-persistent-store/dist/local'; [vite] Internal server error: Failed to resolve import "svelte-persistent-store/dist/local" from "src/lib/authstore.ts". Does the file exist?
Plugin: vite:import-analysis
File: /home/spen/svelte-app-mui/src/lib/authstore.ts
1 | import { writable } from "svelte-persistent-store/dist/local";
| ^
2 | export const jwt = writable("jwt", "");
3 |
at formatError (/home/spen/svelte-app-mui/node_modules/vite/dist/node/chunks/dep-c1a9de64.js:50738:46)
at TransformContext.error (/home/spen/svelte-app-mui/node_modules/vite/dist/node/chunks/dep-c1a9de64.js:50734:19)
at normalizeUrl (/home/spen/svelte-app-mui/node_modules/vite/dist/node/chunks/dep-c1a9de64.js:74223:26)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async TransformContext.transform (/home/spen/svelte-app-mui/node_modules/vite/dist/node/chunks/dep-c1a9de64.js:74356:57)
at async Object.transform (/home/spen/svelte-app-mui/node_modules/vite/dist/node/chunks/dep-c1a9de64.js:50939:30)
at async transformRequest (/home/spen/svelte-app-mui/node_modules/vite/dist/node/chunks/dep-c1a9de64.js:66763:29)
at async viteTransformMiddleware (/home/spen/svelte-app-mui/node_modules/vite/dist/node/chunks/dep-c1a9de64.js:66904:32) import { local } from 'svelte-persistent-store';
const { writable, readable, derived } = local; [vite] Error when evaluating SSR module /src/lib/authstore.ts:
TypeError: Cannot destructure property 'writable' of '__vite_ssr_import_0__.local' as it is undefined.
at /home/spen/svelte-app-mui/src/lib/authstore.ts:19:18
at instantiateModule (/home/spen/svelte-app-mui/node_modules/vite/dist/node/chunks/dep-c1a9de64.js:73464:166)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
Cannot destructure property 'writable' of '__vite_ssr_import_0__.local' as it is undefined.
TypeError: Cannot destructure property 'writable' of '__vite_ssr_import_0__.local' as it is undefined.
at /home/spen/svelte-app-mui/src/lib/authstore.ts:19:18
at instantiateModule (/home/spen/svelte-app-mui/node_modules/vite/dist/node/chunks/dep-c1a9de64.js:73464:166)
at processTicksAndRejections (internal/process/task_queues.js:95:5) I'm new to Svelte and have no clue how to solve this. The workaround proposed by @lhapaipai does not work for me (nothing of what he wrote). |
Okay, so the issue for me seems to be the SSR of SvelteKit. See the section I tried to figure out a solution with the standard writable and came up with the following. See also my answer on StackOverflow. As a bonus this solution also updates the writable if the Put this into a typescript file e.g. import { browser } from '$app/env';
import type { Writable } from 'svelte/store';
import { writable, get } from 'svelte/store'
const storage = <T>(key: string, initValue: T): Writable<T> => {
const store = writable(initValue);
if (!browser) return store;
const storedValueStr = localStorage.getItem(key);
if (storedValueStr != null) store.set(JSON.parse(storedValueStr));
store.subscribe((val) => {
if ([null, undefined].includes(val)) {
localStorage.removeItem(key)
} else {
localStorage.setItem(key, JSON.stringify(val))
}
})
window.addEventListener('storage', () => {
const storedValueStr = localStorage.getItem(key);
if (storedValueStr == null) return;
const localValue: T = JSON.parse(storedValueStr)
if (localValue !== get(store)) store.set(localValue);
});
return store;
}
export default storage This can be used like this: import storage from '$lib/store'
interface Auth {
jwt: string
}
export const auth = storage<Auth>("auth", { jwt: "" }) Maybe this package could be updated to also work around the SSR. |
I'm getting this error using snowpack
Dependency Install Error: Package "svelte-persistent-store/dist/local" not found. Have you installed it?
Package was installed correctly with npm.
Any ideas?
The text was updated successfully, but these errors were encountered: