You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to support SSR with dynamic imports too. In that case, let's say user imported the component inside getInitialProps and pass it to the page via props. We need to support that case allow to do SSR.
Since we don't execute getInitialProps in the client for the first time, we need to find a way to pass down the component from the Server to client.
Reacted by Jesse Ditson, John, Jerome Fitzgerald, Fiona Hopkins, richardgillzdev, Michael Ford, Tom Bray, José Chávez, Brian Partridge, Leland Kwong and 1 more
I've found that if server-side rendering with firebase you need to use firebase-admin and google-storage which are node libraries. Wouldn't want to load these in the client and so it would be nice to be able to load these dynamically if isServer is true when getInitialProps is called.
I was trying to import a client side library (react-leaflet), but was getting errors when this library was getting loaded on the server side for first time page rendering. Making the library to load conditionally was a easy option.
But while conditionally loading the library on the client side, webpack tries to make the bundle again and I get a error for the first load, thereafter it works well.
Activity
arunoda commentedon Jan 10, 2017
@rauchg is this for pages or for anything?
rauchg commentedon Jan 10, 2017
@arunoda anything. Might require whitelisting in config though
impronunciable commentedon Jan 10, 2017
This already works
arunoda commentedon Jan 10, 2017
@impronunciable oh really :)
arunoda commentedon Jan 10, 2017
I got an error. May be we need to bake something more into that.

impronunciable commentedon Jan 10, 2017
Wow, it works on the dev server but not when build + start 🤔
arunoda commentedon Jan 10, 2017
@impronunciable May be dev server serves necessary API endpoints. We may need to allow them in the production for exported chunks.
impronunciable commentedon Jan 10, 2017
that could be
arunoda commentedon Jan 10, 2017
I think this could be easily doable. May be this is the same functionality as
System.importin webpack.mxstbr commentedon Jan 20, 2017
Webpack supports this out of the box and it works just like
System.import, see webpack/webpack#3413impronunciable commentedon Jan 20, 2017
@mxstbr We are using the webpack version but need to adapt our server to allow it
arunoda commentedon Mar 8, 2017
Notes:
We need to support SSR with dynamic imports too. In that case, let's say user imported the component inside
getInitialPropsand pass it to the page via props. We need to support that case allow to do SSR.Since we don't execute
getInitialPropsin the client for the first time, we need to find a way to pass down the component from the Server to client.jesseditson commentedon Mar 28, 2017
Super excited for this to land - is https://github.com/zeit/next.js/compare/import-then getting PR'd any time soon so I can follow along on that thread?
arunoda commentedon Mar 28, 2017
@jesseditson yes. We are doing a PR soon.
mtford90 commentedon Apr 6, 2017
Excited for this.
I've found that if server-side rendering with firebase you need to use
firebase-adminandgoogle-storagewhich are node libraries. Wouldn't want to load these in the client and so it would be nice to be able to load these dynamically ifisServeris true whengetInitialPropsis called.neeraj022 commentedon May 12, 2017
I was trying to import a client side library (react-leaflet), but was getting errors when this library was getting loaded on the server side for first time page rendering. Making the library to load conditionally was a easy option.
But while conditionally loading the library on the client side, webpack tries to make the bundle again and I get a error for the first load, thereafter it works well.
Any workaround for this for the time being?
Code :
frol commentedon May 23, 2017
It seems that this issue is resolved in Next.js 3.0, isn't it?
arunoda commentedon May 23, 2017
@frol Yep. Thanks.
See more: https://zeit.co/blog/next3-preview