From 0a31668755cd7cf23e31221dc18948485b227f4f Mon Sep 17 00:00:00 2001 From: "Sergey M." Date: Tue, 24 Sep 2024 01:24:26 +1000 Subject: [PATCH] fix(replace): The `preventAssignment` option is treated as a value to replace (#1768) * Fix `preventAssignment` option treated as a value to replace * Test the change * Test the change * Test the change * Update the test snapshot * chore: update snapshots * chore: use pnpm lock from upstream --------- Co-authored-by: shellscape --- packages/replace/src/index.js | 1 + .../form/observe-plugin-options/_config.js | 3 ++- .../form/observe-plugin-options/input.js | 1 + .../form/observe-plugin-options/output.js | 1 + packages/replace/test/snapshots/form.js.md | 1 + packages/replace/test/snapshots/form.js.snap | Bin 808 -> 816 bytes packages/replace/test/snapshots/misc.js.snap | Bin 399 -> 398 bytes .../replace/test/snapshots/sourcemaps.js.snap | Bin 377 -> 379 bytes 8 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/replace/src/index.js b/packages/replace/src/index.js index 48f624ad8..5d0427769 100755 --- a/packages/replace/src/index.js +++ b/packages/replace/src/index.js @@ -25,6 +25,7 @@ function getReplacements(options) { delete values.sourcemap; delete values.sourceMap; delete values.objectGuards; + delete values.preventAssignment; return values; } diff --git a/packages/replace/test/fixtures/form/observe-plugin-options/_config.js b/packages/replace/test/fixtures/form/observe-plugin-options/_config.js index 5d1b7ba76..f472fef74 100755 --- a/packages/replace/test/fixtures/form/observe-plugin-options/_config.js +++ b/packages/replace/test/fixtures/form/observe-plugin-options/_config.js @@ -6,6 +6,7 @@ module.exports = { sourcemap: true, sourceMap: true, include: '**/input.js', - exclude: 'node_modules/**' + exclude: 'node_modules/**', + preventAssignment: false } }; diff --git a/packages/replace/test/fixtures/form/observe-plugin-options/input.js b/packages/replace/test/fixtures/form/observe-plugin-options/input.js index 58a951275..3c553f2cc 100755 --- a/packages/replace/test/fixtures/form/observe-plugin-options/input.js +++ b/packages/replace/test/fixtures/form/observe-plugin-options/input.js @@ -5,4 +5,5 @@ console.log(` sourceMap include exclude + preventAssignment `); diff --git a/packages/replace/test/fixtures/form/observe-plugin-options/output.js b/packages/replace/test/fixtures/form/observe-plugin-options/output.js index cbf28032f..df587965c 100755 --- a/packages/replace/test/fixtures/form/observe-plugin-options/output.js +++ b/packages/replace/test/fixtures/form/observe-plugin-options/output.js @@ -5,4 +5,5 @@ console.log(` sourceMap include exclude + preventAssignment `); diff --git a/packages/replace/test/snapshots/form.js.md b/packages/replace/test/snapshots/form.js.md index 014ff876f..e8b50f05c 100644 --- a/packages/replace/test/snapshots/form.js.md +++ b/packages/replace/test/snapshots/form.js.md @@ -37,6 +37,7 @@ Generated by [AVA](https://avajs.dev). sourceMap␊ include␊ exclude␊ + preventAssignment␊ \`);` ## process-check: Handles process type guards in replacements diff --git a/packages/replace/test/snapshots/form.js.snap b/packages/replace/test/snapshots/form.js.snap index 297ea1cd9c369fa459394862cd73bffa5f8bd375..310c56eb38c632cf1ac77b555dd5599f00682428 100644 GIT binary patch literal 816 zcmV-01JC?HRzVW zQP0EIN3XuTg&2H?05f+bU=SZQNAqNmSx5uPBeSOPDuGm^RWd3Z(OUL+JMbNlEPj zAt~>zKuL{WU7Y)75?Dwr%pw$qXSrwB{?)69jZ)LAF*FNc?@ zfKQoaeD$88EY1H%P#i*a*iQMTk@9(7s{^AEV%WRZk%lEkW93F%0@Yu9g%?!_7Sc^` zg*R#7eY;`myXCrLQ=-VpEfc!hAL}Ty}Q1SD*5IhgLIt5ttM$bH>*Cs{BTf z6bOY5O5GLg-y7_o`aA!52|Il+k(M01077oGfC$`FS}|-GywvO#lHHY}B7T_<5OFJ0 u7YO8vS-k1{R;i&-x4}mZ@Ij%2Rd0MeJU)tw8Eas!{r?9!_sxEL2LJ%RnuzuQ literal 808 zcmV+@1K0dPRzVf#q(1H zYEObA4j+pM00000000Axl}&HcKoEvoA%x@`S2!?@RGd_Gk|HFiQ-=>xK#0NtRe}Rj zH@lN$+s&@Evrbwe4qQ0#C(18H{)%nfR?TU5_I2i&cW3O&=|mZRMt}aIlTP9JkP*q5 zUZ8d%2!o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olSHNi5g%(xBoF8e>p!B`F-Wy`M9wj! zh^NvTv$I diff --git a/packages/replace/test/snapshots/sourcemaps.js.snap b/packages/replace/test/snapshots/sourcemaps.js.snap index 8771f707488d59206fffb4afeb8ab8d644af0534..d6aa9654373caa1d7576c65f84fab6998be7636d 100644 GIT binary patch literal 379 zcmV->0fhcRRzVYuO|n!{ zEXJ0H6CP1tWZEff#MllKXCG!!B%HW>@leC!usZWk0Gt810&oYQ!-6&oF2WH>$Jl4t zYPG-`U>;Z#9acG5RMj@ylS7dT=_vi^_-udeK_C;I#b%4@Yh@_cSdRDh1+RJv;2gj; zfGL2d?-Bh%f@TrHx@JVY)V#*}r%SI_*LvcHl=en8pW%6%#nXSVxLq_L3g+{2y7?xD z7jzQ~~M^=24(habxaZ!Ah&(_Fx1WGH$^zljfO# zgij0$rYwYr=gLZ>F%hTMJj}z8TYmZCkPayp?Navy;~C-#afjHW-hg@+!5D<4^mFU` zKA}BA9YXtfr?p?~+5@^HVxDnfA^XU z4Ds|mMYongzm7q*rg^fgIlbzmORZPOZfax5j>e|!;dzt9vwx6yP}d-->CY+IE!HVq zu$v+t|EO>sf!41D?j&4l)OY3j;ab