Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow nodejs build to run npm install with --omit=dev #568

Open
braun1928 opened this issue May 8, 2024 · 1 comment
Open

Allow nodejs build to run npm install with --omit=dev #568

braun1928 opened this issue May 8, 2024 · 1 comment

Comments

@braun1928
Copy link

Is your request related to a problem? Please describe.

When building node lambda, it runs just a npm install. If the package.json file has things in devDependencies, the package file may get a bit bloated unnecessarily. Specific case: one lambda goes from 4MB to 28MB, and obviously, takes a little longer to install the dependencies.

Describe the solution you'd like.

A way to signal the build process to append --omit=dev with node packages.

Describe alternatives you've considered.

Using a command list in source_path works, BUT that makes it not possible to use build_in_docker, which renders another list of issues (lots of different runtimes needed, CI pipelines, etc).

@sachasmart
Copy link

sachasmart commented May 23, 2024

What if you create a separate resource like:

resource "null_resource" "node_build" {
...
  provisioner "local-exec" {
    command = "<build command>"
  }

....
data "archive_file" "lambda_package" {
  depends_on  = [null_resource.function_binary]
  type        = "zip"
  source_file = "<path>"
  output_path = "<path>"
}

...

Then point your lambda resource block to that archive_file resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants