cli icon indicating copy to clipboard operation
cli copied to clipboard

`netlify build` does not import all `included_files`

Open stebogit opened this issue 3 years ago • 1 comments

Describe the bug

According to the CLI docs and this article the included_files directive should tell the build command to include "any type of file in your serverless functions". Even the docs have such example of importing .md files.

However, it seems only JSON files seem to be imported in the bundle and even more only if the code includes such files.

Is this expected?

In a project I need to use .txt files as list of words for different languages; the project was working locally when running netlify dev, however in production I got an ENOENT: no such file or directory error. Digging deeper I looked into the netlify build resulting .zip file and realized the files were in fact not included anywhere.

Steps to reproduce

Please see example repo.

This is the content of my .netlify/functions/test.zip file; as you can see only the data.json file, required in Node, was included, all other files inside files were ignored:

.
└── functions
    └── test
        ├── src
        │   ├── files
        │   │   └── data.json
        │   └── functions
        │       └── test.js
        └── test.js

Configuration

[build]
  functions = "functions"

[functions]
  included_files = [
    "files/*.json",
    "files/*.md",
    "files/*.txt"
  ]

Environment

System:
    OS: macOS 12.4
    CPU: (8) x64 Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
    Memory: 557.52 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.15.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.11.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  npmPackages:
    netlify-cli: 10.5.1 => 10.5.1 
  npmGlobalPackages:
    netlify-cli: 2.32.0

stebogit avatar Jun 27 '22 00:06 stebogit

@stebogit I wasn't able to reproduce this.

I cloned https://github.com/stebogit/netlify_included_files_issue. Ran npm install. Then tried build command after linking. The extracted zip had the following files:

.
├── files
│   ├── data.json
│   ├── data.txt
│   ├── data2.json
│   └── test.md
├── functions
│   └── test.js
└── test.js

System Configuration

  System:
    OS: macOS 12.4
    CPU: (8) arm64 Apple M1
    Memory: 334.94 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
    Watchman: 2022.06.27.00 - /opt/homebrew/bin/watchman

tinfoil-knight avatar Aug 14 '22 11:08 tinfoil-knight

Closing as stale. Please re-open if needed

sarahetter avatar Sep 14 '23 20:09 sarahetter