Webpack encrypted lamdba layer code is not working

24 views Asked by At

I use a lambda layer in my serverless nodejs project and when I deploy the project webpack encrypts the code & the encrypted code is not working. The encrypted code is not able to get the layer. But if I use the raw code in the AWS lambda console its working.

module.exports = {
  target: 'node',
  mode: 'development',
  entry: Object.assign({
    worker: './lib/worker.js', // Use the correct relative path
  }, slsw.lib.entries),
  devtool: 'source-map',
  //externals: ["aws-sdk", "pino-pretty", "vertx"], // modules to be excluded from bundled file
  // externals: ["aws-sdk", "vertx"], // modules to be excluded from bundled file
  resolve: {
    extensions: ['.ts', '.js', '.json'],
    // remove other default values
    modules: [
      path.join(__dirname, "src/commons"),
      "node_modules"
    ],
    alias: {
      '/opt/commons': false,
      'commons': false,
      './commons': false,
      '/opt/logging': false
    }
  },
  output: {
    libraryTarget: "commonjs",
    path: path.join(__dirname, ".webpack"),
    filename: (chunkData) => {
      return chunkData.chunk.name === "worker"
        ? "src/handler/lib/[name].js"
        : "[name].js";
    },
    sourceMapFilename: "[file].map",
  },
  module: {
    rules: [
      {
        test: /\.ts$/, use: 'ts-loader'
      },
      {
        test: /\.js$/,
        loader: "shebang-loader"
      }
    ]
  }
};

This is my webpack.config.js file.

0

There are 0 answers