ampproject / amp-toolbox

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

toolbox-optimizer: cache location breaks Vercel pkg #947

Open svdoever opened 3 years ago

svdoever commented 3 years ago

I would like to embed the toolbox-optimizer in an application which I package with https://github.com/vercel/pkg.

The following code in https://github.com/ampproject/amp-toolbox/blob/main/packages/optimizer/lib/cache.js:

// a shared cache implementation
const cache = FileSystemCache.create({
  log,
  baseDir: path.join(__dirname, '..', '.cache'),
});

breaks this possibility.

Could the cache location be made configurable?

sebastianbenz commented 3 years ago

This should be no problem and makes total sense. The cache location should be configurable via the normal config.

sebastianbenz commented 3 years ago

The path should be added to the default config which can be overwritten by the user. https://github.com/ampproject/amp-toolbox/blob/main/packages/optimizer/lib/DomTransformer.js#L104