Open MickL opened 3 years ago
There are some notes in the console while compiling, not sure if they are related to the issuse:
(!) `this` has been rewritten to `undefined`
https://rollupjs.org/guide/en/#error-this-is-undefined
../node_modules/class-validator/esm5/validation/Validator.js
1: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
^
2: function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3: return new (P || (P = Promise))(function (resolve, reject) {
...and 3 other occurrences
../node_modules/class-transformer/esm5/ClassTransformer.js
1: var __assign = (this && this.__assign) || function () {
^
2: __assign = Object.assign || function(t) {
3: for (var s, i = 1, n = arguments.length; i < n; i++) {
...and 1 other occurrence
../node_modules/class-validator/esm5/decorator/common/ValidateNested.js
1: var __assign = (this && this.__assign) || function () {
^
2: __assign = Object.assign || function(t) {
3: for (var s, i = 1, n = arguments.length; i < n; i++) {
...and 1 other occurrence
@NoNameProvided May you take a look at this? :)
The compiler most probably strips the type information. Make sure the built version contains the type metadata attached to the classes and properties. It should look something like this: __metadata("design:type", <class-type-here>)
@NoNameProvided I see this in the generated built files:
ES5: https://github.com/MickL/class-transformer-type/blob/e61dbf6161033c5dce321b23984c9193aa49234d/my-lib/dist/my-lib.es5.js#L710 UMD: https://github.com/MickL/class-transformer-type/blob/e61dbf6161033c5dce321b23984c9193aa49234d/my-lib/dist/my-lib.umd.js#L718
Is the issue related to the message of rollup about "this"? May you have time to take a look at my minimal reproduction repo? https://github.com/MickL/class-transformer-type
@NoNameProvided Would be very glad if you could take a look at the repo. Is the issue related to the warning about "this"?
I am not super familiar with Rollup, so I don't know. I may take a look at this on the weekend but not promising a thing, as there is a lot of issue to look at.
I had a similar issue. I added class-transformer
as a dependency in package.json
of my shared-types package and it worked :D
Description
I do have a shared project that contains interfaces and dto's:
Which works fine if I use
plainToClass()
in the same project:But after I compiled the project with Rollup, import
MyClassDto
and useplainToClass()
the@Type
does not have any effect anymore:I wonder if you could give me any hint why this could be the case. For everything else (class validator) it works fine. Maybe this is a bug? Or what could it be?
I do compile to umd and es5, not sure which one my app (node.js) picks up.
Version: 0.4.0
I have created a minimal reproduction example: https://github.com/MickL/class-transformer-type