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 2c63917
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 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
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 2c63917

Please sign in to comment.