Open erictaylor opened 1 year ago
For me, simply adding a script tag to import require.min.js
in index.html works fine.
I moved over to react-twitter-widgets https://www.npmjs.com/package/react-twitter-widgets
It's a drop-in replacement which doesn't have this problem.
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.