Skip to content

Commit

Permalink
fix: an issue where addMetadata calls were stripped in production m…
Browse files Browse the repository at this point in the history
…ode, ensuring consistent metadata availability (e.g., `cacheOutcome`) in both development and production environments
  • Loading branch information
alpavlove committed Dec 5, 2024
1 parent cf43315 commit 56ae8e5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-starfishes-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@urql/core': minor
---

Fixes an issue where `addMetadata` calls were stripped in production mode, ensuring consistent metadata availability (e.g., `cacheOutcome`) in both development and production environments
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,6 @@
},
"engines": {
"pnpm": ">=9.0.0"
}
},
"packageManager": "[email protected]+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
}
16 changes: 0 additions & 16 deletions scripts/babel/transform-debug-target.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@ const warningDevCheckTemplate = `
process.env.NODE_ENV !== 'production' ? NODE : undefined
`.trim();

const noopTransformTemplate = `
process.env.NODE_ENV !== 'production' ? NODE : FALLBACK
`.trim();

const plugin = ({ template, types: t }) => {
const wrapWithDevCheck = template.expression(warningDevCheckTemplate, {
placeholderPattern: /^NODE$/,
});

const wrapWithNoopTransform = template.expression(noopTransformTemplate, {
placeholderPattern: /^(NODE|FALLBACK)$/,
});

let name = 'unknownExchange';

return {
Expand Down Expand Up @@ -47,14 +39,6 @@ const plugin = ({ template, types: t }) => {
}

path.replaceWith(wrapWithDevCheck({ NODE: path.node }));
} else if (path.node.callee.name === 'addMetadata') {
path.node[visited] = true;
path.replaceWith(
wrapWithNoopTransform({
NODE: path.node,
FALLBACK: path.node.arguments[0],
})
);
}
},
},
Expand Down

0 comments on commit 56ae8e5

Please sign in to comment.