MCPcopy Index your code
hub / github.com/angular/angular / addPolyfillToConfig

Function addPolyfillToConfig

packages/localize/schematics/ng-add/index.ts:27–63  ·  view source on GitHub ↗
(projectName: string)

Source from the content-addressed store, hash-verified

25const localizeTripleSlashType = `/// <reference types="@angular/localize" />`;
26
27function addPolyfillToConfig(projectName: string): Rule {
28 return updateWorkspace((workspace) => {
29 const project = workspace.projects.get(projectName);
30 if (!project) {
31 throw new SchematicsException(`Invalid project name '${projectName}'.`);
32 }
33
34 const isLocalizePolyfill = (path: string) => path.startsWith('@angular/localize');
35
36 for (const target of project.targets.values()) {
37 switch (target.builder) {
38 case AngularBuilder.Karma:
39 case AngularBuilder.BuildKarma:
40 case AngularBuilder.Server:
41 case AngularBuilder.Browser:
42 case AngularBuilder.BrowserEsbuild:
43 case AngularBuilder.Application:
44 case AngularBuilder.BuildApplication:
45 target.options ??= {};
46 const value = target.options['polyfills'];
47 if (typeof value === 'string') {
48 if (!isLocalizePolyfill(value)) {
49 target.options['polyfills'] = [value, localizePolyfill];
50 }
51 } else if (Array.isArray(value)) {
52 if (!(value as string[]).some(isLocalizePolyfill)) {
53 value.push(localizePolyfill);
54 }
55 } else {
56 target.options['polyfills'] = [localizePolyfill];
57 }
58
59 break;
60 }
61 }
62 });
63}
64
65function addTypeScriptConfigTypes(projectName: string): Rule {
66 return async (host: Tree) => {

Callers 1

index.tsFile · 0.85

Calls 6

isLocalizePolyfillFunction · 0.85
valuesMethod · 0.80
isArrayMethod · 0.80
someMethod · 0.80
getMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…