Closed kvarela closed 6 years ago
Hi @kvarela !
Are you sure this issue is related to this plugin? Surveying the stack trace you provided, I couldn't find any entries related to serverless-plugin-browserifier
.
You can see plugin and PluginManager_ everywhere because that's the way serverless works behind the scenes: everything is a plugin, including its internal functionalities, like
deploy`, which seems to be the one blowing up, given the lines below:
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)
Anyway, a few ways to find that out:
sls package
, which avoids deployment, but builds the packagesserverless.yml
, and verify whether the deployments happens without issuesHi @nolde, thanks for your response. I am sure this plugin is causing the issue. I can successfully deploy and run without the plugin. I get the same error when I run sls package
Here's more complete log output:
Serverless: Browserifier::validate
Serverless: Browserifier::globalConfig
computed globalBrowserifyConfig { disable: false,
exclude: [],
include: [ 'src/**/*.js' ],
ignore: [],
basedir: '/Users/home/roam/backend/.build',
entries: [],
standalone: 'lambda',
browserField: false,
builtins: false,
commondir: false,
ignoreMissing: true,
detectGlobals: true,
insertGlobalVars: { process: [Function: process] },
debug: false }
functionObject for graphql { handler: 'src/graphql.handler',
memorySize: 512,
timeout: 30,
events: [ { http: [Object] } ],
name: 'graphql-api-dev-graphql',
package:
{ exclude: [ 'node_modules/serverless-plugin-typescript' ],
include: [] } }
computed function BrowserifierConfig { disable: false,
exclude: [ 'node_modules/serverless-plugin-typescript' ],
include: [ 'src/**/*.js' ],
ignore: [],
basedir: '/Users/home/roam/backend/.build',
entries: [ 'src/graphql.js' ],
standalone: 'lambda',
browserField: false,
builtins: false,
commondir: false,
ignoreMissing: true,
detectGlobals: true,
insertGlobalVars: { process: [Function: process] },
debug: false }
Serverless: Browserifier: Preparing graphql...
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)
Could you tell me which version of the plugin you are using and, if equal or above v2, could you tell me the version of browserify being used?
Also, I can see that you are using serverless-plugin-typescript
. Those two plugins might conflict with each other, as both are trying to modify the input data.
If you want to use browserify
, I recommend transpiling to typescript
through it, using a plugin like tsify
. Add it to your project, and configure serverless-plugin-browserifier
to use it like this:
custom:
browserify:
transform:
- - tsify
- noImplicitAny: true
More info:
Hi @nolde, sorry for the delay. I'm suing serverless-plugin-browserifier v2.0.0 and browserify v16.2.2.
Using the tsify plugin allows me to package and upload to Lambda, but when I try to run, I get:
Handler 'handler' missing on module 'src/handlers/graphql'
This is all that I see uploaded to Lambda so it appears all my code and dependencies did not get included.
Here's what my serverless.yml looks like now:
package:
individually: true
excludeDevDependencies: true
include:
- src/**/*.js
functions:
graphql:
handler: src/handlers/graphql.handler
memorySize: 512 # optional, in MB, default is 1024
timeout: 30 # optional, in seconds, default is 6, API Gateway timeout is 30s
events:
- http:
path: graphql
method: post
cors: true
ean-update:
handler: src/handlers/ean-update.handler
timeout: 300
events:
- schedule(1 day)
plugins:
- serverless-plugin-browserifier
- serverless-offline
custom:
browserify:
debug: true
transform:
- tsify
- noImplicitAny: true
Any ideas?
Hi @kvarela !
As a quick answer, your transform is wrong. This may or may not be the reason for your issue.
If you want to use tsify
options, such as noImplicitAny
, you format should be as follows (pay attention to the equivalent JSON version added):
tsify
options# yml
custom:
browserify:
transform:
- - tsify # array of array, two dashes!
- noImplicitAny: true
// json
{
"custom": {
"browserify": {
"transform": [
["tsify", { "noImplicitAny": true }] // array of array!
]
}
}
}
If you don't need any options, you can simplify it to the config below:
tsify
options# yml
custom:
browserify:
transform:
- tsify # single dash, simple array
// json
{
"custom": {
"browserify": {
"transform": ["tsify"] // simple array
}
}
}
You also probably want to remove package.include
and package.excludeDevDependencies
, as package construction is handled by browserify.
I will take another look by the end of the week!
Thanks @nolde, was able to get it working.
Sweet!
I'm glad to find out it works fine with TypeScript as well!
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: