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 ability to exclude files from handler lookup #433

Closed
taschmidt opened this issue Aug 15, 2018 · 4 comments · Fixed by #471
Closed

Add ability to exclude files from handler lookup #433

taschmidt opened this issue Aug 15, 2018 · 4 comments · Fixed by #471
Labels
Milestone

Comments

@taschmidt
Copy link

taschmidt commented Aug 15, 2018

This is a Feature Proposal

Description

Please add the ability to exclude certain files from the handler lookup. This is to get around the extraneous (and possibly error-prone) WARNING: More than one matching handlers found for 'handler'. Using 'handler.js' message when there are unit test files in the same directory.

Possible config example:

custom:
  webpack:
    excludeFiles: src/**/*.test.[t|j]s

Similar or dependent issue(s):

@yankeeinlondon
Copy link

Glad to see this issue. Anyone using Typescript is going to immediately run into this. Out of interest, is there currently a work around?

@yankeeinlondon
Copy link

For now I'm changed my tsconfig.json to not create map files and declaration files.

@HyperBrain HyperBrain added this to the 5.3.0 milestone Aug 24, 2018
@designfrontier
Copy link
Contributor

since it looks like this is just sitting at the moment... I am working on a fix for it. Hope to have a pull request put together in the next few days

designfrontier added a commit to designfrontier/serverless-webpack that referenced this issue Jan 5, 2019
This permits you to tell serverless to ignore files that have
similar names to the route handlers. So ignore index.test.js or
index.ts.

This fixes serverless-heaven#433 and serverless-heaven#405

It makes life better for lots of folks :-)
designfrontier added a commit to designfrontier/serverless-webpack that referenced this issue Jan 5, 2019
1. Do not remove any section of the template. If something is not applicable leave it empty but leave it in the PR
2. Please follow the template, otherwise we'll have to ask you to update it and it will take longer until your PR is merged
-->

Closes serverless-heaven#433

<!--
Briefly describe the feature if no issue exists for this PR. If possible only
submit PRs for existing issues. If the PR is trivial (like doc changes or simple
code fixes) it can be submitted without a related issue, but as soon as it adds
or changes functionality, a related issue should be present.
-->

Fairly trivial, just used the ignore option in glob to exclude files matching the glob.

1. Setup a serverless project with an index.test.js and an index.js that handle a route
2. Start it up and see that you get a warning about duplicate files matching for index
3. Now pull in this PR
4. add the following to your serverless.yml file in the custom > webpack section
`excludeFiles: **/*.test.js`
5. restart serverless
6. see that the warnings are now gone!

- [x] Write tests
- [ ] Write documentation
- [x] Fix linting errors
- [x] Make sure code coverage hasn't dropped
- [x] Provide verification config / commands / resources
- [x] Enable "Allow edits from maintainers" for this PR
- [x] Update the messages below

***Is this ready for review?:*** YES
***Is it a breaking change?:*** NO
@HyperBrain
Copy link
Member

Released with 5.3.0

jamesmbourne pushed a commit to jamesmbourne/serverless-webpack that referenced this issue Oct 15, 2019
1. Do not remove any section of the template. If something is not applicable leave it empty but leave it in the PR
2. Please follow the template, otherwise we'll have to ask you to update it and it will take longer until your PR is merged
-->

Closes serverless-heaven#433

<!--
Briefly describe the feature if no issue exists for this PR. If possible only
submit PRs for existing issues. If the PR is trivial (like doc changes or simple
code fixes) it can be submitted without a related issue, but as soon as it adds
or changes functionality, a related issue should be present.
-->

Fairly trivial, just used the ignore option in glob to exclude files matching the glob.

1. Setup a serverless project with an index.test.js and an index.js that handle a route
2. Start it up and see that you get a warning about duplicate files matching for index
3. Now pull in this PR
4. add the following to your serverless.yml file in the custom > webpack section
`excludeFiles: **/*.test.js`
5. restart serverless
6. see that the warnings are now gone!

- [x] Write tests
- [ ] Write documentation
- [x] Fix linting errors
- [x] Make sure code coverage hasn't dropped
- [x] Provide verification config / commands / resources
- [x] Enable "Allow edits from maintainers" for this PR
- [x] Update the messages below

***Is this ready for review?:*** YES
***Is it a breaking change?:*** NO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants