Adobe-Consulting-Services / acs-aem-commons

http://adobe-consulting-services.github.io/acs-aem-commons/
Apache License 2.0
453 stars 600 forks source link

Versioned ClientLibs Transformer does not work with script/link modules #2560

Closed arthurcavallari closed 2 years ago

arthurcavallari commented 3 years ago

Required Information

Expected Behavior

The versioned clientlibs transformer should add a hash to script/link tags even if <script type="module" src="..."/> or <link rel="modulepreload" href="..."/>

Actual Behavior

These tags are excluded because of SaxElementUtils.isCss and SaxElementUtils.isJavaScript, these methods do not accept <script type="module" src="..."/> or <link rel="modulepreload" href="..."/>

Links

https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/84fcdd4bc66b020ac7c1a03134d1d7f474ce10e5/bundle/src/main/java/com/adobe/acs/commons/rewriter/impl/VersionedClientlibsTransformerFactory.java#L198

https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/84fcdd4bc66b020ac7c1a03134d1d7f474ce10e5/bundle/src/main/java/com/adobe/acs/commons/rewriter/impl/VersionedClientlibsTransformerFactory.java#L202

Links to related assets, e.g. content packages containing test components image

image

makro2400 commented 3 years ago

We are facing similar issue. We want to preload some scripts, we tried to add type to link element, but like it was said, the check done in isJavaScript only checks script tags, while it should be also checking link elements if they have proper type set.

jamesg1 commented 3 years ago

I am trying to use Vite.js ES modules with AEM too and we've hit this issue - We are importing javascript via client lib modules <script type="module" src="..."/>.

jamesg1 commented 3 years ago

https://github.com/Adobe-Consulting-Services/acs-aem-commons/pull/2691#issue-727533228 Added the fix to the library to enable support of this. @makro2400 @arthurcavallari

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

arthurcavallari commented 2 years ago

Fixed by https://github.com/Adobe-Consulting-Services/acs-aem-commons/pull/2691#issue-727533228

Thanks @jamesg1