-
Notifications
You must be signed in to change notification settings - Fork 416
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
Support custom packager scripts #344
Conversation
Testing this now. My first command test |
maxbuffer exceeded means you need to set a bigger buffer for stdout: custom:
webpack:
packExternalModulesMaxBuffer: 614400 You can try even bigger values until the error is gone. The reason is, that the script might return more than the 200k default output |
The command failed again. Here's a dump of my console with the full path of my project hidden as
|
oops, sorry. Messages crossed. Trying your suggestion now. |
I think I've gotten past the STDOUT error. Now I see evidence the script in my serverless.yml file ran, but apparently I copied the script wrong since the script encountered an error. See below if interested. It also seems that the package script abandoned everything as-is. That's probably fine in this case to help debug any errors or see what happened. Eventually, it may be worth having some error handling options around script errors. Output:
|
This shows that the script execution works. I think now there's only a parameter error left for the script itself. The guy in the issue you referenced had the same problem, that some download did not work. I'm quite confident that the plugin itself will now do its work. I fully agree with some improved error handling and will add something to make it better (maybe emitting the error and cleaning up the directories should be fine) |
@pflugs30 I'm sure that if you set the correct node version in the params (maybe linux is missing), it will work. |
yes, I'd forgotten to copy one of the parameters for the build. The full command SHOULD have been: Running the package command again now. It's amazing how long this takes for this (seemingly simple) Lambda function. These four dependencies I have branch out a LOT. |
BTW: Now with the scripts possible, I'll probably also increase the max buffer default. It is very likely that scripts output more than 200k of data to the console. |
Agreed. Here's my current
My most recent test with the corrected command completed successfully, including running the script. Here's the new log:
I also opened the ZIP file in the package folder, and I see the Linux version of the binary file listed, meaning the script did what I wanted it to do. Note: the Windows version is also there, but that's because I never executed a script to remove it. I'm now going to test a deployment of the Lambda function, and I do expect that would work. |
I was able to successfully deploy the package to AWS using |
@pflugs30 I'm happy to hear it works. I'll finalize the PR tomorrow and add some documentation to the README. The merge and release will be done soon then. And thanks for testing 👍 |
0408678
to
459072e
Compare
The error handling should be handled by a separate issue. On other errors (anywhere else) the |
3a74fd4
to
83d5c6c
Compare
@HyperBrain Thanks for this piece of work, however for my particular set-up I have had to force myself to use webpack 3.11.0 because of an issue where babel-runtime was not correctly being picked up as a dependency. Full post here: Appreciate it's slightly off-topic, but any ideas on how to solve that one, so that I can use your fix above to get my grpc deployment working? |
@rgandco Right now I have no concrete idea. It could be that Webpack 4's new optimization algorithms and tree shaking now starts to add partial dependencies. You see that in the "external" log. It does not report However the forceInclude should be a proper workaround until it is fixed. |
Can you additionally post your package.json here? I'd like to check if prod/dev dependencies are correct. I just checked the code and the dependency detection seems to be ok in general. |
@HyperBrain Apologies - I totally missed in my haze of the day that I hadn't updated serverless-webpack to 5.1.0 - with webpack 3.11.0 - the fix above now works for me as well, much appreciated. I'll have a think about Webpack 4 and get back to you. |
@HyperBrain Package.json as it stands now - which works, but as mentioned doesn't work if I upgrade webpack. |
…rt-scripts Support custom packager scripts
What did you implement:
Closes #342
Closes #343
How did you implement it:
Scripts given in the
packagerOptions.scripts
array will be executed bynpm run
oryarn run
after the complete function modules have been installed. I added a new interface methodrunScripts
to the packager interface and the created package.json now contain the scripts.How can we verify it:
should print the output on each function or service packaging. Of course the echo does not make sense but replace it with a script that you need (e.g. the one from the original issue).
However, you should always carefully think about the problem you want to solve with a custom script. In most cases a webpack plugin or loader can do the same in a more stable way ;-)
Todos:
Is this ready for review?: YES
Is it a breaking change?: NO