Skip to content

Commit 93c45c6

Browse files
authored
fix: enable Lightning CSS errorRecovery option (#5052)
1 parent 09c9576 commit 93c45c6

File tree

11 files changed

+49
-5
lines changed

11 files changed

+49
-5
lines changed

packages/core/src/plugins/css.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const getLightningCSSLoaderOptions = (
4040

4141
const initialOptions: Rspack.LightningcssLoaderOptions = {
4242
targets,
43+
errorRecovery: true,
4344
};
4445

4546
if (minify) {

packages/core/tests/__snapshots__/builder.test.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ exports[`should use Rspack as the default bundler > apply Rspack correctly 1`] =
6363
{
6464
"loader": "builtin:lightningcss-loader",
6565
"options": {
66+
"errorRecovery": true,
6667
"targets": [
6768
"chrome >= 87",
6869
"edge >= 88",
@@ -94,6 +95,7 @@ exports[`should use Rspack as the default bundler > apply Rspack correctly 1`] =
9495
{
9596
"loader": "builtin:lightningcss-loader",
9697
"options": {
98+
"errorRecovery": true,
9799
"targets": [
98100
"chrome >= 87",
99101
"edge >= 88",

packages/core/tests/__snapshots__/css.test.ts.snap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ exports[`plugin-css > should use custom cssModules rule when using output.cssMod
3838
{
3939
"loader": "builtin:lightningcss-loader",
4040
"options": {
41+
"errorRecovery": true,
4142
"targets": [
4243
"chrome >= 87",
4344
"edge >= 88",
@@ -69,6 +70,7 @@ exports[`plugin-css > should use custom cssModules rule when using output.cssMod
6970
{
7071
"loader": "builtin:lightningcss-loader",
7172
"options": {
73+
"errorRecovery": true,
7274
"targets": [
7375
"chrome >= 87",
7476
"edge >= 88",
@@ -212,6 +214,7 @@ exports[`plugin-css injectStyles > should use css-loader + style-loader when inj
212214
{
213215
"loader": "builtin:lightningcss-loader",
214216
"options": {
217+
"errorRecovery": true,
215218
"targets": [
216219
"chrome >= 87",
217220
"edge >= 88",
@@ -243,6 +246,7 @@ exports[`plugin-css injectStyles > should use css-loader + style-loader when inj
243246
{
244247
"loader": "builtin:lightningcss-loader",
245248
"options": {
249+
"errorRecovery": true,
246250
"targets": [
247251
"chrome >= 87",
248252
"edge >= 88",
@@ -304,6 +308,7 @@ exports[`should ensure isolation of PostCSS config objects between different bui
304308
{
305309
"loader": "builtin:lightningcss-loader",
306310
"options": {
311+
"errorRecovery": true,
307312
"targets": [
308313
"chrome >= 87",
309314
"edge >= 88",
@@ -350,6 +355,7 @@ exports[`should ensure isolation of PostCSS config objects between different bui
350355
{
351356
"loader": "builtin:lightningcss-loader",
352357
"options": {
358+
"errorRecovery": true,
353359
"targets": [
354360
"chrome >= 87",
355361
"edge >= 88",
@@ -419,6 +425,7 @@ exports[`should ensure isolation of PostCSS config objects between different bui
419425
{
420426
"loader": "builtin:lightningcss-loader",
421427
"options": {
428+
"errorRecovery": true,
422429
"targets": [
423430
"chrome >= 87",
424431
"edge >= 88",
@@ -465,6 +472,7 @@ exports[`should ensure isolation of PostCSS config objects between different bui
465472
{
466473
"loader": "builtin:lightningcss-loader",
467474
"options": {
475+
"errorRecovery": true,
468476
"targets": [
469477
"chrome >= 87",
470478
"edge >= 88",

packages/core/tests/__snapshots__/default.test.ts.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
6363
{
6464
"loader": "builtin:lightningcss-loader",
6565
"options": {
66+
"errorRecovery": true,
6667
"targets": [
6768
"chrome >= 87",
6869
"edge >= 88",
@@ -94,6 +95,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
9495
{
9596
"loader": "builtin:lightningcss-loader",
9697
"options": {
98+
"errorRecovery": true,
9799
"targets": [
98100
"chrome >= 87",
99101
"edge >= 88",
@@ -541,6 +543,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when prod
541543
{
542544
"loader": "builtin:lightningcss-loader",
543545
"options": {
546+
"errorRecovery": true,
544547
"targets": [
545548
"chrome >= 87",
546549
"edge >= 88",
@@ -572,6 +575,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when prod
572575
{
573576
"loader": "builtin:lightningcss-loader",
574577
"options": {
578+
"errorRecovery": true,
575579
"minify": true,
576580
"targets": [
577581
"chrome >= 87",
@@ -839,6 +843,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when prod
839843
"_args": [
840844
{
841845
"minimizerOptions": {
846+
"errorRecovery": true,
842847
"targets": [
843848
"chrome >= 87",
844849
"edge >= 88",
@@ -1462,6 +1467,7 @@ exports[`tools.rspack > should match snapshot 1`] = `
14621467
{
14631468
"loader": "builtin:lightningcss-loader",
14641469
"options": {
1470+
"errorRecovery": true,
14651471
"targets": [
14661472
"chrome >= 87",
14671473
"edge >= 88",
@@ -1493,6 +1499,7 @@ exports[`tools.rspack > should match snapshot 1`] = `
14931499
{
14941500
"loader": "builtin:lightningcss-loader",
14951501
"options": {
1502+
"errorRecovery": true,
14961503
"targets": [
14971504
"chrome >= 87",
14981505
"edge >= 88",

packages/core/tests/__snapshots__/environments.test.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,7 @@ exports[`environment config > tools.rspack / bundlerChain can be configured in e
13581358
{
13591359
"loader": "builtin:lightningcss-loader",
13601360
"options": {
1361+
"errorRecovery": true,
13611362
"targets": [
13621363
"chrome >= 87",
13631364
"edge >= 88",
@@ -1389,6 +1390,7 @@ exports[`environment config > tools.rspack / bundlerChain can be configured in e
13891390
{
13901391
"loader": "builtin:lightningcss-loader",
13911392
"options": {
1393+
"errorRecovery": true,
13921394
"targets": [
13931395
"chrome >= 87",
13941396
"edge >= 88",

packages/core/tests/minimize.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ describe('plugin-minimize', () => {
4646
"_args": [
4747
{
4848
"minimizerOptions": {
49+
"errorRecovery": true,
4950
"targets": [
5051
"chrome >= 87",
5152
"edge >= 88",
@@ -204,6 +205,7 @@ describe('plugin-minimize', () => {
204205
"_args": [
205206
{
206207
"minimizerOptions": {
208+
"errorRecovery": true,
207209
"targets": [
208210
"chrome >= 87",
209211
"edge >= 88",
@@ -264,6 +266,7 @@ describe('plugin-minimize', () => {
264266
"_args": [
265267
{
266268
"minimizerOptions": {
269+
"errorRecovery": true,
267270
"targets": [
268271
"chrome >= 87",
269272
"edge >= 88",
@@ -318,6 +321,7 @@ describe('plugin-minimize', () => {
318321
"_args": [
319322
{
320323
"minimizerOptions": {
324+
"errorRecovery": true,
321325
"targets": [
322326
"chrome >= 87",
323327
"edge >= 88",

packages/plugin-less/tests/__snapshots__/index.test.ts.snap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ exports[`plugin-less > should add less-loader 1`] = `
3535
{
3636
"loader": "builtin:lightningcss-loader",
3737
"options": {
38+
"errorRecovery": true,
3839
"targets": [
3940
"chrome >= 87",
4041
"edge >= 88",
@@ -74,6 +75,7 @@ exports[`plugin-less > should add less-loader 1`] = `
7475
{
7576
"loader": "builtin:lightningcss-loader",
7677
"options": {
78+
"errorRecovery": true,
7779
"targets": [
7880
"chrome >= 87",
7981
"edge >= 88",
@@ -140,6 +142,7 @@ exports[`plugin-less > should add less-loader and css-loader when injectStyles 1
140142
{
141143
"loader": "builtin:lightningcss-loader",
142144
"options": {
145+
"errorRecovery": true,
143146
"targets": [
144147
"chrome >= 87",
145148
"edge >= 88",
@@ -179,6 +182,7 @@ exports[`plugin-less > should add less-loader and css-loader when injectStyles 1
179182
{
180183
"loader": "builtin:lightningcss-loader",
181184
"options": {
185+
"errorRecovery": true,
182186
"targets": [
183187
"chrome >= 87",
184188
"edge >= 88",
@@ -248,6 +252,7 @@ exports[`plugin-less > should add less-loader with excludes 1`] = `
248252
{
249253
"loader": "builtin:lightningcss-loader",
250254
"options": {
255+
"errorRecovery": true,
251256
"targets": [
252257
"chrome >= 87",
253258
"edge >= 88",
@@ -290,6 +295,7 @@ exports[`plugin-less > should add less-loader with excludes 1`] = `
290295
{
291296
"loader": "builtin:lightningcss-loader",
292297
"options": {
298+
"errorRecovery": true,
293299
"targets": [
294300
"chrome >= 87",
295301
"edge >= 88",
@@ -356,6 +362,7 @@ exports[`plugin-less > should add less-loader with tools.less 1`] = `
356362
{
357363
"loader": "builtin:lightningcss-loader",
358364
"options": {
365+
"errorRecovery": true,
359366
"targets": [
360367
"chrome >= 87",
361368
"edge >= 88",
@@ -395,6 +402,7 @@ exports[`plugin-less > should add less-loader with tools.less 1`] = `
395402
{
396403
"loader": "builtin:lightningcss-loader",
397404
"options": {
405+
"errorRecovery": true,
398406
"targets": [
399407
"chrome >= 87",
400408
"edge >= 88",
@@ -461,6 +469,7 @@ exports[`plugin-less > should allow to use Less plugins 1`] = `
461469
{
462470
"loader": "builtin:lightningcss-loader",
463471
"options": {
472+
"errorRecovery": true,
464473
"targets": [
465474
"chrome >= 87",
466475
"edge >= 88",
@@ -507,6 +516,7 @@ exports[`plugin-less > should allow to use Less plugins 1`] = `
507516
{
508517
"loader": "builtin:lightningcss-loader",
509518
"options": {
519+
"errorRecovery": true,
510520
"targets": [
511521
"chrome >= 87",
512522
"edge >= 88",

packages/plugin-sass/tests/__snapshots__/index.test.ts.snap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ exports[`plugin-sass > should add sass-loader 1`] = `
3535
{
3636
"loader": "builtin:lightningcss-loader",
3737
"options": {
38+
"errorRecovery": true,
3839
"targets": [
3940
"chrome >= 87",
4041
"edge >= 88",
@@ -82,6 +83,7 @@ exports[`plugin-sass > should add sass-loader 1`] = `
8283
{
8384
"loader": "builtin:lightningcss-loader",
8485
"options": {
86+
"errorRecovery": true,
8587
"targets": [
8688
"chrome >= 87",
8789
"edge >= 88",
@@ -156,6 +158,7 @@ exports[`plugin-sass > should add sass-loader and css-loader when injectStyles 1
156158
{
157159
"loader": "builtin:lightningcss-loader",
158160
"options": {
161+
"errorRecovery": true,
159162
"targets": [
160163
"chrome >= 87",
161164
"edge >= 88",
@@ -203,6 +206,7 @@ exports[`plugin-sass > should add sass-loader and css-loader when injectStyles 1
203206
{
204207
"loader": "builtin:lightningcss-loader",
205208
"options": {
209+
"errorRecovery": true,
206210
"targets": [
207211
"chrome >= 87",
208212
"edge >= 88",
@@ -280,6 +284,7 @@ exports[`plugin-sass > should add sass-loader with excludes 1`] = `
280284
{
281285
"loader": "builtin:lightningcss-loader",
282286
"options": {
287+
"errorRecovery": true,
283288
"targets": [
284289
"chrome >= 87",
285290
"edge >= 88",
@@ -330,6 +335,7 @@ exports[`plugin-sass > should add sass-loader with excludes 1`] = `
330335
{
331336
"loader": "builtin:lightningcss-loader",
332337
"options": {
338+
"errorRecovery": true,
333339
"targets": [
334340
"chrome >= 87",
335341
"edge >= 88",
@@ -404,6 +410,7 @@ exports[`plugin-sass > should allow to use legacy API and mute deprecation warni
404410
{
405411
"loader": "builtin:lightningcss-loader",
406412
"options": {
413+
"errorRecovery": true,
407414
"targets": [
408415
"chrome >= 87",
409416
"edge >= 88",
@@ -452,6 +459,7 @@ exports[`plugin-sass > should allow to use legacy API and mute deprecation warni
452459
{
453460
"loader": "builtin:lightningcss-loader",
454461
"options": {
462+
"errorRecovery": true,
455463
"targets": [
456464
"chrome >= 87",
457465
"edge >= 88",

packages/plugin-stylus/tests/__snapshots__/index.test.ts.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ exports[`plugin-stylus > should add stylus loader config correctly 1`] = `
3535
{
3636
"loader": "builtin:lightningcss-loader",
3737
"options": {
38+
"errorRecovery": true,
3839
"targets": [
3940
"chrome >= 87",
4041
"edge >= 88",
@@ -67,6 +68,7 @@ exports[`plugin-stylus > should add stylus loader config correctly 1`] = `
6768
{
6869
"loader": "builtin:lightningcss-loader",
6970
"options": {
71+
"errorRecovery": true,
7072
"targets": [
7173
"chrome >= 87",
7274
"edge >= 88",
@@ -126,6 +128,7 @@ exports[`plugin-stylus > should allow to configure stylus options 1`] = `
126128
{
127129
"loader": "builtin:lightningcss-loader",
128130
"options": {
131+
"errorRecovery": true,
129132
"targets": [
130133
"chrome >= 87",
131134
"edge >= 88",
@@ -161,6 +164,7 @@ exports[`plugin-stylus > should allow to configure stylus options 1`] = `
161164
{
162165
"loader": "builtin:lightningcss-loader",
163166
"options": {
167+
"errorRecovery": true,
164168
"targets": [
165169
"chrome >= 87",
166170
"edge >= 88",

website/docs/en/config/tools/lightningcss-loader.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55

66
```ts
77
const defaultOptions = {
8-
// use current browserslist config
8+
errorRecovery: true,
9+
// use current project's browserslist config
910
targets: browserslist,
1011
// minify is enabled when output.injectStyles is true and in production mode
1112
minify: config.mode === 'production' && config.output.injectStyles,
1213
};
1314
```
1415

15-
- **Version:** `>= 1.0.0`
16-
1716
You can set the options for [builtin:lightningcss-loader](https://rspack.dev/guide/features/builtin-lightningcss-loader) through `tools.lightningcssLoader`.
1817

1918
## Object type

0 commit comments

Comments
 (0)