netlify / netlify/cli

Netlify deploy with --no-build flag is still building edge functions

Open
#7,933 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
TypeScript
Stars
1.9k
Forks
474
Avg merge
23h 30m
Merged PRs (30d)
53

Description

Describe the bug
Expected behavior

According to the Netlify CLI documentation for netlify deploy:

--no-build Do not run build command before deploying. Only use this if you have no need for a build or your project has already been built.

When running:

  • netlify build
    successfully bundles Edge Functions and places artifacts (.netlify/edge-functions/ or similar)
  • netlify deploy --no-build
    should only upload already-built assets + already-bundled Edge Functions without re-running any bundling
Observed behavior

Even with --no-build, the CLI still runs the Edge Functions bundler:

⠋ Bundling edge functions...
✘ [ERROR] Could not resolve "[REDACTED]"
    [REDACTED]:
      1 │ import * as mod from "[REDACTED]";
        ╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  The module "./dist/index.js" was not found on the file system:
    [REDACTED]:
      11 │ "default": "./dist/index.js"
         ╵ ~~~~~~~~~~~~~~~~~

You can mark the path "[REDACTED]" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.

This fails because:

  • The bundler is looking for source files and/or workspace-internal dist/ artifacts that were produced during the earlier netlify build / monorepo build step.
  • Those files are not present (or not visible) in the clean GitLab CI job for the deploy stage.
  • This forces us to either:
    • Artifact-upload all internal dist/ folders from every workspace/package used by Edge Functions
      This is very messy & results in large artifacts
    • Or give up on separating build & deploy and run full build again in the deploy job (loses the separation benefit)
Why this matters (business / DX impact)
  • In monorepos with many packages, bundling internal dist/ folders into artifacts just to satisfy the Edge Functions bundler is inefficient and error-prone.
  • It defeats one of the main advertised benefits of --no-build: clean separation of build & deploy for faster / more predictable CI, especially on large repos.
  • Regular (non-edge) Functions appear to respect --no-build much better (pre-zipped bundles are reused).
Steps to reproduce
  1. Create a new monorepo where you add a separate Edge Function in a package
  2. Include the Edge Function within the application
  3. Run netlify build
  4. Remove the dist folder of the Edge Function package
  5. Run netlify deploy
  6. See that it can't find the necessary files to create the Edge Function bundle
Configuration
[build]
  publish = "dist"           # or wherever your publish dir is
  command = "turbo run build"  # or similar monorepo build command

[[edge_functions]]
  path = "/*"
  function = "my-function"
Environment
  System:
    OS: macOS 15.7.3
    CPU: (12) arm64 Apple M4 Pro
    Memory: 196.92 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.22.0 - /Users/pvanmeijgaard/.local/state/fnm_multishells/11669_1770277129243/bin/node
    npm: 10.9.4 - /Users/pvanmeijgaard/.local/state/fnm_multishells/11669_1770277129243/bin/npm
    pnpm: 10.28.1 - /Users/pvanmeijgaard/.local/state/fnm_multishells/11669_1770277129243/bin/pnpm
    bun: 1.3.7 - /opt/homebrew/bin/bun

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the netlify deploy --no-build path and the Edge Functions bundling step; reproduce using netlify build, remove the Edge Function package's dist folder, then deploy. Done means deploy reuses the already-built Edge Function artifacts without rerunning the bundler or requiring source and workspace dist files.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.