aralroca / next-translate-plugin

Next-translate plugin for i18n in Next.js 🌍 - Load page translations and use them in an easy way!
MIT License
31 stars 20 forks source link

Nx Nextjs build crashes with error "Module not found: Can't resolve 'fs'" For ISR Pages #84

Open smithgajjar09 opened 4 months ago

smithgajjar09 commented 4 months ago

What version of this package are you using? 2.6.2

What operating system, Node.js, and npm version? Mac, node - v18.17.1, npm - 9.6.7

What happened?

When i am using next-translate inside next.config.js it breaks my app with following error message - Module not found: Can't resolve 'fs' But when remove next-translate from next.config.js, it works fine and also builds the code. Interestingly when I use next-translate along with appWithI18n in _app it starts working again with no issues in the build (Please note even if i have used appWithI18n, loader prop is not set in i18n.js config file)

On digging further found out that this might be causing due to ISR pages, I have both getStaticProps and getServerSideProps to support ISR. When i build my app with next-translate it uses only getStaticProps as loader and does not include getServerSideProps for ISR as a part of the build. Due to which it causes server side code to be included inside client bundle and thus causing above error.

image

Is there a way to support ISR pages as well for i18n ?

What did you expect to happen? Should build next app

Are you willing to submit a pull request to fix this bug? No