Skip to content

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

Merged
sammarks merged 2 commits into
mainfrom
astro-support
Jan 29, 2023
Merged

fix: proper mjs file extension to support astro, and NextJS 13 app directory support#240
sammarks merged 2 commits into
mainfrom
astro-support

Conversation

@sammarks

@sammarks sammarks commented Jan 29, 2023

Copy link
Copy Markdown
Collaborator

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

pheralb commented Jan 29, 2023

Copy link
Copy Markdown

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