@@ -52,69 +52,13 @@ async function main() {
52
52
}
53
53
54
54
function applyPatches ( ) {
55
- // Workaround for https://github.com/angular/angular/issues/18810.
56
- shelljs . exec ( 'ngc -p angular-tsconfig.json' ) ;
57
-
58
- // Workaround for: https://github.com/angular/angular/issues/32651. We just do not
59
- // generate re-exports for secondary entry-points. Similar to what "ng-packagr" does.
60
- searchAndReplace (
61
- / (? ! f u n c t i o n \s + ) c r e a t e M e t a d a t a R e e x p o r t F i l e \( [ ^ ) ] + \) ; / , '' ,
62
- 'node_modules/@angular/bazel/src/ng_package/packager.js' ) ;
63
- searchAndReplace (
64
- / (? ! f u n c t i o n \s + ) c r e a t e T y p i n g s R e e x p o r t F i l e \( [ ^ ) ] + \) ; / , '' ,
65
- 'node_modules/@angular/bazel/src/ng_package/packager.js' ) ;
66
-
67
55
// Workaround for: https://github.com/angular/angular/pull/32650
68
56
searchAndReplace (
69
- 'var indexFile ;' , `
70
- var indexFile = files .find(f => f.endsWith('/public-api.ts'));
57
+ 'let resolvedEntryPoint = null ;' , `
58
+ let resolvedEntryPoint = tsFiles .find(f => f.endsWith('/public-api.ts')) || null ;
71
59
` ,
72
- 'node_modules/@angular/compiler-cli/src/metadata/bundle_index_host.js' ) ;
73
- searchAndReplace (
74
- 'var resolvedEntryPoint = null;' , `
75
- var resolvedEntryPoint = tsFiles.find(f => f.endsWith('/public-api.ts')) || null;
76
- ` ,
77
- 'node_modules/@angular/compiler-cli/src/ngtsc/entry_point/src/logic.js' ) ;
78
-
79
- // Workaround for: https://hackmd.io/MlqFp-yrSx-0mw4rD7dnQQ?both. We only want to discard
80
- // the metadata of files in the bazel managed node modules. That way we keep the default
81
- // behavior of ngc-wrapped except for dependencies between sources of the library. This makes
82
- // the "generateCodeForLibraries" flag more accurate in the Bazel environment where previous
83
- // compilations should not be treated as external libraries. Read more about this in the document.
84
- searchAndReplace (
85
- / i f \( ( t h i s \. o p t i o n s \. g e n e r a t e C o d e F o r L i b r a r i e s = = = f a l s e ) / , `
86
- const fs = require('fs');
87
- const hasFlatModuleBundle = fs.existsSync(filePath.replace('.d.ts', '.metadata.json'));
88
- if ((filePath.includes('node_modules/') || !hasFlatModuleBundle) && $1` ,
89
- 'node_modules/@angular/compiler-cli/src/transformers/compiler_host.js' ) ;
90
- applyPatch ( path . join ( __dirname , './flat_module_factory_resolution.patch' ) ) ;
91
- // The three replacements below ensure that metadata files can be read by NGC and
92
- // that metadata files are collected as Bazel action inputs.
93
- searchAndReplace (
94
- / ( c o n s t N G C _ A S S E T S = \/ [ ^ ( ] + \( ) ( [ ^ ) ] * ) ( \) .* \/ ; ) / , '$1$2|metadata.json$3' ,
95
- 'node_modules/@angular/bazel/src/ngc-wrapped/index.js' ) ;
96
- searchAndReplace (
97
- / ^ ( ( \s * ) r e s u l t s = d e p s e t \( d e p .a n g u l a r .s u m m a r i e s , t r a n s i t i v e = \[ r e s u l t s ] \) ) $ / m,
98
- `$1#\n$2results = depset(dep.angular.metadata, transitive = [results])` ,
99
- 'node_modules/@angular/bazel/src/ng_module.bzl' ) ;
100
- searchAndReplace (
101
- / ^ ( ( \s * ) r e s u l t s = d e p s e t \( t a r g e t .a n g u l a r \. s u m m a r i e s i f _ h a s _ t a r g e t _ a n g u l a r _ s u m m a r i e s \( t a r g e t \) e l s e \[ ] \) ) $ / m,
102
- `$1#\n$2results = depset(target.angular.metadata if _has_target_angular_summaries(target) else [], transitive = [results])` ,
103
- 'node_modules/@angular/bazel/src/ng_module.bzl' ) ;
104
- // Ensure that "metadata" of transitive dependencies can be collected.
105
- searchAndReplace (
106
- / p r o v i d e r s \[ " a n g u l a r " ] \[ " m e t a d a t a " ] = o u t s \. m e t a d a t a / ,
107
- `$& + [m for dep in ctx.attr.deps if (hasattr(dep, "angular") and hasattr(dep.angular, "metadata")) for m in dep.angular.metadata]` ,
108
- 'node_modules/@angular/bazel/src/ng_module.bzl' ) ;
109
-
110
- // Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1208.
111
- applyPatch ( path . join ( __dirname , './manifest_externs_hermeticity.patch' ) ) ;
60
+ 'node_modules/@angular/compiler-cli/bundles/index.js' ) ;
112
61
113
- // Workaround for https://github.com/angular/angular/issues/33452:
114
- searchAndReplace (
115
- / a n g u l a r _ c o m p i l e r _ o p t i o n s = { / , `$&
116
- "strictTemplates": True,` ,
117
- 'node_modules/@angular/bazel/src/ng_module.bzl' ) ;
118
62
119
63
// More info in https://github.com/angular/angular/pull/33786
120
64
shelljs . rm ( '-rf' , [
0 commit comments