external-runtime-plugin.js — react Source File
Architecture documentation for external-runtime-plugin.js, a javascript file in the react codebase.
Entity Profile
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
module.exports = function externalRuntime() {
// When generating the source code for the Fizz runtime chunks we use global identifiers to refer
// to different parts of the implementation. When generating the external runtime we need to
// replace those with local identifiers instead.
return {
name: 'scripts/rollup/plugins/dynamic-imports',
renderChunk(source) {
// This replaces "window['$globalVar']" with "$globalVar".
const variables = new Set();
source = source.replace(
/window\[['"](\$[A-z0-9_]*)['"]\]/g,
(_, variableName) => {
variables.add(variableName);
return variableName;
}
);
const startOfFn = 'use strict';
let index = source.indexOf(startOfFn);
if (index === -1) {
return source;
}
index += startOfFn.length + 2;
// Insert the declarations in the beginning of the function closure
// to scope them to inside the runtime.
let declarations = 'let ';
variables.forEach(variable => {
if (declarations !== 'let ') {
declarations += ', ';
}
declarations += variable;
});
declarations += ';';
source = source.slice(0, index) + declarations + source.slice(index);
return source;
},
};
};
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does external-runtime-plugin.js do?
external-runtime-plugin.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Entrypoint subdomain.
What functions are defined in external-runtime-plugin.js?
external-runtime-plugin.js defines 1 function(s): module.
Where is external-runtime-plugin.js in the architecture?
external-runtime-plugin.js is located at scripts/rollup/plugins/external-runtime-plugin.js (domain: BabelCompiler, subdomain: Entrypoint, directory: scripts/rollup/plugins).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free