Is there anyway to use schemapack without browserfy?
Closed this issue · 9 comments
Hello!
We really want to use this in our current project but using browserfy is not an option. Is there a way to use schemapack on the client without having to build a bundle.js? Can we include some dependencies in script tags directly to make it work?
The server is no problem, just the client.
Thanks!
Hmm, there might be a way, but none that I'm immediately aware of.
The client needs the buffer
dependency as it allows the code to work on both the server and client without modification (as the buffer
dependency has the exact same API as the node server Buffer
).
I'm a bit curious why you cannot use browserify. You just need to execute it once to generate a bundle to include schemapack
with buffer
. Then, instead of including schemapack
in the script tag, you just include that bundle. Would it help if I included a built version in the repo for client use?
Just build it once via browserify and add this code to your project then. This is also how I will do it.
And yes, a ready-to-use browser version would be amazing.
@phretaddin Thanks for the quick response! We don't use broserfy because we have a 'no-build' policy, we like to be able to make changes to our client side code and see them without out an additional build step.
We could manually browserfy schemapack as @jannicars mentioned above, but that means we would have to do that whenever it's updated.
A pre-built client side library with a schemapack global would be super awesome! So we can just include on the client:
<script src="schemapack.js"><script>
<script>
var playerSchema = schemapack.build({
health: "varuint",
jumping: "boolean",
position: [ "int16" ],
attributes: { str: 'uint8', agi: 'uint8', int: 'uint8' }
});
</script>
That would stay up-to-date with your current release process.
Yup, just added this. Let me know if this works for you.
wow that was fast! thanks! I'll try it out now.
@phretaddin Worked great! Would it be possible to include a non-minified version in the build directory? For development sometimes it's nice to use non-minified for debugging, and minified for production.
Sure, one sec.
thanks!