ampproject / amp-toolbox

A collection of AMP tools making it easier to publish and host AMP pages.
Apache License 2.0
450 stars 243 forks source link

[optimizer] not all transformers honor passed configuration #547

Open mk0x9 opened 5 years ago

mk0x9 commented 5 years ago

When optimizer used in conjuction together with optimizer-express it's not possible to pass params to optimizer's transformHtml method, only configuration to the optimizer constructor.

And while some transformers honor those configurations: https://github.com/ampproject/amp-toolbox/blob/efe5775c5ff93ebacd6f7bd336ba02d829eca579/packages/optimizer/lib/transformers/AmpBoilerplateTransformer.js#L30-L37

looks like a lot of other does not: https://github.com/ampproject/amp-toolbox/blob/efe5775c5ff93ebacd6f7bd336ba02d829eca579/packages/optimizer/lib/transformers/RewriteAmpUrls.js

sebastianbenz commented 4 years ago

Yes, that's a good point. We should change the implementation(s) to also support a function that can be passed via the constructor which will calculate the correct option based on the current page.