Results 1 to 7 of 7

Thread: Issues with the microloader and OpenLayers and other scripts

Threaded View

Previous Post Previous Post   Next Post Next Post
    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Feb 2013
    Vote Rating

    Default Issues with the microloader and OpenLayers and other scripts

    Hello! I've run into an issue that I have figured out, but still not quite resolved.

    Our Sencha Touch+OpenLayers application was working fine during development, but the optimized release build failed because OpenLayers could no longer be found. It was as if it never had been loaded, even though I could clearly see it being downloaded. The debugger in Chrome reported several errors like "OpenLayers is not defined".

    After much head scratching I had to investigate what the microloader was doing in the production build. It does an "eval" on each javascript asset defined in app.json (OpenLayers was one of them), in a function called "evaluateAsset". This evaluates the scripts in the local scope of evaluteAsset. This means that any script that introduces new bindings with "var = ..." will not work correctly, because they will be lost when the function returns. This was the case with OpenLayers and Proj4JS in our case.

    I thought this was a very subtle and hard error to track down. It's particularly annoying because during development this is not an issue, because the javascript assets are loaded differently. A working solution for us was to remove the "var" bit from the offending libraries. I'm wondering if the microloader should instead try to evaluate the assets in the global scope? Particularly because otherwise we have these differences with development vs. production.
    Last edited by SimonTheSorcerer; 6 Feb 2013 at 3:45 AM. Reason: typo

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts