Skip to content

includePaths and folder structure issue #53

@hakenmt

Description

@hakenmt

I'm running serverless version 0.5.5 on Windows 10 1511 with node.js version 5.6.0 and serverless-optimizer version 2.5.1.

First, given a folder structure like:

MyProject
|--lib
    |--common.js
|--functions
   |--myFunction1
       |--handler.js 
       |--s-function.json

and my optimize section looks like:

"custom": {
    "optimize": {
      "exclude": [ "aws-sdk" ],
      "require": [ "q", "jsonwebtoken", "rsa-pem-from-mod-exp", "node-uuid" ],
      "excludeStage": [ "dev", "test" ],
      "includePaths": [ "./lib" ]
    }
  }

and my handler is defined as

"handler" : "myFunction1/handler.handler"

When I run sls function deploy myFunction1 it always fails with an error: myFunction1: ENOENT: no such file or directory, lstat 'C:\Workspaces\AWS\LambdaFunctions\MyProject\_meta\_tmp\myFunction1@1464958827455\lib'. So, when I create an empty lib folder in the functions folder, it succeeds. However, the contents of MyProject/functions/lib are not included in the resulting zip file. I'm expecting there to be a folder called lib with the contents of the lib folder in the project, namely common.js. Now, if I put the common.js file in that new empty lib folder, then it does end up in the zip. But, if I delete the lib folder in the project root, because it appears to not actually get utilized, then I get an error: myFunction1: ENOENT: no such file or directory, lstat 'C:\Workspaces\AWS\LambdaFunctions\MyProject\lib'. So it appears that the optimizer is checking for the folder to actually exist in both places, but only taking the content from the one in the functions folder. This is not what I would expect or desire, I want the includePaths to be relative to the project root and actually take the files/folders defined there and not need to maintain a shadow copy somewhere in subfolders.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions