dai-shi / waku

⛩️ The minimal React framework
https://waku.gg
MIT License
4.63k stars 124 forks source link

build / image import broken #498

Closed aheissenberger closed 8 months ago

aheissenberger commented 8 months ago

an image imported in a server component is missing in the dist/public/assets folder. It exists in the dist/assets/sample-Xox1zmov.jpg which is not served by the static server.

Waku Commit: e85380c519a899244c548c460de1d0152efdabbc

import SampleImage from '../assets/sample.jpg';

export const MantineCorePage = async () => {
   return (<img src={SampleImage} />)
}
dai-shi commented 8 months ago

Thanks for reporting. I think we need to copy image assets like we do with css assets. Would you like to try? Otherwise, @Aslemammad can probably help.

aheissenberger commented 8 months ago

Thanks for reporting. I think we need to copy image assets like we do with css assets. Would you like to try? Otherwise, @Aslemammad can probably help.

I will give it a look, maybe I can fix it.

aheissenberger commented 8 months ago

Fixed the Problem in the ClientBuild - all tests and my new one are green, but I do not know if my change has any other side effects as my code will define all assets with extension !== '.js' as assets which need to be copied to the public asset folder.

dai-shi commented 8 months ago

Nice!

all assets with extension !== '.js'

I don't know either. Is it possible that a *.json file imported by an RSC which includes secret information leaks to "public"? (Technically there can be "secret" images, though.)

aheissenberger commented 8 months ago

Based on the current process I agree with you on the possibility too leak assets to a public folder, but you need to know the hash. And there are valid cases where I fetch an asset (e.g. json) on the client from the server.

I have no idea on how to distinguish between assets which are referenced in the rendered rsc output of an server component(e.g image tag, link tag to a json) and an json file where the content was processed in a server component.

aheissenberger commented 8 months ago

These are the rules for public assets:

Is this parcel api an option to solve this: https://parceljs.org/plugin-system/bundler/

dai-shi commented 8 months ago

Okay, let's assume all assets are public by default. I will later introduce a new vite plugin to allow private assets.