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

Uncaught TypeError: Cannot read properties of undefined (reading '$$') #7968

Open
damianof opened this issue Oct 22, 2022 · 3 comments
Open

Comments

@damianof
Copy link

Describe the bug

When referencing an external component library no longer works.
This used to work i previous version of Svelte.

Now, referencing an external component library throws this error at run time:
"Uncaught TypeError: Cannot read properties of undefined (reading '$$')"

Reproduction

Repro code is here https://github.com/damianof/large-scale-apps-my-svelte-project/tree/debug-%24%24-issue
Steps:

  • npm install and build ./my-component-library
  • npm install ./my-svelte-project
  • run my-svelte-project with npm start

Logs

No response

System Info

System:
    OS: macOS 12.6
    CPU: (8) arm64 Apple M2
    Memory: 253.02 MB / 8.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.17.0 - /usr/local/bin/node
    npm: 8.19.2 - /usr/local/bin/npm
  Browsers:
    Chrome: 106.0.5249.119
    Safari: 16.0

Severity

blocking all usage of svelte

@Prinzhorn
Copy link
Contributor

Prinzhorn commented Nov 10, 2022

I didn't run your project but from looking at it, here's what I think: Your component library does not specify a svelte entry point in package.json. So your project is importing the compiled components and now at runtime you have two Svelte instances (with potentially different versions). Refs #3165

Examples:

https://github.com/sveltejs/svelte-scroller/blob/b50ec28bb7fdd9dc8b08ec59b8a34ea7b1d684e6/package.json#L5
https://github.com/isaacHagoel/svelte-dnd-action/blob/148ee38b63919074637095aecfd6e3dcf6770772/package.json#L3
https://grep.app/search?current=2&q=%22svelte%22%3A%20%22.&filter[path.pattern][0]=package.json

@Prinzhorn
Copy link
Contributor

Prinzhorn commented Nov 10, 2022

Yeah, this perfectly explains it given your comment here https://github.com/damianof/large-scale-apps-my-svelte-project/blob/b078d3328024ee34d7322a427eddbb218e447923/my-svelte-project/src/App.svelte#L2-L3
Because when you import from 'my-component-library' it's the compiled components.

@simo-an
Copy link

simo-an commented Sep 6, 2023

If I compile svelte component to web components.

How can I use this web component at my svelte project ?

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

3 participants