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

ReferenceError: self is not defined after migrating to sveltekit2 #526

Closed
noobmaster19 opened this issue Dec 16, 2023 · 8 comments · Fixed by #527
Closed

ReferenceError: self is not defined after migrating to sveltekit2 #526

noobmaster19 opened this issue Dec 16, 2023 · 8 comments · Fixed by #527

Comments

@noobmaster19
Copy link

Here's a shortened form of the error:

4:16:44 PM [vite] Error when evaluating SSR module 
...
ReferenceError: self is not defined
    at .../.pnpm/svelte-dnd-action@0.9.34_svelte@4.2.8/node_modules/svelte-dnd-action/dist/index.js:4:23
    at .../.pnpm/svelte-dnd-action@0.9.34_svelte@4.2.8/node_modules/svelte-dnd-action/dist/index.js:5:2
    at instantiateModule 
@isaacHagoel
Copy link
Owner

isaacHagoel commented Dec 16, 2023 via email

@Rar9
Copy link

Rar9 commented Dec 16, 2023

+1 getting the same [vite] Error when evaluating SSR module
ReferenceError: self is not defined

@Rar9
Copy link

Rar9 commented Dec 16, 2023

down grading from 0.9.34 to 0.9.33 helps but gives this warning

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

svelte-dnd-action@0.9.33

Please see https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#missing-exports-condition for details.

@isaacHagoel
Copy link
Owner

@Rar9 yeah that's the warning 0.9.34 was supposed to fix. checking what this new error is about

@isaacHagoel
Copy link
Owner

I don't have time to get to the bottom of this now (hopefully tomorrow). The lib itself doesn't use "self" (it does use "window" quite a lot) so this error has to do with the code that rollup adds (the irony :)) as can be seen here. Version 0.9.33 has that too, see here so I am not sure why it doesn't trigger the same error. This wasn't a problem with Sveltekit 1 so very strange indeed.
This means that changes to the library code will not solve the issue. It has to be something in the rollup config or the exports config or god knows what.
I followed the advice on the link with 0.9.34 thinking it is a quick fix but looks like I was wrong.
Use 0.9.33 for now. It has all the latest feature.

I will try to make some time for this tomorrow. If anyone knows the solution please do let me know :)

@isaacHagoel
Copy link
Owner

okay, it was a silly mistake i made. please used 0.9.35

@Rar9
Copy link

Rar9 commented Dec 16, 2023

your new updated works, iconify/svelte has the same issue ReferenceError ... what did u change?

@isaacHagoel
Copy link
Owner

I added this to package.json:

"exports": {
        ".": {
            "svelte": "./src/index.js"
        }
    },

Notice that it should point to src not dist, exactly like the top level "svelte" entry in package.json

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.

3 participants