Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Preloading a specific versions of the JSAPI forces consumers to pass same url to loadModules() #51

Closed
tomwayson opened this issue Nov 10, 2017 · 2 comments · Fixed by #66

Comments

@tomwayson
Copy link
Member

tomwayson commented Nov 10, 2017

Kind of an edge case here, but if you pass a specific JSAPI version when preloading (i.e. loadScript({ url: 'https://js.arcgis.com/3.22' })) then you have to make sure that subsequent calls to loadModules() include that same url option. If you don't, and the JSAPI hasn't loaded by the time loadModules() is called, it will try to lazy load the default version (latest 4.x) and it will reject with an error.

One solution is to just document the above.

Another idea would be to cache url that it's attempting to load the first time loadScript() is called and then default to that (instead of latest 4.x) for subsequent calls - either at the loadModules() or loadScript() level.

@leqwasd
Copy link

leqwasd commented Dec 21, 2017

And also loadScript includes this

        if (options.dojoConfig) {
          // set dojo configuration parameters before loading the script
          window['dojoConfig'] = options.dojoConfig;
        }

which could be dangerous - you can break the app, by changing default dojoConfig or dojoConfig, that was set before with loadScript. I would suggest - a factory for whole ersi-loader, which would return new esri-loader with user configured defaults, urls and dojoConfigs

@tomwayson
Copy link
Member Author

you can break the app, by changing default dojoConfig or dojoConfig, that was set before with loadScript.

thanks @leqwasd - but that only executes if the JSAPI is not loaded (i.e. window.require() is not defined) and we're not currently in the process of loading the script (i.e. the script tag does not exist), so I don't think that will be a problem.

#66 is the solution that I'm currently proposing for this problem. I would appreciate your feedback on that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants