You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I like the idea of being consistent within these common tools. No matter if you are coming from Java, Node or Python .gitignore is familiar.
The downside clearly is that not all config is rooted in one serverless.yaml which has a big benefit in terms of clarity (single source of truth). @mthenw how do you feel about that?
The downside clearly is that not all config is rooted in one serverless.yaml which has a big benefit in terms of clarity (single source of truth). @mthenw how do you feel about that?
I prefer following known patters (because users already know them) especially if the goal is to achieve exactly the same feature.
Other option would be to simplify current mechanism and replace include/exclude with ignore.
package:
ignore:
- *.jsx
- !test.jsx
So the same filtering mechanism as in .gitignore but inside serverless.yml.
I personally prefer .serverlessignore because it's more obvious when I looks at list of files in project. I automatically understand what is inside.
My goal here is to reduce confusion.
Reacted by Nik Graf, Mitchell Lawson-Burton and Artur Ampilogov
Also the great benefit of .serverlessignore is that you can place those files deep in the folder structure. It's sometimes helpful to place ignorefile closer to excluded files.
Thx @mthenw. I'm not sure how package.exclude works either. It was pretty straightforward in V.0. The docs aren't helping. ATM, I'm still in the serverless.yml camp. Here's why:
We've had that as a standard since V0, so it's what our users expect.
There is a large audience who use include, which we still need support for, and now this will create a different experience in how you exclude things. Creating a happenstances/divergences in how stuff happens is always an anti-pattern for me. Include is being used often for including files/folders that are outside the service root. Like large JSON/data files, etc., which could exist in a parent directory and several services depend on.
This would remove the ability to set packaging excludes at the function level. Since we have chosen to go down the route of zipping up the entire service, a lot of people complain about unnecessary function bloat. Removing their option to exclude on a function basis would severely add to that problem.
imo codebases are getting polluted with too many .files. Just my opinion, but I'm tired of seeing and learning what all these dot files are about. OCD.
imo, the solution is not to create an entirely different experience for excluding stuff, but stick with what we have, use the ignore package with package.exclude, keep the ability to easily do it at the function level, and document better how it works.
@ac360 it always problematic to change existing feature but I always wonder if we would add a exactly the same feature again. If not we should not block ourselves from changing what is wrong. Users will appreciate even if they use that.
The main problem with using ignore package with package.exclude is that user will be able to also include a file (!) there. Super confusing. Another sls deploy --noDeploy. We should be very careful with that.
@mthenw totally agree that this area needs some TLC. The change to Globs was a good idea but has left packaging system very confusing.
I like the idea of .serverlessignore as it puts the ignore information in the context of the files being packaged. It also keeps serverless.yml focused on function / resource configuration. I'm not normally changing include/exclude and function / resource config at the same time. So I think it's ok for it to be separate.
Still one thing we might be forgetting when it comes to the .serverlessignore, it could be that a service includes multiple functions and for one specific function you might want to add some binaries. How would you see this working? Would it become a mix of serverless.yml:package:include/exclude and .serverlessignore?
Personally I'd rather see everything "documented" within the serverless.yml.
Still one thing we might be forgetting when it comes to the .serverlessignore, it could be that a service includes multiple functions and for one specific function you might want to add some binaries. How would you see this working?
in case of .serverlessignore
Assuming that users have functions in separate dirs it's possible to have one .serverlessignore in root dir and another in function dir. Rules from function's one are merged with those in root dir. I guess this is how .gitignore works.
in case of package.ignore
Same as it works right now. You can define package.ignore for each function.
I second @ac360's proposal to utilize serverless.yml. The ability to both exclude and include is needed, and the ability to do it both at the service or function level is very desirable. Combined with the Serverless variable system you could setup your include/exclude file structure any way you want without restriction.
I'm with @ac360.serverlessignore is even more confusing and more inconvenient than the include/exclude pattern in serverless.yml
At least for me, it works better to ignore all and include files per func, as my project is bloated but my functions are small.
Right know my solution is to have a folder per endpoint controller (which has all the http methods) and include only that folder for those funcs. The problem is forgetting to install npm packages before deploying.
In principle I would support using existing syntax (.gitignore) instead of inventing a new one. But I can see the potential benefits in using Serverless variables. There is also a big difference between .gitignore and .serverlessignore purposes (the other typically excludes node_modules and other generated files, while the other specifically needs to include them) which might be a bit confusing for new users.
I would still add though, that .*ignore files are very easy to manage with shell tools, e.g. find . -name test.json >> .serverlessignore. This is pretty much impossible for serverless.yml.
I'm in total alignment with @tobyhede with needing control on a function by function basis and with @ac360 in that it should stay in serverless.yml.
In fact I think determining what assets need to go in a package should be handled, by default, with software intelligence. This is a solved problem. Java handles this with tooling like maven, Node with tooling like Browserify. IMO optimization is a best practice, and should be on by default (or really easy to turn on). Explicit include/exclude still needs to be available for edge cases, but it becomes less important if we use intelligence.
I'm working on a plugin that will do the optimization for node labda's with 0 config for 80%+ of the use cases.
At this point in the include/exclude/bundling space I'm more concerned that the process to identify assets and bundle them up is different between sls deploy and sls deploy function -f <name>. I have #2561 open to try to address it, but it still seems messy and I don't see how a lang like Java fits into the current architecture (docs say java is supported, is there a v1.0 example someplace?).
My Browserify plugin is now ready. It removes the need for include and IMO drastically simplifies getting your node based code bundled while shrinking code footprint (which makes your Lambda's cold starts faster).
I'm not crazy about using Browserify or Rollup or WebPack for this. I don't think we should stop people from using it, but "optimization" should not be pigeon holed in to requiring these things.
Which simply adds the dependencies to the "not-exclude" list. (The "include" list). You get sort of the same effect as browserify or other kinds of bundling, but everything is preserved in their own files.
So while .serverlessignore is neat, I still want the ability to say "include this file" somehow. I'm fine if that's done via an include: statement (I would update my plugin to use that), regardless if exclusion is done via a .ignore file or what.
I still support serverless.yml as the main method for include/exclude. (Browserify/Rollup/Webpack are great plugins for advanced functionality though.) There seem to be a fair amount of people who highly prefer an external ignore file though.
What if Serverless just allowed for a generic variable handler to parse and convert a plain text document into a YAML list? Perhaps something like ${textList(./.serverlessignore)}? This would bridge the syntax and a single line to serverless.yml would allow the use of something like .serverlessignore.
Personally I would like to see include and exclude again like it was before the globs support merge. That means that it should work like in previous versions but globs are additionally supported (for power users).
That should work on a service but also function level. Furthermore non-globs syntax (such as .git instead of .git/**) should work as well out of the box (Not 100% sure about this yet as it might make the code more complex).
The usage of exclude and include in serverless.yml is more natural to me as it's easier to see it in context and is kind of a configuration (therefore it should stay in serverless.yml).
Chiming in on this one; Originally I thought .serverlessignore was the way to go, but after discussions on Slack and in the forum I think this should be more about bringing back include, being able to include/exclude on a per function basis, and continue to support globs (in addition to non-glob syntax working).
Agreed with @pmuens proposal. The main reason why .serverlessignore is complex is because we need to be able to do include/exclude on a per function level. So one .serverlessignore file can't really capture that use case, we would have to introduce .serverlessignore files per function or some syntax for that. And thats kind of painful.
@nikgraf I did but it was prob 6+ months ago. I've talked with the AWS lambda devs, and its confirmed that smaller code sizes decreases cold start times. As to how much % gain, I don't have firm numbers.
I know your not asking for the following, but I feel its important. IMO "compiling" is super easy to do, so why not even if the gain is 1%. My Browserify plugin makes it dead simple.
In addition to performance gain, it helps you from reaching your account's lambda code size limit and lets you iterate faster (quicker to upload smaller zip).
I know your not asking for the following, but I feel its important. IMO "compiling" is super easy to do, so why not even if the gain is 1%. My Browserify plugin makes it dead simple.
Because more code and more complexity (basically). I'm very very reluctant to add anything to Serverless that doesn't solve actual issues or have noticeable improvements that make a large difference (potentially a few milliseconds at a cold-start is imho not enough). The complexity it would involve to get this in, the complexity in teaching users and the potential for this to be a PITA when users deploy something and errors get thrown in places they don't expect them (which can happen depending on the minimisation technique). So it would have to be a very clear cut advantage for it to get into core.
Thats why I'm super reluctant on any automated optimisations, because they are always tricky, there are always edge cases and they will include more work than we currently think because of those issues. They are really advanced things that users should consciously add themselves once it makes a noticeable difference.
Activity
eahefnawy commentedon Oct 19, 2016
👍 👍 👍 👍 👍 👍
nikgraf commentedon Oct 19, 2016
I like the idea of being consistent within these common tools. No matter if you are coming from Java, Node or Python
.gitignoreis familiar.The downside clearly is that not all config is rooted in one
serverless.yamlwhich has a big benefit in terms of clarity (single source of truth). @mthenw how do you feel about that?mthenw commentedon Oct 19, 2016
I prefer following known patters (because users already know them) especially if the goal is to achieve exactly the same feature.
Other option would be to simplify current mechanism and replace
include/excludewithignore.So the same filtering mechanism as in
.gitignorebut insideserverless.yml.I personally prefer
.serverlessignorebecause it's more obvious when I looks at list of files in project. I automatically understand what is inside.My goal here is to reduce confusion.
mthenw commentedon Oct 19, 2016
Also the great benefit of
.serverlessignoreis that you can place those files deep in the folder structure. It's sometimes helpful to place ignorefile closer to excluded files.austencollins commentedon Oct 19, 2016
Thx @mthenw. I'm not sure how
package.excludeworks either. It was pretty straightforward in V.0. The docs aren't helping. ATM, I'm still in theserverless.ymlcamp. Here's why:include, which we still need support for, and now this will create a different experience in how you exclude things. Creating a happenstances/divergences in how stuff happens is always an anti-pattern for me. Include is being used often for including files/folders that are outside the service root. Like large JSON/data files, etc., which could exist in a parent directory and several services depend on..files. Just my opinion, but I'm tired of seeing and learning what all these dot files are about. OCD.imo, the solution is not to create an entirely different experience for excluding stuff, but stick with what we have, use the ignore package with
package.exclude, keep the ability to easily do it at the function level, and document better how it works.nikgraf commentedon Oct 19, 2016
Haha, reminds me of a tweet I have seen today:
https://twitter.com/thejameskyle/status/788799662438227969
😜
mthenw commentedon Oct 19, 2016
@ac360 it always problematic to change existing feature but I always wonder if we would add a exactly the same feature again. If not we should not block ourselves from changing what is wrong. Users will appreciate even if they use that.
The main problem with using ignore package with
package.excludeis that user will be able to also include a file (!) there. Super confusing. Anothersls deploy --noDeploy. We should be very careful with that.johncmckim commentedon Oct 19, 2016
@mthenw totally agree that this area needs some TLC. The change to Globs was a good idea but has left packaging system very confusing.
I like the idea of
.serverlessignoreas it puts the ignore information in the context of the files being packaged. It also keepsserverless.ymlfocused on function / resource configuration. I'm not normally changinginclude/excludeand function / resource config at the same time. So I think it's ok for it to be separate.mthenw commentedon Oct 20, 2016
cc @serverless/vip
nicka commentedon Oct 20, 2016
Still one thing we might be forgetting when it comes to the
.serverlessignore, it could be that a service includes multiple functions and for one specific function you might want to add somebinaries. How would you see this working? Would it become a mix ofserverless.yml:package:include/excludeand.serverlessignore?Personally I'd rather see everything "documented" within the
serverless.yml.mthenw commentedon Oct 20, 2016
@nicka
in case of
.serverlessignoreAssuming that users have functions in separate dirs it's possible to have one
.serverlessignorein root dir and another in function dir. Rules from function's one are merged with those in root dir. I guess this is how.gitignoreworks.in case of
package.ignoreSame as it works right now. You can define
package.ignorefor each function.jordanmack commentedon Oct 20, 2016
I second @ac360's proposal to utilize serverless.yml. The ability to both exclude and include is needed, and the ability to do it both at the service or function level is very desirable. Combined with the Serverless variable system you could setup your include/exclude file structure any way you want without restriction.
svdgraaf commentedon Oct 20, 2016
yep, I second (third?) doing it in serverless.yml, already way to much .ignore files :)
nachoab commentedon Oct 20, 2016
I'm with @ac360
.serverlessignoreis even more confusing and more inconvenient than the include/exclude pattern in serverless.ymlAt least for me, it works better to ignore all and include files per func, as my project is bloated but my functions are small.
Right know my solution is to have a folder per endpoint controller (which has all the http methods) and include only that folder for those funcs. The problem is forgetting to install npm packages before deploying.
kennu commentedon Oct 20, 2016
In principle I would support using existing syntax (.gitignore) instead of inventing a new one. But I can see the potential benefits in using Serverless variables. There is also a big difference between .gitignore and .serverlessignore purposes (the other typically excludes node_modules and other generated files, while the other specifically needs to include them) which might be a bit confusing for new users.
I would still add though, that .*ignore files are very easy to manage with shell tools, e.g.
find . -name test.json >> .serverlessignore. This is pretty much impossible for serverless.yml.1 remaining item
doapp-ryanp commentedon Oct 28, 2016
I'm in total alignment with @tobyhede with needing control on a function by function basis and with @ac360 in that it should stay in
serverless.yml.In fact I think determining what assets need to go in a package should be handled, by default, with software intelligence. This is a solved problem. Java handles this with tooling like maven, Node with tooling like Browserify. IMO optimization is a best practice, and should be on by default (or really easy to turn on). Explicit include/exclude still needs to be available for edge cases, but it becomes less important if we use intelligence.
I'm working on a plugin that will do the optimization for node labda's with 0 config for 80%+ of the use cases.
At this point in the include/exclude/bundling space I'm more concerned that the process to identify assets and bundle them up is different between
sls deployandsls deploy function -f <name>. I have #2561 open to try to address it, but it still seems messy and I don't see how a lang like Java fits into the current architecture (docs say java is supported, is there a v1.0 example someplace?).doapp-ryanp commentedon Nov 1, 2016
My Browserify plugin is now ready. It removes the need for
includeand IMO drastically simplifies getting your node based code bundled while shrinking code footprint (which makes your Lambda's cold starts faster).dougmoscrop commentedon Nov 3, 2016
I'm not crazy about using Browserify or Rollup or WebPack for this. I don't think we should stop people from using it, but "optimization" should not be pigeon holed in to requiring these things.
I wrote this: https://github.com/dougmoscrop/serverless-plugin-include-dependencies
(still being tested)
Which simply adds the dependencies to the "not-exclude" list. (The "include" list). You get sort of the same effect as browserify or other kinds of bundling, but everything is preserved in their own files.
So while .serverlessignore is neat, I still want the ability to say "include this file" somehow. I'm fine if that's done via an
include:statement (I would update my plugin to use that), regardless if exclusion is done via a .ignore file or what.jordanmack commentedon Nov 3, 2016
I still support
serverless.ymlas the main method for include/exclude. (Browserify/Rollup/Webpack are great plugins for advanced functionality though.) There seem to be a fair amount of people who highly prefer an external ignore file though.What if Serverless just allowed for a generic variable handler to parse and convert a plain text document into a YAML list? Perhaps something like
${textList(./.serverlessignore)}? This would bridge the syntax and a single line toserverless.ymlwould allow the use of something like.serverlessignore.pmuens commentedon Nov 4, 2016
Personally I would like to see
includeandexcludeagain like it was before the globs support merge. That means that it should work like in previous versions but globs are additionally supported (for power users).That should work on a service but also function level. Furthermore non-globs syntax (such as
.gitinstead of.git/**) should work as well out of the box (Not 100% sure about this yet as it might make the code more complex).The usage of
excludeandincludeinserverless.ymlis more natural to me as it's easier to see it in context and is kind of a configuration (therefore it should stay inserverless.yml).I personally don't prefer yet another dotfile.
rowanu commentedon Nov 4, 2016
Chiming in on this one; Originally I thought
.serverlessignorewas the way to go, but after discussions on Slack and in the forum I think this should be more about bringing backinclude, being able toinclude/excludeon a per function basis, and continue to support globs (in addition to non-glob syntax working).flomotlik commentedon Nov 7, 2016
Agreed with @pmuens proposal. The main reason why .serverlessignore is complex is because we need to be able to do include/exclude on a per function level. So one .serverlessignore file can't really capture that use case, we would have to introduce .serverlessignore files per function or some syntax for that. And thats kind of painful.
So yeah include/exclude with globs sounds good.
pmuens commentedon Nov 7, 2016
Ok. Thanks! Will start the work on this one in the next days.
Please let me know if you guys face some issues with this approach or if this should be done differently!
pmuens commentedon Nov 9, 2016
Hey everyone #2681 is the PR which re-adds
include.Could you guys look into it and provide feedback if there's some time? Thanks 👍
nikgraf commentedon Nov 15, 2016
@doapp-ryanp did you run any test on cold-starts with and without your Browserify plugin? I would be super curious how much of an impact it has.
doapp-ryanp commentedon Nov 15, 2016
@nikgraf I did but it was prob 6+ months ago. I've talked with the AWS lambda devs, and its confirmed that smaller code sizes decreases cold start times. As to how much % gain, I don't have firm numbers.
I know your not asking for the following, but I feel its important. IMO "compiling" is super easy to do, so why not even if the gain is 1%. My Browserify plugin makes it dead simple.
In addition to performance gain, it helps you from reaching your account's lambda code size limit and lets you iterate faster (quicker to upload smaller zip).
flomotlik commentedon Nov 16, 2016
Because more code and more complexity (basically). I'm very very reluctant to add anything to Serverless that doesn't solve actual issues or have noticeable improvements that make a large difference (potentially a few milliseconds at a cold-start is imho not enough). The complexity it would involve to get this in, the complexity in teaching users and the potential for this to be a PITA when users deploy something and errors get thrown in places they don't expect them (which can happen depending on the minimisation technique). So it would have to be a very clear cut advantage for it to get into core.
Thats why I'm super reluctant on any automated optimisations, because they are always tricky, there are always edge cases and they will include more work than we currently think because of those issues. They are really advanced things that users should consciously add themselves once it makes a noticeable difference.