When I run sls deploy, I get the following error
Serverless: Bundling with Webpack...
ERROR in /Users/pgonzalez/myapps/happy-soup-bulk-service/node_modules/sfdc-happy-api/lib/rest.js 258:54
Module parse failed: Unexpected token (258:54)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
...
| function isAccessError(jsonResponse){
|
> if(Array.isArray(jsonResponse) && jsonResponse[0]?.message == `Cannot retrieve documents in a user's private folder; move the document to a named folder`){
| return true;
| }
The arrow points to the call of Array.isArray and that is line 258 of the external module, which is the line referenced in the error.
If I remove the import of the external module, the error goes away
import bulkDependecy from 'sfdc-dependency-api-bulk';
What's weird is that I can use Array.isArray() directly on the handler
//import bulkDependecy from 'sfdc-dependency-api-bulk';
async function getUsage(event, context) {
const {ids,connection} = event.body;
// THIS DOESN'T FAIL
Array.isArray(['true']);
//let result = await bulkDependecy.getUsage(ids,connection);
return {
statusCode: 200,
body: 'result'
};
}
export const handler = getUsage;
Here's my serverless.yml
service:
name: happy-soup-bulk-service
plugins:
- serverless-bundle
- serverless-pseudo-parameters
provider:
name: aws
runtime: nodejs12.x
memorySize: 256
stage: ${opt:stage, 'dev'}
region: eu-west-1
functions:
createAuction:
handler: src/handlers/getUsage.handler
events:
- http:
method: POST
path: /usage
And my package.json
{
"name": "happy-soup-bulk-service",
"version": "1.0.0",
"description": "Codingly template for Serverless Framework projects",
"author": "Ariel Weinberger <ariel@codingly.io>",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.25.0",
"babel-loader": "^7.1.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.0.15",
"babel-polyfill": "^6.23.0",
"babel-preset-env": "^1.6.0",
"serverless-bundle": "^1.3.3",
"serverless-pseudo-parameters": "^2.5.0",
"webpack": "^4.35.2"
},
"dependencies": {
"aws-sdk": "^2.639.0",
"sfdc-dependency-api-bulk": "1.0.0"
}
}