MCPcopy
hub / github.com/CesiumGS/cesium / createIndexJs

Function createIndexJs

scripts/build.js:813–845  ·  view source on GitHub ↗
(workspace)

Source from the content-addressed store, hash-verified

811 * @returns {Promise<string>}
812 */
813export async function createIndexJs(workspace) {
814 const version = await getVersion();
815 let contents = `globalThis.CESIUM_VERSION = "${version}";\n`;
816
817 // Iterate over all provided source files for the workspace and export the assignment based on file name.
818 const workspaceSources = workspaceSourceFiles[workspace];
819 if (!workspaceSources) {
820 throw new Error(`Unable to find source files for workspace: ${workspace}`);
821 }
822
823 const files = await globby(workspaceSources);
824 files.forEach(function (file) {
825 file = path.relative(`packages/${workspace}`, file);
826
827 let moduleId = file;
828 moduleId = filePathToModuleId(moduleId);
829
830 // Rename shader files, such that ViewportQuadFS.glsl is exported as _shadersViewportQuadFS in JS.
831
832 let assignmentName = path.basename(file, path.extname(file));
833 if (moduleId.indexOf(`Source/Shaders/`) === 0) {
834 assignmentName = `_shaders${assignmentName}`;
835 }
836 assignmentName = assignmentName.replace(/(\.|-)/g, "_");
837 contents += `export { default as ${assignmentName} } from './${moduleId}.js';${EOL}`;
838 });
839
840 await writeFile(`packages/${workspace}/index.js`, contents, {
841 encoding: "utf-8",
842 });
843
844 return contents;
845}
846
847/**
848 * Creates a single entry point file by importing all individual spec files.

Callers 3

server.jsFile · 0.90
buildEngineFunction · 0.85
buildWidgetsFunction · 0.85

Calls 2

getVersionFunction · 0.85
filePathToModuleIdFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…