philnash / sapper-twilio-chat

0 stars 0 forks source link

Babel setup #1

Open benmccann opened 3 years ago

benmccann commented 3 years ago

The code is failing in Sapper's find_css for babel-runtime/regenerator. I can add a safety check for this in Sapper, but is seems like there might be something wrong with this repo. When I do npm run build I get all kinds of warnings and errors related to babel

philnash commented 3 years ago

Thanks for looking into this @benmccann. I've taken this back to the team building the Chat SDK to try to sort the babel issues.

It would be really useful to see more of a stack trace out of a failure like this, is that possible at all?

benmccann commented 3 years ago

Yeah, I agree that should be fixed. Normally if you just run npm run build instead of npm run dev you'll get more details. I'm not sure why you're getting different errors in this case. I updated Sapper to protect against the issue you're seeing in dev so hopefully it'll be fixed in the next release

philnash commented 3 years ago

Awesome, thanks!

benmccann commented 3 years ago

Sapper 0.28.9 is out now if you'd like to test if that works any better for you

philnash commented 3 years ago

Thanks for this @benmccann! Trying again with version 0.28.9 let the build complete which revealed the underlying issue.

The Sapper/Rollup client build seems to use the browser key in the package.json. In the case of Twilio Chat, the browser version had a bunch of requires from babel-runtime but babel-runtime wasn't in the dependencies. So the build left them as external, but they weren't available. Thus, the front-end failed with missing dependencies.

The fix for Twilio Chat users right now is to either import Chat from "twilio-chat/dist/twilio-chat" or install babel-runtime as a dependency to their app.

Thanks for your help!