AnonymizePlugin() — react Function Reference
Architecture documentation for the AnonymizePlugin() function in anonymize.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 3c4a86cc_3eda_29ff_ff0d_09ed8d407a13["AnonymizePlugin()"] f0bcfde9_0591_4dd2_4c3d_65791a7c39fd["anonymize.js"] 3c4a86cc_3eda_29ff_ff0d_09ed8d407a13 -->|defined in| f0bcfde9_0591_4dd2_4c3d_65791a7c39fd style 3c4a86cc_3eda_29ff_ff0d_09ed8d407a13 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/scripts/anonymize.js lines 149–233
function AnonymizePlugin(_babel) {
let index = 0;
const identifiers = new Map();
const literals = new Map();
return {
name: 'anonymize',
visitor: {
JSXNamespacedName(path) {
throw error('TODO: handle JSXNamedspacedName');
},
JSXIdentifier(path) {
const name = path.node.name;
if (TAG_NAMES.has(name)) {
return;
}
let nextName = identifiers.get(name);
if (nextName == null) {
const isCapitalized =
name.slice(0, 1).toUpperCase() === name.slice(0, 1);
nextName = isCapitalized
? `Component${(index++).toString(16).toUpperCase()}`
: `c${(index++).toString(16)}`;
identifiers.set(name, nextName);
}
path.node.name = nextName;
},
Identifier(path) {
const name = path.node.name;
if (BUILTIN_HOOKS.has(name) || GLOBALS.has(name)) {
return;
}
let nextName = identifiers.get(name);
if (nextName == null) {
const isCapitalized =
name.slice(0, 1).toUpperCase() === name.slice(0, 1);
const prefix = isCapitalized ? 'V' : 'v';
nextName = `${prefix}${(index++).toString(16)}`;
if (name.startsWith('use')) {
nextName =
'use' + nextName.slice(0, 1).toUpperCase() + nextName.slice(1);
}
identifiers.set(name, nextName);
}
path.node.name = nextName;
},
JSXText(path) {
const value = path.node.value;
let nextValue = literals.get(value);
if (nextValue == null) {
let string = '';
while (string.length < value.length) {
string += String.fromCharCode(Math.round(Math.random() * 25) + 97);
}
nextValue = string;
literals.set(value, nextValue);
}
path.node.value = nextValue;
},
StringLiteral(path) {
const value = path.node.value;
let nextValue = literals.get(value);
if (nextValue == null) {
let string = '';
while (string.length < value.length) {
string += String.fromCharCode(Math.round(Math.random() * 58) + 65);
}
nextValue = string;
literals.set(value, nextValue);
}
path.node.value = nextValue;
},
NumericLiteral(path) {
const value = path.node.value;
let nextValue = literals.get(value);
if (nextValue == null) {
nextValue = Number.isInteger(value)
? Math.round(Math.random() * Number.MAX_SAFE_INTEGER)
: Math.random() * Number.MAX_VALUE;
literals.set(value, nextValue);
}
path.node.value = nextValue;
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does AnonymizePlugin() do?
AnonymizePlugin() is a function in the react codebase, defined in compiler/scripts/anonymize.js.
Where is AnonymizePlugin() defined?
AnonymizePlugin() is defined in compiler/scripts/anonymize.js at line 149.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free