Closed washamdev closed 7 years ago
To support this for all scenarios is a bit more tricky than your suggestion. I'm working on a fix that only needs a bit more unit testing to be stable.
The referenced commit solves this issue without known side-effects.
The compressor bundles the first local path for all dependencies and ignores dependencies that are only resolved by url.
The fallback functionality is displayed in RequireJSNet.Examples
on /Home/Index
. Note there is first a load failure for jquery
but it is automatically resolved by requirejs fallback feature.
The bundling of files with multiple paths is displayed in RequireJSNet.Examples
on /Home/Complex
. Note there is no load failure for jquery
here because it uses the bundled version.
The RequireJS documentation describes how you can define two entries in an array to a path, with the second path serving as a fallback in case the first file fails to load. Like so:
I tried using this same method in the RequireJS.json config file but encountered this error:
Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'Newtonsoft.Json.Linq.JObject'.
I noticed that in the \RequireJsNet\RequireJsNet\Configuration\JsonReader.cs file starting on line 100, if the
Value
of the property isn't a string, it assumes the property is aJObject
. I wonder if something like this could be done?The problem then is that
result.Value
expects a single path in a string, not a delimited string, so it would have to know how to handle that. Could it accept a delimited string representing multiple paths and pass that to RequireJS?