New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

serverless-webpack

Package Overview
Dependencies
Maintainers
2
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-webpack - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

coverage/coverage.json

27

index.js

@@ -7,2 +7,3 @@ 'use strict';

const compile = require('./lib/compile');
const copyFunctionArtifact = require('./lib/copyFunctionArtifact');
const wpwatch = require('./lib/wpwatch');

@@ -13,4 +14,10 @@ const cleanup = require('./lib/cleanup');

const packExternalModules = require('./lib/packExternalModules');
const lib = require('./lib');
class ServerlessWebpack {
static get lib() {
return lib;
}
constructor(serverless, options) {

@@ -20,2 +27,11 @@ this.serverless = serverless;

if (
this.serverless.service
&& this.serverless.service.custom
&& this.serverless.service.custom.webpack
&& this.serverless.service.custom.webpack.endsWith('.ts')
) {
require('ts-node/register');
}
Object.assign(

@@ -25,2 +41,3 @@ this,

compile,
copyFunctionArtifact,
wpwatch,

@@ -106,2 +123,10 @@ cleanup,

'before:deploy:function:packageFunction': () => BbPromise.bind(this)
.then(this.validate)
.then(this.compile)
.then(this.packExternalModules),
'after:deploy:function:packageFunction': () => BbPromise.bind(this)
.then(this.copyFunctionArtifact),
'webpack:validate': () => BbPromise.bind(this)

@@ -130,2 +155,3 @@ .then(this.validate),

.then(this.validate)
.then(this.compile)
.then(this.wpwatch),

@@ -135,2 +161,3 @@

.then(this.validate)
.then(this.compile)
.then(this.wpwatch),

@@ -137,0 +164,0 @@

14

lib/cleanup.js

@@ -6,2 +6,3 @@ 'use strict';

const fse = require('fs-extra');
const _ = require('lodash');

@@ -24,7 +25,14 @@ module.exports = {

const functionNames = this.serverless.service.getAllFunctions();
functionNames.forEach(name => {
this.serverless.service.functions[name].artifact = path.join(
_.forEach(functionNames, name => {
const func = this.serverless.service.getFunction(name);
// The location of the artifact property changed from Serverless
// 1.17 to 1.18 (damn, the guys should use SemVer!). We have to
// use the new one if available here.
const artifactParent = func.artifact ? func : func.package;
artifactParent.artifact = path.join(
this.serverless.config.servicePath,
'.serverless',
path.basename(this.serverless.service.functions[name].artifact)
path.basename(artifactParent.artifact)
);

@@ -31,0 +39,0 @@ });

@@ -6,3 +6,15 @@ 'use strict';

const fse = require('fs-extra');
const lib = require('./index');
const _ = require('lodash');
function getEntryForFunction(serverlessFunction) {
const handler = serverlessFunction.handler;
const handlerFile = /(.*)\..*?$/.exec(handler)[1] + '.js';
// Create a valid entry key
return {
[handlerFile]: `./${handlerFile}`
};
};
module.exports = {

@@ -16,3 +28,18 @@ validate() {

if (typeof this.webpackConfig === 'string') {
// Expose entries - must be done before requiring the webpack configuration
const entries = {};
const functions = this.serverless.service.getAllFunctions();
if (this.options.function) {
const serverlessFunction = this.serverless.service.getFunction(this.options.function);
const entry = getEntryForFunction(serverlessFunction);
_.merge(entries, entry);
} else {
_.forEach(functions, func => {
const entry = getEntryForFunction(this.serverless.service.getFunction(func));
_.merge(entries, entry);
});
}
lib.entries = entries;
if (_.isString(this.webpackConfig)) {
const webpackConfigFilePath = path.join(this.serverless.config.servicePath, this.webpackConfig);

@@ -35,3 +62,3 @@ if (!this.serverless.utils.fileExistsSync(webpackConfigFilePath)) {

const outputFilename = path.basename(
Array.isArray(this.webpackConfig.entry)
_.isArray(this.webpackConfig.entry)
&& this.webpackConfig.entry[this.webpackConfig.entry.length - 1]

@@ -38,0 +65,0 @@ || this.webpackConfig.entry

{
"name": "serverless-webpack",
"version": "2.0.0",
"version": "2.1.0",
"description": "Serverless plugin to bundle your javascript with Webpack",

@@ -34,12 +34,15 @@ "main": "index.js",

"fs-extra": "^0.26.7",
"npm-programmatic": "0.0.5"
"lodash": "^4.17.4",
"npm-programmatic": "0.0.5",
"ts-node": "^3.2.0"
},
"devDependencies": {
"chai": "^3.5.0",
"istanbul": "^0.4.4",
"mocha": "^3.0.2",
"mockery": "^1.7.0",
"serverless": "^1.0.0-beta.2",
"sinon": "^1.17.5",
"sinon-chai": "^2.8.0"
"chai": "^4.1.0",
"chai-as-promised": "^7.1.1",
"istanbul": "^0.4.5",
"mocha": "^3.4.2",
"mockery": "^2.1.0",
"serverless": "^1.17.0",
"sinon": "^2.3.8",
"sinon-chai": "^2.12.0"
},

@@ -46,0 +49,0 @@ "peerDependencies": {

# Serverless Webpack
[![Serverless][ico-serverless]][link-serverless]
[![License][ico-license]][link-license]
[![CircleCI][ico-circleci]][link-circleci]

@@ -53,2 +54,32 @@ [![NPM][ico-npm]][link-npm]

You can also let the plugin determine the correct handler entry points at build time.
Then you do not have to care anymore when you add or remove functions from your service:
```js
// webpack.config.js
const slsw = require('serverless-webpack');
module.exports = {
...
entry: slsw.lib.entries,
...
};
```
Custom entries that are not part of the SLS build process can be added too:
```js
// webpack.config.js
const _ = require('lodash');
const slsw = require('serverless-webpack');
module.exports = {
...
entry: _.assign({
myCustomEntry1: './custom/path/something.js'
}, slsw.lib.entries),
...
};
```
Note that, if the `output` configuration is not set, it will automatically be

@@ -146,2 +177,4 @@ generated to write bundles in the `.webpack` directory. If you set your own `output`

You can find an example setup in the [`examples`][link-examples] folder.
#### Custom paths

@@ -210,8 +243,8 @@

_There are plans to remove the integrated simulation functionality in favor of
using serverless-offline (see [#135](https://github.com/elastic-coders/serverless-webpack/issues/135))
which already does the job perfectly and fully integrates with serverless-webpack.
Please consider to switch to serverless-offline if you do not use it already._
_The integrated simulation functionality will be removed in version 3 in favor of
using `serverless-offline` (see [#135][link-135]) which already does the job
perfectly and fully integrates with `serverless-webpack`.
Please switch to `serverless-offline` if you do not use it already._
To start a local server that will act like the API Gateway use the following command.
To start a local server that will act like API Gateway, use the following command.
Your code will be reloaded upon change so that every request to your local server

@@ -249,4 +282,22 @@ will serve the latest code.

## Provider Support
Plugin commands are supported by the following providers. ⁇ indicates that command has not been tested with that provider.
| | AWS Lambda | Apache OpenWhisk | Azure Functions | Google Cloud Functions |
|----------------|------------|------------------|-----------------|------------------------|
| webpack | ✔︎ | ✔︎ | ⁇ | ⁇ |
| webpack invoke | ✔︎ | ✘ | ⁇ | ⁇ |
| webpack watch | ✔︎ | ✔︎ | ⁇ | ⁇ |
| webpack serve | ✔︎ | ✘ | ⁇ | ⁇ |
## Release Notes
* 2.1.0
* Added support for webpack configuration in TypeScript format [#129][link-129]
* Fixed bug with serverless-offline exec [#154][link-154]
* Added unit tests for cleanup. Updated test framework [#11][link-11]
* Support single function deploy and packaging [#107][link-107]
* Fixed path exception bug with individual packaging and SLS 1.18 [#159][link-159]
* 2.0.0

@@ -259,2 +310,3 @@ * Support arbitrary Webpack versions as peer dependency [#83][link-83]

[ico-serverless]: http://public.serverless.com/badges/v3.svg
[ico-license]: https://img.shields.io/github/license/elastic-coders/serverless-webpack.svg
[ico-circleci]: https://img.shields.io/circleci/project/github/elastic-coders/serverless-webpack.svg

@@ -265,2 +317,3 @@ [ico-npm]: https://img.shields.io/npm/v/serverless-webpack.svg

[link-serverless]: http://www.serverless.com/
[link-license]: ./blob/master/LICENSE
[link-circleci]: https://circleci.com/gh/elastic-coders/serverless-webpack/

@@ -281,2 +334,4 @@ [link-npm]: https://www.npmjs.com/package/serverless-webpack

[link-135]: https://github.com/elastic-coders/serverless-webpack/issues/135
[link-83]: https://github.com/elastic-coders/serverless-webpack/pull/83

@@ -290,1 +345,7 @@ [link-88]: https://github.com/elastic-coders/serverless-webpack/pull/88

[link-144]: https://github.com/elastic-coders/serverless-webpack/issues/144
[link-11]: https://github.com/elastic-coders/serverless-webpack/issues/11
[link-107]: https://github.com/elastic-coders/serverless-webpack/issues/107
[link-129]: https://github.com/elastic-coders/serverless-webpack/pull/129
[link-154]: https://github.com/elastic-coders/serverless-webpack/issues/154
[link-159]: https://github.com/elastic-coders/serverless-webpack/issues/159
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