-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow file() variable to support TypeScript format #8071
Comments
@dl748 thanks for request. What is the use case? You've just explained what you want, but not why you want it. Also what value do you see in supporting CoffeeScript? |
Personally, I don't have value in that. But I do have value in TypeScript, where I already have WebPack, and Gulp in full TypeScript, and I'd like to add this support to serverless in the effort of having all executed files as TypeScript. I just figured, if we were to add support for TypeScript why stop there, and we should add whatever tools the developer is comfortable with. .e.g. Webpack, i have all my files as webpack.config.ts, and my gulp configuration as gulpfile.ts Otherwise, I have some typescript and some javascript (untyped). All my handlers are TypeScript, and Id like the configuration options to use TypeScript as well, instead of Javascript |
I don't think we should invest time in things that are just nice to have and doesn't address any real world use case at given point (note that currently we lack resources to address real needs) I'm going to close this now, but we're definitely open to revisit that when eventual demand will appear |
So what about TypeScript support, which I DO want? My real world issue is that I'm forced to use javascript for my file() variables, and that I have a need for using TypeScript (.ts) files instead of javascript. I'm not sure why this was closed because I don't have a specific use for CoffeeScript, as this issue was supporting more than just that. |
Sorry that was not perfectly clear to me. I'll reopen this. As we support TypeScript as top file configuration file format, it definitely makes sense to support TS in variable file service scope. PR that provides that is welcome! |
The PR that i provided does that as well, it just happens to also give support for several other files as well. It adds support for All in one small PR |
There are problems with it.
|
Note: this just provides support, the PR doesn't add ANY transpilers or preprocessors as a dependency. If a developer wants to have that support, they have to install the transpiler to give them that support similar to how your top level works. The included module is just a listing of require() register packages, and it'll "try" them if they are installed. Its VERY lightweight. Why do you want to limit a developers choice when you don't have to? |
For example, if you want to use serverless.ts you have to install a package like ts-node.... similar to my addition to file(), its just that my PR allows for A LOT more extensions than just .ts, and gives developers a lot more choices for their build system. The package that i'm using "interpret" has ZERO dependencies, its just a well maintained list of registered modules by file extensions and will use them if they are installed, nothing more. In fact, I could see this being modified to top level configuration as well. |
Indeed, it just adds dependency of
As I mentioned due to limited resources we're focused on addressing only real world (and not "nice to have") use cases. As we agreed, there's only one real use case to address here (support TS files via variable extensions) and we're open for PR on that. |
Closing, I've found my workaround for this feature. |
@medikoo I'm interested in this, and might try to land a PR for it in the near future - just want to confirm first that this is still true:
It should in theory be a pretty straightforward patch as it should be the same logic as what's used for |
@G-Rath I think as we support TS files being top level, it makes sense to supporting then in
Having that it's probably worth to wait a bit, until above matters settle, and implementing this in current variables resolver context doesn't make much sense, as it's about to be ditched completely. |
Fair enough - I don't mind waiting if there's something actually in the works that's expected to land in a few weeks. When it does land, feel free to ping me - I'd be happy to get this feature landed asap as I'm in need of it :) |
Great thanks @G-Rath for raising an interest! I'll definitely update this issue, once we will settle on recommend approach on solving this issue |
@medikoo This still seems to be an issue following the #8364 changes which I understood were to be a new starting point for whatever solution addresses this particular need. But is a new issue warranted now? I'm not seeing that #28 would address this and also appears stuck. When I reference a TS file with the
|
@pushred in my eyes best way to support it is via introducing extensions as proposed here: #9311 Yet, I'm no longer with Serverless Inc., and I'm not familiar with current roadmap and priorities, I also don't have any rights to accept and release any further updates here (as far as I know it's @Danwakeem that takes care of Framework maintenance now) |
Use case description
Allow file() to accept more than just ".js" files to be executed. e.g. .ts and .coffee
This can require an optional module for support
serverless.json
Proposed solution
Use the interpret package to attempt to use a "require" loader (based on extension), if not, fall back to current processing.
The text was updated successfully, but these errors were encountered: