asprouse / serverless-webpack-plugin Goto Github PK
View Code? Open in Web Editor NEWUse Webpack to optimize your Serverless Node.js Functions
Use Webpack to optimize your Serverless Node.js Functions
After trying to run sls function deploy --all
I see the following.
If I try to deploy each function individually it works, but any more than 1 at a time fails with only one of the zips being created properly.
Only happens with webpack plugin.
On version 0.5.5 of serverless using node 5.11.0
Let me know if you need more details
Serverless: ------------------------
Serverless: Failed to deploy the following functions in "dev" to the following regions:
Serverless: us-west-2 ------------------------
Serverless: create: Uploaded file must be a non-empty zip
Serverless: read: Uploaded file must be a non-empty zip
Serverless: archive: Uploaded file must be a non-empty zip
/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:61
fn = function () { throw arg; };
^
ServerlessError: Function Deployment Failed
at new ServerlessError (/usr/local/lib/node_modules/serverless/lib/Error.js:17:11)
at FunctionDeploy.<anonymous> (/usr/local/lib/node_modules/serverless/lib/actions/FunctionDeploy.js:126:19)
at next (/usr/local/lib/node_modules/serverless/node_modules/rimraf/rimraf.js:74:7)
at FSReqWrap.CB [as oncomplete] (/usr/local/lib/node_modules/serverless/node_modules/rimraf/rimraf.js:110:9)
From previous event:
at FunctionDeploy.functionDeploy (/usr/local/lib/node_modules/serverless/lib/actions/FunctionDeploy.js:105:10)
From previous event:
at /usr/local/lib/node_modules/serverless/lib/Serverless.js:186:31
at Array.reduce (native)
at /usr/local/lib/node_modules/serverless/lib/Serverless.js:185:32
From previous event:
at Serverless._execute (/usr/local/lib/node_modules/serverless/lib/Serverless.js:183:12)
at Serverless.actions.(anonymous function) (/usr/local/lib/node_modules/serverless/lib/Serverless.js:429:20)
at Serverless.command (/usr/local/lib/node_modules/serverless/lib/Serverless.js:398:38)
at /usr/local/lib/node_modules/serverless/bin/serverless:19:16
at tryOnImmediate (timers.js:534:15)
at processImmediate [as _immediateCallback] (timers.js:514:5)
From previous event:
at Object.<anonymous> (/usr/local/lib/node_modules/serverless/bin/serverless:18:4)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:148:18)
at node.js:405:3
Hey there! Gz for the update for v0.5.
So I'm in the process of setting it up. First of, I think that the readme should specify that in the s-function.json
one should have "runtime": "nodejs",
.
Second I tried serverless function run myfunc
and I of course get an error because the js code is not going through babel (nor webpack). How could we solve this?
Thanks!
new webpack.optimize.UglifyJsPlugin({
compress: {
unused: true,
dead_code: true,
warnings: false,
drop_debugger: true,
},
comments: false,
mangle: false,
}),
mangle:false
the above setting will allow node-mysql2 to work, not really an issue per say but just a discovery for modules that have problems,
Last week, I hit this obscure webpack error:
Error: No template for dependency: TemplateArgumentDependency
which was resolved with the following:
webpack/webpack#1082 (comment)
Is there a good way to either structure the docs or redo the way serverless-webpack-plugin
uses webpack to help prevent newcomers from using more than one copy of webpack by default?
added support for loading modules before the handler. However, when I do as the docs suggest I get this error:
Serverless: my-function: Path must be a string. Received [ 'babel-polyfill' ]
...
/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:61
fn = function () { throw arg; };
^
ServerlessError: Function Deployment Failed
at new ServerlessError (/usr/local/lib/node_modules/serverless/lib/Error.js:17:11)
at FunctionDeploy.<anonymous> (/usr/local/lib/node_modules/serverless/lib/actions/FunctionDeploy.js:126:19)
at next (/usr/local/lib/node_modules/serverless/node_modules/rimraf/rimraf.js:74:7)
at FSReqWrap.CB [as oncomplete] (/usr/local/lib/node_modules/serverless/node_modules/rimraf/rimraf.js:110:9)
From previous event:
at FunctionDeploy.functionDeploy (/usr/local/lib/node_modules/serverless/lib/actions/FunctionDeploy.js:105:10)
From previous event:
at /usr/local/lib/node_modules/serverless/lib/Serverless.js:211:25
at Array.reduce (native)
at Serverless._execute (/usr/local/lib/node_modules/serverless/lib/Serverless.js:210:26)
at Object.actions.(anonymous function) [as functionDeplo
this is my webpack.config.js:
var webpack = require("webpack");
module.exports = {
target: "node",
entry: ["babel-polyfill"],
externals: [
"aws-sdk"
],
resolve: {
extensions: ["", ".js"]
},
devtool: "source-map",
plugins: [
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
unused: true,
dead_code: true,
warnings: false,
drop_debugger: true
}
})
],
module: {
loaders: [
{
test: /\.jsx?$/,
loader: "babel",
exclude: /node_modules/,
query: {
presets: ["es2015", "node6", "stage-0"]
}
}
]
}
};
Hi there,
Deploying from project root using sls dash deploy
does not prepend each component's folder to the entry point path (I only have one component called api
). Running the same command from within the component's folder works just fine.
Is there anything I'm missing when configuring the plugin? My entry in s-component.json
in this case is:
"custom": {
"webpack": {
"configPath": "api/webpack.config.js"
}
}
I went through the code in bundle.js
but couldn't figure out where the issue might be. I'm not very familiar with Serverless plugins and can't figure out where the component's name or folder path would come from.
Hello there! serverless 0.5 isn't working here:
/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:49
fn = function () { throw arg; };
^
TypeError: Class extends value #<Serverless> is not a function or null
at getPlugin (/my-serverless-project/node_modules/serverless-webpack-plugin/index.js:6:35)
at Serverless._loadPlugins (/usr/local/lib/node_modules/serverless/lib/Serverless.js:286:25)
at Serverless.loadProjectPlugins (/usr/local/lib/node_modules/serverless/lib/Serverless.js:240:10)
at /usr/local/lib/node_modules/serverless/lib/Serverless.js:77:41
From previous event:
at Serverless.init (/usr/local/lib/node_modules/serverless/lib/Serverless.js:73:25)
at Object.<anonymous> (/usr/local/lib/node_modules/serverless/bin/serverless:17:12)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:142:18)
at node.js:939:3
any clue?
Thanks!
additions from this pull request, though merged is not reflected in npm modules when you do npm install serverless-webpack-plugin. Might need to publish the npm package
hello all, i've been trying to get node-msql2 to work with lambda and i keep getting the above error, turns out, it was caused by webpack's uglifyjs plugin, disable it, and your bundle size will increase by 100%, but this error goes away. In any case, because this is not being transferred every time your client views your page, a big bundle size really doesn't matter that much.
just wanted to point that out, so you don't waste hours on it for no reason ๐
I am getting this error after following the instruction from README.md.
Serverless: Deploying the specified functions in "demo" to the following regions: us-east-1
Serverless: | { [Error: Cannot find module '<<root_folder>>'] code: 'MODULE_NOT_FOUND' }
Serverless: ------------------------
Serverless: Successfully deployed the following functions in "demo" to the following regions:
Serverless: us-east-1 ------------------------
....
metric filters created
My configuration in s-function.json is:
"custom": {
"excludePatterns": [],
"webpack": {
"configPath": "./"
}
}
Not such what I am doing wrong.
We found that in the version 0.4.4 imports and requires are not resolving properly on lambda deployment.
It works fine if version is reverted to 0.4.3
Error we get is:
Module not found: Error: Cannot resolve 'file' or 'directory' ../../lib/auth/login in /home/$PATH/_meta/_tmp/login@1468978270231
@ ./_meta/_tmp/login@1468978270231/handler.js 12:13-44
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.