Closed real050280 closed 7 years ago
Hi!
You said "this setup works when executed locally", but how did you execute it locally? If you did that by using sls invoke local
, you are not invoking the browserified version, but your raw local version.
To be sure if works after browserified, please run sls package
, go to your serverless output folder (usually .serverless
folder within the working folder), unzip the function package and run the extracted script.
This looks like an incompatibility between browserify and bwip-js.
Hello!
Executed it locally by running node test/test.js
.
Yes, you are right, when I run it locally it didn't use the browserified version of the code. It uses the raw version.
I executed your instructions above, but how should I run the extracted script ?
Also, is there a way to resolve this incompatibilities ? bwip-js is a pure Javascript library translated from Postscript.
By the way, I have tried other barcode library (bardcode) which has no issues even deployed to AWS. Only, that library doesn't suport GS1-128 types.
Hi mate!
You could create a small snippet that calls you code, simulating AWS.
// callback function
function done (err, result) {
if (err) {
console.log('failure:', err)
process.exit(1)
}
console.log('success:', result)
}
// example event data
const mockedEventData = {
myInputData: 'anything you want'
}
const contextData = {
// context data, if you use it
someFakeFields: 'to match your needs'
}
// request you code and execute you lambda handler function
const lambda = require('your-browserified-code-path')
lambda.handler(mockedEventData, contextData, done)
That should allow you to debug the browserified code. I will try to add a command in the future that allows you to execute the browserified code using serverless cli.
I have noticed that bwip-js
contains a browser compatible version within its package; maybe you could give that a shot.
I will close this for now, as it is not related to the plugin itself. If you need anything else, just ask!
Take care!
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.
Current configuration is below:
Code snippet.