-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
TypeError: Cannot read properties of undefined (reading '$$') when using 0.42.0 or newer #896
Comments
same environment and same error for me too. The error occurs if you want to render a received component with EXAMPLE CODEcreate a custom event and dispatch at some far place...
const register = new CustomEvent(
"REGISTER_APP",
{
bubbles: true,
detail: {
mycomponent: SomeSvelteComponent,
},
}
)
window.dispatchEvent(register); catch the custom event at store...
export const customComponent = writable(undefined)
window.addEventListener("REGISTER_APP", e => {
customComponent.set(e.detail.mycomponent)
});
... use component...
import { customComponent } from "./store"
<div>
{#if $customComponent}
<svelte:component this={$customComponent} />
{/if}
</div>
... something fails when setting the component but what that I dont know yet. |
Can confirm the same error with v0.42.0 or higher. My env: svelte: 3.44.1 |
I recall experiencing a similar error when using a Svelte library that ships bundled ESM code in addition to uncompiled Svelte source files. Just a hunch, but I wonder if it is trying to use the bundled Carbon Svelte library instead of the uncompiled source. |
Related issue: sveltejs/svelte#6584 |
I was able to repro the error using esbuild + esbuild-svelte + carbon-components-svelte. I definitely think it's related to - "main": "./lib/index.js",
- "module": "./lib/index.mjs",
+ "main": "./src/index.js", It should be prudent to drop support for the bundled source code, and instead point the "svelte" and "main" fields to the Svelte source code. This practice also seems to be encouraged by |
Your PR fixed my issue. Thanks ! |
When I'm using any components from carbon-components-svelte. It trigger the following error :
Here is the code that trigger the error. It happen when I'm using any components (buttons, forms, accordions):
I don't have this issue if I'm using the 0.41.0 version. It start breaking at 0.42.0 or newer.
My package versions :
svelte: 3.44.1
esbuild: 0.13.12
esbuild-svelte: 0.5.7 (and tested with 0.5.3 too)
The text was updated successfully, but these errors were encountered: