Commit d29cd2a
authored
Turbopack: Replace heuristics for detecting manually-configured sass or babel loaders with less-fragile ones, configure rules as a vec and not a map (#83131)
- There was very fragile logic in the sass and babel loaders for trying to detect existing configuration and extend them. I've replaced this with some more advanced heuristics and a warning. See also: https://vercel.slack.com/archives/C03EWR7LGEN/p1756320263002989
- The old logic would break if you used any globs other than the *exact* ones that the code expected.
- Some of this was probably motivated by the map data structure used, which didn't allow duplicate globs as keys.
- The new logic tries to look for a combination of globs and/or loader names, and is only used to control a warning, not to change any behavior.
- Convert rules to a vec instead of a map. This lets us duplicate `glob` keys, which will make supporting the array syntax proposed in #82857 (not implemented there, will come later) easier. Eventually these get turned into an array anyways when `ModuleOptions::new()` is run.
- Remove the `OptionWebpackRules` wrapper type. We can just use an empty `Vec` to represent the `None` state, as they're logically equivalent, and an empty `Vec` requires zero heap allocations. This simplifies the code and reduces the number of cells we need to create.
- Add a couple experimental options for force-disabling the auto-configured babel and sass loaders, as an escape hatch. It seems pretty unlikely that many people will need this, so I'm not spending much time/effort on it. This at least seems better than the previous implicit check.
- This might be useful for somebody who wants to use a `babelrc` with webpack, but not with Turbopack.1 parent c370fb6 commit d29cd2a
10 files changed
Lines changed: 409 additions & 221 deletions
File tree
- crates/next-core/src
- next_client
- next_server
- packages/next/src/server
- turbopack/crates
- turbo-tasks/src
- turbopack/src/module_options
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | | - | |
| 251 | + | |
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
| 255 | + | |
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
868 | 868 | | |
869 | 869 | | |
870 | 870 | | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
871 | 878 | | |
872 | 879 | | |
873 | 880 | | |
| |||
1377 | 1384 | | |
1378 | 1385 | | |
1379 | 1386 | | |
1380 | | - | |
| 1387 | + | |
1381 | 1388 | | |
1382 | | - | |
| 1389 | + | |
1383 | 1390 | | |
1384 | 1391 | | |
1385 | | - | |
| 1392 | + | |
1386 | 1393 | | |
1387 | | - | |
| 1394 | + | |
1388 | 1395 | | |
1389 | 1396 | | |
1390 | 1397 | | |
| |||
1440 | 1447 | | |
1441 | 1448 | | |
1442 | 1449 | | |
1443 | | - | |
| 1450 | + | |
1444 | 1451 | | |
1445 | 1452 | | |
1446 | 1453 | | |
1447 | 1454 | | |
1448 | 1455 | | |
1449 | 1456 | | |
1450 | | - | |
| 1457 | + | |
1451 | 1458 | | |
1452 | 1459 | | |
1453 | 1460 | | |
| |||
1489 | 1496 | | |
1490 | 1497 | | |
1491 | 1498 | | |
1492 | | - | |
| 1499 | + | |
1493 | 1500 | | |
1494 | 1501 | | |
1495 | 1502 | | |
1496 | 1503 | | |
1497 | 1504 | | |
1498 | 1505 | | |
1499 | | - | |
| 1506 | + | |
1500 | 1507 | | |
1501 | 1508 | | |
1502 | 1509 | | |
1503 | 1510 | | |
1504 | | - | |
| 1511 | + | |
1505 | 1512 | | |
1506 | 1513 | | |
1507 | 1514 | | |
| |||
1638 | 1645 | | |
1639 | 1646 | | |
1640 | 1647 | | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
1641 | 1658 | | |
1642 | 1659 | | |
1643 | 1660 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
496 | | - | |
| 496 | + | |
497 | 497 | | |
498 | 498 | | |
499 | 499 | | |
500 | | - | |
| 500 | + | |
501 | 501 | | |
502 | 502 | | |
503 | 503 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | | - | |
| 4 | + | |
| 5 | + | |
3 | 6 | | |
4 | 7 | | |
5 | | - | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| 16 | + | |
| 17 | + | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
| |||
22 | 27 | | |
23 | 28 | | |
24 | 29 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 30 | + | |
| 31 | + | |
44 | 32 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
85 | 48 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
106 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
107 | 66 | | |
108 | | - | |
109 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
110 | 79 | | |
| 80 | + | |
| 81 | + | |
111 | 82 | | |
112 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
113 | 95 | | |
114 | 96 | | |
115 | 97 | | |
| |||
0 commit comments