Git Product home page Git Product logo

Comments (5)

kamilmysliwiec avatar kamilmysliwiec commented on April 29, 2024 4

Add class-transformer/storage to lazyImports https://github.com/hjf/mapped-types-bug/blob/main/webpack.config.js#L2

from mapped-types.

adworacz avatar adworacz commented on April 29, 2024 4

I spent a few hours on this particular issue, especially when using fastify as well.

This feels like a potential gap in the existing NestJS serverless documentation. Would a pull request be accepted to update the documentation with the following example?

For those still wrestling with this issue, my webpack.config.js (targeting AWS Lambda) looked like so:

const path = require('path')

// Documentation:
// https://docs.nestjs.com/faq/serverless#serverless
// https://github.com/nestjs/swagger/issues/1334#issuecomment-836488125

// Tell webpack to ignore specific imports that aren't
// used by our Lambda but imported by NestJS (can cause packing errors).
const lazyImports = [
  '@nestjs/microservices/microservices-module',
  '@nestjs/websockets/socket-module',
  '@nestjs/platform-express',
  'swagger-ui-express',
  'class-transformer/storage' // https://github.com/nestjs/mapped-types/issues/486#issuecomment-932715880
]

module.exports = (options, webpack) => ({
  ...options,
  mode: 'production',
  target: 'node14',
  entry: {
    index: './lib/lambda.js',
  },
  output: {
    filename: '[name].js',
    libraryTarget: 'umd',
    path: path.join(process.cwd(), 'build/dist'),
  },
  externals: {
    'aws-sdk': 'aws-sdk',
  },
  plugins: [
    ...options.plugins,
    new webpack.IgnorePlugin({
      checkResource(resource) {
        if (lazyImports.includes(resource)) {
          try {
            require.resolve(resource)
          } catch (err) {
            return true
          }
        }
        return false
      },
    }),
  ],
})

from mapped-types.

max5432112345 avatar max5432112345 commented on April 29, 2024 1

https://stackoverflow.com/a/70814629

from mapped-types.

micalevisk avatar micalevisk commented on April 29, 2024

For folks looking this, the error is the following:

ERROR in ./node_modules/@nestjs/mapped-types/dist/type-helpers.utils.js 69:27-63
Module not found: Error: Can't resolve 'class-transformer/storage' in '/tmp/mapped-types-bug/node_modules/@nestjs/mapped-types/dist'
resolve 'class-transformer/storage' in '/tmp/mapped-types-bug/node_modules/@nestjs/mapped-types/dist'
  Parsed request is a module
  using description file: /tmp/mapped-types-bug/node_modules/@nestjs/mapped-types/package.json (relative path: ./dist)
    resolve as module
      /tmp/mapped-types-bug/node_modules/@nestjs/mapped-types/dist/node_modules doesn't exist or is not a directory
      /tmp/mapped-types-bug/node_modules/@nestjs/mapped-types/node_modules doesn't exist or is not a directory
      /tmp/mapped-types-bug/node_modules/@nestjs/node_modules doesn't exist or is not a directory
      /tmp/mapped-types-bug/node_modules/node_modules doesn't exist or is not a directory
      looking for modules in /tmp/mapped-types-bug/node_modules
        /tmp/mapped-types-bug/node_modules/class-transformer doesn't exist
      /tmp/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
 @ ./node_modules/@nestjs/mapped-types/dist/index.js 19:27-58
 @ ./node_modules/@nestjs/mapped-types/index.js 6:9-26
 @ ./node_modules/@nestjs/swagger/dist/type-helpers/intersection-type.helper.js 4:23-54
 @ ./node_modules/@nestjs/swagger/dist/type-helpers/index.js 13:13-50
 @ ./node_modules/@nestjs/swagger/dist/index.js 18:13-38
 @ ./node_modules/@nestjs/swagger/index.js 6:9-26
 @ ./src/app.controller.ts 13:16-42
 @ ./src/app.module.ts 11:25-52
 @ ./src/main.ts 4:21-44

from mapped-types.

elucidsoft avatar elucidsoft commented on April 29, 2024

Why was this not fixed?

from mapped-types.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.