Closed nearwood closed 4 years ago
Ah, this is a bug because I forgot to consider server.js
in https://github.com/nicolodavis/boardgame.io/blob/master/scripts/proxy-dirs.js
Cool. Looks like I can just add it to subpackages.js? Easy first PR!
EDIT: Not so fast. Looks like the server code was missed in a conversion from typescript. I also cannot get whatever native library that is compiled on install to compile (but it doesn't look needed yet). I'll try a bit more comparing with the other modules.
Sure, feel free to send a PR.
It's not as simple as adding it to subpackages.js
though. The other subpackages are generated in dist/esm
and dist/cjs
. What we do to wire them both is to generate a package.json
file with a module
and main
field pointing to each.
So, we'd generate something like:
client/package.json
core/package.json
ai/package.json
...
at the top level.
The server package does not have an esm
version (we just generate a cjs
version at ./dist/server.js
like you've discovered already). So we'd need to generate a different package.json
for it. Simpler yet, we don't need to even generate a package.json
for it but just a simple server.js
at the top level that imports ./dist/server.js
.
We'd also need to add a shell.rm
here to clean up the server related files at the top-level. The way this whole thing works is that proxy-dirs.js
is called right before the package is published (so we end up with these files at the top-level that can be imported as boardgame.io/client
for example). clean.js
is run right after the package is published so these temporary files aren't kept around.
Ok, I understand the submodule generation at at least a high level. But, it looks like Rollup is having issues with the typescript in the server module. I see there's a typescript plugin to convert it but something or some config appears to be missing.
But you are able to see dist/server.js and even import it in your client code, so why do you think the typescript compilation isn't working?
On Thu, Nov 21, 2019, 11:00 AM Nick Earwood notifications@github.com wrote:
Ok, I understand the submodule generation at at least a high level. But, it looks like Rollup is having issues with the typescript in the server module. I see there's a typescript plugin to convert it but something appears to be missing.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nicolodavis/boardgame.io/issues/518?email_source=notifications&email_token=AABZULW3OLRKKXBVBK2KHOTQUX2VDA5CNFSM4JP2INE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEYWVGY#issuecomment-556886683, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABZULU4MS3WGIPNS4NJSTLQUX2VDANCNFSM4JP2INEQ .
Yes, I was able to get it working on a packaged version from npm. Here, I am trying to build it locally to create a PR. I think I just figured it out though.
Ok, created #519, let me know if it needs any changes.
Thanks for the PR @nearwood!
It looks like the exports were changed and maybe Server is not longer exported. Using this small example:
With:
Results in:
It looks like it may not be exported anymore:
But I was able to find it at :
So you can use
const Server = require('boardgame.io/dist/server').Server;
but that is weird. Advise on proper way to import it now?