Skip to content

Commit e39027e

Browse files
committed
fix(workbox): deepClone options to avoid cross-build mutation
fixing issue with nuxt static build that initializes module twice
1 parent f07d7e8 commit e39027e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"test": "yarn lint && jest"
2020
},
2121
"dependencies": {
22+
"clone-deep": "^4.0.1",
2223
"defu": "^3.2.2",
2324
"execa": "^5.0.0",
2425
"fs-extra": "^9.0.1",

src/workbox/options.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { resolve } from 'path'
2+
import cloneDeep from 'clone-deep'
23
import { joinUrl, getRouteParams, startCase, randomString, PKG_DIR } from '../utils'
34
import type { WorkboxOptions, PWAContext } from '../../types'
45
import { defaults } from './defaults'
56

67
export function getOptions (nuxt, pwa: PWAContext): WorkboxOptions {
7-
const options: WorkboxOptions = { ...defaults, ...pwa.workbox }
8+
const options: WorkboxOptions = cloneDeep({ ...defaults, ...pwa.workbox })
89

910
// enabled
1011
if (options.enabled === undefined) {

0 commit comments

Comments
 (0)