-
Notifications
You must be signed in to change notification settings - Fork 122
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
Can't export createWidget in Vite 5 #667
Comments
I am sorry but I have no experience using Sveltekit and limited experience using Vite. Can you please provide a reproducible example for both cases - eg. a repo(s) we can clone? The build/index.js actually does export the |
Hi, example repo is here https://github.com/WhoTargetsMe/typeform-sveltekit-example Previously I was only getting the error on build, but with this example the error is in both build and dev. Here is pretty much the entire code. You can find that in src/routes/+page.svelte <script lang="ts">
import "@typeform/embed/build/css/widget.css";
import { createWidget } from "@typeform/embed";
import { onMount } from "svelte";
const formId = "y1uAAugn";
let elem: HTMLElement;
onMount(() => {
elem = document.createElement("div");
try {
createWidget(formId, {
container: elem,
});
} catch (error) {
console.error("Error creating Typeform widget", error);
}
});
</script>
<div bind:this={elem} />
|
Hi @skinofstars Are you still experiencing an issue with this? I played around with your example. It looks like importing the embed lib like this works: import * as pkg from '@typeform/embed'; My no experience with Svelte is limited, though. We did not test the lib with this framework. Sorry for the delayed response. |
Hi, yes I did fix this! My problem was <script lang="ts">
import '@typeform/embed/build/css/widget.css';
import { createWidget } from '@typeform/embed';
import { onMount } from 'svelte';
export let formId: string;
export let options = {};
let elem: HTMLElement;
onMount(() => {
try {
createWidget(formId, {
container: elem,
...options
});
} catch (error) {
console.error('Error creating Typeform widget', error);
}
});
</script>
<div bind:this={elem} /> |
Thats great to hear 🚀 Thanks for sharing! |
Hi, I've got a Sveltekit 2 project using Vite 5.
When I use
import { createWidget } from '@typeform/embed';
I can't build as I get the following error:"createWidget" is not exported by "node_modules/@typeform/embed/build/index.js"
This has worked when I was using Sveltekit 1, Vite 4.
The text was updated successfully, but these errors were encountered: