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

ForceExclude #247

Closed
colinfindlay-nz opened this Issue Oct 2, 2017 · 9 comments

Comments

Projects
None yet
3 participants
@colinfindlay-nz
Copy link

colinfindlay-nz commented Oct 2, 2017

This is a Feature Proposal

Description

Under the current method for bundling externals, while you can exclude dependencies by marking them as devDependencies, if a downstream dependency re-includes it, it will be bundled regardless.

While 99% of the time this makes sense, there are still a lot of projects out there, that are not lambda exclusive, which include aws-sdk as a dependency. While I could ask every project maintainer to move aws-sdk to peerDependency or devDependency - I think adding a forceExclude would be a simple fix for a wide(ish) problem

i.e.

webpackIncludeModules:
    forceInclude:
      - module1
      - module2
    forceExclude:
      - aws-sdk
      - module2
@HyperBrain

This comment has been minimized.

Copy link
Member

HyperBrain commented Oct 2, 2017

Hi @silver2k . Thanks for the good idea 🙌 .
Indeed, it would perfectly complement the forceInclude option.

@HyperBrain HyperBrain added the feature label Oct 2, 2017

@HyperBrain HyperBrain added this to the 3.2.0 milestone Oct 2, 2017

@HyperBrain HyperBrain referenced this issue Oct 4, 2017

Merged

Support forceExclude to exclude dependencies #248

7 of 7 tasks complete
@HyperBrain

This comment has been minimized.

Copy link
Member

HyperBrain commented Oct 4, 2017

@silver2k Can you try with the PR I opened, if that works correctly on your platform? I did some tests locally and it seems to work. Use "serverless-webpack": "serverless-heaven/serverless-webpack#force-exclude to test.

@HyperBrain HyperBrain self-assigned this Oct 4, 2017

@HyperBrain

This comment has been minimized.

Copy link
Member

HyperBrain commented Oct 10, 2017

@silver2k Any chance that you can run some tests? I don't want to merge it only tested by me ;-)

@colinfindlay-nz

This comment has been minimized.

Copy link
Author

colinfindlay-nz commented Oct 10, 2017

@HyperBrain

This comment has been minimized.

Copy link
Member

HyperBrain commented Oct 10, 2017

No, I did not. The only difference between 3.1.0 and 3.1.1 is, that the package-lock.json is honored correctly and sets all installed dependencies fixed, if a lock file is available.
Regarding the dependency drops, it would be great if you'd check the packaged package.json file included in the zip files, to see if these are ok.

@colinfindlay-nz

This comment has been minimized.

Copy link
Author

colinfindlay-nz commented Oct 10, 2017

Packaged package.json between 3.1.0 & 3.1.1 are identical.
Raised #251

@HyperBrain HyperBrain modified the milestones: 3.2.0, 4.0.0 Oct 23, 2017

@HyperBrain

This comment has been minimized.

Copy link
Member

HyperBrain commented Oct 31, 2017

Released with serverless-webpack@4.0.0

@samuraitruong

This comment has been minimized.

Copy link

samuraitruong commented May 11, 2018

hi @HyperBrain ,

this feature doesn't seem works for me

`plugins:

  • serverless-webpack
    custom:
    webpack:
    includeModules:
    forceInclude:
    - "alexa-sdk"
    forceExclude:
    - "aws-sdk"`

In above config, I have aws-sdk is the dependencies of alexa-sdk. I want to exclude aws-sdk in the package out however it still included.

Could you please advise me the best way to exclude aws-sdk .

I am using "serverless-webpack": "^5.1.5",

Thanks

@HyperBrain

This comment has been minimized.

Copy link
Member

HyperBrain commented May 11, 2018

Hi @samuraitruong . This is related to #306 . As long as the aws-sdk is not a peer dependency of alexa-sdk but a real dependency it will be packaged.

However, you can try to actually bundle the alexa-sdk - then the aws-sdk will become a first level dependency and the forceExclude could work.

// webpack.config.js

externals: [ nodeExternals( { whitelist: [ "alexa-sdk" ] } ) ],

and then without the forceInclude

forceExclude:
  - aws-sdk

Can you try that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment