Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webpack-aws-externals

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-aws-externals

Easily exclude node_modules provided by AWS Lambda in Webpack bundle

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
594
increased by12.08%
Maintainers
1
Weekly downloads
 
Created
Source

Webpack-AWS-Externals

Easily exclude node modules that are commonly included in AWS Lambda runtimes from Webpack

Version Downloads

This module builds on webpack-node-externals which is a super handy plugin for Webpack. Webpack-aws-externals will make sure that the core list of modules that are known to be distributed within AWS lambdaLambda node runtimes will not be bundled into your webpack - but everything else will be. This way your uploaded packages for serverless lambdas wont have unnecessary bloat, but you won't have to keep track of a whitelist.

Quick usage

npm install webpack-aws-externals --save-dev

In your webpack.config.js:

var awsExternals = require('webpack-aws-externals');
...
module.exports = {
    ...
    target: 'node', // in order to ignore built-in modules like path, fs, etc.
    externals: [awsExternals()], // in order to ignore all modules in node_modules folder
    ...
};

And that's it. All aws modules will no longer be bundled but will be left as require('module').

Detailed overview

Configuration

This library accepts an options object.

options.whitelist (=[])

An array for the externals to whitelist, so they will be included in the bundle. Can accept exact strings ('module_name'), regex patterns (/^module_name/), or a function that accepts the module name and returns whether it should be included.
Important - if you have set aliases in your webpack config with the exact same names as modules in node_modules, you need to whitelist them so Webpack will know they should be bundled.

options.importType (='commonjs')

The method in which unbundled modules will be required in the code. Best to leave as commonjs for node modules. May be one of documented options or function callback(moduleName) which returns custom code to be returned as import type, e.g:

options.importType = function(moduleName) {
  return "amd " + moduleName;
};

Usage example

var awsExternals = require('webpack-aws-externals');
...
module.exports = {
    ...
    target: 'node', // important in order not to bundle built-in modules like path, fs, etc.
    externals: [awsExternals({
        // this WILL include `uuid` in the bundle
        whitelist: ['uuid']
    })],
    ...
};

For most use cases, the defaults of importType should be used.

Contribute

Contributions and pull requests are welcome.

License

MIT

Thank you

@liady made an awesome package that let us make this very quickly.

Keywords

FAQs

Package last updated on 19 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc