Skip to content
This repository was archived by the owner on May 22, 2024. It is now read-only.

experimentalDecorators / emitDecoratorMetadata not supported in netlify CLI  #1047

@tomardern

Description

@tomardern

Is your feature request related to a problem? Please describe.

We are trying to use the popular https://github.com/microsoft/tsyringe dependancy injection package within netlify functions. This does not seem to be working, and we are getting the following error:

Error: TypeInfo not known for "X"
  InternalDependencyContainer.construct (<project-path>/node_modules/tsyringe/dist/cjs/dependency-container.js:263:23)
  InternalDependencyContainer.resolve (<project-path>/node_modules/tsyringe/dist/cjs/dependency-container.js:105:33)
  Object.<anonymous> (<project-path>/src/main.ts:51:32)
  Module._compile (internal/modules/cjs/loader.js:999:30)
  Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
  Module.load (internal/modules/cjs/loader.js:863:32)
  Function.Module._load (internal/modules/cjs/loader.js:708:14)
  Module.require (internal/modules/cjs/loader.js:887:19)
  require (internal/modules/cjs/helpers.js:74:18)
  Object.<anonymous> (<project-path>/.netlify/functions-serve/incoming/incoming.js:1:18)

I think the underlying issue is that Netlify CLI uses esbuild bundler under-the-hood (https://www.netlify.com/blog/2021/04/02/modern-faster-netlify-functions/), which in turn does not support experimentalDecorators and emitDecoratorMetadata (evanw/esbuild#257).

The solution could be to use https://github.com/thomaschaaf/esbuild-plugin-tsc but there is no way (that I've found) to modify the netlify CLI's esbuild config

Describe the solution you'd like

A way of modifying the esbuild config during netlify dev commands.

Describe alternatives you've considered

N/a

Additional context

N/a

Can you submit a pull request?

No.

Pull requests are welcome! If you would like to help us add this feature, please check our
contributions guidelines.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions