Giter Site home page Giter Site logo

Comments (11)

Nikaple avatar Nikaple commented on May 28, 2024

I tried downgrade and lock the version of class-transformer to 0.4.0, and it works fine. Maybe it's an issue with class-transformer. Needs further investigation.

Edit: You're not able to start example app because you didn't install the dependencies in the root folder. The example apps shares the same dependencies as the main lib, as well as the class-transformer, which is locked at version 0.4.0

Edit again: I think I got it. When your installed version of class-transformer is not the same with nest-typed-config's version, the metadata defined in ConfigModule goes into node_modules/class-transformer, but when calling plainToClass in the library code, it uses node_modules/nest-typed-config/node_modules/class-transformer, which didn't own the metadata you provided.

So for the solution:

  1. (temporary) Downgrade class-transformer to 0.4.0 to match library's, or copy the validate function.
  2. Introduce a breaking change into the library, which declares class-transformer as peerDependencies.

I would try to implement the second solution asap(including code, docs, migration guide, etc.), but I'm busy for the next one or two weeks, feel free to propose a PR if you want the feature to be released quicker!

from nest-typed-config.

imkh avatar imkh commented on May 28, 2024

I tried downgrade and lock the version of class-transformer to 0.4.0, and it works fine. Maybe it's an issue with class-transformer. Needs further investigation.

Good catch, I didn't think of downgrading class-transformer, I only noticed after the fact that the examples shared the same 0.0.4 version as the main lib. Let me know if you need anything else.

from nest-typed-config.

Nikaple avatar Nikaple commented on May 28, 2024

I've edited my previous comment, please check it out 😸

from nest-typed-config.

imkh avatar imkh commented on May 28, 2024

Nice, thanks for looking into it. I'm not sure exactly what change is needed in the lib to fix the bug though and I'm not in any rush, so I don't mind waiting and using the custom validate function in the meantime.

from nest-typed-config.

andrey-hohlov avatar andrey-hohlov commented on May 28, 2024

@Nikaple is there any chance for

Introduce a breaking change into the library, which declares class-transformer as peerDependencies.

?

We are trying nest-typed-config as a replacement for @nestjs/config. It works well except class-transformer versions mismatch. We don't wan / cannot downgrade its version.

temp solution that we can use, but...

"postinstall": "rimraf node_modules/nest-typed-config/node_modules/class-transformer"

from nest-typed-config.

Nikaple avatar Nikaple commented on May 28, 2024

PR #186 tries to fix this issue by import deps from root node_modules first, see:

https://github.com/Nikaple/nest-typed-config/blob/fix%2Fissue-149/lib/utils/imports.util.ts#L5

@andrey-hohlov Please let me know if you have any suggestions

from nest-typed-config.

github-actions avatar github-actions commented on May 28, 2024

🎉 This issue has been resolved in version 2.4.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

from nest-typed-config.

andrey-hohlov avatar andrey-hohlov commented on May 28, 2024

@Nikaple I tried new version and it works. But I'm not sure about the solution.

@nestjs/common accepts any version of class-transformer and class-validator and lists them in peerDependencies.

In my opinion, the right strategy is to follow versions that are used in actual nestjs package - version * in peerDependencies.

from nest-typed-config.

Nikaple avatar Nikaple commented on May 28, 2024

Yes, it's kinda hack, but I want to keep this lib as stable as possible, avoid breaking changes when it doesn't have to.

from nest-typed-config.

svyatogor avatar svyatogor commented on May 28, 2024

This solution completely breaks building monorepos unfortunately. Dynamic requires are not processed by webpack and result in Uncaught Error: Cannot find module 'class-validator'

from nest-typed-config.

Nikaple avatar Nikaple commented on May 28, 2024

@svyatogor Can you provide a minimum reproduction repo? If it's a newly introduced bug, you can file a separate issue.

from nest-typed-config.

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.