The following error occurs when attempting to use class-transformer in my project.
Uncaught ReferenceError: exports is not defined
Additionally the following warning is shown in the terminal.
Warning: /libs/core/feature-components/src/core/fs-component.decorator.ts depends on 'class-transformer'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
Minimal code-snippet showcasing the problem
The error occurs on import.
import {} from 'class-transformer'
Imports to use es5/es2015 formats when in the browser
CommonJS import appears to be used.
My configuration for this project is a little, special. I am rendering React Native Web inside of an Angular project. This is requiring me to use Babel on top of the Angular Webpack configuration. From what I can tell this kills commonjs, not entirely sure why. I attempted to use some babel plugins to correct this and using babel-plugin-transform-commonjs works so long as I use the default import of class-transformer but a few (such as @Type() end up on the default export.
In any case the solution appears to be just to ship ES Modules, which appears to already be planned, just not released yet.
Added in 26b5dac86e41ef206a9ca06eed1993308d6e1481. It will be included in the next release.
_Originally posted by @NoNameProvided in https://github.com/typestack/class-transformer/issues/344#issuecomment-670897655_
So my question is when I can expect this next release?
Can a beta version be released that I could play with in the mean time?
The requested feature is released. Closing as solved. If your issue still persists, please provide a minimal reproducible example of the issue I can debug.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
The requested feature is released. Closing as solved. If your issue still persists, please provide a minimal reproducible example of the issue I can debug.