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

Refs #37102 - detect plugins webpack by looking for remoteEntry.js #10025

Merged
merged 1 commit into from
Jan 30, 2024

Conversation

evgeni
Copy link
Member

@evgeni evgeni commented Jan 30, 2024

Since we switched to Webpack 5, there are no more manifest.json in the plugins webpack folder, but we need some token to detect that we gotta load webpack stuff.

@evgeni
Copy link
Member Author

evgeni commented Jan 30, 2024

For devel setups and Debian this works by checking webpack/index.js, but in RPM we exclude this folder from the installed GEM:
https://github.com/theforeman/foreman-packaging/blob/rpm/develop/gem2rpm/foreman_plugin.spec.erb#L30
(it's correct, we don't need the webpack stuff ON the target system, as we don't compile any assets there, but…)

def uses_webpack?
path && (File.file?(File.join(path, 'webpack', 'index.js')) || webpack_manifest_path.present?)
path && (File.file?(File.join(path, 'webpack', 'index.js')) || webpack_manifest_path.present? || webpack_remote_entry.present?)
Copy link
Member Author

Choose a reason for hiding this comment

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

arguably, webpack_manifest_path.present? can be dropped now
also, this method hits the disk on every page load, we should cache the result in memory (but scope creep!)

Copy link
Member

Choose a reason for hiding this comment

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

Which is exactly what I aimed at in #9834 (comment) but I should have pushed further on this.

Copy link
Member Author

Choose a reason for hiding this comment

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

you mean "hits the disk" part?

@evgeni
Copy link
Member Author

evgeni commented Jan 30, 2024

With this applied I get working Katello prod installs with Webpack 5 \o/

@evgeni evgeni requested a review from MariaAga January 30, 2024 11:34
def uses_webpack?
path && (File.file?(File.join(path, 'webpack', 'index.js')) || webpack_manifest_path.present?)
path && (File.file?(File.join(path, 'webpack', 'index.js')) || webpack_manifest_path.present? || webpack_remote_entry.present?)
Copy link
Member

Choose a reason for hiding this comment

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

When is path && (File.file?(File.join(path, 'webpack', 'index.js')) false? I only see it as true all the time

Copy link
Member Author

Choose a reason for hiding this comment

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

when we use RPMs as we do not ship the webpack folder at all there, as we do not need to compile anything from it on the system where we deploy.

@@ -30,8 +30,13 @@ def webpack_manifest_path
File.file?(manifest_path) ? manifest_path : nil
end

def webpack_remote_entry
remote_entry_path = File.join(path, 'public', 'webpack', id.to_s, "#{id}_remoteEntry.js")
Copy link
Member

Choose a reason for hiding this comment

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

probably should do the - -> _ change for tasks here

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! Updated

Since we switched to Webpack 5, there are no more manifest.json in the
plugins webpack folder, but we need some token to detect that we gotta
load webpack stuff.
@evgeni
Copy link
Member Author

evgeni commented Jan 30, 2024

[test unit]

seems unrelated

@evgeni evgeni merged commit cf47b3c into theforeman:develop Jan 30, 2024
18 checks passed
@evgeni evgeni deleted the detect-webpack branch January 30, 2024 13:16
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.

3 participants