From e39027ee7159103d755fe67c1c105235f3257739 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sun, 20 Dec 2020 16:30:57 +0100 Subject: [PATCH] fix(workbox): deepClone options to avoid cross-build mutation fixing issue with nuxt static build that initializes module twice --- package.json | 1 + src/workbox/options.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index a8535f98..db4b69df 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "test": "yarn lint && jest" }, "dependencies": { + "clone-deep": "^4.0.1", "defu": "^3.2.2", "execa": "^5.0.0", "fs-extra": "^9.0.1", diff --git a/src/workbox/options.ts b/src/workbox/options.ts index f53e0288..8d3b769a 100644 --- a/src/workbox/options.ts +++ b/src/workbox/options.ts @@ -1,10 +1,11 @@ import { resolve } from 'path' +import cloneDeep from 'clone-deep' import { joinUrl, getRouteParams, startCase, randomString, PKG_DIR } from '../utils' import type { WorkboxOptions, PWAContext } from '../../types' import { defaults } from './defaults' export function getOptions (nuxt, pwa: PWAContext): WorkboxOptions { - const options: WorkboxOptions = { ...defaults, ...pwa.workbox } + const options: WorkboxOptions = cloneDeep({ ...defaults, ...pwa.workbox }) // enabled if (options.enabled === undefined) {