feat(compiler-cli): expose function to allow short-circuiting of linking #40137
+119
−12
Conversation
JoostK
reviewed
Dec 15, 2020
* @param source the source file content as a string. | ||
* @returns whether the source file may contain declarations that need to be linked. | ||
*/ | ||
export function sourceFileMayNeedLinking(source: string): boolean { |
A couple notes:
- This function is currently exposed from
@angular/compiler-cli/linker
, which prompts integrators to import from both@angular/compiler-cli/linker
and@angular/compiler-cli/linker/babel
which may not be ideal (the former entry-point is to support linker transform tooling such as the default Babel plugin, not so much integrators of the linker). - This file is currently named
predicate.ts
which may or may not be terrible. Suggestions welcome. - We may want to take the source file path as an input, just so we could potentially make use of it in the future. This would allow us to skip e.g.
node_modules/@angular/core/fesm2015/core.js
(if we were to publish that fully compiled to NPM) which does containɵɵngDeclareComponent
for the JIT functions. Curious what others think here. - Alternative function name suggestions also welcome.
- I'm OK with two entry-points here
- Generally I would recommend the file name matches the main export so:
source_file_may_need_linking.ts
(ormay_need_linking.ts
see 4.) - I think it is a good idea to include the path in the API.
- The current name is a bit of a mouthful. How about just
mayNeedLinking()
or evenneedsLinking()
(ignoring the fact that in some cases running the linker may have no effect).
petebacondarwin
reviewed
Dec 16, 2020
* @param source the source file content as a string. | ||
* @returns whether the source file may contain declarations that need to be linked. | ||
*/ | ||
export function sourceFileMayNeedLinking(source: string): boolean { |
- I'm OK with two entry-points here
- Generally I would recommend the file name matches the main export so:
source_file_may_need_linking.ts
(ormay_need_linking.ts
see 4.) - I think it is a good idea to include the path in the API.
- The current name is a bit of a mouthful. How about just
mayNeedLinking()
or evenneedsLinking()
(ignoring the fact that in some cases running the linker may have no effect).
packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_linker_selector.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/linker/test/file_linker/predicate_spec.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/test/compliance/linked/linked_compile_spec.ts
Outdated
Show resolved
Hide resolved
petebacondarwin
approved these changes
Dec 17, 2020
LGTM - just a question about the file path param.
@@ -18,9 +18,10 @@ import {declarationFunctions} from './partial_linkers/partial_linker_selector'; | |||
* This function may return true even for source files that don't actually contain any declarations | |||
* that need to be compiled. | |||
* | |||
* @param path the path of the source file for which to determine whether linking may be needed. |
Is the path absolute or relative (and if so relative to what)?
The linker is implemented using a Babel transform such that Babel needs to parse and walk a source file to find the declarations that need to be compiled. If it can be determined that a source file is known not to contain any declarations the parsing and walking can be skipped as a performance improvement. This commit adds an exposed function for tools that integrate the linker to use to allow short-circuiting of the linker transform.
twerske
added a commit
to twerske/angular
that referenced
this issue
Jan 5, 2021
…ing (angular#40137) The linker is implemented using a Babel transform such that Babel needs to parse and walk a source file to find the declarations that need to be compiled. If it can be determined that a source file is known not to contain any declarations the parsing and walking can be skipped as a performance improvement. This commit adds an exposed function for tools that integrate the linker to use to allow short-circuiting of the linker transform. PR Close angular#40137
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
The linker is implemented using a Babel transform such that Babel needs
to parse and walk a source file to find the declarations that need to be
compiled. If it can be determined that a source file is known not to
contain any declarations the parsing and walking can be skipped as a
performance improvement. This commit adds an exposed function for tools
that integrate the linker to use to allow short-circuiting of the linker
transform.
The text was updated successfully, but these errors were encountered: