From 8853bc13bc41dc13c5d31565e48b2c6f6273dfb1 Mon Sep 17 00:00:00 2001 From: yukai <645481746@qq.com> Date: Sat, 30 Nov 2024 13:14:41 +0800 Subject: [PATCH] fix(replace): ignore values option when pass an empty value --- 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 816 -> 825 bytes 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/replace/src/index.js b/packages/replace/src/index.js index 5d0427769..f671e8632 100755 --- a/packages/replace/src/index.js +++ b/packages/replace/src/index.js @@ -26,6 +26,7 @@ function getReplacements(options) { delete values.sourceMap; delete values.objectGuards; delete values.preventAssignment; + delete values.values; 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 f472fef74..7a78c2e20 100755 --- a/packages/replace/test/fixtures/form/observe-plugin-options/_config.js +++ b/packages/replace/test/fixtures/form/observe-plugin-options/_config.js @@ -7,6 +7,7 @@ module.exports = { sourceMap: true, include: '**/input.js', exclude: 'node_modules/**', - preventAssignment: false + preventAssignment: false, + values: undefined } }; 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 3c553f2cc..ca62878a0 100755 --- a/packages/replace/test/fixtures/form/observe-plugin-options/input.js +++ b/packages/replace/test/fixtures/form/observe-plugin-options/input.js @@ -6,4 +6,5 @@ console.log(` include exclude preventAssignment + values `); 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 df587965c..14ad69639 100755 --- a/packages/replace/test/fixtures/form/observe-plugin-options/output.js +++ b/packages/replace/test/fixtures/form/observe-plugin-options/output.js @@ -6,4 +6,5 @@ console.log(` include exclude preventAssignment + values `); diff --git a/packages/replace/test/snapshots/form.js.md b/packages/replace/test/snapshots/form.js.md index e8b50f05c..af63073db 100644 --- a/packages/replace/test/snapshots/form.js.md +++ b/packages/replace/test/snapshots/form.js.md @@ -38,6 +38,7 @@ Generated by [AVA](https://avajs.dev). include␊ exclude␊ preventAssignment␊ + values␊ \`);` ## 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 310c56eb38c632cf1ac77b555dd5599f00682428..12ae908dd97d4a9ed893b71e59956f422fcade3c 100644 GIT binary patch literal 825 zcmV-91IGM8RzVv?%J!ltkY0M~mq$I&Et&paWOYeUh=>HQP9EA zZYr4d(yqyd6v`3XIKWe8gd~`aFgZb6G%C$jWV~{L|Nf|y2;z^?H%B**irQ5p|Nqx z;rj?Ru!?}k$8cURwH4<0yxiAY9G^$;M+b=MS_HXDHo|K$H^eE*05R5%12`k87h2*V z=u=HQRD(8EJf|SADT;9x_r}xlG;VS~tcp%DlP|SRTo$ymyuSfh*IdC~fJ)Fu_|QS{ z*BH~-8v*QcFKI2Z!}?{p)>fKaQ3TMgUS*y(WW&=#3q(NK7~Hlqt?oUME0UKfeic?3 zVpL&-tBkPBg;!iOR0UQ%?lV>W)2V8w7Z?uQ{DNc{;Pz~WIJb%x+LDTKa)QIzY&L5) z#X;ts%4Ol*{xEI=@d$rLK_g3 ziU;?5J3WO(%=omhPqy#<(rF+W^5~P7tU?eZXM{@D}Yd=K~ZiL~a5G+Gcqe zU-00Nd{R!aFo|3VFXaA(!+BQxk5L_>IqawWxs&oyQEPy+gc5Vkt3z6x*I!Fzkn_z&y#s2KVEqs>(@=+&krA1n99t*Pwn;ix_3r-8f`{wi@9 zc@dm%^;P|`V66z14z=zx?C(14uP1jt@e+3?(L#F;cmgKrtU`*g(q5f)3@$ZyE6Lrx zq9OjV7$BBjXCYA}jqr5chpthhQuo2nJK)nwhkb9ndiwHtTFqDo^WgvgClZjAga-fs Du1=lr literal 816 zcmV-01JC?HRzVW zQ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