| 25 | const localizeTripleSlashType = `/// <reference types="@angular/localize" />`; |
| 26 | |
| 27 | function 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 | |
| 65 | function addTypeScriptConfigTypes(projectName: string): Rule { |
| 66 | return async (host: Tree) => { |