Skip to content
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 hook *before:step-functions-offline:start* #313

Merged
merged 9 commits into from Feb 27, 2018
3 changes: 3 additions & 0 deletions index.js
Expand Up @@ -153,6 +153,9 @@ class ServerlessWebpack {
.then(this.prepareOfflineInvoke)
.then(this.wpwatch),

'before:step-functions-offline:start': () => BbPromise.bind(this)
.then(this.validate)
.then(this.compile)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watch will automatically watch for source changes. Both functionalities (offline watch and invoke local watch) set the base directory for the execution properly, e.g. for serverless-offline the location parameter is set correctly.

If there is something similar for the step-functions that needs to be done, we had to add a different "watch" or "prepare" function for step (e.g. stepWatch).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using .then(this.validate).then(this.compile) need to create separate function for plugin ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only if we want to support watch mode and if step-offline needs to know the compiled directory, then you can do:

.then(this.validate)
.then(this.prepareStepOffline)   <<<--- see here
.then(this.wpwatch)

The new prepareStepOffline function should then do something similar as https://github.com/serverless-heaven/serverless-webpack/blob/master/lib/prepareOfflineInvoke.js, only that it prepares the root folder for the step-offline plugin.

Otherwise the step-offline will just run on the uncompiled code.

Copy link
Contributor Author

@vkkis93 vkkis93 Jan 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need only compile code once, run step-offline and stop process.
I don't need to have watch mode
About compiled directory, user will indicate the path to directory by himself in plugin settings.

Referring to my requirements - need to change something or this code makes sense?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense with the compile, yes.

However:

About compiled directory, user will indicate the path to directory by himself.

That will not really work out, if you set package: individually. Then the compiled code will then be distributed. I think you need a "prepare" function because for the offline, it has to be set to service packaging (then the output directory is ".webpack/service") like in the prepareOffline.

With individual packaging it is ".webpack/" which is not predictable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give me the link to your plugin. Maybe I have some time over the weekend to have a look, if we can combine this in an easy and compatible way there.

Copy link
Contributor Author

@vkkis93 vkkis93 Jan 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HyperBrain but looks like your approach very good.
Makes sense to rewrite it.
Only one question, serverless-webpack compiles all functions which described in section functions in serverless.yml ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great,
I update this pull request to Is this ready for review?: NO at this moment.
When I will rewrite code, I will notify you

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I'm already excited 😄

};
}
}
Expand Down