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

experimentalDecorators / emitDecoratorMetadata not supported in netlify CLI #1047

Open
tomardern opened this issue Feb 22, 2022 · 4 comments
Labels
area: command: dev area: command: functions area: functions type: feature code contributing to the implementation of a feature and/or user facing functionality

Comments

@tomardern
Copy link

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.

@tomardern tomardern added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Feb 22, 2022
@iib0011
Copy link

iib0011 commented Feb 25, 2022

Should we add a flag for the plugin to use?

@tomardern
Copy link
Author

Maybe something in the toml file? eg

[functions]
  directory = "src/"
  node_bundler = "esbuild"
  esbuild_config_file = "./config_file"  # Specifies `esbuild` config

@iib0011
Copy link

iib0011 commented Feb 28, 2022

Okay

@erezrokah
Copy link
Contributor

Hi all 👋 This issue belongs in https://github.com/netlify/zip-it-and-ship-it.
I'm trying to transfer it, however GitHub seems to dislike it.

For esbuild plugins support you might want to look at the discussion in #392

@ehmicky ehmicky transferred this issue from netlify/cli Feb 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: command: dev area: command: functions area: functions type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

No branches or pull requests

3 participants