Dependency on external JavaScript

70 views
Skip to first unread message

Phil Gates-Idem

unread,
Oct 2, 2013, 10:47:29 AM10/2/13
to rapt...@googlegroups.com
It looks like this is possible:

However, it appears that unless this dependency is included from async module, the code won't be included in the build output.

I think there should be more flexibility in how external dependencies are handled.

I think these should be the options:
  • The code for the external resource is fetched during build time and included just like a file resource (if it's an asynchronous bundle the source code will come from one of the build output bundles not the external web server)
  • The code for the external resource is kept external regardless of whether it is included asynchronously or synchronously
Currently, it looks like a JavaScript resource dependency with the "url" property is always associated with the external URL. If the dependency is not within an asynchronous bundle then the file is not included at all (this seems like a bug).

Do you think we can modify Dependency_js.js so that the external resource is fetched during build so that the output includes a snapshot of the file?

Patrick Steele-Idem

unread,
Oct 2, 2013, 12:24:16 PM10/2/13
to rapt...@googlegroups.com
Are you sure that URL dependencies are only being included if they are part of an async module? I've not observed that behavior, but if that is the case then it is indeed a bug...

As for downloading external URLs, that was the intention, but I never got around to implementing that feature. What I am thinking is the following:

Do not download an external resource if the "external" property is undefined or true (i.e. external defaults to true):
{"type": "js", "url": "http://code.jquery.com/jquery-1.10.1.min.js", "external": true}

Do download the resource if "external" === false:
{"type": "js", "url": "http://code.jquery.com/jquery-1.10.1.min.js", "external": false}

If you want to take on the feature, please feel free. I don't believe "getCode()" currently supports returning a promise, but that is the change that needs to happen to support downloading an external resource asynchronously. I don't have the bandwidth to work on it right now. Also, in "development" mode, I think it is best to disable downloading external resource URLs and, instead, include the resource URL directly as its own bundle (as is currently the case).

--Patrick
Reply all
Reply to author
Forward
0 new messages