Class-transformer: question: Uncaught ReferenceError: exports is not defined when using in browser

Created on 18 Dec 2020  路  2Comments  路  Source: typestack/class-transformer

Description

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'

Expected behavior

Imports to use es5/es2015 formats when in the browser

Actual behavior

CommonJS import appears to be used.

Additional context

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?

question

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.

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gregsolo-intent picture gregsolo-intent  路  5Comments

VivienAdnot picture VivienAdnot  路  6Comments

ERPedersen picture ERPedersen  路  4Comments

prbaron picture prbaron  路  3Comments

SC30SC picture SC30SC  路  4Comments