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

Update Class Transformer Package v0.5.1 #1526

Open
1 task done
john-shika opened this issue Nov 5, 2024 · 2 comments
Open
1 task done

Update Class Transformer Package v0.5.1 #1526

john-shika opened this issue Nov 5, 2024 · 2 comments

Comments

@john-shika
Copy link

john-shika commented Nov 5, 2024

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

I am trying to bundle all files into single main file, it's work until supposed conflict with some dependencies, because @nestjs /mapped-types required [email protected] for work, but my project need [email protected].
trying run this command with bun and esbuild

bun run nest build
esbuild --bundle --minify --sourcemap=external --platform=node --target=es2020 --outdir=bin .\dist\main.js
X [ERROR] Could not resolve "class-transformer/storage"

    node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_mu3cclgr33ip2qq3tugjdeyzwe/node_modules/@nestjs/mapped-types/dist/type-helpers.utils.js:80:35:
      80 │ ...lassTransformer = require('class-transformer/storage');
         ╵                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "class-transformer/storage" as external to
  exclude it from the bundle, which will remove this error and leave
  the unresolved path in the bundle. You can also surround this
  "require" call with a try/catch block to handle this failure at
  run-time instead of bundle-time.

Describe the solution you'd like

I have new solution! let me explain.

[email protected] keep it class-transformer/cjs/storage.js until now, so replacing from

let classTransformer;
    try {
        classTransformer = require('class-transformer/cjs/storage');
    }
    catch {
        classTransformer = require('class-transformer/storage');
    }

with

const classTransformer = require('class-transformer/cjs/storage');

it's work. no error message from my console! but idk this is make some bad decision in the feature. :)

Teachability, documentation, adoption, migration strategy

no migration, but not tested as well

What is the motivation / use case for changing the behavior?

to make it single bundle file or compile it to executable exe if supported by platform like bun, deno, or something similarity, make it fast because bundle with minify.

@kamilmysliwiec
Copy link
Member

Yeah, we can't do that yet as this would introduce a breaking change. We'll address that in the next major release

@john-shika
Copy link
Author

Yeah, we can't do that yet as this would introduce a breaking change. We'll address that in the next major release

Not bad, I have another solution with my problem, thanks for sharing your time, my another solution to built single file with injection link script to class-transformer to link /storage.js to /cjs/storage.js, yea it's work, I am built with powershell script build.ps1 👌🏻✨ source ready to compile 😎

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

No branches or pull requests

2 participants