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

Svelte 3 weird error #1825

Closed
ValentinH opened this issue Apr 29, 2019 · 8 comments
Closed

Svelte 3 weird error #1825

ValentinH opened this issue Apr 29, 2019 · 8 comments

Comments

@ValentinH
Copy link
Contributor

ValentinH commented Apr 29, 2019

I've just tried the new Svelte 3 template and I get a weird error: Cropper component is not defined (Cropper is my component coming from a npm package).

Is it related to codesandbox or the way the component is exported?

Demo: https://codesandbox.io/s/z2l9zqv73x

@SaraVieira
Copy link
Contributor

Hey!

Svelte 3 has not been deployed yet, so you are still using version 2 for the compiler there

I'm gonna close as we will deploy this tonight and please re open if you still have issues tomorrow

@ValentinH
Copy link
Contributor Author

OK makes sense, I was too impatient! 😄

I don't know if it changes anything, but I had the same error with the deployed branch at http://pr1820.cs.lbogdan.tk/s/z2l9zqv73x though.

@SaraVieira
Copy link
Contributor

Makes sense because it's using the old template with version two of the svelte

We check what version svelte is in to show the accurate compiler :/

I will try your thing as soon as it's live and let you know :)

@SaraVieira
Copy link
Contributor

Hey!

Updated with the new template I get an error in the module
https://codesandbox.io/s/xj4mr8zzxq

@ValentinH
Copy link
Contributor Author

OK, then something is wrong on my module. I've actually noticed this behavior as well when manually importing the index.js (compiled code).

Just to share what I understand: when importing a Svelte shared module in a Svelte application, it should directly read the source file (the one pointed by the "svelte" property of package.json).
On Codesandbox, it behaves differently as it imports directly the index.js file (which is buggy in my case).

Don't know if it makes sense :)

@SaraVieira
Copy link
Contributor

OHHH!

So we get these things from unpkg and that always redirects to the main in the package.json

https://unpkg.com/svelte-easy-crop

@ValentinH
Copy link
Contributor Author

AH yes, I understand better now 🙂

How complex would it be to detect the svelte property of the package.json and retrieve the correct file? For instance, here it would be: https://unpkg.com/svelte-easy-crop@1.0.0/src/Cropper.svelte.

@ValentinH
Copy link
Contributor Author

Hey @SaraVieira, I'm still stuck on this and I can't use CodeSandbox to demo my component 😢 Do you have any idea on how CodeSandbox could detect the svelte property and use it? I'd be happy to provide a PR but I'm not sure where to look at 😄

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

No branches or pull requests

2 participants