Skip to content
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

ReferenceError: Element is not defined #8

Open
linonetwo opened this issue Feb 3, 2024 · 3 comments · May be fixed by #9
Open

ReferenceError: Element is not defined #8

linonetwo opened this issue Feb 3, 2024 · 3 comments · May be fixed by #9

Comments

@linonetwo
Copy link

Get this error from esbuild when add this to my existing project

import { ConnectionObserver } from '@wessberg/connection-observer';
@wessberg
Copy link
Owner

wessberg commented Feb 3, 2024

Element is a global object defined within browser runtimes. If your build fails with this error, that's because you're attempting to execute this code server-side. I'm guessing you're doing some type of SSR. To resolve this, either make sure this code will never execute server-side, or mock browser-specific globals such as Element. JSDom is an example of a library that shims a browser environment for Node.js. But ideally, this code should strictly execute in the browser.

@linonetwo
Copy link
Author

Thanks, I was confused, because I only use Element as type on my code

render(parent: Element, nextSibling: Element) {

Tiddlywiki is a universal framework, so it might run on server side.

After make sure this only run on browser side, this is fixed.

@linonetwo
Copy link
Author

You have some code that execute immediately, so will execute when render, it is hard to elegently avoid them.

@linonetwo linonetwo reopened this Mar 28, 2024
@linonetwo linonetwo linked a pull request Mar 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants