dai-shi / waku

⛩️ The minimal React framework

Home Page:https://waku.gg

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

build / image import broken

aheissenberger opened this issue · comments

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} />)
}

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.

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.

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.

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.)

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.

These are the rules for public assets:

  • referenced by any code in the client bundle
  • referenced only by the rendered (rsc) output of a server component

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

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