MCPcopy Create free account
hub / github.com/angular/angular / constructWasm

Function constructWasm

packages/compiler-cli/preprocessor/src/analyzer_loader.ts:265–288  ·  view source on GitHub ↗
(spec: string, options: LoadAnalyzerOptions)

Source from the content-addressed store, hash-verified

263}
264
265async function constructWasm(spec: string, options: LoadAnalyzerOptions): Promise<IAnalyzer> {
266 const mod = requireFromHere(spec);
267 const Inner = mod?.WasmAnalyzer as WasmInnerConstructor | undefined;
268 if (typeof Inner !== 'function') {
269 // Guards against pointing this at napi's WASI build, which exposes the napi
270 // surface (Analyzer/TestAnalyzer) rather than the wasm-bindgen WasmAnalyzer.
271 throw new Error(
272 `'${spec}' does not export a 'WasmAnalyzer' constructor (${describeExports(mod)})`,
273 );
274 }
275 const {WasmAnalyzer} = await import('./analyzer_wasm.js');
276
277 // The engine has no OS beneath it, so without this bridge it can only see
278 // `virtualFiles` and cannot analyze a project on disk. Callers can substitute their
279 // own host (a bundler's module graph, say) or pass null to keep it in-memory only.
280 let hostFs = options.hostFs;
281 if (hostFs === undefined) {
282 const {createNodeHostFs} = await import('./wasm_host_fs.js');
283 hostFs = createNodeHostFs();
284 }
285
286 const inner = new Inner(JSON.stringify(engineOptions(options)), hostFs);
287 return new WasmAnalyzer(inner);
288}
289
290function hostDescription(): string {
291 const parts = [`${process.platform}/${process.arch}`, `node ${process.version}`];

Callers 1

loadAnalyzerWithInfoFunction · 0.85

Calls 3

describeExportsFunction · 0.85
createNodeHostFsFunction · 0.85
engineOptionsFunction · 0.85

Tested by

no test coverage detected