architect / functions

AWS Lambda Node runtime helpers for Architect apps
https://arc.codes
163 stars 38 forks source link

Static does not work with fingerprinting #536

Open mokkabonna opened 1 year ago

mokkabonna commented 1 year ago

Steps to reproduce Steps to reproduce the behavior:

  1. Setup static with fingerprinting
@static
fingerprint true
  1. Use static helper to get fingerprinted path of asset
  2. deploy

Expected behavior Expect the static helper to get the fingerprinted path. It does not. it only get the non fingerprinted path.

Seems this is the problem: Why does the code look here(node_modules folder) https://github.com/architect/functions/blob/main/src/static/index.js#L18 for the manifest? While the file is written to /public/static.json? https://github.com/architect/deploy/blob/main/src/static/publish/write-static-manifest.js#L11

@architect/functions 5.2.3 @architect/architect 10.7.1

beckelmw commented 1 year ago

I ended up working around this with a custom plugin which copies the file where it needs to be during hydrate.

module.exports = {
  hydrate: {
    copy: async ({ arc, inventory, copy }) => {
      await copy({
        source: "./public/static.json",
        target:
          "@architect/shared/static.json",
      });
    },
  },
};
Xiphe commented 1 year ago

I was also encountering this issue together with the typescript plugin. I suspect the problem is that with typescript esbuild bundles the whole function but the static sill tries to look up the static.json on the file system