{"id":794,"hash":"cb0fa33268de37f7e41507246b0c4a8635ebf19584e31cca4d82bda30bc75fba","pattern":"Uncaught (in promise) TypeError: Illegal constructor at new SvelteElement (index.mjs:1381)","full_message":"Uncaught promise when registering a custom element using the latest\n  sapper, svelte, nodeJS, and rollup stack using the following\n  statements.\n\nREPL example: https://svelte.dev/repl/489ee8acd10848b0bb1feb2535bd6cc5?version=3.16.5 created locally\n\n<svelte:options tag=\"parlax-background\" />\n    & rollup.config.js\n    export default {\n    client: {\n    input: config.client.input(),\n    output: config.client.output(),\n    plugins: [\n    replace({...})\n    svelte({\n    dev: !production,\n    customElement: true,\n    // and tried also with customElement: { tag: \"my-element\"}\n    hydratable: true,\n    emitCss: true\n\nI want to mention that I had tested on a fresh project\n\nLogs\n\n[Client Side]\n    => Uncaught (in promise) TypeError: Illegal constructor\n    at new SvelteElement (index.mjs:1381)\n    [Server Side]\n    => The 'tag' option is used when generating a custom element. Did you forget the 'customElement: true' compile option?\n    44: <svelte:options tag=\"my-element\" />\n\n1. When I registering  [ **customElement: true ] in the config i get**\n\n2. If I do not register my element in the config I do not get any error, but neither my element is registered  :(\n\nRef: https://github.com/sveltejs/svelte/issues/4132","ecosystem":"npm","package_name":"custom-element","package_version":null,"solution":"As described in the referenced GitHub issue, once you configure the Svelte compiler with customElements: true, you're expected to provide an element tag for all your components (using <svelte:options tag=\"my-component\"/>.\n\nIn your REPL's example, this would mean updating App.svelte with e.g. <svelte:options tag=\"my-app\"/>\n\nWhen you now run the app, you should not see the error in the console anymore, but a working app.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/59437094/uncaught-in-promise-typeerror-illegal-constructor-at-new-svelteelement-index","votes":8,"created_at":"2026-04-19T04:51:43.009329+00:00","updated_at":"2026-04-19T04:51:43.009329+00:00"}