Commit 0475403
authored
fix(cli): Fix configuration reuse issue in swcDir() by deep clone (#95)
- **Issue:** The `swcDir()` function in the `@swc` project was
experiencing configuration reuse issues due to shared references in the
options object. This led to unintended side effects when compiling
different module types (ESM and CommonJS) in the same process.
- **Fix:** Implemented a `deepClone` function to ensure complete
isolation of configuration objects. This prevents shared references and
ensures that modifications to one configuration do not affect others.
- **Testing:**
- Created a comprehensive test suite to verify the functionality of the
`deepClone` function. The tests demonstrated that deep cloning maintains
object isolation, while shallow cloning does not.
- Conducted end-to-end tests by simulating the compilation of both ESM
and CommonJS modules. Verified that the output file extensions were
correct and that the configurations were isolated, confirming the
effectiveness of the fix.
Closes #971 parent 3351d6b commit 0475403
File tree
4 files changed
+79
-20
lines changed- .changeset
- packages/cli/src/swc
4 files changed
+79
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
404 | | - | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
405 | 407 | | |
406 | | - | |
407 | | - | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
408 | 412 | | |
409 | 413 | | |
410 | | - | |
| 414 | + | |
411 | 415 | | |
412 | 416 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
18 | 21 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
23 | 26 | | |
24 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
25 | 31 | | |
26 | | - | |
| 32 | + | |
| 33 | + | |
27 | 34 | | |
28 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
29 | 45 | | |
30 | 46 | | |
31 | 47 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
36 | 52 | | |
37 | 53 | | |
38 | 54 | | |
39 | 55 | | |
40 | | - | |
| 56 | + | |
41 | 57 | | |
42 | 58 | | |
43 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
7 | 30 | | |
8 | 31 | | |
9 | 32 | | |
| |||
43 | 66 | | |
44 | 67 | | |
45 | 68 | | |
46 | | - | |
| 69 | + | |
| 70 | + | |
47 | 71 | | |
48 | | - | |
| 72 | + | |
| 73 | + | |
49 | 74 | | |
50 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
51 | 85 | | |
52 | 86 | | |
53 | 87 | | |
| |||
0 commit comments