Skip to content

Cannot redefine property: $persist #3353

Answered by ekwoka
terryupton asked this question in 5. Bugs
Discussion options

You must be logged in to vote

It looks like this is vite with HMR.

You can't really do HMR with the Alpine build, as there isn't a way to (currently) throw away an actively running stance of Alpine.

Vite is trying to run the persist plugin twice.

You can prevent the errors by checking if the properties already exist on Alpine before adding the plugin and similarly check that Alpine hasn't already run before running it again.

I think you can also use @refresh reload as a comment in that file to make the browser reload instead of doing HMR when it might want to.

That's all vite stuff for dev only.

So the error itself is an incompatibility between how Alpine in implemented and vites HMR system.

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by terryupton
Comment options

You must be logged in to vote
2 replies
@Paperweb
Comment options

@ekwoka
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants