MCPcopy Index your code
hub / github.com/TypeScriptToLua/TypeScriptToLua / getPlugins

Function getPlugins

src/transpilation/plugins.ts:71–110  ·  view source on GitHub ↗
(program: ts.Program)

Source from the content-addressed store, hash-verified

69}
70
71export function getPlugins(program: ts.Program): { diagnostics: ts.Diagnostic[]; plugins: Plugin[] } {
72 performance.startSection("getPlugins");
73 const diagnostics: ts.Diagnostic[] = [];
74 const pluginsFromOptions: Plugin[] = [];
75 const options = program.getCompilerOptions() as CompilerOptions;
76
77 for (const [index, pluginOption] of (options.luaPlugins ?? []).entries()) {
78 const optionName = `tstl.luaPlugins[${index}]`;
79
80 const factory = (() => {
81 if ("plugin" in pluginOption) {
82 return pluginOption.plugin;
83 } else {
84 const { error: resolveError, result: factory } = resolvePlugin(
85 "plugin",
86 `${optionName}.name`,
87 getConfigDirectory(options),
88 pluginOption.name,
89 pluginOption.import
90 );
91
92 if (resolveError) diagnostics.push(resolveError);
93 return factory;
94 }
95 })();
96
97 if (factory === undefined) continue;
98
99 const plugin = typeof factory === "function" ? factory(pluginOption) : factory;
100 pluginsFromOptions.push(plugin);
101 }
102
103 if (options.tstlVerbose) {
104 console.log(`Loaded ${pluginsFromOptions.length} plugins`);
105 }
106
107 performance.endSection("getPlugins");
108
109 return { diagnostics, plugins: pluginsFromOptions };
110}

Callers 1

emitMethod · 0.90

Calls 4

resolvePluginFunction · 0.90
getConfigDirectoryFunction · 0.90
factoryFunction · 0.85
entriesMethod · 0.65

Tested by

no test coverage detected