You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When shipping to production you end up getting errors about "require" not being defined.
For my project I've manually patched this problem by creating a Yarn patch and refactored all usage of the require('scriptjs') in effects to use dynamic imports instead:
useEffect(()=>{// ...constloadScript=async()=>{constscriptModule=awaitimport('scriptjs');constscript=scriptModule.default;// ... specific script() call for given useEffect};loadScript();// ... the useEffect return statement},[/* the deps */];
I'm happy to provide a PR to make this change @saurabhnemade if desired.
The text was updated successfully, but these errors were encountered:
The "modern" build of this library causes problems with some build systems (such as Vite) because of the usage of dynamic requires (ex: https://github.com/saurabhnemade/react-twitter-embed/blob/master/src/components/TwitterTweetEmbed.tsx#L41) since "require" is a Node thing.
When shipping to production you end up getting errors about "require" not being defined.
For my project I've manually patched this problem by creating a Yarn patch and refactored all usage of the
require('scriptjs')
in effects to use dynamic imports instead:I'm happy to provide a PR to make this change @saurabhnemade if desired.
The text was updated successfully, but these errors were encountered: