MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / linkFile

Function linkFile

packages/vite/helpers/prelink-angular.ts:19–34  ·  view source on GitHub ↗
(babel: any, createLinker: any, src: string)

Source from the content-addressed store, hash-verified

17}
18
19async function linkFile(babel: any, createLinker: any, src: string): Promise<string | null> {
20 const code = await fs.readFile(src, 'utf8');
21 if (!code) return null;
22 // Quick check to skip non-partial files
23 if (code.indexOf('\u0275\u0275ngDeclare') === -1 && code.indexOf('ɵɵngDeclare') === -1 && code.indexOf('ngDeclare') === -1) return null;
24 const plugin = createLinker({ sourceMapping: false });
25 const res = await babel.transformAsync(code, {
26 filename: src,
27 configFile: false,
28 babelrc: false,
29 sourceMaps: false,
30 compact: false,
31 plugins: [plugin],
32 });
33 return res?.code && res.code !== code ? res.code : null;
34}
35
36async function copyOrLinkInto(babel: any, createLinker: any, srcFile: string, cacheFile: string) {
37 const dir = path.dirname(cacheFile);

Callers 1

copyOrLinkIntoFunction · 0.85

Calls 1

indexOfMethod · 0.80

Tested by

no test coverage detected