-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(bazel): downlevel async generators along with async/await
This is necessary as ESBuild does not support it. It is also needed to bring our pipeline in sync with the Angular CLI. Note that I combined both linker & optimization into a single plugin so that we do not have to run slow Babel compilations more than once. This matches with the Angular CLI too. Long-term we might be able to leverage a plugin from them directly when the ESBuild builder is the default.
- Loading branch information
1 parent
9a7aea3
commit c154da1
Showing
12 changed files
with
196 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
shared-scripts/angular-optimization/ensure-no-linker-decl.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
/** Naively checks whether this node path resolves to an Angular declare invocation. */ | ||
function isNgDeclareCallExpression(nodePath) { | ||
if (!nodePath.node.name.startsWith('ɵɵngDeclare')) { | ||
return false; | ||
} | ||
|
||
// Expect the `ngDeclare` identifier to be used as part of a property access that | ||
// is invoked within a call expression. e.g. `i0.ɵɵngDeclare<>`. | ||
return ( | ||
nodePath.parentPath?.type === 'MemberExpression' && | ||
nodePath.parentPath.parentPath?.type === 'CallExpression' | ||
); | ||
} | ||
|
||
/** Asserts that the given AST does not contain any Angular partial declaration. */ | ||
export async function assertNoPartialDeclaration(filePath, ast, traverseFn) { | ||
// Naively check if there are any Angular declarations left that haven't been linked. | ||
traverseFn(ast, { | ||
Identifier: (astPath) => { | ||
if (isNgDeclareCallExpression(astPath)) { | ||
throw astPath.buildCodeFrameError( | ||
`Found Angular declaration that has not been linked. ${filePath}`, | ||
Error, | ||
); | ||
} | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
export interface OptimizationOptions { | ||
enableLinker?: { | ||
ensureNoPartialDeclaration: boolean; | ||
linkerOptions?: object; | ||
}; | ||
optimize?: { | ||
isSideEffectFree?: (absoluteDiskPath: string) => boolean; | ||
}; | ||
downlevelAsyncGeneratorsIfPresent?: boolean; | ||
} |
Oops, something went wrong.