wrapWithTopLevelDefinitions() — react Function Reference
Architecture documentation for the wrapWithTopLevelDefinitions() function in wrappers.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD f7a8465f_031f_4135_492d_60fa9de72501["wrapWithTopLevelDefinitions()"] 0a96609e_e37e_0b13_8c4d_e99f38daf174["wrappers.js"] f7a8465f_031f_4135_492d_60fa9de72501 -->|defined in| 0a96609e_e37e_0b13_8c4d_e99f38daf174 ebb8cf09_71f9_7943_0c84_19b826974c90["wrapWithRegisterInternalModule()"] f7a8465f_031f_4135_492d_60fa9de72501 -->|calls| ebb8cf09_71f9_7943_0c84_19b826974c90 style f7a8465f_031f_4135_492d_60fa9de72501 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
scripts/rollup/wrappers.js lines 507–563
function wrapWithTopLevelDefinitions(
source,
bundleType,
globalName,
filename,
moduleType,
wrapWithModuleBoundaries
) {
if (wrapWithModuleBoundaries) {
switch (bundleType) {
case NODE_DEV:
case NODE_PROFILING:
case FB_WWW_DEV:
case FB_WWW_PROFILING:
case RN_OSS_DEV:
case RN_OSS_PROFILING:
case RN_FB_DEV:
case RN_FB_PROFILING:
// Remove the 'use strict' directive from source.
// The module start wrapper will add its own.
// This directive is only meaningful when it is the first statement in a file or function.
source = source.replace(USE_STRICT_HEADER_REGEX, '');
// Certain DEV and Profiling bundles should self-register their own module boundaries with DevTools.
// This allows the Timeline to de-emphasize (dim) internal stack frames.
source = wrapWithRegisterInternalModule(source);
break;
}
}
if (bundleType === BROWSER_SCRIPT) {
// Bundles of type BROWSER_SCRIPT get sent straight to the browser without
// additional processing. So we should exclude any extra wrapper comments.
return source;
}
if (moduleType === RECONCILER) {
// Standalone reconciler is only used by third-party renderers.
// It is handled separately.
const wrapper = reconcilerWrappers[bundleType];
if (typeof wrapper !== 'function') {
throw new Error(
`Unsupported build type for the reconciler package: ${bundleType}.`
);
}
return wrapper(source, globalName, filename, moduleType);
}
// All the other packages.
const wrapper = topLevelDefinitionWrappers[bundleType];
if (typeof wrapper !== 'function') {
throw new Error(`Unsupported build type: ${bundleType}.`);
}
return wrapper(source, globalName, filename, moduleType);
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does wrapWithTopLevelDefinitions() do?
wrapWithTopLevelDefinitions() is a function in the react codebase, defined in scripts/rollup/wrappers.js.
Where is wrapWithTopLevelDefinitions() defined?
wrapWithTopLevelDefinitions() is defined in scripts/rollup/wrappers.js at line 507.
What does wrapWithTopLevelDefinitions() call?
wrapWithTopLevelDefinitions() calls 1 function(s): wrapWithRegisterInternalModule.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free