Skip to content

Commit

Permalink
fix(core): make metadata available in production (#3714)
Browse files Browse the repository at this point in the history
Co-authored-by: Jovi De Croock <[email protected]>
  • Loading branch information
alpavlove and JoviDeCroock authored Dec 9, 2024
1 parent cf43315 commit 4d1b14e
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
---

Remove `addMetadata` transform where we'd strip out metadata for production environments, this particularly affects `OperationResult.context.metadata.cacheOutcome`
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 4d1b14e

Please sign in to comment.