fix(ngcc): do not fail hard when a format-path points to a non-existing or empty file#40985
fix(ngcc): do not fail hard when a format-path points to a non-existing or empty file#40985gkalpak wants to merge 2 commits intoangular:masterfrom
Conversation
|
You can preview 0b49aee at https://pr40985-0b49aee.ngbuilds.io/. |
0b49aee to
e8a341a
Compare
|
You can preview e8a341a at https://pr40985-e8a341a.ngbuilds.io/. |
…ng or empty file Previously, when `ngcc` encountered an entry-point with a format-path that pointed to a non-existing or empty file it would throw an error and stop processing the remaining tasks. In the past, we used to ignore such format-paths and continue processing the rest of the tasks ([see code][1]). This was changed to a hard failure in 2954d1b. Looking at the code history, the reason for changing the behavior was an (incorrect) assumption that the condition could not fail. This assumption failed to take into account the case where a 3rd-party library has an invalid format-path in its `package.json`. This is an issue with the library, but it should not prevent `ngcc` from processing other packages/entry-points/formats. This commit fixes this by reporting the task as failed but not throwing an error, thus allowing `ngcc` to continue processing other tasks. [1]: https://github.com/angular/angular/blob/3077c9a1f89c5bd75fb96c16e/packages/compiler-cli/ngcc/src/main.ts#L124 Fixes angular#40965
e8a341a to
d0a6348
Compare
| `${formatProperty} (formatPath: ${formatPath} | format: ${format})`); | ||
| onTaskCompleted( | ||
| task, TaskProcessingOutcome.Failed, | ||
| `property '${formatProperty}' pointing to a missing or empty file (${formatPath}).`); |
There was a problem hiding this comment.
Subjective NIT:
| `property '${formatProperty}' pointing to a missing or empty file (${formatPath}).`); | |
| `property \`${formatProperty}\` pointing to a missing or empty file: ${formatPath}.`); |
| function createErrorMessage(fs: ReadonlyFileSystem, task: Task, message: string|null): string { | ||
| const jsFormat = | ||
| `${task.formatProperty} as ${getEntryPointFormat(fs, task.entryPoint, task.formatProperty)}`; | ||
| const jsFormat = `${task.formatProperty} as ${ |
There was a problem hiding this comment.
Subjective NIT:
| const jsFormat = `${task.formatProperty} as ${ | |
| const jsFormat = `\`${task.formatProperty}\` as ${ |
There was a problem hiding this comment.
This seems out of scope for this PR.
(Also, you do realize this is your code, right? 😛)
There was a problem hiding this comment.
Given that you are changing the line anyway. (And I have never been one to ideologically stick with my previous decisions).
| const logger = new MockLogger(); | ||
| mainNgcc({ | ||
| basePath: '/dist', | ||
| propertiesToConsider: ['es2015', 'fesm5', 'main'], |
There was a problem hiding this comment.
Perhaps put the main property earlier in the list so that we can see that it failure does not block other formats from being processed.
Also, what happens if the main property is the one that is assigned to the typings processing?
There was a problem hiding this comment.
Also, what happens if the main property is the one that is assigned to the typings processing?
Not great things 😁
Hopefully, since main is low in the list of default properties to consider (and in CLI's list of properties), main will rarely be associated with processing typings.
In any case, this is not much different from what would happen if the formatPath for another property (which is associated with typings processing) points to a missing/empty file. In fact, ngcc seems to fail silently (from a super-quick loog) in that case, which is argueably worse than failing the taks and printing an error message 😁
55a33b7 to
fcb6051
Compare
|
You can preview fcb6051 at https://pr40985-fcb6051.ngbuilds.io/. |
fcb6051 to
f82d92b
Compare
|
You can preview f82d92b at https://pr40985-f82d92b.ngbuilds.io/. |
…-existing or empty file
f82d92b to
50265ed
Compare
This comment has been minimized.
This comment has been minimized.
…ng or empty file (#40985) Previously, when `ngcc` encountered an entry-point with a format-path that pointed to a non-existing or empty file it would throw an error and stop processing the remaining tasks. In the past, we used to ignore such format-paths and continue processing the rest of the tasks ([see code][1]). This was changed to a hard failure in 2954d1b. Looking at the code history, the reason for changing the behavior was an (incorrect) assumption that the condition could not fail. This assumption failed to take into account the case where a 3rd-party library has an invalid format-path in its `package.json`. This is an issue with the library, but it should not prevent `ngcc` from processing other packages/entry-points/formats. This commit fixes this by reporting the task as failed but not throwing an error, thus allowing `ngcc` to continue processing other tasks. [1]: https://github.com/angular/angular/blob/3077c9a1f89c5bd75fb96c16e/packages/compiler-cli/ngcc/src/main.ts#L124 Fixes #40965 PR Close #40985
|
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. |
Previously, when
ngccencountered an entry-point with a format-path that pointed to a non-existing or empty file it would throw an error and stop processing the remaining tasks.In the past, we used to ignore such format-paths and continue processing the rest of the tasks (see code). This was changed to a hard failure in 2954d1b. Looking at the code history, the reason for changing the behavior was an (incorrect) assumption that the condition could not fail. This assumption failed to take into account the case where a 3rd-party library has an invalid format-path in its
package.json. This is an issue with the library, but it should not preventngccfrom processing other packages/entry-points/formats.This commit fixes this by reporting the task as failed but not throwing an error, thus allowing
ngccto continue processing other tasks.Fixes #40965.