Enigmatic-Smile / serverless-plugin-optimize

⛔️ DEPRECATED ⛔️ Bundle with Browserify, transpile and minify with Babel automatically to your NodeJS runtime compatible JavaScript
https://www.npmjs.com/package/serverless-plugin-optimize
MIT License
130 stars 54 forks source link

Including a binary file #13

Closed talolard closed 7 years ago

talolard commented 8 years ago

Hey, Thanks for the awesome plugin. Some of my functions require a binary (ffmpeg). How can I set browserify to package the binary for some functions and not others? Thanks!

goncaloneves commented 8 years ago

Thanks Terry! ;)

Right now the way Browserify bundles is recursevily adding Commonjs requires. For this reason in your situation if you are not directly requiring anywhere in your code it just doesn't add.

What needs to be done is adding support for Browserify require method that you can define a collection of modules outside the scope of your source code.

We could do this in a way it can be added globally or by function.

I am off for two weeks from today. When I get back I can do a pull request on this.

On 10 Nov 2016 6:16 am, "Tal Perry" notifications@github.com wrote:

Hey, Thanks for the awesome plugin. Some of my functions require a binary (ffmpeg). How can I set browserify to package the binary for some functions and not others? Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/FidelLimited/serverless-plugin-optimize/issues/13, or mute the thread https://github.com/notifications/unsubscribe-auth/AGO-8eEZHOkWnLH2HQudZaX7DT5DgxVSks5q8ra2gaJpZM4KuUNR .

goncaloneves commented 8 years ago

Another reason, may be the extensions support. Another config setting.

It only bundles json and js files right now. This should be it.

Basically bringing support for these two will solve your issue.

On 10 Nov 2016 6:16 am, "Tal Perry" notifications@github.com wrote:

Hey, Thanks for the awesome plugin. Some of my functions require a binary (ffmpeg). How can I set browserify to package the binary for some functions and not others? Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/FidelLimited/serverless-plugin-optimize/issues/13, or mute the thread https://github.com/notifications/unsubscribe-auth/AGO-8eEZHOkWnLH2HQudZaX7DT5DgxVSks5q8ra2gaJpZM4KuUNR .

dionysio commented 7 years ago

hey @goncaloneves, I am not quite sure I follow. Could you give an example of how you would include a binary to the package?

goncaloneves commented 7 years ago

I thought that you could use extensions as a way to do that.

I need to have some time to run that scenario. You want to include a binary inside your bundle folder? Are you running in your code?

dionysio commented 7 years ago

Currently I have a function that starts new process with child_process.exec and it is just a binary stored in the same folder as the function.

ffmpeg is a good example for such use-case as OP pointed out.

goncaloneves commented 7 years ago

I understand now what it is. Files outside requires (Browserify bundle).

Solution is new PR that adds an include array option with file paths to be included in the prefix folder and keep the same relative path structure.

Hopefully people write relative file paths in their code, otherwise it won't find the file and will fail.

goncaloneves commented 7 years ago

@dionysio Can you test new release with includePaths?

dionysio commented 7 years ago

@goncaloneves works great! Thank you for your effort :+1:

goncaloneves commented 7 years ago

Perfect! 🙏

GL in your work.