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
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
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:
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