https://pulumi.com logo
Title
t

tall-librarian-49374

07/06/2018, 2:34 PM
When using
cloud.API
, should I
require
my modules inside the
get
function itself? I tried to use
request
imported on top of the files and it failed with a warning not to close on requires... So I do
endpoint.get("/", (req, res) => {
    const request = require('request');
    request(url, ...
w

white-balloon-205

07/06/2018, 4:21 PM
Yes - that will work, and is generally recommended currently. This ensures that you will get exactly this
require
at runtime. We are discussing in https://github.com/pulumi/pulumi/issues/1588#issuecomment-401968174 an approach which would allow capture of top-level imports to be interpreted as a top-level
require
at runtime - feel free to add in there as well.
👍 1