MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / plugin

Function plugin

modules/code-generator/src/plugins/project/constants.ts:14–55  ·  view source on GitHub ↗
(pre: ICodeStruct)

Source from the content-addressed store, hash-verified

12
13const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
14 const plugin: BuilderComponentPlugin = async (pre: ICodeStruct) => {
15 const next: ICodeStruct = {
16 ...pre,
17 };
18
19 const ir = next.ir as IProjectInfo;
20 const scope = Scope.createRootScope();
21 const constantStr = generateCompositeType(ir.constants || {}, scope);
22
23 next.chunks.push({
24 type: ChunkType.STRING,
25 fileType: FileType.JS,
26 name: COMMON_CHUNK_NAME.FileVarDefine,
27 content: `
28 const __$$constants = (${constantStr});
29 `,
30 linkAfter: [
31 COMMON_CHUNK_NAME.ExternalDepsImport,
32 COMMON_CHUNK_NAME.InternalDepsImport,
33 COMMON_CHUNK_NAME.ImportAliasDefine,
34 ],
35 });
36
37 next.chunks.push({
38 type: ChunkType.STRING,
39 fileType: FileType.JS,
40 name: COMMON_CHUNK_NAME.FileExport,
41 content: `
42 export default __$$constants;
43 `,
44 linkAfter: [
45 COMMON_CHUNK_NAME.ExternalDepsImport,
46 COMMON_CHUNK_NAME.InternalDepsImport,
47 COMMON_CHUNK_NAME.ImportAliasDefine,
48 COMMON_CHUNK_NAME.FileVarDefine,
49 COMMON_CHUNK_NAME.FileUtilDefine,
50 COMMON_CHUNK_NAME.FileMainContent,
51 ],
52 });
53
54 return next;
55 };
56 return plugin;
57};
58

Callers

nothing calls this directly

Calls 3

generateCompositeTypeFunction · 0.90
createRootScopeMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…