-
Notifications
You must be signed in to change notification settings - Fork 417
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
Add support for webpack configuration in TypeScript format #129
Conversation
Shouldn't we detect whether a TypeScript format configuration is being used before loading |
I agree with @hassankhan . Unconditionally requiring |
I was thinking of something more lo-fi like checking the file extension, either way sounds good 👍 |
I originally had the I wouldn't worry about any side effects, since ts-node actually does hook into |
@jussikinnula Any update here? |
Updated version of the patch is now on top of latest upstream master! I tested with my Angular starter project, and works (e.g. |
@@ -15,6 +15,15 @@ class ServerlessWebpack { | |||
this.serverless = serverless; | |||
this.options = options; | |||
|
|||
if ( | |||
this.serverless.service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could these perhaps use Lodash's has()
instead? Something like:
if (
_.has(this.serverless.service, 'custom.webpack')
&& _.endsWith(this.serverless.service.custom.webpack, '.ts')
) {
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. and lodash's _.endsWith()
😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the comment 😉
Aside from the one thing mentioned, this looks good to go! 👍 |
I didn't want to add any extra dependencies besides |
That's a valid point. We can do a "lodash"ification as a completely separate branch/PR and switch the code to use it everywhere, not only here. I will create a task for that, so that we get the whole codebase a bit leaner. |
To add support for webpack configuration in TypeScript format (e.g. webpack.config.ts), there's an existing package
ts-node
which just does the magic.Webpack uses this method also internally, if specifying configuration file to webpack by using
webpack --config webpack.config.ts
. But sinceserverless-webpack
does require the configuration by using a "require",ts-node
needs to be required to support on-the-fly.ts
-file requires.