Skip to content

Commit

Permalink
feat: migrate workbox-webpack-plugin to typescript (#2882)
Browse files Browse the repository at this point in the history
* feat: migrate workbox-webpack-plugin to typescript

* progress on typescript migration

* 15e from ts lint

* draft

* fixing webpack version

* running tests

* running tests

* eslint

* passing tests for workbox webpack plugin

* passing tests for wb wpp

* passing tests for workbox webpack plugin

passing tests for wb wpp

cleaning imports

* cleaning some eslint messages

* keeping the checkConditions method signature for backward compatibility

* fixing documentation

* commiting package-lock

* updating the webpack plugin package-lock

* Fixing typescript typing issues

Co-authored-by: Adriana Jara Salazar <ajara@google.com>
Co-authored-by: Adriana Jara <32825533+tropicadri@users.noreply.github.com>
  • Loading branch information
3 people committed Feb 18, 2022
1 parent 10859de commit 55e8144
Show file tree
Hide file tree
Showing 29 changed files with 32,741 additions and 467 deletions.
25,721 changes: 25,582 additions & 139 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -123,6 +123,5 @@
"test_node": "gulp test_node",
"test_server": "gulp test_server",
"version": "gulp build && git add -A packages"
},
"version": "0.0.0"
}
}
4 changes: 2 additions & 2 deletions packages/workbox-build/src/lib/populate-sw-template.ts
Expand Up @@ -31,9 +31,9 @@ export function populateSWTemplate({
offlineGoogleAnalytics,
runtimeCaching = [],
skipWaiting,
}: GeneratePartial & {manifestEntries: Array<ManifestEntry>}): string {
}: GeneratePartial & {manifestEntries?: Array<ManifestEntry>}): string {
// There needs to be at least something to precache, or else runtime caching.
if (!(manifestEntries.length > 0 || runtimeCaching.length > 0)) {
if (!(manifestEntries?.length > 0 || runtimeCaching.length > 0)) {
throw new Error(errors['no-manifest-entries-or-runtime-caching']);
}

Expand Down
7 changes: 5 additions & 2 deletions packages/workbox-build/src/schema/GenerateSWOptions.json
Expand Up @@ -467,11 +467,14 @@
"QueueOptions": {
"type": "object",
"properties": {
"onSync": {
"$ref": "#/definitions/OnSyncCallback"
"forceSyncFallback": {
"type": "boolean"
},
"maxRetentionTime": {
"type": "number"
},
"onSync": {
"$ref": "#/definitions/OnSyncCallback"
}
},
"additionalProperties": false
Expand Down
7 changes: 5 additions & 2 deletions packages/workbox-build/src/schema/GetManifestOptions.json
Expand Up @@ -342,11 +342,14 @@
"QueueOptions": {
"type": "object",
"properties": {
"onSync": {
"$ref": "#/definitions/OnSyncCallback"
"forceSyncFallback": {
"type": "boolean"
},
"maxRetentionTime": {
"type": "number"
},
"onSync": {
"$ref": "#/definitions/OnSyncCallback"
}
},
"additionalProperties": false
Expand Down
7 changes: 5 additions & 2 deletions packages/workbox-build/src/schema/InjectManifestOptions.json
Expand Up @@ -357,11 +357,14 @@
"QueueOptions": {
"type": "object",
"properties": {
"onSync": {
"$ref": "#/definitions/OnSyncCallback"
"forceSyncFallback": {
"type": "boolean"
},
"maxRetentionTime": {
"type": "number"
},
"onSync": {
"$ref": "#/definitions/OnSyncCallback"
}
},
"additionalProperties": false
Expand Down
Expand Up @@ -445,11 +445,14 @@
"QueueOptions": {
"type": "object",
"properties": {
"onSync": {
"$ref": "#/definitions/OnSyncCallback"
"forceSyncFallback": {
"type": "boolean"
},
"maxRetentionTime": {
"type": "number"
},
"onSync": {
"$ref": "#/definitions/OnSyncCallback"
}
},
"additionalProperties": false
Expand Down
Expand Up @@ -345,11 +345,14 @@
"QueueOptions": {
"type": "object",
"properties": {
"onSync": {
"$ref": "#/definitions/OnSyncCallback"
"forceSyncFallback": {
"type": "boolean"
},
"maxRetentionTime": {
"type": "number"
},
"onSync": {
"$ref": "#/definitions/OnSyncCallback"
}
},
"additionalProperties": false
Expand Down
6 changes: 4 additions & 2 deletions packages/workbox-build/src/types.ts
Expand Up @@ -437,7 +437,8 @@ export interface WebpackPartial {
* as `webpack`'s standard `exclude` option.
* If not provided, the default value is `[/\.map$/, /^manifest.*\.js$]`.
*/
exclude?: Array<string | RegExp | ((arg0: string) => boolean)>;
//eslint-disable-next-line @typescript-eslint/ban-types
exclude?: Array<string | RegExp | ((arg0: any) => boolean)>;
/**
* One or more chunk names whose corresponding output files should be excluded
* from the precache manifest.
Expand All @@ -449,7 +450,8 @@ export interface WebpackPartial {
* [the same rules](https://webpack.js.org/configuration/module/#condition)
* as `webpack`'s standard `include` option.
*/
include?: Array<string | RegExp | ((arg0: string) => boolean)>;
//eslint-disable-next-line @typescript-eslint/ban-types
include?: Array<string | RegExp | ((arg0: any) => boolean)>;
/**
* If set to 'production', then an optimized service worker bundle that
* excludes debugging info will be produced. If not explicitly configured
Expand Down

0 comments on commit 55e8144

Please sign in to comment.