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

Added forceInclude setting to add dynamically required modules explicitly #226

Merged
merged 3 commits into from
Sep 19, 2017

Conversation

HyperBrain
Copy link
Member

@HyperBrain HyperBrain commented Sep 17, 2017

What did you implement:

Closes #217
Relates to #223

How did you implement it:

The webpack configuration in serverless.yml now supports forced include of production node modules that are not detected by Webpack (node-externals) as external dependencies. Samples are dynamically required dependencies that webpack cannot detect.

Forced includes can now be configured as follows:

# serverless.yml

custom:
  webpackIncludeModules:
    forceInclude:
      - module1
      - module2

This will forcefully package module1 and module2 to the service or every function if the modules are specified in the production dependencies in package.json.

How can we verify it:

Use a project that does not reference a production module in its code (so that a serverless package will omit the dependency). The package should not contain the module.
Then add the module to the forceInclude array. The next serverless package should package the included module unconditionally.

Todos:

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

Is this ready for review?: YES
Is it a breaking change?: NO

@HyperBrain
Copy link
Member Author

HyperBrain commented Sep 17, 2017

@jonni-larjomaa Can you check if this PR works if you add pg to the new forceInclude array in your serverless.yml?
The basic implementation should already work, but I have to add unit tests and documentation to merge it to master.

@jonni-larjomaa
Copy link

Hi,

Tested this with npm install from this branch and it works perfectly now the external modules that are not directly accessed will be packaged along.

thx, for really quick reaction to this!

@HyperBrain HyperBrain merged commit 60680f4 into master Sep 19, 2017
@HyperBrain HyperBrain deleted the force-include-modules branch September 19, 2017 10:48
@HyperBrain
Copy link
Member Author

Merged into master. Will be part of the 3.1.0 release later this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants