Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ module.exports = {
if (purge) {
utils.purgeCache(handlerFilePath);
}
//set environment before requiring, as imported modules will be immediately
this.setEnvironmentVars(functionId);
const module = require(handlerFilePath);
const functionObjectPath = handler.slice(1);
let func = module;
Expand Down
6 changes: 6 additions & 0 deletions lib/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ module.exports = {
throw err;
}
const loadedModules = [];
// We need to set all environments before requiring any handlers, as
// imported modules may be in a single file and immediately require
// their environment.
for (let funcConf of funcConfs) {
this.setEnvironmentVars(funcConf.id);
}
for (let funcConf of funcConfs) {
funcConf.handlerFunc = this.loadHandler(
stats,
Expand Down