5

Resolved

Issue with SetDependencies (since 1.6)

description

Copy/paste from a ResourceManifest.cs file of mine:

manifest.DefineScript("GMap3_GoogleAPI").SetUrl("http://maps.googleapis.com/maps/api/js?sensor=false");

// GMap3 core
manifest.DefineScript("GMap3").SetUrl("gmap3.min.js", "gmap3.js").SetVersion("4.1").SetDependencies("jQuery", "GMap3_GoogleAPI");



In my view I do:

Script.Require("GMap3").AtHead();

Result @ output:

<script src="/Modules/AIM.GMap3/Scripts/gmap3.min.js" type="text/javascript"></script>
<!--[if lt IE 9]> <script src="/Core/Shapes/Scripts/html5.js" type="text/javascript"></script> <![endif]--> <meta content="Orchard" name="generator" />
<meta content="IE=edge,chrome=1" name="X-UA-Compatible" />
<link href="/modules/orchard.themes/Content/orchard.ico" rel="shortcut icon" type="image/x-icon" />
<script src="http://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script>

Notice how it first included gmap3.min.js and THEN the dependency! This breaks our site currently..

comments

0lukasz0 wrote Nov 28, 2012 at 2:05 PM

we got the same problem and I wouldn't say impact is low...

randompete wrote Dec 4, 2012 at 7:41 PM

I'm also getting strange script ordering since upgrading to 1.6 (I have a number of modules defining script resources, and a several levels deep dependency hierarchy). I'm investigating the problem further, doesn't seem any logic to it and I can't see any changesets that should have affected this.

sebastienros wrote Dec 6, 2012 at 9:41 PM

I can repro. It seems the AtHead() is not correctly propagated to the dependency. Working on it...

sebastienros wrote Dec 6, 2012 at 9:55 PM

nailing it down ...
Let's say resource B (b.js) is dependent on A (a.js).

It works if A and B are BOTH NOT EXISTING on the file system or if A and B are BOTH EXISTING.

A workaround now should then be to copy the online resource locally I think.

sebastienros wrote Dec 6, 2012 at 10:54 PM

Fixed in changeset 3ad6518a57a3

randompete wrote Dec 7, 2012 at 12:13 AM

In my case the script was in a subfolder (e.g. module/Scripts/swfobject/swfobject.js) ... the file was there but I guess for some reason Orchard won't believe it is unless it's directly in Scripts. Had just about figured out what was going on when I saw the fix.

sfmskywalker wrote Mar 28 at 12:28 AM

Fixed in changeset e3fa12bcc73876d7653da43dcd6e18b6a3ef4bda