When JavaScript aggregation is enabled (typically on production environments), Drupal throws an exception when trying to optimize the external CDN JavaScript files defined in search_api_typesense.libraries.yml:
Error trying to optimize JavaScript asset: https://cdn.jsdelivr.net/npm/algoliasearch@4.20.0/dist/algoliasearch-lite.umd.js. Only file JavaScript assets can be optimized.
The error occurs in Drupal\Core\Asset\JsOptimizer->optimize() because the optimizer attempts to process external URLs as local files.
1. Enable the search_api_typesense module in Drupal 11.3.1
2. Enable JavaScript aggregation (/admin/config/development/performance)
3. Visit a page that loads the search_api_typesense/instantsearch library
4. Observe the exception in the logs
The external JavaScript files in search_api_typesense.libraries.yml need to be marked with type: external attribute:
instantsearch:
js:
https://cdn.jsdelivr.net/npm/typesense-instantsearch-adapter@2/dist/typesense-instantsearch-adapter.min.js: { type: external }
https://cdn.jsdelivr.net/npm/algoliasearch@4.20.0/dist/algoliasearch-lite.umd.js: { type: external }
https://cdn.jsdelivr.net/npm/instantsearch.js@4.60.0/dist/instantsearch.production.min.js: { type: external }
See: https://www.drupal.org/docs/develop/creating-modules/adding-assets-css-j... →
- Apply the fix to search_api_typesense.libraries.yml
- Review and commit
Active
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.