MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / angularConfig

Function angularConfig

packages/vite/configuration/angular.ts:175–348  ·  view source on GitHub ↗
({ mode })

Source from the content-addressed store, hash-verified

173];
174
175export const angularConfig = ({ mode }): UserConfig => {
176 const disableAnimations = true;
177 //process.env.NS_DISABLE_NG_ANIMATIONS === "1" ||
178 //process.env.NS_DISABLE_NG_ANIMATIONS === "true";
179
180 // Post-link emitted chunks to catch any remaining partial declarations that slipped through
181 // due to plugin order or external transforms.
182 const postLinker = {
183 name: 'ns-angular-linker-post',
184 apply: 'build' as const,
185 enforce: 'post' as const,
186 async generateBundle(_options, bundle) {
187 function isNsAngularPolyfillsChunk(chunk: any): boolean {
188 if (!chunk || !(chunk as any).modules) return false;
189 return Object.keys((chunk as any).modules).some((m) => m.includes('node_modules/@nativescript/angular/fesm2022/nativescript-angular-polyfills.mjs'));
190 }
191 const { babel, linkerPlugin } = await ensureSharedAngularLinker(process.cwd());
192 if (!babel || !linkerPlugin) return;
193 const strict = process.env.NS_STRICT_NG_LINK === '1' || process.env.NS_STRICT_NG_LINK === 'true';
194 const enforceStrict = process.env.NS_STRICT_NG_LINK_ENFORCE === '1' || process.env.NS_STRICT_NG_LINK_ENFORCE === 'true';
195 const debug = process.env.VITE_DEBUG_LOGS === '1' || process.env.VITE_DEBUG_LOGS === 'true';
196 const unlinked: string[] = [];
197 for (const [fileName, chunk] of Object.entries(bundle)) {
198 if (!fileName.endsWith('.mjs') && !fileName.endsWith('.js')) continue;
199 if (chunk && (chunk as any).type === 'chunk') {
200 const code = (chunk as any).code as string;
201 if (!code) continue;
202 const isNsPolyfills = isNsAngularPolyfillsChunk(chunk);
203 try {
204 const res = await (babel as any).transformAsync(code, {
205 filename: fileName,
206 configFile: false,
207 babelrc: false,
208 sourceMaps: false,
209 compact: false,
210 plugins: [linkerPlugin],
211 });
212 const finalCode = res?.code && res.code !== code ? res.code : code;
213 if (finalCode !== code) {
214 (chunk as any).code = finalCode;
215 if (debug) {
216 try {
217 console.log('[ns-angular-linker][post] linked', fileName, isNsPolyfills ? '(polyfills)' : '');
218 } catch {}
219 }
220 }
221 if (strict && !isNsPolyfills && containsRealNgDeclare(finalCode)) {
222 unlinked.push(fileName);
223 }
224 } catch {
225 if (strict) unlinked.push(fileName);
226 }
227 }
228 }
229 if (strict && unlinked.length) {
230 const details: string[] = [];
231 for (const fname of unlinked) {
232 const chunk: any = (bundle as any)[fname];

Callers

nothing calls this directly

Calls 2

baseConfigFunction · 0.85
angularRollupLinkerFunction · 0.85

Tested by

no test coverage detected