feat(service-worker): remove deprecated `versionedFiles` option (#32862)

BREAKING CHANGE:

Remove deprecated option `versionedFiles` from service worker asset group configuration in `ngsw-config.json`

Before
```json
"assetGroups": [
  {
    "name": "test",
    "resources": {
      "versionedFiles": [
        "/**/*.txt"
      ]
    }
  }
]
```

After
```json
"assetGroups": [
  {
    "name": "test",
    "resources": {
      "files": [
        "/**/*.txt"
      ]
    }
  }
]
```

PR Close #32862
This commit is contained in:
Alan Agius 2019-09-26 18:10:28 +02:00 committed by atscott
parent 090732fc2d
commit 5d5c94d83a
6 changed files with 5 additions and 40 deletions

View File

@ -52,7 +52,6 @@ v8 - v11
| `@angular/upgrade` | [`setAngularLib`](#upgrade-static) | <!--v8--> v9 | | `@angular/upgrade` | [`setAngularLib`](#upgrade-static) | <!--v8--> v9 |
| template syntax | [`/deep/`, `>>>`, and `::ng-deep`](#deep-component-style-selector) | <!--v7--> unspecified | | template syntax | [`/deep/`, `>>>`, and `::ng-deep`](#deep-component-style-selector) | <!--v7--> unspecified |
| template syntax | [`<template`>](#template-tag) | <!--v7--> v9 | | template syntax | [`<template`>](#template-tag) | <!--v7--> v9 |
| service worker | [`versionedFiles` setting](#sw-versionedfiles)| v9 |
| polyfills | [reflect-metadata](#reflect-metadata) | <!--v8--> v9 | | polyfills | [reflect-metadata](#reflect-metadata) | <!--v8--> v9 |
| `@angular/core` | [`defineInjectable`](#core) | v11 | | `@angular/core` | [`defineInjectable`](#core) | v11 |
| `@angular/router` | [`loadChildren` string syntax](#loadChildren) | v11 | | `@angular/router` | [`loadChildren` string syntax](#loadChildren) | v11 |
@ -211,14 +210,6 @@ Support for using the `ngModel` input property and `ngModelChange` event with re
For more information, see the usage notes for [`FormControlDirective`](api/forms/FormControlDirective#use-with-ngmodel) and [`FormControlName`](api/forms/FormControlName#use-with-ngmodel). For more information, see the usage notes for [`FormControlDirective`](api/forms/FormControlDirective#use-with-ngmodel) and [`FormControlName`](api/forms/FormControlName#use-with-ngmodel).
{@a sw-versionedfiles}
### Service worker versionedFiles
In the service worker configuration file `ngsw-config.json`, `versionedFiles` and `files` have the same behavior. As of v6, `versionedFiles` is deprecated; use `files` instead.
For more information, see [Service Worker Configuration](guide/service-worker-config#assetgroups).
{@a reflectiveinjector} {@a reflectiveinjector}
### ReflectiveInjector ### ReflectiveInjector
@ -418,7 +409,7 @@ The following APIs have been removed starting with version 8.0.0:
| `@angular/platform-browser` | [`DOCUMENT`](https://v7.angular.io/api/platform-browser/DOCUMENT) | [`DOCUMENT` in `@angular/common`](api/common/DOCUMENT) | Updating to version 8 with [`ng update`](cli/update) changes this automatically. | | `@angular/platform-browser` | [`DOCUMENT`](https://v7.angular.io/api/platform-browser/DOCUMENT) | [`DOCUMENT` in `@angular/common`](api/common/DOCUMENT) | Updating to version 8 with [`ng update`](cli/update) changes this automatically. |
| `@angular/core/testing` | [`TestBed.deprecatedOverrideProvider()`](https://v7.angular.io/api/core/testing/TestBed#deprecatedoverrideprovider) | [`TestBed.overrideProvider()`](api/core/testing/TestBed#overrideprovider) | none | | `@angular/core/testing` | [`TestBed.deprecatedOverrideProvider()`](https://v7.angular.io/api/core/testing/TestBed#deprecatedoverrideprovider) | [`TestBed.overrideProvider()`](api/core/testing/TestBed#overrideprovider) | none |
| `@angular/core/testing` | [`TestBedStatic.deprecatedOverrideProvider()`](https://v7.angular.io/api/core/testing/TestBedStatic#deprecatedoverrideprovider) | [`TestBedStatic.overrideProvider()`](api/core/testing/TestBedStatic#overrideprovider) | none | | `@angular/core/testing` | [`TestBedStatic.deprecatedOverrideProvider()`](https://v7.angular.io/api/core/testing/TestBedStatic#deprecatedoverrideprovider) | [`TestBedStatic.overrideProvider()`](api/core/testing/TestBedStatic#overrideprovider) | none |
| `@angular/service-worker` | `versionedFiles` | `files` | In the service worker configuration file `ngsw-config.json`, replace `versionedFiles` with `files`. See [Service Worker Configuration](guide/service-worker-config#assetgroups). |
<!-- The following anchor is used by redirects from the removed API pages. Do not change or remove. --> <!-- The following anchor is used by redirects from the removed API pages. Do not change or remove. -->

View File

@ -71,8 +71,6 @@ interface AssetGroup {
updateMode?: 'prefetch' | 'lazy'; updateMode?: 'prefetch' | 'lazy';
resources: { resources: {
files?: string[]; files?: string[];
/** @deprecated As of v6 `versionedFiles` and `files` options have the same behavior. Use `files` instead. */
versionedFiles?: string[];
urls?: string[]; urls?: string[];
}; };
} }
@ -104,12 +102,10 @@ Defaults to the value `installMode` is set to.
### `resources` ### `resources`
This section describes the resources to cache, broken up into three groups. This section describes the resources to cache, broken up into the following groups:
* `files` lists patterns that match files in the distribution directory. These can be single files or glob-like patterns that match a number of files. * `files` lists patterns that match files in the distribution directory. These can be single files or glob-like patterns that match a number of files.
* `versionedFiles` has been deprecated. As of v6 `versionedFiles` and `files` options have the same behavior. Use `files` instead.
* `urls` includes both URLs and URL patterns that will be matched at runtime. These resources are not fetched directly and do not have content hashes, but they will be cached according to their HTTP headers. This is most useful for CDNs such as the Google Fonts service.<br> * `urls` includes both URLs and URL patterns that will be matched at runtime. These resources are not fetched directly and do not have content hashes, but they will be cached according to their HTTP headers. This is most useful for CDNs such as the Google Fonts service.<br>
_(Negative glob patterns are not supported and `?` will be matched literally; i.e. it will not match any character other than `?`.)_ _(Negative glob patterns are not supported and `?` will be matched literally; i.e. it will not match any character other than `?`.)_

View File

@ -45,26 +45,13 @@ export class Generator {
Promise<Object[]> { Promise<Object[]> {
const seenMap = new Set<string>(); const seenMap = new Set<string>();
return Promise.all((config.assetGroups || []).map(async(group) => { 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 fileMatcher = globListToMatcher(group.resources.files || []);
const versionedMatcher = globListToMatcher(group.resources.versionedFiles || []);
const allFiles = await this.fs.list('/'); const allFiles = await this.fs.list('/');
const plainFiles = allFiles.filter(fileMatcher).filter(file => !seenMap.has(file)); const matchedFiles = allFiles.filter(fileMatcher).filter(file => !seenMap.has(file)).sort();
plainFiles.forEach(file => seenMap.add(file)); matchedFiles.forEach(file => seenMap.add(file));
const versionedFiles = allFiles.filter(versionedMatcher).filter(file => !seenMap.has(file));
versionedFiles.forEach(file => seenMap.add(file));
// Add the hashes. // Add the hashes.
const matchedFiles = [...plainFiles, ...versionedFiles].sort();
await matchedFiles.reduce(async(previous, file) => { await matchedFiles.reduce(async(previous, file) => {
await previous; await previous;
const hash = await this.fs.hash(file); const hash = await this.fs.hash(file);

View File

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

View File

@ -35,8 +35,6 @@ describe('Generator', () => {
'/**/*.html', '/**/*.html',
'/**/*.?s', '/**/*.?s',
'!/ignored/**', '!/ignored/**',
],
versionedFiles: [
'/**/*.txt', '/**/*.txt',
], ],
urls: [ urls: [

View File

@ -3,7 +3,6 @@ export interface AssetGroup {
name: string; name: string;
resources: { resources: {
files?: Glob[]; files?: Glob[];
/** @deprecated */ versionedFiles?: Glob[];
urls?: Glob[]; urls?: Glob[];
}; };
updateMode?: 'prefetch' | 'lazy'; updateMode?: 'prefetch' | 'lazy';