cloudflare / pages-action

MIT License
468 stars 95 forks source link

Poor performance because wrangler is not cached or in-lined #60

Open ari-becker opened 1 year ago

ari-becker commented 1 year ago

This action invokes npx wrangler via the shell: https://github.com/cloudflare/pages-action/blob/0fc25c3c282fb26e9a53abfadf6d2898adcac3de/src/index.ts#L37

This causes NPM to re-download and re-install wranger on each invocation of this action.

image

Notice how there is an NPM warning that it will need to install wrangler.

We're considering migrating from Netlify to Cloudflare Pages - to deploy the same site, nwtgck/actions-netlify takes 2 seconds while this action takes 19 seconds.

image

If wrangler was in-lined / cached by this action, the deployment would take much less time to finish.

WalshyDev commented 1 year ago

Once we have more of the Wrangler API built out we could use it as a dependency + bundle it into the action. Right now, however, we cannot.

We could theoretically use cache here, I'm not too sure it'll make a big improvement. 19 seconds is still a pretty short time. I'll leave this open to consider though.

aaronadamsCA commented 1 year ago

Unless I'm missing something:

Given the Wrangler CLI is already an NPM package, is there any reason it doesn't export its main program to be invoked programmatically? It wouldn't increase the API surface of that package at all, but it would allow this package to import main and call it directly, at which point it would also allow this package to esbuild that package into the shipped JavaScript file. It would also resolve #74 and #75.