Open HyperDwarf opened 2 months ago
Is there any chance you create a minimal repo with a reproduction of the bug? It'll help us investigate.
Is there any chance you create a minimal repo with a reproduction of the bug? It'll help us investigate.
Sorry for the late reply.
After some investigation, I think I found the cause. The problem is I am trying to import dependency which is installed on efs.
I have to use tensorflow-js on lmabda, which contains some native binaries to accelerate inferences.
According to the guide provided by AWS, I will have to first create an amazon linux2 instance, install the tfjs to somewhere, then let lambda import the module from the install location.
In my case I install tfjs to efs. But this make webpack fails for some reason.
Here is the minimal repo: https://github.com/HyperDwarf/sls-test
So I think I should rather ask, how to exclude imports that does not present in package.json
correctly?
This is a Bug Report
Description
However, when I tried to deploy a single function, which depends only on aws-api, it throws the error below:
The
package.json
under.webpack/dependencies
:It generates a weird "" in dependencies, and the problem still persists even if I exclude "" from
serverless.yml
orwebpack-config.js
Making anode_modules
manually won't help either, because webpack (or serverless) removes the directory when packing. Could be related to #497.What did you expect should have happened? Pack successfully.
What was the config you used?
serverless.yml
:custom: webpack: webpackConfig: "webpack.config.js" includeModules: forceExclude:
...
const path = require('path'); const nodeExternals = require('webpack-node-externals'); const slsw = require('serverless-webpack');
const isLocal = slsw.lib.webpack.isLocal;
module.exports = { mode: isLocal ? 'development' : 'production', entry: slsw.lib.entries, externals: [ nodeExternals(), "@aws-sdk/client-s3", "@aws-sdk/client-dynamodb", "@aws-sdk/client-sqs", "@aws-sdk/util-dynamodb" ], devtool: 'source-map', resolve: { extensions: ['.js', '.jsx', ".mjs", '.json', '.ts', '.tsx'] }, output: { libraryTarget: 'commonjs2', path: path.join(__dirname, '.webpack'), filename: '[name].js' }, target: 'node', cache: { type: 'filesystem', allowCollectingMemory: true, cacheDirectory: path.resolve('.webpackCache') }, module: { rules: [ { // Include ts, tsx, js, and jsx files. test: /.(mjs|ts|js)x?$/, exclude: /node_modules/, use: ['babel-loader'] } ] }, plugins: [] };