justinmahar / react-social-media-embed

📰 Easily embed social media posts from Facebook, Instagram, LinkedIn, Pinterest, TikTok, X (Twitter), and YouTube in React.
https://justinmahar.github.io/react-social-media-embed/
MIT License
225 stars 31 forks source link

Parse failed on Babel-loader #2

Closed timomak closed 2 years ago

timomak commented 2 years ago

I get this error when trying to compile the project.

Module parse failed: Unexpected token (135:23) File was processed with these loaders: ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js You may need an additional loader to handle the result of these loaders.

const win = typeof window !== 'undefined' ? window : undefined; if (!win.instgrm?.Embeds) { const scriptElement = document.createElement('script'); scriptElement.setAttribute('src', '//www.instagram.com/embed.js');

I tried debugging it with no success. Let me know if I can be of help debugging it!

import { EmbedPlaceholder } from 'react-social-media-embed';

justinmahar commented 2 years ago

@timomak Ahh. This is a complaint about the ?. optional chaining syntax which is a newer JS feature. I'll lower my compilation target to ES2015, that should do the trick. Will have something ready this evening. Thanks for such amazing feedback on this library!

justinmahar commented 2 years ago

@timomak Alright, I believe I've corrected the issue. Give it a try.

npm i react-social-media-embed@latest

FYI, I'm still working on placeholders for each platform. I've updated the docs here with the latest changes.

timomak commented 2 years ago

Wow, wonderful! Thank you, this embed is super cool!

Found a few more bugs, all hopefully easy to squash. I'll open up a few issues, feel free to message me with a follow up on anything!

justinmahar commented 2 years ago

Thanks and you’re welcome! Going to put a little more time into this today.

Will try to address those issues best I can, or at least have some workarounds for you.

Centering is a little tricky because the embeds sometimes have a mind of their own. I’ll add some stories to the docs site for centering so you can see the CSS for that. I’ll see if I can get them all to behave.