serverless-next.js: Deploy with `build: false` doesn't work

Describe the bug

Running sls with build vs running sls with manual build do not yield the same result.

This is my config WITH specified build:

# serverless.yml
distDir: ''

my-app:
  component: "@sls-next/serverless-component@1.19"
  inputs:
    nextConfigDir: ${distDir}
    build:
      cmd: "nx"
      args: ["run", "desktop:build:production"]
      cwd: "../../"

This is config WITHOUT build:

# serverless.yml
distDir: ''

my-app:
  component: "@sls-next/serverless-component@1.19"
  inputs:
    nextConfigDir: ${distDir}
    build: false

Actual behavior

When I run that nx run desktop:build:production I do not get .serverless_nextjs folder in my dist. Then when I run sls to deploy I get:

Error: ENOENT: no such file or directory, open 'absolute-path-to-dist/.serverless_nextjs/default-lambda/manifest.js

Expected behavior

Running sls to deploy with build: false after manually building should result in correct deploy.

Steps to reproduce

Just follow bug description.

Screenshots/Code/Logs

Versions

Additional context

I have searched through the source code and found out that build operation actually passes that folder name to Builder: https://github.com/serverless-nextjs/serverless-next.js/blob/41b6be1943bca70a1e2e6f919b5ee6fecc56389f/packages/serverless-components/nextjs-component/src/component.ts#L219

Then it is latter used as buildDir https://github.com/serverless-nextjs/serverless-next.js/blob/41b6be1943bca70a1e2e6f919b5ee6fecc56389f/packages/libs/lambda-at-edge/src/build.ts#L72

This is all I could find. There is a lot going on that file, and I am not that proficient in serverless DevOps stuff to understand it.

Checklist

  • You have reviewed the README and FAQs, which answers several common questions.
  • Please first try using the most recent latest or alpha @sls-next/serverless-component release version, which may have already fixed your issue or implemented the feature you are trying to use. Note that the old serverless-next.js component and the serverless-next.js plugin are deprecated and no longer maintained.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21

Most upvoted comments

Not yet, I will release it soon. There were a couple regressions in the latest alphas which were fixed so I think it can be released.

Now that e2e tests are a bit more complete/stable I think we can go for a faster release cycle

@Bielik20 ah, that makes sense now, I think it was there before I started on this project, it might be to ensure a clean state before trying to build. But I guess any build commands (whether Next.js’s or custom ones) should handle the cleanup instead of this component? It looks like just a one line removal if so

Sure, I will update the docs and I think we should be able to close this if there are no further issues.