-
Notifications
You must be signed in to change notification settings - Fork 102
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
Update Optimization Detective plugin build process #1080
Changes from 1 commit
d5785eb
381ba0f
c2815e3
d0cb266
2f3605a
b246546
767c895
4656cbf
6ae5fb0
0e07d11
3aae425
ae07548
bc906ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,21 @@ | |
return; | ||
} | ||
|
||
if ( ! file_exists( __DIR__ . '/detection/web-vitals.asset.php' ) ) { | ||
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error | ||
trigger_error( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem with As for a more robust error notices like in the AMP plugin, I think that might be overkill for Optimization Detective. There are a lot more dependencies for the AMP plugin which can cause errors to happen a lot more often, so more users will be seeing that notice, even end users. For Optimization Detective, the only users seeing the error would be developers cloning from GitHub. So I think what we have now is sufficient. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense regarding Regarding the AMP plugin, as to what I had mentioned before, there's also https://github.com/ampproject/amp-wp/blob/develop/amp.php#L162 which shows an admin notice for when the plugin isn't built. That's just as much applicable here, which is why I was proposing it. But not a necessity to have either way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, for that we just included it among the other load error checks since the infrastructure was already there. But since that is a build time error rather than a runtime error, it technically isn't needed for the production build. |
||
esc_html( | ||
sprintf( | ||
/* translators: 1: File path. 2: CLI command. */ | ||
'[Optimization Detective] ' . __( 'Unable to load %1$s. Please make sure you have run %2$s.', 'optimization-detective' ), | ||
'detection/web-vitals.asset.php', | ||
'`npm install && npm run build:optimization-detective`' | ||
) | ||
), | ||
E_USER_ERROR | ||
); | ||
} | ||
|
||
define( 'OPTIMIZATION_DETECTIVE_VERSION', '0.1.0' ); | ||
|
||
require_once __DIR__ . '/helper.php'; | ||
|
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.
@westonruter Can't we wrap it in
is_admin()
? Users will face this problem while activating the plugin. So having this in admin should suffice? In production this check will be redundant anyway.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.
Good idea! Did that in ae07548 as well as checking if WP-CLI.
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.
@westonruter @thelovekesh Alternatively we could consider using
require
in atry catch
like you had before, given you mentioned thefile_exists
check as a potential concern.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 think this is good now as otherwise it would need to
require
the PHP file on every request when it may not be needed.