diff --git a/.changeset/tricky-cats-fail.md b/.changeset/tricky-cats-fail.md new file mode 100644 index 000000000..c3c43195b --- /dev/null +++ b/.changeset/tricky-cats-fail.md @@ -0,0 +1,5 @@ +--- +"@modular-css/processor": patch +--- + +chore: only .toString() if dirty when replacing `@value` references diff --git a/packages/processor/plugins/values-replace.js b/packages/processor/plugins/values-replace.js index a8e6c6a1c..492aa4d1e 100644 --- a/packages/processor/plugins/values-replace.js +++ b/packages/processor/plugins/values-replace.js @@ -34,6 +34,7 @@ module.exports = () => ({ const replacer = (prop) => (thing) => { const parsed = value(thing[prop]); + let modified = false; parsed.walk((node) => { if(node.type !== "word" || !values[node.value]) { @@ -47,9 +48,13 @@ module.exports = () => ({ // Replace any value instances node.value = current.value; + + modified = true; }); - thing[prop] = parsed.toString(); + if(modified) { + thing[prop] = parsed.toString(); + } }; return {