react-xr icon indicating copy to clipboard operation
react-xr copied to clipboard

Including @react-three/xr in my project add multiple large files to my build, for example meeting_room-COtFIOij.js and living_room-CVCYIB7e.js

Open Bossieh opened this issue 1 month ago • 9 comments

When I include @react-three/xr in my project multiple large .js files are added to my build, for example meeting_room-COtFIOij.js and living_room-CVCYIB7e.js.

Is there any way to prevent this from happening?

Snippet of my package.json:

    "@react-three/xr": "6.6.27",
    "@react-three/drei": "10.7.5",
    "@react-three/fiber": "9.3.0",
    "three": "0.180.0",
    "typescript": "5.9.2",
    "vite": "7.2.4"

Bossieh avatar Nov 27 '25 13:11 Bossieh

Seems like the package @iwer/sem is responsible for adding the files.

Bossieh avatar Nov 27 '25 13:11 Bossieh

@Bossieh these files are not automatically loaded, just when you start the emulator

bbohlender avatar Nov 27 '25 13:11 bbohlender

Thanks for the quick reply.

They appear in my dist folder after building my app.

  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
dist/assets/music_room-DAOruTFO.js
dist/assets/office_large-DoJFWIAy.js

Bossieh avatar Nov 27 '25 13:11 Bossieh

yes, but they are not loaded by the browser unless you start the emulator

bbohlender avatar Nov 27 '25 13:11 bbohlender

Yes I understand, but now my build size is increased drastically.

I don't use the emulator at all, I only use the AR functionality. I prefer to only have files in my /dist folder which are actually used.

Bossieh avatar Nov 27 '25 13:11 Bossieh

You can remove them after the build or maybe there's a vite script to exclude the imports that cause them to be included:

const { emulate } = await import('./emulate.js')

Why do you care about build size?

bbohlender avatar Nov 27 '25 13:11 bbohlender

Because I like to keep my build size small.

Bossieh avatar Nov 27 '25 13:11 Bossieh

I guess this would also be nice in my use case, as I'm exporting the app build automatically and zipping it to the user, so i guess the less size the better

joaomelorodrigues avatar Dec 05 '25 09:12 joaomelorodrigues

just found this today when trying to figure out why I had an old version of three in my build (0.165.0) which apparently is required by @iwer/devui and @iwer/sem which are also in the build. I've handled this in vite config but it would be nice if it could be made optional in /xr. really the emulator should probably be a separate package imo.

theshanergy avatar Dec 07 '25 21:12 theshanergy