-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Labels
awaiting submitterneeds a reproduction, or clarificationneeds a reproduction, or clarification
Description
Describe the bug
I was trying to integrate svelte with phoenix liveview and initially there were no issues.
However after upgrading from [email protected] -> [email protected]. I get the below error when trying to build.
Downgrading to [email protected] successfully builds.
Reproduction
import Counter from "./pages/Counter.svelte";
import Ledgers from "./pages/Ledgers.svelte";
import { mount, unmount } from "svelte";
const components = {
Counter, Ledgers
};
function parsedProps(el) {
const props = el.getAttribute("data-props");
return props ? JSON.parse(props) : {};
}
const Hooks = {};
Hooks.SvelteHook = {
mounted() {
const componentName = this.el.getAttribute("data-name");
if (!componentName) throw new Error("Component name must be provided");
const requiredApp = components[componentName];
if (!requiredApp) {
throw new Error(
`Unable to find ${componentName} component. Did you forget to import it into hooks.js?`,
);
}
const pushEvent = (event, data, callback) => {
this.pushEvent(event, data, callback);
};
const handleEvent = (event, callback) => {
this.handleEvent(event, callback);
}
const goto = (href) => {
this.pushHistoryPatch(href, "push", this.el);
};
// eslint-disable-next-line no-undef
const props = $state({ ...parsedProps(this.el), pushEvent, handleEvent, goto })
this._instance = mount(requiredApp, {
target: this.el,
props
});
},
updated() {
this._instance.update({ ...parsedProps(this.el) })
},
destroyed() {
if (this._instance) {
window.addEventListener("phx:page-loading-stop", () => unmount(this._instance), { once: true })
}
},
};
export default Hooks;Logs
error during build:
[vite-plugin-svelte-module] [plugin vite-plugin-svelte-module] Cannot read properties of undefined (reading 'some')
file: /home/hvaria/repos/subledger/assets/src/hooks.svelte.js
TypeError: [plugin vite-plugin-svelte-module] Cannot read properties of undefined (reading 'some')
at validate_assignment (file:///home/hvaria/repos/subledger/assets/node_modules/svelte/src/compiler/phases/2-analyze/visitors/shared/utils.js:45:24)
at AssignmentExpression (file:///home/hvaria/repos/subledger/assets/node_modules/svelte/src/compiler/phases/2-analyze/visitors/AssignmentExpression.js:11:2)
at next (file:///home/hvaria/repos/subledger/assets/node_modules/zimmerframe/src/walk.js:107:21)
at _ (file:///home/hvaria/repos/subledger/assets/node_modules/svelte/src/compiler/phases/2-analyze/index.js:126:3)
at visit (file:///home/hvaria/repos/subledger/assets/node_modules/zimmerframe/src/walk.js:101:13)
at Object.next (file:///home/hvaria/repos/subledger/assets/node_modules/zimmerframe/src/walk.js:63:23)
at ExpressionStatement (file:///home/hvaria/repos/subledger/assets/node_modules/svelte/src/compiler/phases/2-analyze/visitors/ExpressionStatement.js:37:10)
at next (file:///home/hvaria/repos/subledger/assets/node_modules/zimmerframe/src/walk.js:107:21)
at _ (file:///home/hvaria/repos/subledger/assets/node_modules/svelte/src/compiler/phases/2-analyze/index.js:126:3)
at visit (file:///home/hvaria/repos/subledger/assets/node_modules/zimmerframe/src/walk.js:101:13)System Info
upgrade from [email protected] -> [email protected]Severity
blocking an upgrade
webJose, brunocalou and mquandalle
Metadata
Metadata
Assignees
Labels
awaiting submitterneeds a reproduction, or clarificationneeds a reproduction, or clarification