-
Notifications
You must be signed in to change notification settings - Fork 80
Server rendering problem #64
Comments
Thanks @tgeorges I would like to make this work, but unfortunately I don't have a server rendered react app nor the relevant expertise to test with. If you manage to get this working and want to make a pull request w/ the fix, I'd be glad to review/merge assuming I can reason about the changes and that tests pass. |
@tgeorges did your code work with a previous version of |
That's a good question @andygup, I can see how it would have worked w/ an older version and not this one, and that's what I was assuming, but would be good to confirm from @tgeorges. I neglected to mention before that I have a WIP example of how to use esri-loader in an Ember Fastboot (server-rendered) app. That uses esri-loader 1.5^. One difference w/ Ember is that the addon that wraps this library explicitly overwrites the Promise implementation w/ Ember's RSVP. That said, I'm still a bit surprised the above line didn't cause an issue in Ember Fastboot b/c I believe that is executed before the code that overwrites it. Which brings up a point that generally speaking if you want to use this in a server-rendered application you can not load JSAPI modules or render a map on the server side (b/c you can't run We could implement a naive fix like |
Hi @tomwayson and @andygup ! Thanks for your suggestions :-) import Promise from 'bluebird';
global.window = global.window || {};
global.window.Promise = global.window.Promise || Promise; Its a not elegant solutions but working for now. What I can suggest is to use an universal implementation of Promises (working in both client and server sides) as a dependency. What is your opinion ? |
Thanks @tgeorges I deliberately chose not to take a dependency on a promise library. I don't think that is needed to solve this problem. I think we can do what I suggest above ( |
Ok I understand, do you need some support for that ? I think a simple test in your library to ensure that browser window is defined is enough |
Well, since I can't currently reproduce the problem, I can't be sure that my suggestion would fix it. I'd prefer to have that confirmation before making that change and cutting a release. Is your application's code available somewhere so I can try it myself? Alternatively would you be able to reproduce the problem in a minimal react app created from one of the universal boilerplates, or at least point me to one that approximates your application's setup? Left to my own devices I'd just try creating an app via Next.js b/c that looks like the fastest way for me to get something up and running, but I'm not sure if that would accurately approximate how your app is rendered server-side. |
Hi @tomwayson, In this component, load Esri Js with your library, and try showing it directly : it will be server rendered and you will touch the problem :-) I will be unavailable next week but I can find some time the 1st week of 2018 to help you reproduce that Cheers and happy XMas time :-) |
@tgeorges this should be fixed by installing esri-loader@^1.6.0 |
Hi, It is a pity that map cannot be rendered at the server side as well. Thanks ! |
@Biboba I've updated my comment above to be more accurate: "you can't run the ArcGIS API for JavaScript in node." I haven't tried it myself, but server-side rendering JavaScript maps is not trivial even w/o the challenges of trying to load Dojo modules. Instead, I'd look into doing something like rendering a static image on the server and replacing that w/ the map once the ArcGIS API is loaded in the browser. |
@tomwayson Thanks for your precisions ! |
Hi esri-loader team !
I experienced a bad issue when using version from 1.5.x with React server rendering : window.Promise was not defined.
The workaround was quite simple but not esthetic...
Maybe you can fix it and make this library server rendering aware ?
=> link to the problem :
esri-loader/src/esri-loader.ts
Line 80 in 21e7323
The text was updated successfully, but these errors were encountered: