Open UndarkAido opened 6 months ago
I'm trying to use
@xmcl/resourcepack
Three.js project with Vite
Hey! Very interesting! Do you have a live demo for the project??
I've got a similar project where I bundle that package without any issues but using esbuild (for more fine-tuned import control and because its 3x harder to write plugins for vite).
You can fix the issue by using aliases like that:
export default defineConfig({
resolve: {
alias: {
'fs/promises': "./empty.js", // "fs" or relative path to that empty.js file (which is just `module.exports = {}`)
},
},
})
Let me know if you still have any questions
@zardoy I think I tried to get something similar to a polyfill to work, but wouldn't that cause issues when I actually try to open a resource pack? Either way, I asked on the Discord and @ci010 the the browser
value of the package.json
for @xmcl/system
was incorrctly set, so I've manually changed it to ./dist/index.browser.mjs
. Haven't had the time to actually start implementing anything yet, but this gets past the errors I was running into.
Sorry I didnt try to work with that module in the way you want. But I've also done the resource pack support in the browser as well and I'm actively using the fs module in browser only code. You can also do this by setting up browserfs (it's called ZenFS now).
Can I get a live preview link for your project or exact things you want to get from the resourcepack module? I might better help you if you would be kind enough to provide some additional details or your final goal… (I just think you might not need to use this module at all but I might be wrong)
This is all I've got so far, haven't even gotten a block to render: https://gist.github.com/UndarkAido/515bfec5b5db20139b5496c5be12fad0
I want to recreate the Minecraft Plus! screensavers but with more customization
@UndarkAido I made a whole library for you that you can use to render things with modern bundlers like Vite: https://npmjs.com/mc-assets
@zardoy That's awesome, thank you so much! I'm dealing with the aftermath of a cross-country move but I'm going to love digging into this when I have the time.
You need to thank @ci010 who made making this module possible! I'm using @xmcl/installer
to auto-publish new versions assets
Oh, it's not reading from a JAR or ZIP? I was hoping to also support resource packs, still cool though.
Oh, it's not reading from a JAR or ZIP? I was hoping to also support resource packs, still cool though.
It's reading from jar during the build before publish. You can still support resource packs (see there is an example with generating custom atlas) if you want you can use browserfs to read files dynamically or you can also do it at build step (which is recommended). I can give you a complete code if interested.
I'm trying to use
@xmcl/resourcepack
Three.js project with Vite but I can't get past@xmcl/system
's use offs
. I've tried usingvite-plugin-node-polyfills
but I can't seem to get it set up quite right. Has anyone else done this before?Edit: Oh, errors would rpobably be useful: First error I got:
After adding
vite-plugin-node-polyfills
:davidmyersdev/vite-plugin-node-polyfills#16 fives a proposal for how to resolve this last error but I haven't been smart enough to figure it out.