Open orr-levinger opened 3 years ago
If you are using typescript you want to use the srcPath
option https://github.com/DavidWells/serverless-manifest-plugin/pull/18/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R44
This should resolve the file
Hey, getting the same problem here with Typescript, tried this workaround but srcPath does not seem to solve the problem as I feel the individual packing for lambda functions causes troubles:
using serverless framework template 'aws-nodejs-typescript'
# serverless.yaml
plugins:
- serverless-offline
- serverless-appsync-plugin
- serverless-iam-roles-per-function
- serverless-webpack
- serverless-export-env
- serverless-manifest-plugin
- serverless-prune-plugin
custom:
manifest:
srcPath: .webpack
functions:
confirmUserSignup:
handler: src/functions/user/save-user-profile-at-signup.saveUserProfileAtSignup
Webpack config
const path = require('path');
const slsw = require('serverless-webpack');
const nodeExternals = require('webpack-node-externals');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
module.exports = {
context: __dirname,
mode: slsw.lib.webpack.isLocal ? 'development' : 'production',
entry: slsw.lib.entries,
devtool: slsw.lib.webpack.isLocal ? 'eval-cheap-module-source-map' : 'source-map',
resolve: {
extensions: ['.mjs', '.json', '.ts'],
symlinks: false,
cacheWithContext: false,
plugins: [
new TsconfigPathsPlugin({
configFile: './tsconfig.paths.json',
}),
],
},
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, '.webpack'),
filename: '[name].js',
},
optimization: {
concatenateModules: false,
},
target: 'node',
externals: [nodeExternals()],
module: {
rules: [
// all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
{
test: /\.(tsx?)$/,
loader: 'ts-loader',
exclude: [
[
path.resolve(__dirname, 'node_modules'),
path.resolve(__dirname, '.serverless'),
path.resolve(__dirname, '.webpack'),
],
],
options: {
transpileOnly: true,
experimentalWatchApi: true,
},
},
],
},
plugins: [],
};
Output:
.webpack
|- confirmuserSignup
|- src
|- functions
|- user
|- save-user-profile-at-signup.js
Error: File "src/functions/user/save-user-profile-at-signup.js" not found. .webpack/src/functions/user/save-user-profile-at-signup.js missing
I am using this plugin for a while now to set env variables. recently i added the serverless-webpack to reduce my bundle size i am using typescrypt so my webpack.config looks like this:
/ eslint-disable @typescript-eslint/no-var-requires / const path = require('path'); const slsw = require('serverless-webpack'); const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const isLocal = slsw.lib.webpack.isLocal;
i am getting this error from the manifest plugin: