-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add AutoExtensions transformer #210
Conversation
87eca1b
to
075329a
Compare
c8042c0
to
13cdd18
Compare
075329a
to
65720fa
Compare
13cdd18
to
ca64667
Compare
65720fa
to
a42f024
Compare
Should this add a special case for |
a42f024
to
3d80083
Compare
Waiting on ampproject/amp-toolbox#1241 |
3d80083
to
d8269c2
Compare
@schlessera I have a request: please include a configuration option to omit certain scripts from ever being imported. The use case is present in ampproject/amp-wp#6527 where if the user opts-in to native Here's how the plugin is currently handling that omission: https://github.com/ampproject/amp-wp/blob/ebb400816a34c3a9cea768486ac2d19c8211e5cf/includes/class-amp-theme-support.php#L1535-L1542 So if the transformer could be configured to omit |
@westonruter Yes, makes sense. We can add an |
d8269c2
to
d626d4d
Compare
Hi @schlessera I've pushed the new changes. The spec tests for AutoExtensions are passing now except the Also, added the $config = new AutoExtensionsConfiguration([
'ignore' => ['amp-form', 'amp-ad', ...]
]); |
@schlessera Updated the code and added support to auto include |
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.
There is still part of the implementation missing => removal of unneeded extensions.
Also, after getting past the SVG case inconsistency and re-enabling the SVG test, it produced a different failure that needs to be looked into.
@schlessera The test is failing because of self closing |
I don't think the problem is with the spec of the Looking at the test output, it seems like the trailing slash for the self-closing tags is being stripped already from the input (i.e. the expected markup shows |
I wanted to call out another scenario to make sure it is accounted for. In the AMP plugin, we use Therefore, the AMP plugin's auto-extension logic will prevent removal of In short: Adding |
@schlessera Updated the code with following changes,
|
Co-authored-by: Alain Schlesser <alain.schlesser@gmail.com>
Co-authored-by: Alain Schlesser <alain.schlesser@gmail.com>
989f2cb
to
1d2aefe
Compare
tests/Optimizer/Configuration/AutoExtensionsConfigurationTest.php
Outdated
Show resolved
Hide resolved
I just send the review as a "comment", instead of a "change request", but most of the above needs changes, though. But it's only minor tweaks, the overall logic LGTM. |
Ah, just realized that I was not able to "Request Changes" because I created the initial PR myself. I've requested a review from you instead now. |
Co-authored-by: Alain Schlesser <alain.schlesser@gmail.com>
@schlessera Updated the code according to your suggestions. Please take a look. |
This PR adds a new transformer that automatically imports missing extension scripts and removes unneeded ones.
Depends on #100
Fixes #32