experimentalDecorators / emitDecoratorMetadata not supported in netlify CLI
tomardern opened this issue · comments
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.
Should we add a flag for the plugin to use?
Maybe something in the toml file? eg
[functions]
directory = "src/"
node_bundler = "esbuild"
esbuild_config_file = "./config_file" # Specifies `esbuild` config
Okay
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