I want to extend the functionality by creating a sendmail endpoint. I created a new file called sendMail.js and registered a new GET-Endpoint.
The endpoint was correctly initialized. To send an email i want to use nodemailer. I added the package wir “yarn add nodemailer” and imported the mailer in my sendMail.js.
I checked in this case with my team and was able to confirm that at the moment, we do not support the defining of any node dependencies. We only support a small list of dependencies built-in. You can check out the list here.
As such, if you’d like to use the dependency, you would need to use something like webpack to bundle the dependency into your function.
While we currently do not have any real resources on that front just yet, do let us know if your team run into any specific issues bundling the dependency.
Installing dependencies (in particular, “nodemail”) via
$ npm install --save
Third, we run webpack on this app:
$ webpack --config webpack.config.js
Webpack has now compiled the node app into a flat file “bundle.js” (as per my config file), which contains close to 1 Million characters of gibberish (i.e. compiled javascript, including all nested dependencies of the app):
Hello @Megh_Patel , I would recommend you pose your question as a new forum post or on our developer Slack server. I would also recommend you provide some additional detail there on steps you have already tried, on the runtime and packages that comprise your app, on any errors you are getting, etc.
@vbrech this is really cool and thanks for sharing! I was wondering though, does `hs project upload` / `hs project dev` support webpack? To say, that if we use webpack that we would have to always manually copy data into the file we want to use the packaged code for?