refactor(ngcc): do not crash if package build version is outdated (#35079)
Now `hasBeenProcessed()` will no longer throw if there is an entry-point that has been built with an outdated version of ngcc. Instead it just returns `false`, which will include it in this processing run. This is a precursor to adding functionality that will automatically revert outdate build artifacts. PR Close #35079
This commit is contained in:

committed by
Misko Hevery

parent
171a79d04f
commit
cc43bfa725
@ -5,7 +5,7 @@
|
||||
* 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
|
||||
*/
|
||||
import {AbsoluteFsPath, absoluteFrom, getFileSystem} from '../../../src/ngtsc/file_system';
|
||||
import {absoluteFrom, getFileSystem} from '../../../src/ngtsc/file_system';
|
||||
import {runInEachFileSystem} from '../../../src/ngtsc/file_system/testing';
|
||||
import {loadTestFiles} from '../../../test/helpers';
|
||||
import {hasBeenProcessed, markAsProcessed} from '../../src/packages/build_marker';
|
||||
@ -177,97 +177,22 @@ runInEachFileSystem(() => {
|
||||
});
|
||||
|
||||
describe('hasBeenProcessed', () => {
|
||||
let entryPointPath: AbsoluteFsPath;
|
||||
let nodeModulesPath: AbsoluteFsPath;
|
||||
|
||||
beforeEach(() => {
|
||||
entryPointPath = _('/node_modules/test');
|
||||
nodeModulesPath = _('/node_modules');
|
||||
});
|
||||
|
||||
it('should return true if the marker exists for the given format property', () => {
|
||||
expect(hasBeenProcessed(
|
||||
{name: 'test', __processed_by_ivy_ngcc__: {'fesm2015': '0.0.0-PLACEHOLDER'}},
|
||||
'fesm2015', entryPointPath))
|
||||
'fesm2015'))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
it('should return false if the marker does not exist for the given format property', () => {
|
||||
expect(hasBeenProcessed(
|
||||
{name: 'test', __processed_by_ivy_ngcc__: {'fesm2015': '0.0.0-PLACEHOLDER'}},
|
||||
'module', entryPointPath))
|
||||
'module'))
|
||||
.toBe(false);
|
||||
});
|
||||
|
||||
it('should return false if no markers exist',
|
||||
() => { expect(hasBeenProcessed({name: 'test'}, 'module', entryPointPath)).toBe(false); });
|
||||
|
||||
it('should throw an Error if the format has been compiled with a different version.', () => {
|
||||
expect(
|
||||
() => hasBeenProcessed(
|
||||
{name: 'test', __processed_by_ivy_ngcc__: {'fesm2015': '8.0.0'}}, 'fesm2015',
|
||||
entryPointPath))
|
||||
.toThrowError(
|
||||
'The ngcc compiler has changed since the last ngcc build.\n' +
|
||||
`Please remove "${nodeModulesPath}" and try again.`);
|
||||
});
|
||||
|
||||
it('should throw an Error if any format has been compiled with a different version.', () => {
|
||||
expect(
|
||||
() => hasBeenProcessed(
|
||||
{name: 'test', __processed_by_ivy_ngcc__: {'fesm2015': '8.0.0'}}, 'module',
|
||||
entryPointPath))
|
||||
.toThrowError(
|
||||
'The ngcc compiler has changed since the last ngcc build.\n' +
|
||||
`Please remove "${nodeModulesPath}" and try again.`);
|
||||
expect(
|
||||
() => hasBeenProcessed(
|
||||
{
|
||||
name: 'test',
|
||||
__processed_by_ivy_ngcc__: {'module': '0.0.0-PLACEHOLDER', 'fesm2015': '8.0.0'}
|
||||
},
|
||||
'module', entryPointPath))
|
||||
.toThrowError(
|
||||
'The ngcc compiler has changed since the last ngcc build.\n' +
|
||||
`Please remove "${nodeModulesPath}" and try again.`);
|
||||
expect(
|
||||
() => hasBeenProcessed(
|
||||
{
|
||||
name: 'test',
|
||||
__processed_by_ivy_ngcc__: {'module': '0.0.0-PLACEHOLDER', 'fesm2015': '8.0.0'}
|
||||
},
|
||||
'fesm2015', entryPointPath))
|
||||
.toThrowError(
|
||||
'The ngcc compiler has changed since the last ngcc build.\n' +
|
||||
`Please remove "${nodeModulesPath}" and try again.`);
|
||||
});
|
||||
|
||||
it('should throw an Error, with the appropriate path to remove, if the format has been compiled with a different version',
|
||||
() => {
|
||||
expect(
|
||||
() => hasBeenProcessed(
|
||||
{name: 'test', __processed_by_ivy_ngcc__: {'fesm2015': '8.0.0'}}, 'fesm2015',
|
||||
_('/node_modules/test')))
|
||||
.toThrowError(
|
||||
'The ngcc compiler has changed since the last ngcc build.\n' +
|
||||
`Please remove "${_('/node_modules')}" and try again.`);
|
||||
|
||||
expect(
|
||||
() => hasBeenProcessed(
|
||||
{name: 'nested', __processed_by_ivy_ngcc__: {'fesm2015': '8.0.0'}}, 'fesm2015',
|
||||
_('/node_modules/test/node_modules/nested')))
|
||||
.toThrowError(
|
||||
'The ngcc compiler has changed since the last ngcc build.\n' +
|
||||
`Please remove "${_('/node_modules/test/node_modules')}" and try again.`);
|
||||
|
||||
expect(
|
||||
() => hasBeenProcessed(
|
||||
{name: 'test', __processed_by_ivy_ngcc__: {'fesm2015': '8.0.0'}}, 'fesm2015',
|
||||
_('/dist/test')))
|
||||
.toThrowError(
|
||||
'The ngcc compiler has changed since the last ngcc build.\n' +
|
||||
`Please remove "${_('/dist/test')}" and try again.`);
|
||||
});
|
||||
() => { expect(hasBeenProcessed({name: 'test'}, 'module')).toBe(false); });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user