(code, id)
| 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 |
| 84 | const cleanId = id.split('?', 1)[0]; |
| 85 | // Same policy as load(): in strictAll we allow any file that actually |
| 86 | // contains a real ngDeclare call; otherwise we restrict to framework libs. |
| 87 | if (!strictAll && !FILTER.test(cleanId)) return null; |
| 88 | if (!code) return null; |
| 89 | if (strictAll && !FILTER.test(cleanId) && !containsRealNgDeclare(code)) return null; |
| 90 | await ensureDeps(); |
| 91 | if (!babel || !createLinker) return null; |
| 92 | try { |
| 93 | const plugin = createLinker({ sourceMapping: false }); |
| 94 | if (debug) { |
| 95 | try { |
| 96 | console.log('[ns-angular-linker][vite] linking', cleanId); |
| 97 | } catch {} |
| 98 | } |
| 99 | const result = await (babel as any).transformAsync(code, { |
| 100 | filename: cleanId, |
| 101 | configFile: false, |
| 102 | babelrc: false, |
| 103 | sourceMaps: false, |
| 104 | compact: false, |
| 105 | plugins: [plugin], |
| 106 | }); |
| 107 | if (result?.code && result.code !== code) { |
| 108 | return { code: result.code, map: null }; |
| 109 | } |
| 110 | } catch { |
| 111 | // Soft-fail; return original code |
| 112 | } |
| 113 | return null; |
| 114 | }, |
| 115 | }; |
| 116 | } |
| 117 |
nothing calls this directly
no test coverage detected