- Issue created by @star-szr
- 🇨🇦Canada star-szr
Pipeline that shows the test + fix and test-only jobs: https://git.drupalcode.org/issue/vite-3499492/-/pipelines/394927
When using the feature of this module that adds manifest imports as additional JS files to the Drupal library, the imports are loaded twice by the browser.
Once, by the script tag added with rel = modulepreload, type = module. This one will have the cache-busting string appended, for example:
<script src="/modules/custom/example/dist/assets/vendor-BJeRhW_B.js?spvp1h" rel="modulepreload" type="module"></script>
The second time is when the actual JavaScript module imports the dependency, it doesn't have the cache-busting string.
So the preload doesn't seem to do anything helpful in this case, since to the browser these are two separate assets and the cache can't be used.
Define a vite library that uses imports, but don't create a separate library for those imports. Build for production, clear Drupal caches, and navigate to a page that will render your vite Drupal library.
The expected result is that the import will only be loaded once, but it's preloaded with the cache buster query string then loaded again from the JavaScript module without the cache buster query string.
I will try to put together a failing test case to demonstrate the behaviour.
Consider removing the 'preload' script tags since they aren't actually working as a preload, or some other method of reconciling this mismatch.
Should be none
Should be none
Should be none
Active
1.3
Code
Pipeline that shows the test + fix and test-only jobs: https://git.drupalcode.org/issue/vite-3499492/-/pipelines/394927