@jscutlery/swc-angular 0.19.4 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.20.0 (2025-03-24)
2
+
3
+ ### 🚀 Features
4
+
5
+ - ✨ handle `useDefineForClassFields` option ([#793](https://github.com/jscutlery/devkit/pull/793))
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - Younes Jaaidi @yjaaidi
10
+
1
11
  ## 0.19.4 (2025-02-28)
2
12
 
3
13
  ### 🩹 Fixes
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <!-- TOC -->
4
4
 
5
- - [⚡️ Speed Up Angular Testing with SWC 🦀](#-speed-up-angular-testing-with-swc-)
5
+ - [⚡️ Speed Up Angular Testing with SWC 🦀](#️-speed-up-angular-testing-with-swc-)
6
6
  - [👀 What is this?](#-what-is-this)
7
7
  - [🤔 Context](#-context)
8
8
  - [🥇 Benchmark Summary](#-benchmark-summary)
@@ -10,13 +10,15 @@
10
10
  - [1. Install](#1-install)
11
11
  - [2. Configure](#2-configure)
12
12
  - [3. Add `reflect-metadata`](#3-add-reflect-metadata)
13
- - [⚡️Setup with Vitest](#setup-with-vitest)
13
+ - [⚡️Setup with Vitest](#️setup-with-vitest)
14
14
  - [1. Install](#1-install-1)
15
15
  - [2. Configure](#2-configure-1)
16
16
  - [3. Add `reflect-metadata`](#3-add-reflect-metadata-1)
17
+ - [🙋‍♂️ F.A.Q.](#️-faq)
18
+ - [TypeScript property inheritance issue](#typescript-property-inheritance-issue)
17
19
  - [🥇 Benchmark Data](#-benchmark-data)
18
20
  - [🔥 No Cache](#-no-cache)
19
- - [⚡️ With Cache](#-with-cache)
21
+ - [⚡️ With Cache](#️-with-cache)
20
22
  - [🥱 Cold Start](#-cold-start)
21
23
  - [Configurations](#configurations)
22
24
  - [Source](#source)
@@ -134,6 +136,24 @@ located at `src/test-setup.ts`.
134
136
  import 'reflect-metadata';
135
137
  ```
136
138
 
139
+ ## 🙋‍♂️ F.A.Q.
140
+
141
+ ### TypeScript property inheritance issue
142
+
143
+ If you encounter an issue with TypeScript property inheritance _(Cf. https://github.com/jscutlery/devkit/issues/376)_, then you can try to disable the `useDefineForClassFields` option:
144
+
145
+ ```ts
146
+ swcAngularJestTransformer({ useDefineForClassFields: false });
147
+ ```
148
+
149
+ or
150
+
151
+ ```ts
152
+ swcAngularUnpluginOptions({ useDefineForClassFields: false });
153
+ ```
154
+
155
+ _🙏 Thanks to [@santiagof4](https://github.com/santiagof4), [@pumano](https://github.com/pumano), and [@ryan-bendel](https://github.com/ryan-bendel)._
156
+
137
157
  ## 🥇 Benchmark Data
138
158
 
139
159
  ### 🔥 No Cache
package/index.cjs.js CHANGED
@@ -36,7 +36,8 @@ function swcAngularPreset(options = {}) {
36
36
  },
37
37
  transform: {
38
38
  legacyDecorator: true,
39
- decoratorMetadata: true
39
+ decoratorMetadata: true,
40
+ useDefineForClassFields: options.useDefineForClassFields
40
41
  },
41
42
  experimental: {
42
43
  plugins: [
@@ -52,6 +53,9 @@ function swcAngularPreset(options = {}) {
52
53
  }
53
54
  },
54
55
  env: {
56
+ targets: [
57
+ 'last 2 chrome versions'
58
+ ],
55
59
  include: [
56
60
  'transform-async-to-generator'
57
61
  ]
@@ -59,21 +63,21 @@ function swcAngularPreset(options = {}) {
59
63
  swcrc: false
60
64
  };
61
65
  }
62
- function swcAngularJestTransformer() {
66
+ function swcAngularJestTransformer(options = {}) {
63
67
  return [
64
68
  '@swc/jest',
65
- swcAngularPreset()
69
+ swcAngularPreset(options)
66
70
  ];
67
71
  }
68
- function swcAngularVitePreset() {
69
- return swcAngularPreset({
72
+ function swcAngularVitePreset(options = {}) {
73
+ return swcAngularPreset(_extends({
70
74
  importStyles: true,
71
75
  styleInlineSuffix: true,
72
76
  templateRawSuffix: true
73
- });
77
+ }, options));
74
78
  }
75
- function swcAngularUnpluginOptions() {
76
- return _extends({}, swcAngularVitePreset(), {
79
+ function swcAngularUnpluginOptions(options = {}) {
80
+ return _extends({}, swcAngularVitePreset(options), {
77
81
  /* Since we are using SWC's env option, we need to disable the tsconfigFile option.
78
82
  * Otherwise `unpluggin-swc` will try to use the target from the tsconfig's `compilerOptions`,
79
83
  * and make SWC produce the following error: "`env` and `jsc.target` cannot be used together".
package/index.esm.js CHANGED
@@ -32,7 +32,8 @@ function swcAngularPreset(options = {}) {
32
32
  },
33
33
  transform: {
34
34
  legacyDecorator: true,
35
- decoratorMetadata: true
35
+ decoratorMetadata: true,
36
+ useDefineForClassFields: options.useDefineForClassFields
36
37
  },
37
38
  experimental: {
38
39
  plugins: [
@@ -48,6 +49,9 @@ function swcAngularPreset(options = {}) {
48
49
  }
49
50
  },
50
51
  env: {
52
+ targets: [
53
+ 'last 2 chrome versions'
54
+ ],
51
55
  include: [
52
56
  'transform-async-to-generator'
53
57
  ]
@@ -55,21 +59,21 @@ function swcAngularPreset(options = {}) {
55
59
  swcrc: false
56
60
  };
57
61
  }
58
- function swcAngularJestTransformer() {
62
+ function swcAngularJestTransformer(options = {}) {
59
63
  return [
60
64
  '@swc/jest',
61
- swcAngularPreset()
65
+ swcAngularPreset(options)
62
66
  ];
63
67
  }
64
- function swcAngularVitePreset() {
65
- return swcAngularPreset({
68
+ function swcAngularVitePreset(options = {}) {
69
+ return swcAngularPreset(_extends({
66
70
  importStyles: true,
67
71
  styleInlineSuffix: true,
68
72
  templateRawSuffix: true
69
- });
73
+ }, options));
70
74
  }
71
- function swcAngularUnpluginOptions() {
72
- return _extends({}, swcAngularVitePreset(), {
75
+ function swcAngularUnpluginOptions(options = {}) {
76
+ return _extends({}, swcAngularVitePreset(options), {
73
77
  /* Since we are using SWC's env option, we need to disable the tsconfigFile option.
74
78
  * Otherwise `unpluggin-swc` will try to use the target from the tsconfig's `compilerOptions`,
75
79
  * and make SWC produce the following error: "`env` and `jsc.target` cannot be used together".
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jscutlery/swc-angular",
3
- "version": "0.19.4",
3
+ "version": "0.20.0",
4
4
  "repository": {
5
5
  "url": "https://github.com/jscutlery/devkit"
6
6
  },
package/src/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export interface AngularPresetOptions {
3
3
  importStyles?: boolean;
4
4
  styleInlineSuffix?: boolean;
5
5
  templateRawSuffix?: boolean;
6
+ useDefineForClassFields?: boolean;
6
7
  }
7
8
  export declare function swcAngularPreset(options?: AngularPresetOptions): {
8
9
  jsc: {
@@ -14,18 +15,20 @@ export declare function swcAngularPreset(options?: AngularPresetOptions): {
14
15
  transform: {
15
16
  legacyDecorator: true;
16
17
  decoratorMetadata: true;
18
+ useDefineForClassFields: boolean | undefined;
17
19
  };
18
20
  experimental: {
19
21
  plugins: [string, SwcPluginAngularOptions][];
20
22
  };
21
23
  };
22
24
  env: {
25
+ targets: string[];
23
26
  include: string[];
24
27
  };
25
28
  swcrc: false;
26
29
  };
27
- export declare function swcAngularJestTransformer(): [string, Record<string, unknown>];
28
- export declare function swcAngularVitePreset(): {
30
+ export declare function swcAngularJestTransformer(options?: AngularPresetOptions): [string, Record<string, unknown>];
31
+ export declare function swcAngularVitePreset(options?: AngularPresetOptions): {
29
32
  jsc: {
30
33
  parser: {
31
34
  syntax: "typescript";
@@ -35,17 +38,19 @@ export declare function swcAngularVitePreset(): {
35
38
  transform: {
36
39
  legacyDecorator: true;
37
40
  decoratorMetadata: true;
41
+ useDefineForClassFields: boolean | undefined;
38
42
  };
39
43
  experimental: {
40
44
  plugins: [string, SwcPluginAngularOptions][];
41
45
  };
42
46
  };
43
47
  env: {
48
+ targets: string[];
44
49
  include: string[];
45
50
  };
46
51
  swcrc: false;
47
52
  };
48
- export declare function swcAngularUnpluginOptions(): Options & {
53
+ export declare function swcAngularUnpluginOptions(options?: AngularPresetOptions): Options & {
49
54
  tsconfigFile?: boolean;
50
55
  };
51
56
  interface SwcPluginAngularOptions {
@@ -65,12 +70,14 @@ declare const _default: {
65
70
  transform: {
66
71
  legacyDecorator: true;
67
72
  decoratorMetadata: true;
73
+ useDefineForClassFields: boolean | undefined;
68
74
  };
69
75
  experimental: {
70
76
  plugins: [string, SwcPluginAngularOptions][];
71
77
  };
72
78
  };
73
79
  env: {
80
+ targets: string[];
74
81
  include: string[];
75
82
  };
76
83
  swcrc: false;