hanami / assets-js

esbuild plugin for Hanami Assets
3 stars 5 forks source link

Ignore file system meta files like .DS_Store #25

Open svoop opened 5 months ago

svoop commented 5 months ago

On macOS filesystems (HFS and APFS), finder metadata is written to .DS_Store which causes loads of fun in many places. Other filesystems might have similar reserved metadata files as well, but I'm not aware of any since the only other filesystem I'm really familiar with is ext on Linux.

When building the assets on macOS, these .DS_Store directories are processed as well:

image

And as a consequence, they also show up in the assets.json manifest:

  ".DS_Store": {
    "url": "/assets/.DS_Store-49C419DE"
  },

If the assets are compiled during development and not during deployment (maybe not a common scenario, but certainly not impossible) or when deploying to such a filesystem, this finder metadata is exposed to the public. There might not be critical information in there, but .DS_Store is a black box and who knows what Apple decides to persist there in the future.

Maybe, there should be a short denylist with known files like .DS_Store which should never be processed.

svoop commented 5 months ago

I did some research on this, unfortunately, there doesn't seem to be any way to ignore certain files or directories using esbuildOptions. Maybe marking those files as external in order not to bundle them could work, but currently this mechanism is used for all assets but those in css/ and js/. This might change with #24 though.

Otherwise, the only alternative would be the removal of those .DS_Store files prior to the run. That's certainly too invasive to be built into Hanami and would have to be done hooking in some code into assets.js or even by sweeping them manually before compiling the assets.

I'll reach out to the esbuild community to see what they'd suggest.