I am trying to connect the JS library as a module in Grails application. For this, I use the following format in the GSP:
<asset:javascript src="myLibrary.js" type="module"/>
The "type" attribute is the usual one for the "script" tag. W3 specification
The "type" attribute with the value "text/javascript" is hard-coded into the string.
It is necessary to add a check for the presence of the attribute "type" in the "attrs" list: if (!attrs.containsKey('type'))
And only in this case add "type="text/javascript"" to the generated string.
I am trying to connect the JS library as a module in Grails application. For this, I use the following format in the GSP:
<asset:javascript src="myLibrary.js" type="module"/>
The "type" attribute is the usual one for the "script" tag. W3 specification
The error is on the following line: https://github.com/bertramdev/asset-pipeline/blob/45f2f332362402acec7d8ae1cdc8f1c719597581/asset-pipeline-grails/grails-app/taglib/asset/pipeline/grails/AssetsTagLib.groovy#L33
The "type" attribute with the value "text/javascript" is hard-coded into the string.
It is necessary to add a check for the presence of the attribute "type" in the "attrs" list:
if (!attrs.containsKey('type'))
And only in this case add "type="text/javascript"" to the generated string.Example result code:
outPw << '<script ' << (!attrs.containsKey('type') ? 'type="text/javascript"' : '') << ' src="' << assetPath(src: src, useManifest: useManifest) << queryString << '" ' << paramsToHtmlAttr(outputAttrs) << '></script>' << endOfLine