-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Moving from bower to npm #14297
Comments
something to consider when creating packages for 2.1. Thanks for noting that. |
This is a very important issue! Especially due to the fact that installation of bower and npm/yarn packages is totally different (flat vs. tree). Since many repos are also dropping The good thing is, that we actually could use that to our advantage. While the current implementation of the fxp plugin parses This would be much less error prone. But we would need a separate bundling process which reads |
@schmunk42 I would drop using composer-asset-plugin in 2.1, if you ask me. Composer should install php packages, not make it do other things. I would suggest others devs to use npm, yarn or webpack separately and make documentation on using them in yii2 projects. As for 2.0 version, I guess we would need to switch to npm from bower somehow. |
If you would completely drop dependency resolution for assets in 2.1 you could (need to) also remove Rather than sacrificing dependency resolution between widgets/extension/modules and assets completely, I'd like to find/propose a solution which is much faster and less error-prone - and even without the need of How about changing the asset installation like so:
|
@tonydspaniard I totally agree that there are tools which can handle asset management better than Yii + fxp currently does. The use-case is not only about jQuery, take VueJs as an example - you start a nice module now, which requires I agree that we do not have to care about the sub-(non-peer)-dependencies like What I am proposing involves like only 2% of the - literally - constraints we have to obey now. |
As @schmunk42 noted, it will trigger removal of widgets (or at least reducing their scope a lot) cause most of widgets do not make sense w/o assets. Personally I'd do it to drop JS and assets burden but it could be too shocking change for Yii community.
Never in the core again :) We've provided support for one of such great tools — jQuery which is now considered not-so-modern thing. We may consider providing template for REST apps (that's what's needed for vue, react etc.) But overall I'd like to focus on PHP and leave JS alone. Trends are moving too fast there. |
A core completely without assets and an asset system as a Yiisoft extension would be great!
I agree, but we're also still building sites with jQuery in them 😨 😏 AFAIR the decision was once made, because Yii wanted to have a PHP only solution. This restriction should be dropped, but there should be a common workflow for developers when working with extensions and their assets. |
@tonydspaniard It's not about locking deps in the end. It's about very minimal constraints between server and client packages and the fact that you might intervene in this process instead of completely separating it. While this suitable for larger apps, it just makes no sense for tiny libs like a date-picker for example. You'd need another kind of "contact" between them, like a REST API or data-adapters, but this is not feasible for all situations. |
This matter is already tracked by issue #8452. Keep in mind that Yii core tools like The core team needs a lot of helping hands to extract JS code into separated packages and update/rewrite JS parts of many crucial extensions like If you wish to continue disscussion about packages separation and structure, please use issue #8452 for that and do not mix 2 different things here. |
Ideally without that or with it developed by interested parties. Possibly by the name of YiiSoft :)
Then there will be no difference. Add one of extensions and you have basically the same stuff you had in 2.0.
Extensions and a huge mess if we'll not provide a standard way to manage dependencies and assets as we do now. |
And yes, as @klimov-paul said, we need extra hands. |
As for moving from bower itself, I don't think bower support will be dropped during Yii 2.0 lifetime so I'd consider it non-issue for 2.0. |
I agree with everyone about using Nodejs + NPM/Yarn to manage assets. I never liked to use the solver SAT of Composer to manage asset dependencies, but as your project, I have PHP libraries that must use asset dependencies for the front-end (as well as working with private repositories and lock file), it was for these reasons that I created this plugin. In the meantime many things have changed on the side of Javascript, and Nodejs becomes almost mandatory to use and compile assets (typescript, babel, scss, less, etc...). NPM has evolved a lot in recent months (organizations, private repositories with git+ssh, a true lock file), and Bower is dead, and Yarn is a new great tool. I personally removed my plugin from my main project for using Yarn + Webpack (recently). However, removing asset dependency management is really frustrating: when I install a new PHP library that using the assets, the front-end of the component does not work because there is no more management of the assets, and so the assets are missing if I do not add them manually to the All this to say that I started this morning to develop the version 2.0 using Nodejs (see the closed issue fxpio/composer-asset-plugin#93), but only compatible with NPM/Yarn, and installable in project mode. I know, there are Composer plugins that using Nodejs, but none allows to use the features to 100% for NPM or Yarn, and does not use the Of course, the entire plugin is configurable (in global config, in project config and with the environment variables) and it is possible to replace the installation or update commands to add options (ex. Regarding migration: modify each PHP library by moving the asset dependencies of the For those interested, this new version of the plugin will be available tomorrow, I think at the end of the day, because I still have to write tests and the documentation. PS. Composer Asset Plugin + Yarn: it's a rocket with the same advantages, and more, but without the disadvantages! :-) |
Given that there is a break compatibility, and it is impossible to have a version of the plugin installed globally, and another version installed in the project - because Composer will install the plugin in the project, but will only use the plugin installed globally - the plugin becomes a new project. Of course, the Composer Asset Plugin will continue to be maintained but it will no longer evolve without the contributions of the community. To know: I have not yet finished, and it still lack the documentation for the use of the plugin, tests, and add the restoration of the project in the case if NPM or Yarn terminates with an error. All this will come in the next few days. However, for the more reckless among you, you can start playing with Foxy (the new name of the plugin), and make returns and/or contribute. Do not forget, this is an alpha version, so a little leniency please :-). |
The Foxy's version v1.0.0-beta1 is released. All features are implemented and tested. |
Bower.io saying that "...psst! While Bower is maintained, we recommend yarn and webpack for new front-end projects! "
Should we migrate the exising bower assets configurations to npm?
What steps will reproduce the problem?
What is the expected result?
What do you get instead?
Additional info
The text was updated successfully, but these errors were encountered: