Skip to content

Commit

Permalink
Revert "Avoid loading ActionView::Base during initialization (#1528)"
Browse files Browse the repository at this point in the history
This reverts commit 22dbe8f.
  • Loading branch information
jonrohan committed Jan 11, 2023
1 parent 6aba644 commit cf65bbb
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 144 deletions.
112 changes: 0 additions & 112 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,118 +10,6 @@ nav_order: 5

## main

* Fix tests using `with_rendered_component_path` with custom layouts.

*Ian Hollander*

## 2.81.0

* Adjust the way response objects are set on the preview controller to work around a recent change in Rails main.

*Cameron Dutro*

* Fix typo in "Generate a Stimulus controller" documentation.

*Ben Trewern*

* Modify the `render_in_view_context` test helper to forward its args to the block.

*Cameron Dutro*

## 2.80.0

* Move system test endpoint out of the unrelated previews controller.

*Edwin Mak*

* Display Ruby 2.7 deprecation notice only once, when starting the application.

*Henrik Hauge Bjørnskov*

* Require Rails 5.2+ in gemspec and update documentation.

*Drew Bragg*

* Add documentation for using `with_rendered_component_path` with RSpec.

*Edwin Mak*

## 2.79.0

* Add ability to pass explicit `preview_path` to preview generator.

*Erinna Chen*

* Add `with_rendered_component_path` helper for writing component system tests.

*Edwin Mak*

* Include gem name and deprecation horizon in every deprecation message.

*Jan Klimo*

## 2.78.0

* Support variants with dots in their names.

*Javi Martín*

## 2.77.0

* Support variants with dashes in their names.

*Javi Martín*

## 2.76.0

* `Component.with_collection` supports components that accept splatted keyword arguments.

*Zee Spencer*

* Remove `config.view_component.use_consistent_rendering_lifecycle` since it is no longer planned for 3.0.

*Blake Williams*

* Prevent polymorphic slots from calculating `content` when setting a slot.

*Blake Williams*

* Add ability to pass in the preview class to `render_preview`.

*Jon Rohan*

* Fix issue causing PVC tests to fail in CI.

*Cameron Dutro*

* Fix YARD docs build task.

*Hans Lemuet*

* Add Startup Jobs to list of companies using ViewComponent.

*Marc Köhlbrugge*

* Run PVC's accessibility tests in a single process to avoid resource contention in CI.

*Cameron Dutro*

## 2.75.0

* Avoid loading ActionView::Base during Rails initialization.

*Jonathan del Strother*

<!-- vale off -->
* Mention lambda slots rendering returned values lazily in the guide.

*Graham Rogers*
<!-- vale on -->

* Add "ViewComponent In The Wild" articles to resources.

*Alexander Baygeldin*

## 2.74.1

* Add more users of ViewComponent to docs.
Expand Down
2 changes: 1 addition & 1 deletion lib/view_component/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class << self
#
# @return [ViewComponent::Config]
def config
@config ||= ActiveSupport::OrderedOptions.new
@config ||= ViewComponent::Config.defaults
end

# Replaces the entire config. You shouldn't need to use this directly
Expand Down
9 changes: 5 additions & 4 deletions lib/view_component/engine.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

require "rails"
require "view_component/config"
require "view_component/base"

module ViewComponent
class Engine < Rails::Engine # :nodoc:
config.view_component = ViewComponent::Config.defaults
config.view_component = ViewComponent::Base.config

rake_tasks do
load "view_component/rails/tasks/view_component.rake"
Expand All @@ -14,6 +14,9 @@ class Engine < Rails::Engine # :nodoc:
initializer "view_component.set_configs" do |app|
options = app.config.view_component

%i[generate preview_controller preview_route show_previews_source].each do |config_option|
options[config_option] ||= ViewComponent::Base.public_send(config_option)
end
options.instrumentation_enabled = false if options.instrumentation_enabled.nil?
options.render_monkey_patch_enabled = true if options.render_monkey_patch_enabled.nil?
options.show_previews = (Rails.env.development? || Rails.env.test?) if options.show_previews.nil?
Expand All @@ -36,8 +39,6 @@ class Engine < Rails::Engine # :nodoc:

initializer "view_component.enable_instrumentation" do |app|
ActiveSupport.on_load(:view_component) do
Base.config = app.config.view_component

if app.config.view_component.instrumentation_enabled.present?
# :nocov:
ViewComponent::Base.prepend(ViewComponent::Instrumentation)
Expand Down
18 changes: 0 additions & 18 deletions test/sandbox/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,6 @@
require "action_view/railtie"
require "sprockets/railtie"

# Track when different Rails frameworks get loaded.
# Ideally, none of them should be loaded until after initialization is complete.
# See config/initializers/zzz_complete_initialization.rb for the other half of this.
RAILS_FRAMEWORKS = [
:action_cable,
:action_controller,
:action_mailer,
:action_view,
:active_job,
:active_record
]
FRAMEWORK_LOAD_POINTS = {}
RAILS_FRAMEWORKS.each do |feature|
ActiveSupport.on_load(feature) do
FRAMEWORK_LOAD_POINTS[feature] = caller
end
end

require "view_component"

require "haml"
Expand Down

This file was deleted.

0 comments on commit cf65bbb

Please sign in to comment.