-
Notifications
You must be signed in to change notification settings - Fork 18
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
Sapper issues #14
Comments
i use dynamic import like that: <script>
import { onMount } from "svelte";
let ProgressBar;
onMount(async () => {
const module = await import("@okrad/svelte-progressbar");
ProgressBar = module.default;
});
</script>
{#if typeof window !== 'undefined'}
<svelte:component this={ProgressBar}/>
{/if} and i get this error messege:
|
You need to add svelte-progressbar/package.json Line 6 in e569c16
|
in "exports": {
".": "./package.json",
".": "./index.mjs"
}, and i get the same error message |
i use this component in svelte project with no problems! this is happens only in Sapper (or SSR) |
It might be related to sveltejs/rollup-plugin-svelte#119? |
I create a new template of sapper, with new packages.. So, i get this clean message:
I added this to package.json : "exports": {
".": "./index.mjs",
".": "./package.json"
}, and everything was okay! But in my original sapper project nothing is fixed! i think that's because of the version of rollup, "rollup-plugin-svelte": "^5.0.1",
"rollup-plugin-terser": "^5.3.0", and this in the new sapper template (the test): "rollup-plugin-svelte": "^6.0.0",
"rollup-plugin-terser": "^7.0.0" |
Yes, it fixed by updating both packages But this issue still open until Mr. @okrad reads this message:
Thanks Mr. @benmccann We have to make this component SSR compatible, So the usage of this component inside Sapper is like that: <script>
import { onMount } from "svelte";
let ProgressBar;
let series = [
{
perc: 10,
color: "#5AB6DF"
}
];
onMount(async () => {
const module = await import("@okrad/svelte-progressbar");
ProgressBar = module.default;
});
</script> <svelte:component
this={ProgressBar}
style="semicircle"
{series}
thickness={15}
width="500px" /> |
Hi @zakaria-chahboun, I added the package.json export, your issue should be fixed... I also removed the "legacy" build... It's not needed anymore since I changed the way the progress value label is rendered. Also, thank you @benmccann for your suggestions! |
@okrad When i updated the package (1.9.2) i don't have Stack:
Error: Cannot find module 'typescript' But i install it now, and then this issue is shown! node_modules/@okrad/svelte-progressbar/src/types.d.ts:28:3 - error TS1036: Statements are not allowed in ambient contexts.
28 };
~
✗ client
[svelte-preprocess] Error transforming 'typescript'.
Message:
[svelte-preprocess] Encountered type error
|
I think I definitely fixed the issues with sapper now... Can you confirm it? |
@okrad For svelte project it's working fine! but with Sapper no, This error message is shown up internal/modules/cjs/loader.js:984
throw new ERR_REQUIRE_ESM(filename);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/zaki/Desktop/QuizGame-Sapper-Codyframe/node_modules/@okrad/svelte-progressbar/index.mjs
at Module.load (internal/modules/cjs/loader.js:984:11)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/zaki/Desktop/QuizGame-Sapper-Codyframe/__sapper__/dev/server/server.js:29:35)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
code: 'ERR_REQUIRE_ESM' |
@okrad So i have to load it with the old technic,client side only ( |
Closing, the library is now converted to SvelteKit |
Hi! installed svelte-progressbar by npm
Then i use it like this:
So when i start the project i get this errors! (i don't use typescript)
The text was updated successfully, but these errors were encountered: