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

Fixes for Zeitwerk #176

Merged
merged 4 commits into from
Oct 24, 2019
Merged

Conversation

kennyadsl
Copy link
Member

In production, we are experiencing issues with this extension and Zeitwerk, due to how it works and how we named filenames and classes (they should match). See #174

This PR fixes the issue by removing some deface overrides that are no longer needed (since they only apply to Solidus <= 2.5, currently EOL). Also, this PR reorganize some classes that use class_eval in favor of Module#prepend, which allows us to define a module that has the same name as the file.

A version bump will probably follow this PR.

They are not compatible with Zeitwerk, which is shipped
with Rails 6. Since they are not used in Solidus versions
that are compatible with Rails 6, there's no reason to
keep them.
@kennyadsl kennyadsl self-assigned this Oct 8, 2019
@kennyadsl kennyadsl changed the title Fix for Zeitwerk Fixes for Zeitwerk Oct 8, 2019
@kennyadsl kennyadsl requested a review from a team October 8, 2019 10:00
@kennyadsl kennyadsl force-pushed the kennyadsl/zeitwerk-fixes branch from b962a0c to 78c8fdb Compare October 8, 2019 16:25
This file has not a class defined with the same name as the
filename itself. Zeitwerk does not like it.
With this PR we changed things that makes the extension no more
compatible with Solidus < 2.5 and we need to reflect this in
the gemspec.
@kennyadsl kennyadsl force-pushed the kennyadsl/zeitwerk-fixes branch from 78c8fdb to 329f89d Compare October 9, 2019 16:20
Copy link
Member

@spaghetticode spaghetticode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix + cleanup, thank you @kennyadsl 👍

@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
s.require_path = "lib"
s.requirements << "none"

solidus_version = [">= 1.2.0", "< 3"]
solidus_version = [">= 2.6", "< 3"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Copy link
Contributor

@jacobherrington jacobherrington left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks Alberto!

@aldesantis
Copy link
Member

@kennyadsl instead of making overrides compliant with Zeitwerk, I think we should simply prevent Zeitwerk from loading them in the first place:

config.eager_load_paths -= %W(#{config.root}/app/overrides)

Deface will still load them manually, so this won't create any problems. Furthermore, it's also what @fxn suggests to do (rails/rails#36100 (comment)).

@kennyadsl
Copy link
Member Author

kennyadsl commented Oct 23, 2019

@aldesantis added the proposed solution directly into Deface with a fix: spree/deface#202 which has now been released. I'll re-run specs here and we should be good to merge.

@kennyadsl kennyadsl merged commit 9551eff into solidusio:master Oct 24, 2019
@kennyadsl kennyadsl deleted the kennyadsl/zeitwerk-fixes branch October 24, 2019 13:01
@kennyadsl kennyadsl mentioned this pull request Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants