Merge pull request #2010 from sbwalker/dev

Add support for ES6 module JavaScript resources
This commit is contained in:
Shaun Walker 2022-02-19 17:14:21 -05:00 committed by GitHub
commit e305c488d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 4 deletions

View File

@ -55,7 +55,7 @@ namespace Oqtane.Modules
var scripts = new List<object>();
foreach (Resource resource in Resources.Where(item => item.ResourceType == ResourceType.Script && item.Declaration != ResourceDeclaration.Global))
{
scripts.Add(new { href = resource.Url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "" });
scripts.Add(new { href = resource.Url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", ismodule = resource.IsModule ?? false});
}
if (scripts.Any())
{

View File

@ -34,7 +34,7 @@ namespace Oqtane.Themes
var scripts = new List<object>();
foreach (Resource resource in Resources.Where(item => item.ResourceType == ResourceType.Script && item.Declaration != ResourceDeclaration.Global))
{
scripts.Add(new { href = resource.Url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "" });
scripts.Add(new { href = resource.Url, bundle = resource.Bundle ?? "", integrity = resource.Integrity ?? "", crossorigin = resource.CrossOrigin ?? "", ismodule = resource.IsModule ?? false });
}
if (scripts.Any())
{

View File

@ -232,6 +232,9 @@ Oqtane.Interop = {
if (path === scripts[s].href && scripts[s].crossorigin !== '') {
element.crossOrigin = scripts[s].crossorigin;
}
if (path === scripts[s].href && scripts[s].ismodule === true) {
element.type = "module";
}
}
}
})

View File

@ -33,8 +33,7 @@ namespace Oqtane.Models
public string Bundle { get; set; }
/// <summary>
/// Determines if the Resource is global, meaning that the entire solution uses it or just some modules.
/// TODO: VERIFY that this explanation is correct.
/// Determines if the Resource is global or local, meaning that the entire solution uses it or just some modules.
/// </summary>
public ResourceDeclaration Declaration { get; set; }
@ -42,5 +41,10 @@ namespace Oqtane.Models
/// If the Resource should be included in the `head` of the HTML document or the `body`
/// </summary>
public ResourceLocation Location { get; set; }
/// <summary>
/// For Scripts this allows type="module" registrations - not applicable to Stylesheets
/// </summary>
public bool? IsModule { get; set; }
}
}