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

"window is not defined" Error Persists in SSR Context Despite Fixes #92

Open
luvkapur opened this issue May 22, 2024 · 0 comments
Open

Comments

@luvkapur
Copy link

luvkapur commented May 22, 2024

Description

quill-magic-url in ssr throws "window is not defined" error.

Although PR #42 aimed to address this by guarding the window object checks before registering the MagicUrl module, this error persists in the compiled dist/index.js. The UMD build wrapper used might be executing some code that expects the window object to be present globally, which is not the case in ssr.

Steps to Reproduce

  • Integrate quill-magic-url with a server-rendered application
  • Attempt to render a page that includes the Quill editor and quill-magic-url
  • Note that a server-side render attempt throws a "window is not defined" error.

Expected Behaviour

The module should not attempt to access or modify the window object when executed in a server-side environment

Actual Behaviour

The error "window is not defined" is thrown. The UMD output specifically invokes a function with window as a parameter immediately during module definition:

!function(t,e){...}(window, (function(){...}));

This pattern assumes window is available globally at the time of script execution, which leads to issues under Node.js where window is undefined.

I guess I could get around this by lazily importing it during render instead. But it would be nice to have the module supports SSR out of the box

Environment:

OS: macOS Sonoma 14.4.1
Browser: Chrome, Server-side (Node.js)
Version of quill-magic-url: 4.2.0
Node.js version: 18.16.1

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

No branches or pull requests

1 participant