Has anyone actually got a Typescript lambda workin...
# orm-help
n
Has anyone actually got a Typescript lambda working with data proxy? the examples in the doc are using just JS and I can't quite get it to work
various errors but basically when serverless wants to deploy it gets an error such as:
Copy code
ERROR in ./node_modules/@prisma/client/index.js 1:15-46
Module not found: Error: Can't resolve '.prisma/client/index' in '/services/queries/node_modules/@prisma/client'
resolve '.prisma/client/index' in '/services/queries/node_modules/@prisma/client'
  Parsed request is a module
  using description file: /services/queries/node_modules/@prisma/client/package.json (relative path: .)
(cc @Alex Ruheni)
I saw @Ryanโ€™s great CDK example but it'd be great if we could have a Serverless+typescript without CDK too since that'd be a common stack for typescript Prisma users (cc @janpio)
a
Hi Nima ๐Ÿ‘‹๐Ÿฝ One possible solution is using
serverless-webpack-prisma
by @Daniel Uhm. We updated our docs with a new section on deploying your application using `serverless-webpack` and `serverless-webpack-prisma`. The guide also includes a section setting up a minimal webpack config file with TypeScript, which you could give a shot ๐Ÿ™‚
prisma rainbow 1
Hereโ€™s the
webpack.config.js
file using TypeScript:
Copy code
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path')
const nodeExternals = require('webpack-node-externals')
const slsw = require('serverless-webpack')
const { isLocal } = slsw.lib.webpack

module.exports = {
  target: 'node',
  stats: 'normal',
  entry: slsw.lib.entries,
  externals: [nodeExternals()],
  mode: isLocal ? 'development' : 'production',        
module: {
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'ts-loader',
        exclude: /node_modules/,
      },
    ],
  },
  optimization: { concatenateModules: false },
  resolve: { extensions: ['.js', '.ts' ] },
  output: {
    libraryTarget: 'commonjs',
    filename: '[name].js',
    path: path.resolve(__dirname, '.webpack'),
  },
}
Feel free to reach out if you hit a snag ๐Ÿ™‚
n
Thanks Alex that's the example I was looking at but I'll give it another go
@Alex Ruheni you are a legend, so it is now building correctly, if you have any tips about making the bundle size smaller or is around 70mb expected?
a
Hey Nima, sorry for the delayed response Iโ€™m not completely sure, but this would be dependent on your project size.
serverless-webpack-prisma
should help reduce the bundle size
๐Ÿ™Œ 1