Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack build failes - Can't resolve 'class-transformer/storage' #2835

Closed
2 of 4 tasks
yifanwww opened this issue Dec 7, 2024 · 1 comment · Fixed by #2838
Closed
2 of 4 tasks

webpack build failes - Can't resolve 'class-transformer/storage' #2835

yifanwww opened this issue Dec 7, 2024 · 1 comment · Fixed by #2838

Comments

@yifanwww
Copy link
Contributor

yifanwww commented Dec 7, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Build failes with 1 module not found error:

Module not found: Error: Can't resolve 'class-transformer/storage' in ...

Minimum reproduction code

https://gist.github.com/yifanwww/0e843ee0d5ba66a2dfd34fe3300c66bf

Steps to reproduce

  1. nest new test
  2. add/install class-validator, class-transformer and @nestjs/mapped-types
  3. update nest-cli.json to switch builder to webpack (according to https://docs.nestjs.com/cli/monorepo#global-compiler-options)
  4. create webpack.config.js with following contents (according to https://docs.nestjs.com/cli/monorepo#webpack-options):
module.exports = {
  externals: [],
};
  1. add the following code to src/main.ts
import { IntersectionType } from '@nestjs/mapped-types';

class DtoA {}

class DtoB {}

class DtoC extends IntersectionType(DtoA, DtoB) {}

DtoC;
  1. npm run build produces 1 error

Module not found: Error: Can't resolve 'class-transformer/storage' in ...

Expected behavior

lib/compiler/defaults/webpack-defaults/ts should be upgraded as following shows

          const lazyImports = [
            '@nestjs/microservices',
            '@nestjs/microservices/microservices-module',
            '@nestjs/websockets/socket-module',
            'class-validator',
            'class-transformer',
+            'class-transformer/storage',
          ];

Package version

10.4.8

NestJS version

10.3.8

Node.js version

20.17.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

similar to this issue
relevant to this issue

@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants