fix(service-worker): deprecate versionedFiles in asset-group resources (#23584)

Since `versionedFiles` behaves in the exact same way as `files`, there
is no reaason to have both. Users should use `files` instead.

This commit deprecates the property and prints a warning when coming
across an asset-group that uses it. It should be completely removed in
a future version.

Note, it has also been removed from the default `ngsw-config.json`
template in angular/devkit#754.

PR Close #23584
This commit is contained in:
George Kalpakas
2018-04-28 02:01:28 +03:00
committed by Alex Rickabaugh
parent ad6052e397
commit c6b618d020
5 changed files with 21 additions and 10 deletions

View File

@ -44,6 +44,13 @@ export class Generator {
Promise<Object[]> {
const seenMap = new Set<string>();
return Promise.all((config.assetGroups || []).map(async(group) => {
if (group.resources.versionedFiles) {
console.warn(
`Asset-group '${group.name}' in 'ngsw-config.json' uses the 'versionedFiles' option.\n` +
'As of v6 \'versionedFiles\' and \'files\' options have the same behavior. ' +
'Use \'files\' instead.');
}
const fileMatcher = globListToMatcher(group.resources.files || []);
const versionedMatcher = globListToMatcher(group.resources.versionedFiles || []);

View File

@ -38,7 +38,13 @@ export interface AssetGroup {
name: string;
installMode?: 'prefetch'|'lazy';
updateMode?: 'prefetch'|'lazy';
resources: {files?: Glob[]; versionedFiles?: Glob[]; urls?: Glob[];};
resources: {
files?: Glob[];
/** @deprecated As of v6 `versionedFiles` and `files` options have the same behavior. Use
`files` instead. */
versionedFiles?: Glob[];
urls?: Glob[];
};
}
/**