Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace bower-asset with npm-asset #20067

Open
karelvasicek opened this issue Nov 13, 2023 · 12 comments
Open

Replace bower-asset with npm-asset #20067

karelvasicek opened this issue Nov 13, 2023 · 12 comments
Milestone

Comments

@karelvasicek
Copy link

Related f.ex. to hiqdev/asset-packagist#163 and especially to hiqdev/asset-packagist#163 (comment) .

composer update results to some packages downgrade.

Question is if/how it's related to https://bower.io/, it (as stated there) is maintained, but f.ex.

  • it's officially stated that "...we recommend using Yarn and Vite..."
  • package search on https://bower.io/search/ does not work at all

All packages required by Yii2 are available as npm-asset/package and versions seem to be correct in that case.

@schmunk42
Copy link
Contributor

Just replacing bower with npm might lead to problems, since both services work very differently.
In a nutshell: Bower was actually made in a way how we use it in Yii 2 for (pre-bundled) frontend assets, npm is more meant to be build with ie. webpack, although most packages have dist files, but it's not required. Also the dependencies may vary a lot.

I'd strongly recommend to wait for a fix in asset-packagist.

@bizley @terabytesoftw A change from bower to npm might be an option for 2.2, but please not for 2.0.

@samdark samdark added this to the 2.2.0 milestone Nov 23, 2023
@r-simlinger
Copy link

Is there any workaround?
Does not look like there will be someone wo will fix it from the asset-packagist side.

@ItsReddi
Copy link
Contributor

A the moment bower-asset/jquery is not installable anymore for us. @karelvasicek do you have any workaround?

@karelvasicek
Copy link
Author

@ItsReddi

do you have any workaround?

No, we unfortunately don't have any. We updated our main project some time ago and it hadn't worked either initially (packages had been downgraded), but started to work some time later (packages were updated again). It seems to work from time to time.

@ailmanki
Copy link

ailmanki commented Sep 16, 2024

In composer.json:
add (this makes composer believe these packages are installed)

"replace": {
    "bower-asset/jquery": "*",
    "bower-asset/jquery-ui": "*"
}

Next install the depencies with npm,

 "jquery-ui": "npm:components-jqueryui@^1.12.1",
 "jquery": "^3.0.0"

Above dependency for jquery-ui, makes it being installed into jquery-ui instead of components-jqueryui, long ago - I think that fixes some issues with Yii and maybe older JS.

Lastly see here how to tell yii Asset Manager to load your npm files..
https://www.yiiframework.com/doc/guide/2.0/en/structure-assets#customizing-asset-bundles

Rinse and repeat for whatever library u need to replace.

@ItsReddi
Copy link
Contributor

@karelvasicek @ailmanki Thanks.
For reference:
hiqdev/asset-packagist#167

@terabytesoftw
Copy link
Member

Here i think it is worth considering two solutions for the future.

  1. One possible solution is to use cdn, both in dev and prod versions.
  2. The other is to extract the assets from the composer.json of the packages and use npm, all the packages used are compatible and have dist for use, in this case we can use npm or php-forge/foxy for this purpose.

@ailmanki
Copy link

It seems to me no issue; the framework allows perfectly to replace it with NPM or any other mechanism.
Maybe a guide would help - instead of my small post above?

@inversed
Copy link

I don't know what's been going on with Bower's jQuery but I clicked Fetch Updates just now on https://asset-packagist.org/package/bower-asset/jquery and it is now showing the newer releases of jQuery beyond 3.6.1. My composer project is no longer downgrading my bower jquery package.

@ItsReddi
Copy link
Contributor

I don't know what's been going on with Bower's jQuery but I clicked Fetch Updates just now on https://asset-packagist.org/package/bower-asset/jquery and it is now showing the newer releases of jQuery beyond 3.6.1. My composer project is no longer downgrading my bower jquery package.

Sadly that works only sometimes for some hours. It is already gone again.
grafik

@samdark
Copy link
Member

samdark commented Sep 20, 2024

@SilverFire, @hiqsol would you please take a look at this one?

@alireza-salehi
Copy link

we already use yarn in our projects and removed bower completely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants