-
Notifications
You must be signed in to change notification settings - Fork 385
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
Integrate Composer into production build process #1836
Conversation
…d, and thus ditch PHP 5.4 version override for development builds.
@kasparsd What do you think of this approach, referencing your #1131 (comment)? |
@westonruter I think it is a good idea to lock down the platform requirements and dependency requirements to ensure reliable and reproducible builds by default. Removing the platform requirement from Considering that we're not planning to remove How about we keep the defaults locked down as is and introduce a dedicated script that removes those locks when needed -- something like
Then
which is nice and clean. Then for the newer versions of PHP in the Travis jobs list we run the unlock command during |
That's a good point. Let's add the platform requirement back to the default |
…ser-patches version, and simplify Grunt composer_production logic.
@@ -33,6 +33,12 @@ module.exports = function( grunt ) { | |||
webpack_production: { | |||
command: 'cross-env BABEL_ENV=production webpack' | |||
}, | |||
composer_production: { | |||
command: 'rm -rf vendor && composer install --no-dev' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rm -rf vendor
here is problematic because it blows away any Git repos that are installed via composer install --prefer-source
. If this is to be done, then it should temporarily rename vendor
to vendor-dev
and then afterward delete the new vendor
and rename vendor-dev
back to its original location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -94,10 +102,8 @@ module.exports = function( grunt ) { | |||
paths = lsOutput.trim().split( /\n/ ).filter( function( file ) { | |||
return ! /^(blocks|\.|bin|([^/]+)+\.(md|json|xml)|Gruntfile\.js|tests|wp-assets|dev-lib|readme\.md|composer\..*|patches|webpack.*)/.test( file ); | |||
} ); | |||
paths.push( 'vendor/autoload.php' ); | |||
paths.push( 'vendor/**' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed this is resulting in vendor/cweagans/composer-patches
being included unexpectedly. Also, there are lot of php-css-parser
files being included which should not be part of the build. In particular, tests
. Only the files in vendor/sabberworm/php-css-parser/lib/*
should be included.
I believe this has been addressed separately. See #3183. |
When running
composer install
for a production build, it needs to be ensured that all dependencies are compatible with PHP 5.4. It furthermore needs to be ensured that only the dependencies needed for production are part of the build.This PR integrates Composer into the build process so that it no longer needs to rely on the user manually doing things right in that regard:
shell:composer_production
is run, which temporarily removes all local dependencies and installs only the production ones via the--no-dev
flag. Furthermore, for that one call the PHP version is hard-set to 5.4, to ensure dependencies are compatible. This mitigates the issue noticed in Switch to installing wp-dev-lib via composer instead of via submodule #1131, where you can't use newer versions of for example the dev dependencies during development.shell:webpack_production
is run.build
directory. Sincevendor
now only has the dependencies needed, we can rely on that and copy the whole vendor directory.composer install
is run again to have access to all the regular dev dependencies again.dev-lib
, which via Switch to installing wp-dev-lib via composer instead of via submodule #1131 will be installed via Composer. Therefore it's crucial for the regularcomposer install
to be run before this, as mentioned above.