Skip to content

fix: proper mjs file extension to support astro, and NextJS 13 app directory support #240

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

Merged
merged 2 commits into from
Jan 29, 2023

Conversation

sammarks
Copy link
Collaborator

@sammarks sammarks commented Jan 29, 2023

Resolves #238
Resolves #219

Astro Support: All I changed for this was adding .mjs to the extension of all of the files inside the dist/esm directory, because Astro seems to be happier with importing those than when they ended in just .js (even though package.json mentions they are for ESM; so this is probably an Astro bug, but 🤷🏼‍♂️)

NextJS 13 (Server Component) Support: The primary issue is around createContext being used, so I had to create a completely separate distribution targeted to be used in server components, where none of the icons import the context. I would like to have just added IconoirContext.server.mjs (like React Native supports) and just returned a dummy context, but, alas, server components does not support that and instead requires a new entry inside the exports configuration on package.json, which means I have to create a completely separate version of the package.

If you are using IconoirProvider inside a NextJS server component, you will receive a warning in the console at build time (since NextJS does not support server components), but not if you use any other icon.

@pheralb
Copy link

pheralb commented Jan 29, 2023

Thanks 🥹✨

@sammarks sammarks changed the title fix: proper mjs file extension to support astro fix: proper mjs file extension to support astro, and NextJS 13 app directory support Jan 29, 2023
@sammarks sammarks merged commit 888f634 into main Jan 29, 2023
@sammarks sammarks deleted the astro-support branch January 29, 2023 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

👨‍🚀 Compatibility with Astro React Server Components not supported in NextJS 13
2 participants