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

@grammyjs/types doesn't appear to be written in CJS, but also doesn't appear to be a valid ES module (i.e. it doesn't have "type": "module" in package.json or an .mjs extension for the entry point) #23

Closed
ni554n opened this issue Mar 15, 2023 · 16 comments · Fixed by #24 or #26
Labels
invalid This doesn't seem right

Comments

@ni554n
Copy link
Contributor

ni554n commented Mar 15, 2023

Version: 3.0.3

I'm getting this warning in an Astro project that uses Vite under the hood.

I think the solution might be to add an empty export to the mod.js file so that it can be detected as Common JS module in Vite.

@KnorpelSenf
Copy link
Member

Can you share how to reproduce this?

@ni554n
Copy link
Contributor Author

ni554n commented Mar 18, 2023

@KnorpelSenf
Copy link
Member

I don't really see how this can be fixed. This package is meant to be empty, it contains 0 bytes of executable code. There is nothing wrong here, so there is nothing that we can do to fix it.

It seems like Astro seems to assume that such packages are invalid. IMO this assumption is incorrect. Perhaps you should open an issue for Astro and tell them that this warning is reported incorrectly. Perhaps there is a way to suppress such warnings.

I will close this now as there is nothing to do here. Please comment if the astro authors disagree and can come up with any ideas that can be improved about this repo.

@KnorpelSenf KnorpelSenf added the invalid This doesn't seem right label Mar 19, 2023
@ni554n
Copy link
Contributor Author

ni554n commented Mar 19, 2023

Thanks for looking into it.

I searched around a bit on GitHub issues and found out it's a Vite thing. The solution is very simple though.
Just adding // module.exports (as a comment) in the mod.js file makes the warning go away. 😅

@KnorpelSenf
Copy link
Member

KnorpelSenf commented Mar 19, 2023

Oh wow. Feel free to open a pull request that adds such a comment to mod.ts if that helps :)

@ni554n
Copy link
Contributor Author

ni554n commented Apr 25, 2023

@KnorpelSenf Hi, I just checked the latest release of this package, and the comments are not present in the mod.js file.
Aren't they supposed to be there if not explicitly disabled using https://www.typescriptlang.org/tsconfig#removeComments ?

@KnorpelSenf
Copy link
Member

@wojpawlik?

@wojpawlik
Copy link

Looks like a TypeScript bug. deno2node forces the option off.

@ni554n
Copy link
Contributor Author

ni554n commented May 1, 2023

Maybe setting that option explicitly in this project's tsconfig would do the trick!?

@wojpawlik
Copy link

That'd change nothing. What about adding export {} to mod.ts?

@wojpawlik wojpawlik reopened this May 1, 2023
@KnorpelSenf
Copy link
Member

We'd have to experiment with this. Why are JSDoc string kept but // comments stripped? Or did I misunderstand?

@ni554n
Copy link
Contributor Author

ni554n commented May 21, 2023

@KnorpelSenf I'm not sure how to experiment with this package. I've never used deno in a local environment. Can you please write a build instruction?

@KnorpelSenf
Copy link
Member

Yes, I should add that to the README, you're right.

Just run npm install in the top level directory of this repo. That will download all deps and compile the code. Run npm run prepare to recompile.

It's easier to install Deno tooling. There's a VSCode extension for Deno. Run deno task to see available tasks, and run deno task backport to compile. In fact, that's what npm uses under the hood, too.

@KnorpelSenf
Copy link
Member

I found the problem. Please review #26.

@KnorpelSenf
Copy link
Member

Update your deps and it will be fixed

@ni554n
Copy link
Contributor Author

ni554n commented Jun 17, 2023

Yes! Just tested it. No more warning! Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
3 participants