@jscutlery/swc-angular 0.13.0 → 0.14.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 +25 -26
- package/README.md +24 -24
- package/index.cjs.js +21 -6
- package/index.esm.js +20 -5
- package/package.json +1 -1
- package/src/utils.d.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,72 +1,75 @@
|
|
|
1
|
-
## 0.
|
|
1
|
+
## 0.14.0 (2024-05-03)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### 🚀 Features
|
|
5
5
|
|
|
6
|
-
- ✨
|
|
6
|
+
- **swc-angular:** ✨ allow @swc/core 1.5.x ([#366](https://github.com/jscutlery/devkit/pull/366))
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
### ❤️ Thank You
|
|
10
10
|
|
|
11
11
|
- Younes Jaaidi
|
|
12
12
|
|
|
13
|
-
## 0.
|
|
13
|
+
## 0.13.1 (2024-05-03)
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
###
|
|
16
|
+
### 🩹 Fixes
|
|
17
17
|
|
|
18
|
-
- **swc-angular:**
|
|
18
|
+
- **swc-angular:** 🐞 fix stackblitz support ([#364](https://github.com/jscutlery/devkit/pull/364))
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
### ❤️ Thank You
|
|
22
22
|
|
|
23
23
|
- Younes Jaaidi
|
|
24
24
|
|
|
25
|
-
## 0.
|
|
26
|
-
|
|
25
|
+
## 0.12.0 (2024-04-12)
|
|
27
26
|
|
|
28
27
|
### 🚀 Features
|
|
29
28
|
|
|
30
|
-
- **swc-angular
|
|
29
|
+
- **swc-angular:** ✨ rename swc-angular packages ([#324](https://github.com/jscutlery/devkit/pull/324))
|
|
30
|
+
|
|
31
|
+
### ❤️ Thank You
|
|
31
32
|
|
|
33
|
+
- Younes Jaaidi
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
## 0.3.0 (2024-04-11)
|
|
36
|
+
|
|
37
|
+
### 🚀 Features
|
|
38
|
+
|
|
39
|
+
- **swc-angular-preset:** ✨ fail gracefully if @swc/core is
|
|
40
|
+
incompatible ([#322](https://github.com/jscutlery/devkit/pull/322))
|
|
41
|
+
|
|
42
|
+
### ❤️ Thank You
|
|
34
43
|
|
|
35
44
|
- Younes Jaaidi
|
|
36
45
|
|
|
37
46
|
## 0.2.2 (2024-04-09)
|
|
38
47
|
|
|
39
|
-
|
|
40
48
|
### 🩹 Fixes
|
|
41
49
|
|
|
42
50
|
- **swc-angular-preset:** 🐞 fix jest preset typing ([9c6de1c](https://github.com/jscutlery/devkit/commit/9c6de1c))
|
|
43
51
|
|
|
44
|
-
|
|
45
|
-
### ❤️ Thank You
|
|
52
|
+
### ❤️ Thank You
|
|
46
53
|
|
|
47
54
|
- Younes Jaaidi
|
|
48
55
|
|
|
49
56
|
## 0.2.1 (2024-04-08)
|
|
50
57
|
|
|
51
|
-
|
|
52
58
|
### 🩹 Fixes
|
|
53
59
|
|
|
54
60
|
- **swc-plugin-angular:** 🐞 transform async/await ([#313](https://github.com/jscutlery/devkit/pull/313))
|
|
55
61
|
|
|
56
|
-
|
|
57
|
-
### ❤️ Thank You
|
|
62
|
+
### ❤️ Thank You
|
|
58
63
|
|
|
59
64
|
- Younes Jaaidi
|
|
60
65
|
|
|
61
66
|
## 0.2.0 (2024-04-04)
|
|
62
67
|
|
|
63
|
-
|
|
64
68
|
### 🚀 Features
|
|
65
69
|
|
|
66
70
|
- **swc-angular-preset:** ✨ add vite support ([#307](https://github.com/jscutlery/devkit/pull/307))
|
|
67
71
|
|
|
68
|
-
|
|
69
|
-
### ❤️ Thank You
|
|
72
|
+
### ❤️ Thank You
|
|
70
73
|
|
|
71
74
|
- Younes Jaaidi
|
|
72
75
|
|
|
@@ -76,28 +79,24 @@
|
|
|
76
79
|
|
|
77
80
|
- **swc-angular-preset:** 🐞 publish dist artefact
|
|
78
81
|
|
|
79
|
-
|
|
80
82
|
## 0.1.1 (2024-03-29)
|
|
81
83
|
|
|
82
|
-
|
|
83
84
|
### 🩹 Fixes
|
|
84
85
|
|
|
85
|
-
- **swc-angular-preset:** 🐞 allow recent versions of
|
|
86
|
-
|
|
86
|
+
- **swc-angular-preset:** 🐞 allow recent versions of
|
|
87
|
+
swc-plugin-angular ([c715414](https://github.com/jscutlery/devkit/commit/c715414))
|
|
87
88
|
|
|
88
|
-
### ❤️
|
|
89
|
+
### ❤️ Thank You
|
|
89
90
|
|
|
90
91
|
- Edouard Bozon @edbzn
|
|
91
92
|
- Younes Jaaidi
|
|
92
93
|
|
|
93
94
|
## 0.1.0 (2024-03-26)
|
|
94
95
|
|
|
95
|
-
|
|
96
96
|
### 🚀 Features
|
|
97
97
|
|
|
98
98
|
- ✨ add swc-angular-preset and swc-plugin-angular ([#273](https://github.com/jscutlery/devkit/pull/273))
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
### ❤️ Thank You
|
|
100
|
+
### ❤️ Thank You
|
|
102
101
|
|
|
103
102
|
- Edouard Bozon @edbzn
|
package/README.md
CHANGED
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- TOC -->
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
- [⚡️ Speed Up Angular Testing with SWC 🦀](#-speed-up-angular-testing-with-swc-)
|
|
6
|
+
- [👀 What is this?](#-what-is-this)
|
|
7
|
+
- [🤔 Context](#-context)
|
|
8
|
+
- [🥇 Benchmark Summary](#-benchmark-summary)
|
|
9
|
+
- [🎭 Setup with Jest](#-setup-with-jest)
|
|
10
|
+
- [1. Install](#1-install)
|
|
11
|
+
- [2. Configure](#2-configure)
|
|
12
|
+
- [3. Add `reflect-metadata`](#3-add-reflect-metadata)
|
|
13
|
+
- [⚡️Setup with Vitest](#setup-with-vitest)
|
|
14
|
+
- [1. Install](#1-install-1)
|
|
15
|
+
- [2. Configure](#2-configure-1)
|
|
16
|
+
- [3. Add `reflect-metadata`](#3-add-reflect-metadata-1)
|
|
17
|
+
- [🥇 Benchmark Data](#-benchmark-data)
|
|
18
|
+
- [🔥 No Cache](#-no-cache)
|
|
19
|
+
- [⚡️ With Cache](#-with-cache)
|
|
20
|
+
- [🥱 Cold Start](#-cold-start)
|
|
21
|
+
- [Configurations](#configurations)
|
|
22
|
+
- [Source](#source)
|
|
23
23
|
|
|
24
24
|
<!-- TOC -->
|
|
25
25
|
|
|
@@ -120,7 +120,7 @@ import { defineConfig } from 'vite';
|
|
|
120
120
|
|
|
121
121
|
export default defineConfig({
|
|
122
122
|
// ...
|
|
123
|
-
plugins: [swc.vite(swcAngularUnpluginOptions())]
|
|
123
|
+
plugins: [swc.vite(swcAngularUnpluginOptions())],
|
|
124
124
|
// ...
|
|
125
125
|
});
|
|
126
126
|
```
|
|
@@ -141,7 +141,7 @@ import 'reflect-metadata';
|
|
|
141
141
|
All caches are cleared before each benchmark run.
|
|
142
142
|
|
|
143
143
|
| Configuration | Relative | Mean [s] | Min [s] | Max [s] |
|
|
144
|
-
|
|
144
|
+
| :---------------------------- | -----------: | -------------: | ------: | ------: |
|
|
145
145
|
| 🥇`vitest-swc-no-isolate` | 1.00 | 3.137 ± 0.061 | 3.042 | 3.227 |
|
|
146
146
|
| 🥈`jest-swc` | 3.31 ± 0.15 | 10.393 ± 0.429 | 9.745 | 10.994 |
|
|
147
147
|
| 🥉`angular-cli-karma` | 3.52 ± 0.53 | 11.041 ± 1.642 | 10.218 | 15.690 |
|
|
@@ -157,7 +157,7 @@ All caches are cleared before each benchmark run.
|
|
|
157
157
|
All tests are ran once to warm up the cache before running the benchmark.
|
|
158
158
|
|
|
159
159
|
| Configuration | Relative | Mean [s] | Min [s] | Max [s] |
|
|
160
|
-
|
|
160
|
+
| :---------------------------- | -----------: | -------------: | ------: | ------: |
|
|
161
161
|
| 🥇`vitest-swc-no-isolate` | 1.00 | 3.092 ± 0.090 | 3.030 | 3.301 |
|
|
162
162
|
| 🥈`angular-cli-karma` | 1.91 ± 0.07 | 5.901 ± 0.139 | 5.718 | 6.131 |
|
|
163
163
|
| 🥉`jest-swc` | 2.93 ± 0.18 | 9.045 ± 0.494 | 8.513 | 10.065 |
|
|
@@ -176,7 +176,7 @@ All tests are ran once to warm up the cache before running the benchmark.
|
|
|
176
176
|
Run a single test module just and try to measure the bootstrap time.
|
|
177
177
|
|
|
178
178
|
| Configuration | Relative | Mean [s] | Min [s] | Max [s] |
|
|
179
|
-
|
|
179
|
+
| :---------------------------- | ----------: | ------------: | ------: | ------: |
|
|
180
180
|
| 🥇`vitest-swc-no-isolate` | 1.00 | 1.260 ± 0.024 | 1.241 | 1.314 |
|
|
181
181
|
| 🥈`vitest-swc` | 1.00 ± 0.03 | 1.262 ± 0.026 | 1.225 | 1.305 |
|
|
182
182
|
| 🥉`jest-swc` | 1.44 ± 0.15 | 1.812 ± 0.186 | 1.714 | 2.310 |
|
|
@@ -190,7 +190,7 @@ Run a single test module just and try to measure the bootstrap time.
|
|
|
190
190
|
### Configurations
|
|
191
191
|
|
|
192
192
|
| | Configuration | Test Isolation\* |
|
|
193
|
-
|
|
193
|
+
| ----------------------------- | :----------------------------- | ---------------: |
|
|
194
194
|
| `angular-cli-karma` | Angular CLI's Karma | false |
|
|
195
195
|
| `angular-cli-jest` | Angular CLI's Jest | true |
|
|
196
196
|
| `angular-cli-web-test-runner` | Angular CLI's @web/test-runner | true |
|
|
@@ -206,5 +206,5 @@ Run a single test module just and try to measure the bootstrap time.
|
|
|
206
206
|
|
|
207
207
|
### Source
|
|
208
208
|
|
|
209
|
-
💻 try it yourself: https://github.com/yjaaidi/experiments/tree/angular-
|
|
209
|
+
💻 try it yourself: https://github.com/yjaaidi/experiments/tree/angular-swc-benchmark
|
|
210
210
|
or checkout the last benchmark results: https://github.com/yjaaidi/experiments/actions/workflows/benchmark.yml
|
package/index.cjs.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var core = require('@swc/core');
|
|
6
|
+
var node_fs = require('node:fs');
|
|
7
|
+
var node_path = require('node:path');
|
|
6
8
|
|
|
7
9
|
function _extends() {
|
|
8
10
|
_extends = Object.assign || function assign(target) {
|
|
@@ -15,7 +17,15 @@ function _extends() {
|
|
|
15
17
|
return _extends.apply(this, arguments);
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
class FileSystem {
|
|
21
|
+
readJsonFile(path) {
|
|
22
|
+
const content = node_fs.readFileSync(path, 'utf-8');
|
|
23
|
+
return JSON.parse(content);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const fileSystem = new FileSystem();
|
|
27
|
+
|
|
28
|
+
assertCompatibleSwcCoreVersion(core.version);
|
|
19
29
|
function swcAngularPreset(options = {}) {
|
|
20
30
|
return {
|
|
21
31
|
jsc: {
|
|
@@ -72,12 +82,17 @@ function swcAngularUnpluginOptions() {
|
|
|
72
82
|
/**
|
|
73
83
|
* @deprecated Use {@link swcAngularVitePreset}, {@link swcAngularJestTransformer} or {@link swcAngularPreset} instead.
|
|
74
84
|
*/ var index = swcAngularPreset();
|
|
75
|
-
function assertCompatibleSwcCoreVersion() {
|
|
76
|
-
|
|
85
|
+
function assertCompatibleSwcCoreVersion(version) {
|
|
86
|
+
/* Fallback to reading version from package.json when not exported.
|
|
87
|
+
* This happens on Stackblitz. */ if (version == undefined) {
|
|
88
|
+
const packageJsonPath = node_path.join(node_path.dirname(require.resolve('@swc/core')), 'package.json');
|
|
89
|
+
version = fileSystem.readJsonFile(packageJsonPath).version;
|
|
90
|
+
}
|
|
91
|
+
if (!(version.startsWith('1.4.') || version.startsWith('1.5.'))) {
|
|
77
92
|
console.error(`
|
|
78
|
-
@swc/core version ${
|
|
79
|
-
Please use @swc/core version 1.4.x.
|
|
80
|
-
> npm add -D @swc/core@~1.
|
|
93
|
+
@swc/core version ${version} is incompatible with @jscutlery/swc-angular.
|
|
94
|
+
Please use @swc/core version 1.4.x or 1.5.x.
|
|
95
|
+
> npm add -D @swc/core@~1.5.0
|
|
81
96
|
`);
|
|
82
97
|
process.exit(1);
|
|
83
98
|
}
|
package/index.esm.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { version } from '@swc/core';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { join, dirname } from 'node:path';
|
|
2
4
|
|
|
3
5
|
function _extends() {
|
|
4
6
|
_extends = Object.assign || function assign(target) {
|
|
@@ -11,7 +13,15 @@ function _extends() {
|
|
|
11
13
|
return _extends.apply(this, arguments);
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
class FileSystem {
|
|
17
|
+
readJsonFile(path) {
|
|
18
|
+
const content = readFileSync(path, 'utf-8');
|
|
19
|
+
return JSON.parse(content);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const fileSystem = new FileSystem();
|
|
23
|
+
|
|
24
|
+
assertCompatibleSwcCoreVersion(version);
|
|
15
25
|
function swcAngularPreset(options = {}) {
|
|
16
26
|
return {
|
|
17
27
|
jsc: {
|
|
@@ -68,12 +78,17 @@ function swcAngularUnpluginOptions() {
|
|
|
68
78
|
/**
|
|
69
79
|
* @deprecated Use {@link swcAngularVitePreset}, {@link swcAngularJestTransformer} or {@link swcAngularPreset} instead.
|
|
70
80
|
*/ var index = swcAngularPreset();
|
|
71
|
-
function assertCompatibleSwcCoreVersion() {
|
|
72
|
-
|
|
81
|
+
function assertCompatibleSwcCoreVersion(version) {
|
|
82
|
+
/* Fallback to reading version from package.json when not exported.
|
|
83
|
+
* This happens on Stackblitz. */ if (version == undefined) {
|
|
84
|
+
const packageJsonPath = join(dirname(require.resolve('@swc/core')), 'package.json');
|
|
85
|
+
version = fileSystem.readJsonFile(packageJsonPath).version;
|
|
86
|
+
}
|
|
87
|
+
if (!(version.startsWith('1.4.') || version.startsWith('1.5.'))) {
|
|
73
88
|
console.error(`
|
|
74
89
|
@swc/core version ${version} is incompatible with @jscutlery/swc-angular.
|
|
75
|
-
Please use @swc/core version 1.4.x.
|
|
76
|
-
> npm add -D @swc/core@~1.
|
|
90
|
+
Please use @swc/core version 1.4.x or 1.5.x.
|
|
91
|
+
> npm add -D @swc/core@~1.5.0
|
|
77
92
|
`);
|
|
78
93
|
process.exit(1);
|
|
79
94
|
}
|
package/package.json
CHANGED
package/src/utils.d.ts
ADDED