question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dependency Injection not working when using serverless-esbuild plugin

See original GitHub issue

Hello,

I’ve encountered that weirdly dependency injection breaks(Nest.js project) when attempting to use serverless-esbuild in local environment. However when attempting to use serverless-webpack it’s all working fine.

serverless-offline@8.3.1 serverless-esbuild@1.23.3 serverless@2.72.2 serverless-webpack@5.6.0

custom:
  serverless-offline:
    httpPort: 4000
    lambdaPort: 4001
  esbuild:
    bundle: true
    minify: false
    platform: 'node'
    external:
      - "cache-manager"
      - "class-transformer"
      - "class-validator"
      - "@nestjs/microservices"
      - "@nestjs/websockets/socket-module"
      - "fastify-swagger"
    watch:
      pattern: ['src/**/*.ts']

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
svetlasyrimiscommented, Feb 17, 2022

Update: Using esbuild-plugin-ts-decorators and plugins option in serverless.yaml actually made it work. Thanks for the help @vinicius91carvalho 😃

1reaction
vinicius91carvalhocommented, Feb 11, 2022

I used @anatine/esbuild-decorators plugin as this example here: https://docs.serverless-stack.com/constructs/Function, and it solved the problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Esbuild - Serverless Framework: Plugins
Serverless plugin for zero-config JavaScript and TypeScript code bundling using promising fast & furious esbuild bundler and minifier.
Read more >
Plugins - esbuild
Plugins. The plugin API allows you to inject code into various parts of the build process. Unlike the rest of the API, it's...
Read more >
How We Sped Up Our TypeScript Serverless Builds Ten ...
We are using decorators, but emitting decorator metadata is not supported by esbuild. We fixed a bug and submitted a PR to the...
Read more >
serverless/serverless - Gitter
I installed serverless with npm i -g serverless. Now I want to generate a project to run on Azure. npm i -g serverless-azure-functions...
Read more >
serverless AWS deployment fails because of esbuild
If you are installing with npm, you can try ensuring that both npm and node are not running under Rosetta 2 and then...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found