floydspace / serverless-esbuild

💨 A Serverless framework plugin to bundle JavaScript and TypeScript with extremely fast esbuild
MIT License
452 stars 139 forks source link

Esbuild does not build on file change #390

Open Edweis opened 2 years ago

Edweis commented 2 years ago

Describe the bug Running sls offline with a serverless.yml containing

custom:
  plugins:
    - serverless-esbuild
    - serverless-offline
  #esbuild: no extra esbuild setting

functions:
  testFn:
    handler: src/endpoints/index.handler
    events:
      - http:
          method: GET
          path: /hello

When editing the file src/endpoints/index.ts, calling the endpoint is using the version of the code when the first compilation started.

To Reproduce Steps to reproduce the behavior. If you have an example repository that would be even better:

  1. Create a new project with the configuration above
  2. in src/endpoints/index.ts, insert
    export const handler = async () => ({
    statusCode: 200,
    body: 'batman',
    });
  3. run serverless offline
  4. curl http://localhost:3000/dev/hello returns batman
  5. change src/endpoints/index.ts, to
    export const handler = async () => ({
    statusCode: 200,
    body: 'robin',
    });
  6. curl http://localhost:3000/dev/hello returns batman, expected robin

Versions (please complete the following information):

herebebogans commented 2 years ago

Had the same issue after serverless-offline upgrade, try adding reloadHandler: true to serverless-offline configuration.

Fixed it for me.

Edweis commented 1 year ago

Thank you, it doesn’t work for me. I’ll check with serverless-offline

JoeKolba commented 1 year ago

I am having the same issue, reloadHandler doesn't work for me either.

JoeKolba commented 1 year ago

we just solved this, make sure you don't have any rules that would exclude everything in your pacakge option like this:

package:
  individually: true
  patterns:
    - '!**'
    - 'src/assets/*/**'

it was importing the ** pattern into our exclude