-
Notifications
You must be signed in to change notification settings - Fork 369
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
Deployment on Vercel using .mjs #438
Comments
Sorry for running into this. What version of Helmet are you using? And if you're using TypeScript, what's in your tsconfig.json?
|
Hello Evan. The version I am using is 7.0.0 for helmet and I am implementing it in Node v18.17.1. |
This seems like a Vercel issue, but I'm not sure. Could you paste the full error that Vercel gives you? Does this problem happen with any other modules? Is Vercel respecting |
This issue does not occur with any other module but only with helmet and this is the error it logs on Vercel |
Strange. |
Changing it to But on Vercel it is working with the |
How are you running this locally? I'm surprised that you're seeing different behavior between Vercel and your local machine. Maybe that's where the problem lives? |
If it was a local environment issue then the other libraries should have also complained to some extent but they work perfectly fine only Helmet has this issue. The named exports force the use of importing it as "helmet" whereas it should not but it is an issue which appears frequently for module type. Some misconfiguration exists inside the Helmet package should makes it not able to deploy to Vercel as a simple import compared to all the other packages. |
In the short term, you might be able to import the .mjs file from the node_modules directory directly.
In the long term, I'll take deeper look, though I probably won't be able to get to it soon. If you (or anyone else) has time to investigate, I'd appreciate.
|
I haven't had time to investigate this problem, apologies. Do you have any updates? Is this still an issue for you? |
Hello Evan. I haven't really checked it again after that but i can try to create soft example to test again if this issue presists or not. |
A sample app would be super useful to help debug. If you have the time to build one, I'd appreciate it!
|
Related:
... is expected & correct behavior. helmet only defines a default export and an implementation respecting the exports spec would error here. I tested different variations of this (using type: module/ commonjs, from within cjs/js/mjs files) and they all worked as expected locally. According to Vercel's docs (https://vercel.com/docs/functions/runtimes/node-js)...
... it is evident that they do a compilation and given that they support loading Typescript files directly, I wouldn't be surprised that they actually run regular JS files through the Typescript compiler as well, making this a TS compilation error closely related to #441 |
There hasn't been any movement on this issue in 6 months, so I'm going to close it. This seems like a Vercel bug to me. If someone can produce a sample app that reproduces this problem outside of Vercel, please let me know and I will reopen (or open a new issue). |
When deployed on Vercel with this library it causes issues as vercel is unable to read this library import properly but if you change the import to
import helmet from "helmet/index.cjs"
It starts working on Vercel but using this way makes the local environment crash requiring the import to be
import helmet from "helmet"
I couldn't really find a good workaround as the imports are not defined inside the package.json provided for helmet so would be good if that can be resolved.
The text was updated successfully, but these errors were encountered: