I’m currently migrating our monorepo from npm to u...
# help
j
I’m currently migrating our monorepo from npm to use yarn and lerna to manage dependencies/packages and having some issues with some of the packaging. I’m not using sst, just serverless and seed. I’ve got yarn and lerna workspaces set up correctly based on what I’m seeing with the lerna outputs and what services deploy in seed due to package updates. However, I think there’s an issue with the packaging itself, maybe it’s hoisting related, I’m not sure. Since migrating our dev env to use this all services have this error:
Copy code
{
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module 'jmespath'\nRequire stack:\n- /var/task/node_modules/aws-sdk/lib/request.js\n- /var/task/node_modules/aws-sdk/lib/core.js\n- /var/task/node_modules/aws-sdk/lib/event-stream/event-message-chunker-stream.js\n- /var/task/node_modules/aws-sdk/lib/event-stream/streaming-create-event-stream.js\n- /var/task/node_modules/aws-sdk/lib/node_loader.js\n- /var/task/node_modules/aws-sdk/lib/aws.js\n- /var/task/handler.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
}
So it seems like all services don’t have the dependencies of the libraries that they use/are in their service specific package.json Anyone have any thoughts here on things to try?
t
Seems like maybe the dependencies aren't bundled?
I'm not familiar with serverless framework
j
I don’t think it’s a serverless framework issue moreso than something I’m probably doing wrong in transitioning from npm to yarn/lerna. I’ve never worked with Yarn before so that’s what I’m assuming it is anyways.
I’m looking at https://github.com/AnomalyInnovations/serverless-lerna-yarn-starter and think I need to include use
serverless-bundle
as I read this more thoroughly and I think you’re right
“Without Webpack, you’ll need to disable hoisting since Serverless Framework does not package the dependencies of a service correctly on its own.”
o
Yup - also use the esbuild option, its much faster than webpack
j
Is unhoisting an acceptable option? The webpack compile has errors that have never been an issue before in our monorepo
I tried setting the esbuild option set to true and it’s still using webpack for bundling
o
Whatever makes it work is an acceptable option 😛
Can you check what version of serverless-bundle you’re running? I think esbuild only recently got promoted to master
j
"serverless-bundle": "^5.0.0",
is the version added to my package.json doing npm install
o
Hmm that’s the right one, and your
serverless.yml
looks something like this?
Copy code
custom:
  bundle:
    tsConfig: '../../tsconfig.json'
    disableForkTsChecker: true
    esbuild: true
j
Copy code
plugins:
  - serverless-bundle

custom:
  bundle:
    esbuild: true
I’m not using ts, using node
o
Yeah I dunno about the esbuild option then. That also doesn’t solve your core issue about webpack compilation errors. There are packages that aren’t compatible with webpack bundling and
serverless-bundle
has some fixes for specific packages built in
j
I think adding
serverless-bundle
has fixed the packaging stuff, there’s just a fair amount of eslint problems that the webcack compilation doesn’t like rn. Think I’m makign progress/getting close
appreciate the help!