New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add back lib export #923
Add back lib export #923
Conversation
- Hopefully this fixes the SSR issue
@NerdCowboy Hey! Thanks for the PR, I've tried this but then the issue is #901 starts again, the problem is when you export named and default imports with SSR. You can create a simple project using Next.JS and try it yourself, or try it in this codesandbox. I haven't found the best way to do it yet, I am happy to work together with you. I was checking at this solution but haven't tried yet: https://stackoverflow.com/a/51519513/4949445 |
@itsmichaeldiego I did some debugging and confirmed the issue appears to be using default and named exports in the same file. If I covert the default export Ignore my commit name on the last push, it does not actually fix the issue entirely, but it does fix it if you consume Obviously not ideal as it's a breaking change, but I'll try to look into this issue more later. |
That would be amazing, thanks @NerdCowboy This way it would work with NextJS only if its named imported, right? |
@NerdCowboy If you look at the latest stable version 1.1.7: https://github.com/google-map-react/google-map-react/tree/1.1.7 |
The issue appears to be with Microbundle. They don't support and seem to actively discourage using mixed named and default exports per developit/microbundle#306. I tried the workaround suggested, but it didn't work for me as it looks like the exports var gets renamed when compiled, so it's never exported. I think React Helmet might have also been bit by this issue, so I'm guessing it's more of a Rollup issue since Microbundle also uses Rollup. nfl/react-helmet#547. They initially only used named exports, but ended using both a named and default export. nfl/react-helmet#395 Not sure what you want to do here. From what I see, here's the options:
Since 2.0 came with breaking changes and 2.0+ itself has technically been broken since its release for anyone using lib methods, I think the path of least resistance would be to convert the default export to a named one. For what it's worth, a lot of people are starting to push for only using named exports Let me know what you think |
Thanks for your research, its super helpful, I didn't know it was a problem with microbundle itself. I did see this problem with rollup though, and I was thinking the only way was to change microbundle to another similar technology. Let me get this straight, you recommend that we convert the default export to a named one for SSR or in general? |
No problem. I'm recommending converting the default export to use a named one only. In general, I think the arguments for using only named exports are pretty sound, but I'm not recommending refactoring any other default exports unless you think it's possible you'll want to add named exports from the same file in the future. Up to you what you want to do though. Just let me know and I'll update my PR or if you want to tackle it, that's cool too. |
I agree with @NerdCowboy, even though it's not ideal - it may be the way to go moving forward! |
@NerdCowboy @karldanninger I agree with you both, I am just worried that we're not providing backwards compatibility for those people using SSR + default import. Instead we're breaking it. I think we should do these steps:
|
7877457
to
8e67c08
Compare
@NerdCowboy @karldanninger Hey folks, I've opened a new issue in microbundle: developit/microbundle#712 and I got an answer, will try that and let you know |
You're the man @itsmichaeldiego! 💪💪 I'm glad they gave a useful response on the issue. |
This was fixed and released in 2.1.3, please let me know if it works!! 🙏 Sorry for the delay! Thanks to both of you! |
Fixes #903
There still may be issues with SSR per #903 (comment). I assume that issue is related to the wildcard export, so I manually exported everything instead.