What happened?
Description
When a plugin uses yii2-adapter and an asset bundle declares JqueryAsset as a dependency, the dependent asset resources are included before jQuery.
This causes errors such as:
Uncaught ReferenceError: $ is not defined
For example, the asset bundle has:
public $depends = [
\craft\web\JqueryAsset::class,
];
Steps to reproduce
- register an asset bundle in widget body like
public function init()
{
$this->sourcePath = "@vnali/counter/resources";
$this->depends = [
JqueryAsset::class,
];
$this->js = [
'js/counter-widget-settings.js',
];
2- counter-widget-settings.js is loaded before vendor/craft/legacy/jquery/dist/jquery.js?v=6.0.0-alpha.16)
3- it throws an Uncaught ReferenceError: $ is not defined
Expected behavior
I would expect the generated resources to be ordered as:
jquery.js
counter-widget-settings.js
Actual behavior
However, they are currently included as:
counter-widget-settings.js
jquery.js
Craft CMS version
6.0.0-alpha.16
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
What happened?
Description
When a plugin uses yii2-adapter and an asset bundle declares JqueryAsset as a dependency, the dependent asset resources are included before jQuery.
This causes errors such as:
Uncaught ReferenceError: $ is not definedFor example, the asset bundle has:
Steps to reproduce
2- counter-widget-settings.js is loaded before vendor/craft/legacy/jquery/dist/jquery.js?v=6.0.0-alpha.16)
3- it throws an Uncaught ReferenceError: $ is not defined
Expected behavior
I would expect the generated resources to be ordered as:
jquery.js
counter-widget-settings.js
Actual behavior
However, they are currently included as:
counter-widget-settings.js
jquery.js
Craft CMS version
6.0.0-alpha.16
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions