Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module support #107

Closed
kraxarn opened this issue Jan 7, 2022 · 3 comments · Fixed by #108
Closed

Module support #107

kraxarn opened this issue Jan 7, 2022 · 3 comments · Fixed by #108

Comments

@kraxarn
Copy link

kraxarn commented Jan 7, 2022

nakama-js seems to stop working once a project uses ES6 modules. For example, simply doing this:

import { Client } from "@heroiclabs/nakama-js"
const client = new Client()

Results in error:

import { Client } from "@heroiclabs/nakama-js";
         ^^^^^^
SyntaxError: Named export 'Client' not found. The requested module '@heroiclabs/nakama-js' is a CommonJS module, which may not support all module.exports as named exports.

It instead suggests importing it like:

import nakama from "@heroiclabs/nakama-js"
const {Client} = nakama

But that instead throws another error:

   import nakama from "@heroiclabs/nakama-js"
          ^
   const { Client } = nakama
> 'default' is not exported by node_modules/@heroiclabs/nakama-js/dist/nakama-js.esm.js

Seems to be related to using TypeScript with "module": "es2020".

@novabyte
Copy link
Member

novabyte commented Jan 7, 2022

@kraxarn Thanks for the issue report. I'm not familiar with how the TypeScript "module": "es2020" affects a project built with ES6 modules. Can you suggest how it should be updated?

@kraxarn
Copy link
Author

kraxarn commented Jan 8, 2022

Tested the solution from #108 and can confirm it works fine now.
@bluwy Thank you for looking into this!

@andreavaccari
Copy link

@bluwy I have seen your name pop up so many times. Thank you for your contributions to Vite and Svelte!

Would you consider chiming in here to help us figure out how to make this library work with SvelteKit?

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants