digitalmaas / serverless-plugin-browserifier Goto Github PK
View Code? Open in Web Editor NEWReduce the size and speed up your Node.js based lambda's using browserify.
License: Other
Reduce the size and speed up your Node.js based lambda's using browserify.
License: Other
I'm experiencing an error on sls package
trying to have both of these plugins active in my project. It appears to be looking for my .serverless dir inside my .build dir, even though they are both at the root of my project. If I run either plugin without the other, everything works fine. Any ideas how to fix?
Here's the end:
Serverless: Packaging service...
Error --------------------------------------------------
ENOENT: no such file or directory, lstat '/Users/home/roam/backend/.build/.serverless'
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Stack Trace --------------------------------------------
Error: ENOENT: no such file or directory, lstat '/Users/home/roam/backend/.build/.serverless'
at PluginManager.invoke (/Users/home/.config/yarn/global/node_modules/serverless/lib/classes/PluginManager.js:390:22)
at PluginManager.run (/Users/home/.config/yarn/global/node_modules/serverless/lib/classes/PluginManager.js:421:17)
at variables.populateService.then.then (/Users/home/.config/yarn/global/node_modules/serverless/lib/Serverless.js:157:33)
at runCallback (timers.js:693:18)
at tryOnImmediate (timers.js:664:5)
at processImmediate (timers.js:646:5)
at process.topLevelDomainCallback (domain.js:121:23)
From previous event:
at Serverless.run (/Users/home/.config/yarn/global/node_modules/serverless/lib/Serverless.js:144:8)
at serverless.init.then (/Users/home/.config/yarn/global/node_modules/serverless/bin/serverless:43:50)
I just started using this plugin, switched over from webpack and I really like it, however after getting the plugin working and packaging properly the first time, the build now fails with the following error:
https://gist.github.com/RobBrazier/010880575cac41b57c0311eb55ed7aae
I'm able to resolve this by changing bundle.js#87 and bundle.js#90 from data.functionObject.artifact
to data.functionObject.package.artifact
, however I'm not sure if I'm doing something wrong here?
I'm happy to raise a PR to check both objects if you want.
I have one serverless.yaml to deploy Lambda Functions in Python with ECR (Elastic Container Repository) and Lambda Functions in NodeJs, Everything works fine without the plugin, but when I add it, I get the error below
NodeJS 14.15.5
npm 6.14.11
Serverless Framework 2.23
sls package --stage dev -v --service name-of-service
.
.
.
.
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Invoke warmup:addWarmers
Serverless: WarmUp: Skipping warmer "default" creation. No functions to warm up.
Serverless: Browserifier: Service runtime is not nodejs...
Serverless: Browserifier: Service not set to package individually...
Serverless: Browserifier: Computing global config...
Serverless: Browserifier: Using [email protected]
Serverless: Browserifier: Using browserify "node" option...
Serverless: Browserifier: Computed globalBrowserifyConfig: {"disable":false,"exclude":[],"include":[],"external":[],"ignore":[],"basedir":"/home/xxxxxxx/repos/name-of-the-service","entries":[],"bare":true,"standalone":"lambda","ignoreMissing":true,"detectGlobals":true,"debug":true,"node":true}
Serverless: Browserifier: Preparing 1 function(s)...
Serverless: Browserifier: Preparing "name_of_function"...
Serverless: Browserifier: functionObject for name_of_function: {"description":"commit: branch: ","image":{"name":"name_of_image"},"memorySize":10240,"environment":{"STAGE":"dev","SNS_TOPIC_NAME":"xxx-yyy-zzz","SNS_ARN":"arn:aws:sns:us-east-1:xxx:xxx-yyy-zzz","SNS_JSON_BUCKET":"xxx-yyyy-zzz","SNS_AB_TEST_TOGGLE":"False"},"events":[],"name":"name-of-service-stage-function"}
Serverless: Browserifier: Unexpected failure detected!
Type Error ----------------------------------------------
TypeError: Cannot read property 'split' of undefined
I get the following failure when I try to set disable: true
:
$ yarn clean && serverless deploy -v --stage prod
$ (rm -r ./.build || echo "") && (rm -r ./.serverless || echo "") && (find ./src -name '*.js' -delete || echo "")
rm: ./.build: No such file or directory
Serverless: Browserifier: unexpected failure detected
Serverless Error ---------------------------------------
custom.browserify.disable is true in serverless.yml
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information -----------------------------
OS: darwin
Node Version: 11.1.0
Serverless Version: 1.30.1
Here's my browserify setup for reference:
custom:
browserify:
disable: true
basedir: ./
entries: ['src/handlers/graphql.ts']
exclude:
- envkey
- dotenv
- glob
- fs.realpath
- minimatch
- brace-expansion
- concat-map
- balanced-match
- inherits
- path-is-absolute
- inflight
- wrappy
- once
require:
- node_modules/envkey
- node_modules/dotenv
- node_modules/glob
- node_modules/fs.realpath
- node_modules/minimatch
- node_modules/brace-expansion
- node_modules/concat-map
- node_modules/balanced-match
- node_modules/inherits
- node_modules/path-is-absolute
- node_modules/inflight
- node_modules/wrappy
- node_modules/once
node: true
debug: true
extensions: ['.ts']
plugin:
- tsify
Hello there,
Now node 14 version is available to use on AWS lambda, I'm trying to use a feature from this version optional chaining, however I'm facing a error when I try to use serverless-plugin-browserifier, without this plugin it's possible to compile code.
This is the error: "OperationalError: Parsing file {path}: Unexpected token (32:27)"
Is the plugin compatible with node 14 version ?
next
branch failed. π¨I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. Iβm sure you can fix this πͺ.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the next
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here are some links that can help you:
If those donβt help, or if this issue is reporting something you think isnβt right, you can always ask the humans behind semantic-release.
The npm token configured in the NPM_TOKEN
environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/
.
If you are using Two Factor Authentication for your account, set its level to "Authorization only" in your account settings. semantic-release cannot publish with the default "
Authorization and writes" level.
Please make sure to set the NPM_TOKEN
environment variable in your CI with the exact value of the npm token.
Good luck with your project β¨
Your semantic-release bot π¦π
I received an error when using bwip-js for serverless project.
Though this setup works when executed locally, when deployed to AWS, it throws some error.
Unable to import module 'test/index': Error
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
...
Current configuration is below:
serverless.yml
package:
individually: true
plugins:
- serverless-plugin-browserifier
package.json
...
"dependencies": {
"aws-sdk": "2.104.0",
"bardcode": "1.0.0",
"bwip-js": "1.5.6",
"pdfkit": "0.8.3"
},
"devDependencies": {
"chai": "4.1.1",
"mocha": "3.5.0",
"nock": "9.0.14",
"serverless": "1.20.2",
"serverless-plugin-browserifier": "1.0.5"
}
Code snippet.
'use strict';
const bardcode = require('bardcode');
const fs = require('fs');
const bwipjs = require('bwip-js');
Hello! I'm currently using serverless-plugin-browserifier on its latest version (3.1.0). When I audit with npm audit
, it points me a high vulnerability in the package glob-parent
, which could be solved by updating the dependency of globby
(currently on version 9.2.0
).
I noticed the commit 0089e68 from 5 months ago seems to intent to solve this problem, but it's currently in the branch update-dependencies
and isn't merged with master
.
Could we maybe merge this branch with master
, or solve this vulnerability issue another way?
Thanks!
npm audit output:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Manual Review β
β Some vulnerabilities require your attention to resolve β
β β
β Visit https://go.npm.me/audit-guide for additional guidance β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β High β Regular expression denial of service β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β glob-parent β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=5.1.2 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β serverless-plugin-browserifier β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β serverless-plugin-browserifier > globby > fast-glob > β
β β glob-parent β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://github.com/advisories/GHSA-ww39-953v-wcq6 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
How do we pass options to a browserify plugin?
I have tried both:
custom:
browserify:
plugin:
- prepackify:
compatibility: node-cli
custom:
browserify:
plugin:
- prepackify --compatibility=node-cli
Hi everyone, good afternoon.
It seems that there is a vulnerability issue with the async
package as we can see below with the npm audit
command:
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β High β Prototype Pollution in async β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β async β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Patched in β >=3.2.2 β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β serverless-plugin-browserifier [dev] β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β serverless-plugin-browserifier > archiver > async β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://github.com/advisories/GHSA-fwr7-v2mv-hh25 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Did you guys have the chance to look at this?
Thank you,
Regards.
First off, thanks for continuing this project. I'm having a really hard time figuring out how to get my serverless typescript function small enough to upload to Lambda, and I really hope this works.
I'm getting the error:
ENOENT: no such file or directory, lstat '/Users/home/roam/backend/.build/.serverless'
I don't know why it's looking in /.build/.serverless. My .serverless dir is at the same level as ./build. Is there a config option I need to set to make this work?
Here's my stacktrace:
Error: ENOENT: no such file or directory, lstat '/Users/home/roam/backend/.build/.serverless'
at PluginManager.invoke (/Users/home/.config/yarn/global/node_modules/serverless/lib/classes/PluginManager.js:390:22)
at PluginManager.spawn (/Users/home/.config/yarn/global/node_modules/serverless/lib/classes/PluginManager.js:408:17)
at Deploy.BbPromise.bind.then.then (/Users/home/.config/yarn/global/node_modules/serverless/lib/plugins/deploy/deploy.js:123:50)
From previous event:
at Object.before:deploy:deploy [as hook] (/Users/home/.config/yarn/global/node_modules/serverless/lib/plugins/deploy/deploy.js:113:10)
at BbPromise.reduce (/Users/home/.config/yarn/global/node_modules/serverless/lib/classes/PluginManager.js:390:55)
From previous event:
at PluginManager.invoke (/Users/home/.config/yarn/global/node_modules/serverless/lib/classes/PluginManager.js:390:22)
at PluginManager.run (/Users/home/.config/yarn/global/node_modules/serverless/lib/classes/PluginManager.js:421:17)
at variables.populateService.then.then (/Users/home/.config/yarn/global/node_modules/serverless/lib/Serverless.js:157:33)
at runCallback (timers.js:693:18)
at tryOnImmediate (timers.js:664:5)
at processImmediate (timers.js:646:5)
at process.topLevelDomainCallback (domain.js:121:23)
From previous event:
at Serverless.run (/Users/home/.config/yarn/global/node_modules/serverless/lib/Serverless.js:144:8)
at serverless.init.then (/Users/home/.config/yarn/global/node_modules/serverless/bin/serverless:43:50)
Hello there,
Noticed an inconsistency during the migration of the no longer supported serverless-plugin-browserify
plugin to this one. Seems like they included a version of browserify in their dependencies while this package does not.
Is this intended in order to allow customization of the browserify version or is there any other reason behind not including the package within the plugin?
I'm having a hard time debugging an issue with my function; any way to get a source map and figure out exactly where the issue is?
fyi here's the error I'm seeing on Lambda:
2018-11-14 16:24:22.407 graphql-api-dev-graphql error module initialization error: TypeError
at Object.1764.. (/var/task/src/handlers/graphql.js:239273:65)
at o (/var/task/src/handlers/graphql.js:1:693)
at /var/task/src/handlers/graphql.js:1:744
at Object.1761../PointTransaction (/var/task/src/handlers/graphql.js:239051:16)
at o (/var/task/src/handlers/graphql.js:1:693)
at /var/task/src/handlers/graphql.js:1:744
at Object.1759../HotelBooking (/var/task/src/handlers/graphql.js:238935:20)
at o (/var/task/src/handlers/graphql.js:1:693)
at /var/task/src/handlers/graphql.js:1:744
at Object.1750.. (/var/task/src/handlers/graphql.js:238349:28)
As soon as I added multiple entry points to my custom.browserify options, AWS is no longer able to find my handlers.
For example, I see AWS errors like:
Handler 'webhook' missing on module 'src/handlers/graphql'
Even though when I inspect the bundle and looks at the .js, I see exports.handler defined.
Interestingly though, a different function does work and AWS is able to find the handler.
And when I only include 1 entry in entries, the function for which I add the entry works, but the others do not.
None of my handlers have the same name.
Please let me know if you have any ideas.
Here's a stripped version of my serverless.yml:
package:
individually: true
excludeDevDependencies: true
include:
- node_modules/dotenv/**/*
- node_modules/envkey/*
- node_modules/envkey/ext/envkey-fetch_1.2.4_linux*/*
- node_modules/glob/**/*
- node_modules/fs.realpath/**/*
- node_modules/minimatch/**/*
- node_modules/brace-expansion/**/*
- node_modules/concat-map/**/*
- node_modules/balanced-match/**/*
- node_modules/inherits/**/*
- node_modules/path-is-absolute/**/*
- node_modules/inflight/**/*
- node_modules/wrappy/**/*
- node_modules/once/**/*
functions:
expedia-update:
handler: src/handlers/expedia.update
graphql:
handler: src/handlers/graphql.handler
events:
- http:
path: graphql
method: post
cors: true
membership-check:
handler: src/handlers/membership.check
stripe:
handler: src/handlers/stripe.webhook
events:
- http:
path: stripe
method: post
cors: true
plugins:
- serverless-plugin-browserifier
- serverless-offline
custom:
browserify:
basedir: ./
entries:
[
'src/handlers/graphql.ts',
'src/handlers/stripe.ts',
'src/handlers/membership.ts',
'src/handlers/expedia.ts',
]
exclude:
- envkey
- dotenv
- glob
- fs.realpath
- minimatch
- brace-expansion
- concat-map
- balanced-match
- inherits
- path-is-absolute
- inflight
- wrappy
- once
require:
- node_modules/envkey
- node_modules/dotenv
- node_modules/glob
- node_modules/fs.realpath
- node_modules/minimatch
- node_modules/brace-expansion
- node_modules/concat-map
- node_modules/balanced-match
- node_modules/inherits
- node_modules/path-is-absolute
- node_modules/inflight
- node_modules/wrappy
- node_modules/once
node: true
debug: false
extensions: ['.ts']
plugin:
- tsify
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.