Closed nazar-pc closed 6 years ago
--no-dev Disables installation of require-dev packages.
this means that the packages are not installed after dependency resolution. They are still included in resolving dependencies otherwise a lock file may result in a set of package versions that is not installable when --no-dev
is not specified.
It does make some sense, but in context of this being plugin for Composer it doesn't make as much sense as it would for NPM. If we're using PHP instead of Node.js to install packages, there is a good chance we don't need dev packages too.
What about some option, probably in extra
section, to ignore dev packages entirely and thus improve performance as well as avoiding potential conflicts in dev packages that might not be used anyway?
how would you expect a composer install
to behave with a composer.lock file that has been created without dev dependencies?
Typically composer.lock
is accompanied with original composer.json
. In this case it is possible to use extra
information from composer.json
(not sure how Composer itself works in this case) since composer.lock
doesn't store extra
's contents itself.
In other words, require-dev
should be constructed, but fxp/composer-asset-plugin
can skip downloading and resolving any dependencies from that list of packages if corresponding option is set in extra
key.
I was have similar problem with dependencies. In my quite big project it was take more than half of hour for each "composer require" or "composer update", and respectively to debug output from composer (with option -vvv), 90% of that time was spend to packages that i absolutelly no need. In my case that is not only dev dependencies, but for big part of packages i do not need regular dependencies too. So I made small patch for composer-asset-plugin, as temporary solution (i hope :) ). I was not have to much time for this work, so it maybe quite dirty solution.
It add two options under config.fxp-asset, skipDependencies and skipDevDependencies. skipDevDependencies should be boolean value, and in case of "true", all devDependencies skipped. skipDependencies can be boolean or array. In case of boolean "true", all dependencies of all packages skipped. In case if that value is array, it should contain names of packages dependencies of which should be skipped. Package names should be without prefix "npm-asset/".
Sample config:
"config": {
"fxp-asset": {
"skipDependencies": ["admin-lte", "gentelella"],
"skipDevDependencies": true
}
}
Here is the patch: https://gist.github.com/Zaporozhec7/6ba54ad9369e44d6b83df0ca2e10a896
EDITED:
Seems I missed something, that my solution cause bugs with some packages.
@francoispluchino, was this fixed? Or does closing mean we'll suffer forever?
Your error isn't a bug, because Composer can only install a single version of the same dependency (npm-asset/underscore[1.6.0, 1.4.4]).
Use the config.fx-asset.resolutions
option to solve the resolution of version (see the doc).
And Composer doesn't install the dev dependencies. On the other hand, Composer analyzes the dev section, and therefore the plugin imports the packages. It's not a bug, it's the standard behavior of Composer.
So, I want to re-open this issue if it's for an optimization request, but not for a report of a bug that is not one :-).
It's not a bug, it's the standard behavior of Composer.
Agree, but complaint was that it doesn't make any sense to do anything with frontend dev dependencies in Composer. Analyzing those dev dependencies takes time as well as become a source of unnecessary conflicts:
because Composer can only install a single version of the same dependency (npm-asset/underscore[1.6.0, 1.4.4])
I agree this might not be a bug, but rather a very good optimization to have.
Something as simple as optionally dropping devDependencies
property early in the process for each package could greatly improve installation time.
I agree with you. So, I reopen this issue and change the labels. Just for info, I closed all the old issues with the label support
. That's why it was closed.
I think, for this to happen it should be enough to simplify following: https://github.com/fxpio/composer-asset-plugin/blob/61352d99940d2b2392a5d2db83b8c0ef5faf222a/Converter/AbstractPackageConverter.php#L173-L184 to:
protected function getMapDependencies()
{
return array(
'dependencies' => 'require',
);
}
If this is not desired to be hardcoded, new options would be nice to have.
This is very important IMHO, just try to install
composer require -vvv npm-asset/selectize.js
It has Babel in it's devDependencies
and ~installs~ clones and analyzes 100s of packages.
You can install this via Asset-Packagist, with half a dozen dependencies
.
@hiqsol @SilverFire Does AP discard devDependencies
?
npm
itself also does not behave this way, devDependencies
are not installed - I even think there's no way to do this with the standard CLI, without going to each module-directory.
I think there has to be an option to discard devDependencies
and it should be on
by default. If you need to develop a npm-package, you'll need npm
anyway.
Does AP discard
devDependencies
?
Yes. When AP converts bower/npm packages to composer packages it preserves dependencies and completely skips devDependencies. See AssetPackage::prepareReleases
@francoispluchino Would it be possible to get a fix for this? CAP is practically unusable with npm-assets.
If we can get the value of the --no-dev
option, we can avoid adding the devDependencies
section of the package.json
file during the conversion. Any PR will be appreciated :-).
I think it should be disabled by default and not depending on composer --no-dev
since it has a completely different context.
If you need development packages for client packages you also have the development tools.
Performance improved by 3ec92aa5f07ed7398c37b54e0442048abc5306bd.
Composer 1.3.0 stable fxp/composer-asset-plugin 1.2.2 stable
package.json:
What should be installed (dependencies tree without devDependencies on any level):
And now look at this (ignore error for now):
Clearly more packages than necessary.