-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add module.exports
to the main module
#13
Comments
@FlyingDR How do you use the package with vite? Can you give an example? |
Sure, I use SvelteKit which, in its turn, uses Vite as a bundler and dev server. I use Node.js 16 which reports JSON module import as an experimental feature. To remove this warning from Node.js I've added your package to the project and it causes Vite to report a warning, given above. |
Ok but how did you add the package to the project? Is it part of the Svelte config and if so, how does it look like? |
No, I use it in a way, which is recommended by you, for console commands runner: #!/usr/bin/env bash
if [ $# -eq 0 ]; then
node --require=suppress-experimental-warnings console/index.js --help
else
node --require=suppress-experimental-warnings console/index.js "$@"
fi But it looks like Vite parses contents of the |
@FlyingDR Ok I dug myself into it and imho this is a vite issue. So, here is the regex that basically checks if this is a commonjs module and this looks pretty hacky to me. If the package would have require call or Object.assign or something similar, the warning would not be thrown anymore. I'd suggest to open an issue in the vite repo to fix it there. The issue seems to also seems to happen with a lot of other packages:
|
@dword-design Thank you for such great research! I've seen several similar issues in the Vite repository too, but it looks like that Vite' developers position is that external packages need to be fixed, not their code. But it may be worth opening another issue in Vite. It is really strange that they're detecting CJS module by If you prefer to keep your project as it is now - please close the issue. |
I'd say close for now and observe what Vite devs are doing. |
At this moment main module of the project does not include
module.exports
statement.Of course it is not needed in this case, there is a practical reason: Vite reports a warning for modules without
module.exports
statements, effectively polluting logs with:suppress-experimental-warnings 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" or an .mjs extension for the entry point). Please contact the package author to fix.
Hope that it is not a big deal to update module in this way.
The text was updated successfully, but these errors were encountered: