From 9cc0dccb0da58e8f195003d01312c1a4fc130d05 Mon Sep 17 00:00:00 2001 From: yoyo930021 Date: Thu, 13 Oct 2022 14:50:38 +0800 Subject: [PATCH] feat: inject mode when injectManifest --- package.json | 1 + pnpm-lock.yaml | 237 +++++++++++++++++-------------------------------- src/modules.ts | 13 +-- 3 files changed, 91 insertions(+), 160 deletions(-) diff --git a/package.json b/package.json index 2bf04e10..e3903dbf 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "workbox-window": "^6.5.4" }, "dependencies": { + "@rollup/plugin-replace": "^4.0.0", "debug": "^4.3.4", "fast-glob": "^3.2.11", "pretty-bytes": "^6.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index afa7a930..73904ae9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,6 +6,7 @@ importers: specifiers: '@antfu/eslint-config': ^0.26.3 '@antfu/ni': ^0.18.0 + '@rollup/plugin-replace': ^4.0.0 '@types/debug': ^4.1.7 '@types/node': ^18.7.15 '@types/prompts': ^2.4.0 @@ -31,6 +32,7 @@ importers: workbox-build: ^6.5.4 workbox-window: ^6.5.4 dependencies: + '@rollup/plugin-replace': 4.0.0_rollup@2.79.0 debug: 4.3.4 fast-glob: 3.2.11 pretty-bytes: 6.0.0 @@ -45,7 +47,7 @@ importers: '@types/prompts': 2.4.0 '@types/react': 18.0.18 '@types/workbox-build': 5.0.1 - '@typescript-eslint/eslint-plugin': 5.36.2_yqf6kl63nyoq5megxukfnom5rm + '@typescript-eslint/eslint-plugin': 5.36.2_iurrlxgqcgk5svigzxakafpeuu eslint: 8.23.0 esno: 0.16.3 kolorist: 1.5.1 @@ -85,17 +87,17 @@ importers: devDependencies: '@types/fs-extra': 9.0.13 '@vitejs/plugin-vue': 3.1.0_vite@3.1.0+vue@3.2.38 - esbuild-register: 3.3.3 + esbuild-register: 3.3.3_esbuild@0.15.7 eslint: 8.23.0 fast-glob: 3.2.11 fs-extra: 10.1.0 https-localhost: 4.7.1 typescript: 4.8.2 unocss: 0.45.18_vite@3.1.0 - unplugin-vue-components: 0.22.4_vite@3.1.0+vue@3.2.38 + unplugin-vue-components: 0.22.4_5bjofutushg57eypoldhhzllr4 vite: 3.1.0 vite-plugin-pwa: link:.. - vitepress: 1.0.0-alpha.13 + vitepress: 1.0.0-alpha.13_tbpndr44ulefs3hehwpi2mkf2y workbox-window: 6.5.4 examples/preact-router: @@ -118,8 +120,8 @@ importers: preact: 10.10.6 preact-router: 4.1.0_preact@10.10.6 devDependencies: - '@preact/preset-vite': 2.3.1_preact@10.10.6+vite@3.1.0 - '@rollup/plugin-replace': 4.0.0 + '@preact/preset-vite': 2.3.1_ifsvlmccd3wx4hujwr6c53d6cq + '@rollup/plugin-replace': 4.0.0_rollup@2.79.0 cross-env: 7.0.3 https-localhost: 4.7.1 rimraf: 3.0.2 @@ -161,7 +163,7 @@ importers: react-router-config: 5.1.1_77xmmbgo3eovj6t3xv35v52s6m react-router-dom: 6.3.0_biqbaboplfbrettd7655fr4n2y devDependencies: - '@rollup/plugin-replace': 4.0.0 + '@rollup/plugin-replace': 4.0.0_rollup@2.79.0 '@types/react': 18.0.18 '@types/react-dom': 18.0.6 '@types/react-router-config': 5.0.6 @@ -198,7 +200,7 @@ importers: solid-app-router: 0.4.2_solid-js@1.5.4 solid-js: 1.5.4 devDependencies: - '@rollup/plugin-replace': 4.0.0 + '@rollup/plugin-replace': 4.0.0_rollup@2.79.0 cross-env: 7.0.3 https-localhost: 4.7.1 rimraf: 3.0.2 @@ -232,7 +234,7 @@ importers: workbox-precaching: ^6.5.4 workbox-routing: ^6.5.4 devDependencies: - '@rollup/plugin-replace': 4.0.0 + '@rollup/plugin-replace': 4.0.0_rollup@2.79.0 '@roxi/routify': 2.18.8 '@sveltejs/vite-plugin-svelte': 1.0.5_svelte@3.50.0+vite@3.1.0 '@tsconfig/svelte': 3.0.0 @@ -274,9 +276,9 @@ importers: workbox-precaching: ^6.5.3 workbox-routing: ^6.5.3 devDependencies: - '@rollup/plugin-replace': 4.0.0 - '@sveltejs/adapter-static': 1.0.0-next.42 - '@sveltejs/kit': 1.0.0-next.476_svelte@3.50.0 + '@rollup/plugin-replace': 4.0.0_rollup@2.79.0 + '@sveltejs/adapter-static': 1.0.0-next.44 + '@sveltejs/kit': 1.0.0-next.515_svelte@3.50.0+vite@3.1.0 '@typescript-eslint/eslint-plugin': 5.36.2_iurrlxgqcgk5svigzxakafpeuu '@typescript-eslint/parser': 5.36.2_yqf6kl63nyoq5megxukfnom5rm cross-env: 7.0.3 @@ -323,7 +325,7 @@ importers: dependencies: vue: 3.2.38 devDependencies: - '@rollup/plugin-replace': 4.0.0 + '@rollup/plugin-replace': 4.0.0_rollup@2.79.0 '@vitejs/plugin-vue': 3.1.0_vite@3.1.0+vue@3.2.38 '@vueuse/core': 9.2.0_vue@3.2.38 cross-env: 7.0.3 @@ -353,7 +355,7 @@ importers: vue: 3.2.38 vue-router: 4.1.5_vue@3.2.38 devDependencies: - '@rollup/plugin-replace': 4.0.0 + '@rollup/plugin-replace': 4.0.0_rollup@2.79.0 '@vitejs/plugin-vue': 3.1.0_vite@3.1.0+vue@3.2.38 '@vueuse/core': 9.2.0_vue@3.2.38 cross-env: 7.0.3 @@ -375,13 +377,14 @@ packages: '@algolia/autocomplete-shared': 1.7.1 dev: true - /@algolia/autocomplete-preset-algolia/1.7.1_algoliasearch@4.14.2: + /@algolia/autocomplete-preset-algolia/1.7.1_qs6lk5nhygj2o3hj4sf6xnr724: resolution: {integrity: sha512-pJwmIxeJCymU1M6cGujnaIYcY3QPOVYZOXhFkWVM7IxKzy272BwCvMFMyc5NpG/QmiObBxjo7myd060OeTNJXg==} peerDependencies: '@algolia/client-search': ^4.9.1 algoliasearch: ^4.9.1 dependencies: '@algolia/autocomplete-shared': 1.7.1 + '@algolia/client-search': 4.14.2 algoliasearch: 4.14.2 dev: true @@ -1159,15 +1162,6 @@ packages: '@babel/helper-plugin-utils': 7.19.0 dev: false - /@babel/plugin-syntax-jsx/7.18.6: - resolution: {integrity: sha512-6mmljtAedFGTWu2p/8WIORGwy+61PLgOMPOdazc7YoJ9ZCWUyFy3A6CpPkRKLKD1ToAesxX8KGEViAiLo9N+7Q==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0-0 - dependencies: - '@babel/helper-plugin-utils': 7.19.0 - dev: true - /@babel/plugin-syntax-jsx/7.18.6_@babel+core@7.19.0: resolution: {integrity: sha512-6mmljtAedFGTWu2p/8WIORGwy+61PLgOMPOdazc7YoJ9ZCWUyFy3A6CpPkRKLKD1ToAesxX8KGEViAiLo9N+7Q==} engines: {node: '>=6.9.0'} @@ -1532,13 +1526,14 @@ packages: '@babel/helper-plugin-utils': 7.19.0 dev: false - /@babel/plugin-transform-react-jsx-development/7.18.6: + /@babel/plugin-transform-react-jsx-development/7.18.6_@babel+core@7.19.0: resolution: {integrity: sha512-SA6HEjwYFKF7WDjWcMcMGUimmw/nhNRDWxr+KaLSCrkD/LMDBvWRmHAYgE1HDeF8KUuI8OAu+RT6EOtKxSW2qA==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/plugin-transform-react-jsx': 7.19.0 + '@babel/core': 7.19.0 + '@babel/plugin-transform-react-jsx': 7.19.0_@babel+core@7.19.0 dev: true /@babel/plugin-transform-react-jsx-self/7.18.6_@babel+core@7.19.0: @@ -1561,16 +1556,17 @@ packages: '@babel/helper-plugin-utils': 7.19.0 dev: true - /@babel/plugin-transform-react-jsx/7.19.0: + /@babel/plugin-transform-react-jsx/7.19.0_@babel+core@7.19.0: resolution: {integrity: sha512-UVEvX3tXie3Szm3emi1+G63jyw1w5IcMY0FSKM+CRnKRI5Mr1YbCNgsSTwoTwKphQEG9P+QqmuRFneJPZuHNhg==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: + '@babel/core': 7.19.0 '@babel/helper-annotate-as-pure': 7.18.6 '@babel/helper-module-imports': 7.18.6 '@babel/helper-plugin-utils': 7.19.0 - '@babel/plugin-syntax-jsx': 7.18.6 + '@babel/plugin-syntax-jsx': 7.18.6_@babel+core@7.19.0 '@babel/types': 7.19.0 dev: true @@ -1838,10 +1834,10 @@ packages: resolution: {integrity: sha512-gaP6TxxwQC+K8D6TRx5WULUWKrcbzECOPA2KCVMuI+6C7dNiGUk5yXXzVhc5sld79XKYLnO9DRTI4mjXDYkh+g==} dev: true - /@docsearch/js/3.2.1: + /@docsearch/js/3.2.1_tbpndr44ulefs3hehwpi2mkf2y: resolution: {integrity: sha512-H1PekEtSeS0msetR2YGGey2w7jQ2wAKfGODJvQTygSwMgUZ+2DHpzUgeDyEBIXRIfaBcoQneqrzsljM62pm6Xg==} dependencies: - '@docsearch/react': 3.2.1 + '@docsearch/react': 3.2.1_tbpndr44ulefs3hehwpi2mkf2y preact: 10.10.6 transitivePeerDependencies: - '@algolia/client-search' @@ -1850,7 +1846,7 @@ packages: - react-dom dev: true - /@docsearch/react/3.2.1: + /@docsearch/react/3.2.1_tbpndr44ulefs3hehwpi2mkf2y: resolution: {integrity: sha512-EzTQ/y82s14IQC5XVestiK/kFFMe2aagoYFuTAIfIb/e+4FU7kSMKonRtLwsCiLQHmjvNQq+HO+33giJ5YVtaQ==} peerDependencies: '@types/react': '>= 16.8.0 < 19.0.0' @@ -1865,7 +1861,7 @@ packages: optional: true dependencies: '@algolia/autocomplete-core': 1.7.1 - '@algolia/autocomplete-preset-algolia': 1.7.1_algoliasearch@4.14.2 + '@algolia/autocomplete-preset-algolia': 1.7.1_qs6lk5nhygj2o3hj4sf6xnr724 '@docsearch/css': 3.2.1 algoliasearch: 4.14.2 transitivePeerDependencies: @@ -2021,17 +2017,18 @@ packages: resolution: {integrity: sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==} dev: true - /@preact/preset-vite/2.3.1_preact@10.10.6+vite@3.1.0: + /@preact/preset-vite/2.3.1_ifsvlmccd3wx4hujwr6c53d6cq: resolution: {integrity: sha512-QG9w1VIumLoqfH9FPbG8TgQMG2cNhIPtAiKQWPPZ/XuiqPBpnEksuHhLozrl9oj97m4SFbLvXfxKSGX7Ovysgg==} peerDependencies: '@babel/core': 7.x vite: 2.x || 3.x dependencies: - '@babel/plugin-transform-react-jsx': 7.19.0 - '@babel/plugin-transform-react-jsx-development': 7.18.6 + '@babel/core': 7.19.0 + '@babel/plugin-transform-react-jsx': 7.19.0_@babel+core@7.19.0 + '@babel/plugin-transform-react-jsx-development': 7.18.6_@babel+core@7.19.0 '@prefresh/vite': 2.2.8_preact@10.10.6+vite@3.1.0 '@rollup/pluginutils': 4.2.1 - babel-plugin-transform-hook-names: 1.0.2 + babel-plugin-transform-hook-names: 1.0.2_@babel+core@7.19.0 debug: 4.3.4 kolorist: 1.5.1 resolve: 1.22.1 @@ -2116,25 +2113,14 @@ packages: rollup: 2.79.0 dev: false - /@rollup/plugin-replace/4.0.0: + /@rollup/plugin-replace/4.0.0_rollup@2.79.0: resolution: {integrity: sha512-+rumQFiaNac9y64OHtkHGmdjm7us9bo1PlbgQfdihQtuNxzjpaB064HbRnewUOggLQxVCCyINfStkgmBeQpv1g==} peerDependencies: rollup: ^1.20.0 || ^2.0.0 dependencies: - '@rollup/pluginutils': 3.1.0 + '@rollup/pluginutils': 3.1.0_rollup@2.79.0 magic-string: 0.25.9 - dev: true - - /@rollup/pluginutils/3.1.0: - resolution: {integrity: sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==} - engines: {node: '>= 8.0.0'} - peerDependencies: - rollup: ^1.20.0||^2.0.0 - dependencies: - '@types/estree': 0.0.39 - estree-walker: 1.0.1 - picomatch: 2.3.1 - dev: true + rollup: 2.79.0 /@rollup/pluginutils/3.1.0_rollup@2.79.0: resolution: {integrity: sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==} @@ -2146,7 +2132,6 @@ packages: estree-walker: 1.0.1 picomatch: 2.3.1 rollup: 2.79.0 - dev: false /@rollup/pluginutils/4.2.1: resolution: {integrity: sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==} @@ -2199,12 +2184,12 @@ packages: string.prototype.matchall: 4.0.7 dev: false - /@sveltejs/adapter-static/1.0.0-next.42: - resolution: {integrity: sha512-BLMQY8zfUibex5FE3zkMXdkW4l/n+1tecUrCxmmO5jc8vEuZc41VQdmQtDifX80Bf1pCG3RH7151tJ+jqte2lg==} + /@sveltejs/adapter-static/1.0.0-next.44: + resolution: {integrity: sha512-qBtkmIMYGiDv5r2F3AfSG0ABHZim2NC+1PL2YVCa+QYz8IVCm1E/wGQ0RW4KVrANZ3MZk8y52PPajx+8/fwmNw==} dev: true - /@sveltejs/kit/1.0.0-next.476_svelte@3.50.0: - resolution: {integrity: sha512-sCd51gwU5eva/bFEQCQDgRc2buNCHC3bk5tLz7uoF7PUkNFFuqJSfkLYd3hs1T3VQWrkH8oU9HK3mJsUKAWe1A==} + /@sveltejs/kit/1.0.0-next.515_svelte@3.50.0+vite@3.1.0: + resolution: {integrity: sha512-Ck+T16bci7VWc4CNP61xvfMrbDHX1Q8aPZWgthnrSH8hsdx9w1MP80D9V4A98WX0cyhCQ02JzlTmxgf2UpYRbQ==} engines: {node: '>=16.14'} hasBin: true requiresBuild: true @@ -2212,46 +2197,25 @@ packages: svelte: ^3.44.0 vite: ^3.1.0 dependencies: - '@sveltejs/vite-plugin-svelte': 1.0.5_svelte@3.50.0 + '@sveltejs/vite-plugin-svelte': 1.0.5_svelte@3.50.0+vite@3.1.0 + '@types/cookie': 0.5.1 cookie: 0.5.0 - devalue: 3.1.3 + devalue: 4.0.0 kleur: 4.1.5 magic-string: 0.26.3 mime: 3.0.0 - node-fetch: 3.2.10 sade: 1.8.1 set-cookie-parser: 2.5.1 sirv: 2.0.2 svelte: 3.50.0 tiny-glob: 0.2.9 - undici: 5.10.0 + undici: 5.11.0 + vite: 3.1.0 transitivePeerDependencies: - diff-match-patch - supports-color dev: true - /@sveltejs/vite-plugin-svelte/1.0.5_svelte@3.50.0: - resolution: {integrity: sha512-CmSdSow0Dr5ua1A11BQMtreWnE0JZmkVIcRU/yG3PKbycKUpXjNdgYTWFSbStLB0vdlGnBbm2+Y4sBVj+C+TIw==} - engines: {node: ^14.18.0 || >= 16} - peerDependencies: - diff-match-patch: ^1.0.5 - svelte: ^3.44.0 - vite: ^3.0.0 - peerDependenciesMeta: - diff-match-patch: - optional: true - dependencies: - '@rollup/pluginutils': 4.2.1 - debug: 4.3.4 - deepmerge: 4.2.2 - kleur: 4.1.5 - magic-string: 0.26.3 - svelte: 3.50.0 - svelte-hmr: 0.14.12_svelte@3.50.0 - transitivePeerDependencies: - - supports-color - dev: true - /@sveltejs/vite-plugin-svelte/1.0.5_svelte@3.50.0+vite@3.1.0: resolution: {integrity: sha512-CmSdSow0Dr5ua1A11BQMtreWnE0JZmkVIcRU/yG3PKbycKUpXjNdgYTWFSbStLB0vdlGnBbm2+Y4sBVj+C+TIw==} engines: {node: ^14.18.0 || >= 16} @@ -2284,6 +2248,10 @@ packages: resolution: {integrity: sha512-pYrtLtOwku/7r1i9AMONsJMVYAtk3hzOfiGNekhtq5tYBGA7unMve8RvUclKLMT3PrihvJqUmzsRGh0RP84hKg==} dev: true + /@types/cookie/0.5.1: + resolution: {integrity: sha512-COUnqfB2+ckwXXSFInsFdOAWQzCCx+a5hq2ruyj+Vjund94RJQd4LG2u9hnvJrTgunKAaax7ancBYlDrNYxA0g==} + dev: true + /@types/debug/4.1.7: resolution: {integrity: sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==} dependencies: @@ -2444,32 +2412,6 @@ packages: - supports-color dev: true - /@typescript-eslint/eslint-plugin/5.36.2_yqf6kl63nyoq5megxukfnom5rm: - resolution: {integrity: sha512-OwwR8LRwSnI98tdc2z7mJYgY60gf7I9ZfGjN5EjCwwns9bdTuQfAXcsjSB2wSQ/TVNYSGKf4kzVXbNGaZvwiXw==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - peerDependencies: - '@typescript-eslint/parser': ^5.0.0 - eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@typescript-eslint/scope-manager': 5.36.2 - '@typescript-eslint/type-utils': 5.36.2_yqf6kl63nyoq5megxukfnom5rm - '@typescript-eslint/utils': 5.36.2_yqf6kl63nyoq5megxukfnom5rm - debug: 4.3.4 - eslint: 8.23.0 - functional-red-black-tree: 1.0.1 - ignore: 5.2.0 - regexpp: 3.2.0 - semver: 7.3.7 - tsutils: 3.21.0_typescript@4.8.2 - typescript: 4.8.2 - transitivePeerDependencies: - - supports-color - dev: true - /@typescript-eslint/parser/5.36.2_yqf6kl63nyoq5megxukfnom5rm: resolution: {integrity: sha512-qS/Kb0yzy8sR0idFspI9Z6+t7mqk/oRjnAYfewG+VN73opAUvmYL3oPIMmgOX6CnQS6gmVIXGshlb5RY/R22pA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -3076,10 +3018,12 @@ packages: - supports-color dev: false - /babel-plugin-transform-hook-names/1.0.2: + /babel-plugin-transform-hook-names/1.0.2_@babel+core@7.19.0: resolution: {integrity: sha512-5gafyjyyBTTdX/tQQ0hRgu4AhNHG/hqWi0ZZmg2xvs2FgRkJXzDNKBZCyoYqgFkovfDrgM8OoKg8karoUvWeCw==} peerDependencies: '@babel/core': ^7.12.10 + dependencies: + '@babel/core': 7.19.0 dev: true /babel-preset-solid/1.5.4_@babel+core@7.19.0: @@ -3193,6 +3137,13 @@ packages: load-tsconfig: 0.2.3 dev: true + /busboy/1.6.0: + resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} + engines: {node: '>=10.16.0'} + dependencies: + streamsearch: 1.1.0 + dev: true + /bytes/3.0.0: resolution: {integrity: sha512-pMhOfFDPiv9t5jjIXkHosWmkSyQbvsgEVNkz0ERHbuLh2T/7j4Mqqpz523Fe8MVY89KC6Sh/QfS2sM+SjgFDcw==} engines: {node: '>= 0.8'} @@ -3464,11 +3415,6 @@ packages: /csstype/3.1.0: resolution: {integrity: sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA==} - /data-uri-to-buffer/4.0.0: - resolution: {integrity: sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==} - engines: {node: '>= 12'} - dev: true - /data-urls/2.0.0: resolution: {integrity: sha512-X5eWTSXO/BJmpdIKCRuKUgSCgAN0OwliVK3yPKbwIWU1Tdw5BRajxlzMidvh+gwko9AfQ9zIj52pzF91Q3YAvQ==} engines: {node: '>=10'} @@ -3562,8 +3508,8 @@ packages: resolution: {integrity: sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==} dev: true - /devalue/3.1.3: - resolution: {integrity: sha512-9KO89Cb+qjzf2CqdrH+NuLaqdk9GhDP5EhR4zlkR51dvuIaiqtlkDkGzLMShDemwUy21raSMdu+kpX8Enw3yGQ==} + /devalue/4.0.0: + resolution: {integrity: sha512-w25siwXyuMUqMr7jPlEjyNCp1vn0Jzj/fNg3qVt/r/Dpe8HjESh2V92L0jmh3uq4iJt0BvjH+Azk1pQzkcnDWA==} dev: true /dir-glob/3.0.1: @@ -3851,10 +3797,12 @@ packages: dev: true optional: true - /esbuild-register/3.3.3: + /esbuild-register/3.3.3_esbuild@0.15.7: resolution: {integrity: sha512-eFHOkutgIMJY5gc8LUp/7c+LLlDqzNi9T6AwCZ2WKKl3HmT+5ef3ZRyPPxDOynInML0fgaC50yszPKfPnjC0NQ==} peerDependencies: esbuild: '>=0.12 <1' + dependencies: + esbuild: 0.15.7 dev: true /esbuild-sunos-64/0.15.7: @@ -4443,14 +4391,6 @@ packages: dependencies: reusify: 1.0.4 - /fetch-blob/3.2.0: - resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==} - engines: {node: ^12.20 || >= 14.13} - dependencies: - node-domexception: 1.0.0 - web-streams-polyfill: 3.2.1 - dev: true - /file-entry-cache/6.0.1: resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} engines: {node: ^10.12.0 || >=12.0.0} @@ -4522,13 +4462,6 @@ packages: mime-types: 2.1.35 dev: true - /formdata-polyfill/4.0.10: - resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==} - engines: {node: '>=12.20.0'} - dependencies: - fetch-blob: 3.2.0 - dev: true - /forwarded/0.2.0: resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==} engines: {node: '>= 0.6'} @@ -5474,11 +5407,6 @@ packages: engines: {node: '>= 0.6'} dev: true - /node-domexception/1.0.0: - resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} - engines: {node: '>=10.5.0'} - dev: true - /node-fetch-native/0.1.4: resolution: {integrity: sha512-10EKpOCQPXwZVFh3U1ptOMWBgKTbsN7Vvo6WVKt5pw4hp8zbv6ZVBZPlXw+5M6Tyi1oc1iD4/sNPd71KYA16tQ==} dev: true @@ -5495,15 +5423,6 @@ packages: whatwg-url: 5.0.0 dev: true - /node-fetch/3.2.10: - resolution: {integrity: sha512-MhuzNwdURnZ1Cp4XTazr69K0BTizsBroX7Zx3UgDSVcZYKF/6p0CBe4EUb/hLqmzVhl0UpYfgRljQ4yxE+iCxA==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dependencies: - data-uri-to-buffer: 4.0.0 - fetch-blob: 3.2.0 - formdata-polyfill: 4.0.10 - dev: true - /node-gyp-build/4.5.0: resolution: {integrity: sha512-2iGbaQBV+ITgCz76ZEjmhUKAKVf7xfY1sRl4UiKQspfZMH2h06SyhNsnSVy50cwkFQDGLyif6m/6uFXHkOZ6rg==} hasBin: true @@ -6449,6 +6368,11 @@ packages: engines: {node: '>= 0.8'} dev: true + /streamsearch/1.1.0: + resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==} + engines: {node: '>=10.0.0'} + dev: true + /string.prototype.matchall/4.0.7: resolution: {integrity: sha512-f48okCX7JiwVi1NXCVWcFnZgADDC/n2vePlQ/KUCNqCikLLilQvwjMO8+BHVKvgzH0JB0J9LEPgxOGT02RoETg==} dependencies: @@ -6918,6 +6842,13 @@ packages: engines: {node: '>=12.18'} dev: true + /undici/5.11.0: + resolution: {integrity: sha512-oWjWJHzFet0Ow4YZBkyiJwiK5vWqEYoH7BINzJAJOLedZ++JpAlCbUktW2GQ2DS2FpKmxD/JMtWUUWl1BtghGw==} + engines: {node: '>=12.18'} + dependencies: + busboy: 1.6.0 + dev: true + /unicode-canonical-property-names-ecmascript/2.0.0: resolution: {integrity: sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ==} engines: {node: '>=4'} @@ -6999,7 +6930,7 @@ packages: engines: {node: '>= 0.8'} dev: true - /unplugin-vue-components/0.22.4_vite@3.1.0+vue@3.2.38: + /unplugin-vue-components/0.22.4_5bjofutushg57eypoldhhzllr4: resolution: {integrity: sha512-2rRZcM9OnJGXnYxQNfaceEYuPeVACcWySIjy8WBwIiN3onr980TmA3XE5pRJFt8zoQrUA+c46oyIq96noLqrEQ==} engines: {node: '>=14'} peerDependencies: @@ -7018,7 +6949,7 @@ packages: magic-string: 0.26.3 minimatch: 5.1.0 resolve: 1.22.1 - unplugin: 0.9.5_vite@3.1.0 + unplugin: 0.9.5_esbuild@0.15.7+vite@3.1.0 vue: 3.2.38 transitivePeerDependencies: - esbuild @@ -7028,7 +6959,7 @@ packages: - webpack dev: true - /unplugin/0.9.5_vite@3.1.0: + /unplugin/0.9.5_esbuild@0.15.7+vite@3.1.0: resolution: {integrity: sha512-luraheyfxwtvkvHpsOvMNv7IjLdORTWKZp0gWYNHGLi2ImON3iIZOj464qEyyEwLA/EMt12fC415HW9zRpOfTg==} peerDependencies: esbuild: '>=0.13' @@ -7047,6 +6978,7 @@ packages: dependencies: acorn: 8.8.0 chokidar: 3.5.3 + esbuild: 0.15.7 vite: 3.1.0 webpack-sources: 3.2.3 webpack-virtual-modules: 0.4.4 @@ -7152,12 +7084,12 @@ packages: fsevents: 2.3.2 dev: true - /vitepress/1.0.0-alpha.13: + /vitepress/1.0.0-alpha.13_tbpndr44ulefs3hehwpi2mkf2y: resolution: {integrity: sha512-gCbKb+6o0g5wHt2yyqBPk7FcvrB+MfwGtg1JMS5p99GTQR87l3b7symCl8o1ecv7MDXwJ2mPB8ZrYNLnQAJxLQ==} hasBin: true dependencies: '@docsearch/css': 3.2.1 - '@docsearch/js': 3.2.1 + '@docsearch/js': 3.2.1_tbpndr44ulefs3hehwpi2mkf2y '@vitejs/plugin-vue': 3.1.0_vite@3.1.0+vue@3.2.38 '@vue/devtools-api': 6.2.1 '@vueuse/core': 9.2.0_vue@3.2.38 @@ -7254,11 +7186,6 @@ packages: minimalistic-assert: 1.0.1 dev: true - /web-streams-polyfill/3.2.1: - resolution: {integrity: sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==} - engines: {node: '>= 8'} - dev: true - /webidl-conversions/3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} dev: true diff --git a/src/modules.ts b/src/modules.ts index 1e499442..07398af6 100644 --- a/src/modules.ts +++ b/src/modules.ts @@ -3,6 +3,7 @@ import { promises as fs } from 'fs' import { fileURLToPath } from 'url' import type { BuildResult } from 'workbox-build' import type { ResolvedConfig } from 'vite' +import replace from '@rollup/plugin-replace' import type { ResolvedVitePWAOptions } from './types' import { logWorkboxResult } from './log' import { defaultInjectManifestVitePlugins } from './constants' @@ -98,7 +99,13 @@ export async function generateInjectManifest(options: ResolvedVitePWAOptions, vi if (includedPluginNames.length === 0) includedPluginNames.push(...defaultInjectManifestVitePlugins) - const plugins = viteOptions.plugins.filter(p => includedPluginNames.includes(p.name)) + const plugins = [ + replace({ + 'preventAssignment': true, + 'process.env.NODE_ENV': JSON.stringify(options.mode), + }), + ...viteOptions.plugins.filter(p => includedPluginNames.includes(p.name)), + ] const { rollup } = await import('rollup') const bundle = await rollup({ input: options.swSrc, @@ -124,10 +131,6 @@ export async function generateInjectManifest(options: ResolvedVitePWAOptions, vi swSrc: options.injectManifest.swDest, } - // options.injectManifest.mode won't work!!! - // error during build: ValidationError: "mode" is not allowed - // delete injectManifestOptions.mode - const { injectManifest } = await loadWorkboxBuild() // inject the manifest