(id)
| 46 | name: 'ns-angular-linker-vite', |
| 47 | enforce: 'pre', |
| 48 | async load(id) { |
| 49 | const debug = process.env.VITE_DEBUG_LOGS === 'true' || process.env.VITE_DEBUG_LOGS === '1'; |
| 50 | const cleanId = id.split('?', 1)[0]; |
| 51 | // In non-strict mode we only ever touch Angular framework libraries. |
| 52 | if (!strictAll && !FILTER.test(cleanId)) return null; |
| 53 | try { |
| 54 | const fs = await import('node:fs/promises'); |
| 55 | const code = await fs.readFile(cleanId, 'utf8'); |
| 56 | if (!code) return null; |
| 57 | // Under NS_STRICT_NG_LINK_ALL we will attempt to link **any** file |
| 58 | // that actually contains a ɵɵngDeclare* call site. |
| 59 | if (strictAll && !FILTER.test(cleanId) && !containsRealNgDeclare(code)) return null; |
| 60 | const { babel, linkerPlugin } = await ensureSharedAngularLinker(projectRoot); |
| 61 | if (!babel || !linkerPlugin) return null; |
| 62 | if (debug) { |
| 63 | try { |
| 64 | console.log('[ns-angular-linker][vite-load] linking', cleanId); |
| 65 | } catch {} |
| 66 | } |
| 67 | const result = await (babel as any).transformAsync(code, { |
| 68 | filename: cleanId, |
| 69 | configFile: false, |
| 70 | babelrc: false, |
| 71 | sourceMaps: false, |
| 72 | compact: false, |
| 73 | plugins: [linkerPlugin], |
| 74 | }); |
| 75 | if (result?.code && result.code !== code) { |
| 76 | return { code: result.code, map: null } as any; |
| 77 | } |
| 78 | } catch {} |
| 79 | return null; |
| 80 | }, |
| 81 | async transform(code, id) { |
| 82 | const debug = process.env.VITE_DEBUG_LOGS === 'true' || process.env.VITE_DEBUG_LOGS === '1'; |
| 83 | // Strip Vite/Rollup query strings before testing |
nothing calls this directly
no test coverage detected