fix(ngcc): prevent including JavaScript sources outside of the package #37596
Conversation
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Couple of nits.
Nice and clean PR!
| @@ -68,7 +68,7 @@ export function makeTestBundleProgram( | |||
| const rootDir = fs.dirname(entryPointPath); | |||
| const options: ts.CompilerOptions = | |||
| {allowJs: true, maxNodeModuleJsDepth: Infinity, checkJs: false, rootDir, rootDirs: [rootDir]}; | |||
| const host = new NgccSourcesCompilerHost(fs, options, entryPointPath); | |||
| const host = new NgccSourcesCompilerHost(fs, options, rootDir); | |||
I would rather we change the makeTestBundleProgram to accept an additional packagePath parameter, rather than relying upon the package being two directories up from the source file path.
This code has always made the assumption that path corresponds with a secondary entry-point, while that is not true in most cases. Cleaning up would likely be a large task, given that this function has ~480 callers. I could add an optional param here but that doesn't sounds like a proper way to go either.
…rce files Changes `isWithinPackage` to take an `AbsoluteFsPath` instead of `ts.SourceFile`, to allow for an upcoming change to use it when no `ts.SourceFile` is available, but just a path.
When ngcc creates an entry-point program, the `allowJs` option is enabled in order to operate on the JavaScript source files of the entry-point. A side-effect of this approach is that external modules that don't ship declaration files will also have their JavaScript source files loaded into the program, as the `allowJs` flag allows for them to be imported. This may pose an issue in certain edge cases, where ngcc would inadvertently operate on these external modules. This can introduce all sorts of undesirable behavior and incompatibilities, e.g. the reflection host that is selected for the entry-point's format could be incompatible with that of the external module's JavaScript bundles. To avoid these kinds of issues, module resolution that would resolve to a JavaScript file located outside of the package will instead be rejected, as if the file would not exist. This would have been the behavior when `allowJs` is set to false, which is the case in typical Angular compilations. Fixes angular#37508
|
merge-assistance: angular bot seems to have stalled, all checks should have passed. |
#37596) When ngcc creates an entry-point program, the `allowJs` option is enabled in order to operate on the JavaScript source files of the entry-point. A side-effect of this approach is that external modules that don't ship declaration files will also have their JavaScript source files loaded into the program, as the `allowJs` flag allows for them to be imported. This may pose an issue in certain edge cases, where ngcc would inadvertently operate on these external modules. This can introduce all sorts of undesirable behavior and incompatibilities, e.g. the reflection host that is selected for the entry-point's format could be incompatible with that of the external module's JavaScript bundles. To avoid these kinds of issues, module resolution that would resolve to a JavaScript file located outside of the package will instead be rejected, as if the file would not exist. This would have been the behavior when `allowJs` is set to false, which is the case in typical Angular compilations. Fixes #37508 PR Close #37596
#37596) When ngcc creates an entry-point program, the `allowJs` option is enabled in order to operate on the JavaScript source files of the entry-point. A side-effect of this approach is that external modules that don't ship declaration files will also have their JavaScript source files loaded into the program, as the `allowJs` flag allows for them to be imported. This may pose an issue in certain edge cases, where ngcc would inadvertently operate on these external modules. This can introduce all sorts of undesirable behavior and incompatibilities, e.g. the reflection host that is selected for the entry-point's format could be incompatible with that of the external module's JavaScript bundles. To avoid these kinds of issues, module resolution that would resolve to a JavaScript file located outside of the package will instead be rejected, as if the file would not exist. This would have been the behavior when `allowJs` is set to false, which is the case in typical Angular compilations. Fixes #37508 PR Close #37596
|
@JoostK help please! I'm trying to upgrade a website to changing the target of the libraries from I've also used this postinstall script with no joy: Do you have any clue to share with us? or we should disable Ivy in the meantime? :( |
|
Reading #32902 I guess that something is happening with the definition files |
|
@matheo I can't tell from the top of my head, sorry. Aliased exports are generally supported I think. For some reason, compiling Regarding the Without a reproduction I'm afraid I can't really give more accurate and actionable advice :-( We have not seen issues with private declarations together with ngcc in a very long time, so I'm really not sure what is wrong here. If you are able to reproduce, do feel free to open a new issue. This PR does not seem relevant so this may not be the best place to discuss your problem ;-) |
|
Thanks for the answer @JoostK I will trace the problem a bit and open a new issue to discuss this particular case. |
|
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. |
…rce files (angular#37596) Changes `isWithinPackage` to take an `AbsoluteFsPath` instead of `ts.SourceFile`, to allow for an upcoming change to use it when no `ts.SourceFile` is available, but just a path. PR Close angular#37596
angular#37596) When ngcc creates an entry-point program, the `allowJs` option is enabled in order to operate on the JavaScript source files of the entry-point. A side-effect of this approach is that external modules that don't ship declaration files will also have their JavaScript source files loaded into the program, as the `allowJs` flag allows for them to be imported. This may pose an issue in certain edge cases, where ngcc would inadvertently operate on these external modules. This can introduce all sorts of undesirable behavior and incompatibilities, e.g. the reflection host that is selected for the entry-point's format could be incompatible with that of the external module's JavaScript bundles. To avoid these kinds of issues, module resolution that would resolve to a JavaScript file located outside of the package will instead be rejected, as if the file would not exist. This would have been the behavior when `allowJs` is set to false, which is the case in typical Angular compilations. Fixes angular#37508 PR Close angular#37596
See individual commits for details.
Fixes #37508
The text was updated successfully, but these errors were encountered: