- Issue created by @djdevin
- πΊπΈUnited States djdevin Philadelphia
Possibly the same as π Asset optimization breaks functionality Active
- π¬π§United Kingdom catch
Had a look at the logic. I think the problem might be that preprocess is set to TRUE by default, and it's not set to false for external files automatically.
You could try explicitly setting preprocess: false in the library definition - or this MR might work, but I haven't tested it, just a theory.
- Status changed to Needs work
12 months ago 3:56pm 29 April 2024 - πΊπΈUnited States djdevin Philadelphia
I tried the MR and those suggestions to no avail. I noticed the problem was no longer happening for me so I backtracked over any changes and found out that I added a dependency on a completely different library, to a completely different library (on core/once) which causes some change in how the JS gets grouped.
As a test, I just added a dependency on core/once to the broken external library (which has no dependencies) and that also worked.
some-external-library: js: //domain.com/ext.js: { type: external, minified: true } //domain.com/ext2.js: { type: external, minified: true } dependencies: # Why is this needed? We don't know. - core/once
Can't figure it out but at least I know removing that seemingly innocuous library dependency triggers the issue.
The working JS output looks like:
When the JS is broken it looks like: with that last aggregated file being blank. Regular pages are unaffected, only broken in this case where we are calling getJsAssets() manually for some decoupled functionality. - πΊπΈUnited States djdevin Philadelphia
It's me, hi, I'm the problem, it's me...
We had this code altering JS, removing it also fixes the issue.
function xxx_js_alter(&$javascript, AttachedAssetsInterface $assets) { $request = \Drupal::request(); if ($request->getPathInfo() === '/xxx') { unset($javascript['core/misc/drupal.init.js']); unset($javascript['core/misc/drupalSettingsLoader.js']); unset($javascript['core/misc/drupal.js']); } }
Though I'm not sure why doing that wiped out the rest of the JS, and how adding a dependency on core/once fixes it.
- Status changed to Closed: cannot reproduce
12 months ago 4:19pm 30 April 2024