From 20d21ca4268853c85d203f1270c77c40922a2052 Mon Sep 17 00:00:00 2001 From: Taj Pereira Date: Sat, 1 Jun 2024 06:17:44 +0930 Subject: [PATCH 1/3] build: set useDefineForClassFields to false --- .changeset/tiny-boxes-play.md | 9 +++++++++ tsconfig.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/tiny-boxes-play.md diff --git a/.changeset/tiny-boxes-play.md b/.changeset/tiny-boxes-play.md new file mode 100644 index 0000000000..4bcfec3111 --- /dev/null +++ b/.changeset/tiny-boxes-play.md @@ -0,0 +1,9 @@ +--- +"mobx": patch +"eslint-plugin-mobx": patch +"mobx-react": patch +"mobx-react-lite": patch +"mobx-undecorate": patch +--- + +In TypeScript transpilation, disable useDefineForClassFields to reduce memory requirements of classes having optional members. diff --git a/tsconfig.json b/tsconfig.json index c0c18f028f..32fa6607d9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,7 @@ "noImplicitThis": false, "noEmit": true, "experimentalDecorators": true, - "useDefineForClassFields": true, + "useDefineForClassFields": false, "jsx": "react", "esModuleInterop": true }, From 18c82b96dbd0fa53a16353b6627695f20f399609 Mon Sep 17 00:00:00 2001 From: Taj Pereira Date: Sat, 1 Jun 2024 10:35:40 +0930 Subject: [PATCH 2/3] fix: enable for tests --- tsconfig.json | 1 + tsconfig.test.json | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 32fa6607d9..7a26c1bb72 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,7 @@ "noImplicitThis": false, "noEmit": true, "experimentalDecorators": true, + // See: https://github.com/mobxjs/mobx/pull/3884 "useDefineForClassFields": false, "jsx": "react", "esModuleInterop": true diff --git a/tsconfig.test.json b/tsconfig.test.json index f8e4f8c916..0bfdfaf815 100644 --- a/tsconfig.test.json +++ b/tsconfig.test.json @@ -3,6 +3,8 @@ "compilerOptions": { // "module": "commonjs", "allowJs": true, - "noUnusedLocals": false + "noUnusedLocals": false, + // See: https://github.com/mobxjs/mobx/pull/3884 + "useDefineForClassFields": true } } From 3d894152a47786a38d95a4c0ce48e1e1cb4d8221 Mon Sep 17 00:00:00 2001 From: Taj Pereira Date: Sun, 2 Jun 2024 08:16:05 +0930 Subject: [PATCH 3/3] Update .changeset/tiny-boxes-play.md --- .changeset/tiny-boxes-play.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/tiny-boxes-play.md b/.changeset/tiny-boxes-play.md index 4bcfec3111..d0bd3fd006 100644 --- a/.changeset/tiny-boxes-play.md +++ b/.changeset/tiny-boxes-play.md @@ -6,4 +6,4 @@ "mobx-undecorate": patch --- -In TypeScript transpilation, disable useDefineForClassFields to reduce memory requirements of classes having optional members. +Disable `useDefineForClassFields` in `tsconfig.json` to reduce memory footprint and improve performance of class instances with undefined and unused members.