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

Remove yarn integrity check #2518

Merged
merged 3 commits into from Apr 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 8 additions & 21 deletions README.md
Expand Up @@ -28,7 +28,6 @@ in which case you may not even need the asset pipeline. This is mostly relevant
- [Webpack Configuration](#webpack-configuration)
- [Custom Rails environments](#custom-rails-environments)
- [Upgrading](#upgrading)
- [Yarn Integrity](#yarn-integrity)
- [Integrations](#integrations)
- [React](./docs/integrations.md#react)
- [Angular with TypeScript](./docs/integrations.md#angular-with-typescript)
Expand Down Expand Up @@ -107,6 +106,12 @@ Optional: To fix ["unmet peer dependency" warnings](https://github.com/rails/web
yarn upgrade
```

When `package.json` and/or `yarn.lock` changes, such as when pulling down changes to your local environemnt in a team settings, be sure to keep your NPM packages up-to-date:

```bash
yarn install
```

### Usage

Once installed, you can start writing modern ES6-flavored JavaScript apps right away:
Expand Down Expand Up @@ -300,26 +305,6 @@ yarn upgrade webpack-dev-server --latest
yarn add @rails/webpacker@next
```

### Yarn Integrity

By default, in development, webpacker runs a yarn integrity check to ensure that all local JavaScript packages are up-to-date. This is similar to what bundler does currently in Rails, but for JavaScript packages. If your system is out of date, then Rails will not initialize. You will be asked to upgrade your local JavaScript packages by running `yarn install`.

To turn off this option, you will need to change the default setting in `config/webpacker.yml`:

```yaml
# config/webpacker.yml
development:
...
# Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
check_yarn_integrity: false
```

You may also turn on this feature by adding the config option for any Rails environment in `config/webpacker.yml`:

```yaml
check_yarn_integrity: true
```

## Integrations

Webpacker ships with basic out-of-the-box integration. You can see a list of available commands/tasks by running `bundle exec rails webpacker`.
Expand Down Expand Up @@ -413,6 +398,8 @@ Webpacker::Compiler.watched_paths << 'bower_components'

Webpacker hooks up a new `webpacker:compile` task to `assets:precompile`, which gets run whenever you run `assets:precompile`. If you are not using Sprockets, `webpacker:compile` is automatically aliased to `assets:precompile`. Similar to sprockets both rake tasks will compile packs in production mode but will use `RAILS_ENV` to load configuration from `config/webpacker.yml` (if available).

When compiling assets for production on a remote server, such as a continuous integration environment, it's recommended to use `yarn install --frozen-lockfile` to install NPM packages on the remote host to ensure that the installed packages match the `yarn.lock` file.

## Docs

- [Development](https://github.com/rails/webpacker#development)
Expand Down
4 changes: 0 additions & 4 deletions lib/install/config/webpacker.yml
Expand Up @@ -6,7 +6,6 @@ default: &default
public_root_path: public
public_output_path: packs
cache_path: tmp/cache/webpacker
check_yarn_integrity: false
webpack_compile_output: true

# Additional paths webpack should lookup modules
Expand Down Expand Up @@ -52,9 +51,6 @@ development:
<<: *default
compile: true

# Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
check_yarn_integrity: true

# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
https: false
Expand Down
6 changes: 1 addition & 5 deletions lib/webpacker/configuration.rb
Expand Up @@ -64,11 +64,7 @@ def extensions
end

def check_yarn_integrity=(value)
data[:check_yarn_integrity] = value
end

def check_yarn_integrity?
fetch(:check_yarn_integrity)
warn "Webpacker::Configuration#check_yarn_integrity=(value) has been deprecated. The integrity check has been removed from Webpacker so changing this setting will have no effect."
end

def webpack_compile_output?
Expand Down
43 changes: 0 additions & 43 deletions lib/webpacker/railtie.rb
Expand Up @@ -7,49 +7,6 @@ class Webpacker::Engine < ::Rails::Engine
# Allows Webpacker config values to be set via Rails env config files
config.webpacker = ActiveSupport::OrderedOptions.new

initializer "webpacker.set_configs" do |app|
if app.config.webpacker.key?(:check_yarn_integrity)
Webpacker.config.check_yarn_integrity = app.config.webpacker.check_yarn_integrity
end
end

# ================================
# Check Yarn Integrity Initializer
# ================================
#
# development (on by default):
#
# to turn off:
# - edit config/environments/development.rb
# - add `config.webpacker.check_yarn_integrity = false`
#
# production (off by default):
#
# to turn on:
# - edit config/environments/production.rb
# - add `config.webpacker.check_yarn_integrity = true`
initializer "webpacker.yarn_check" do |app|
if File.exist?("yarn.lock") && Webpacker.config.config_path.exist? && Webpacker.config.check_yarn_integrity?
output = `yarn check --integrity && yarn check --verify-tree 2>&1`

unless $?.success?
$stderr.puts "\n\n"
$stderr.puts "========================================"
$stderr.puts " Your Yarn packages are out of date!"
$stderr.puts " Please run `yarn install --check-files` to update."
$stderr.puts "========================================"
$stderr.puts "\n\n"
$stderr.puts "To disable this check, please change `check_yarn_integrity`"
$stderr.puts "to `false` in your webpacker config file (config/webpacker.yml)."
$stderr.puts "\n\n"
$stderr.puts output
$stderr.puts "\n\n"

exit(1)
end
end
end

initializer "webpacker.proxy" do |app|
insert_middleware = Webpacker.config.dev_server.present? rescue nil
if insert_middleware
Expand Down
1 change: 0 additions & 1 deletion test/test_app/config/application.rb
Expand Up @@ -6,7 +6,6 @@ module TestApp
class Application < ::Rails::Application
config.secret_key_base = "abcdef"
config.eager_load = true
config.webpacker.check_yarn_integrity = false
config.active_support.test_order = :sorted
end
end