FormidableLabs/serverless-jetpack

Files that contain dots are ignored during packaging

crash7 opened this issue · 0 comments

DISCLAIMER: This issue was raised against serverless/serverless too, but since I use jetpack for some services and it contains the same issue, maybe it's a good idea to add a fix to the plugin too.

I have a serverless service that contains files that starts with something like [...file].js. When running sls package, those files don't end in the zipfile because they are being ignored.

The problem, at least one part of it, lies in the dot parameter that the library use for globby:
https://github.com/FormidableLabs/serverless-jetpack/blob/master/util/bundle.js#L18

I have multiple ideas for a fix (maybe use globby again without dot: true to get just valid files?) but I would like to know your thoughts before I try to make a PR.

So, given a file structure like this:

folder/
  other.js
  [...file].js
handler.js

The end result is:

Archive:  .serverless/my-service.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  01-01-1980 00:00   folder/other.js
      442  01-01-1980 00:00   handler.js
---------                     -------
      442                     2 files

This is my serverless.yml:

service: my-service

provider:
  name: aws
  runtime: nodejs12.x

package:
  excludeDevDependencies: true
  exclude: 
    - '**/*'
  include:
    - handler.js
    - folder/**
    - folder/[...file].js

functions:
  hello:
    handler: handler.hello

plugins:
  - serverless-jetpack