Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service Worker fails in dev if runtimeOnly flag is set to false #1333

Closed
4 tasks done
Polm90 opened this issue Feb 15, 2023 · 1 comment
Closed
4 tasks done

Service Worker fails in dev if runtimeOnly flag is set to false #1333

Polm90 opened this issue Feb 15, 2023 · 1 comment
Labels
❗ p4-important Priority 4: bugs that violate documented behavior, or significantly impact perf Type: Improvement Includes backwards-compatible fixes

Comments

@Polm90
Copy link

Polm90 commented Feb 15, 2023

Reporting a bug?

If I configure the VueI18nPlugin with the runtimeOnly flag to false, I cannot run in dev mode a service worker injected with the vite-plugin-pwa plugin with strategy 'injectManifest'. I receive as error 'cannot use import statement outside a module'.

Setting the flag to true, everything works as expected.
However, with the flag set to true, the named interpolation is not working when the app is built. See this #1278

Expected behavior

I should be able to use the serviceworker properly.

Reproduction

Custom service worker file:

import` {precacheAndRoute} from 'workbox-precaching';

precacheAndRoute(self.__WB_MANIFEST);

vite.config.js plugins configuration:

VueI18nPlugin({
			include: resolve(dirname(fileURLToPath(import.meta.url)), './src/locales/**'),
			runtimeOnly: false
		}),
		VitePWA({
			injectRegister: 'auto',
			registerType: 'prompt',
			devOptions: {
				enabled: true,
				type: 'module'
			},
			workbox: {
				globPatterns: ['**/*.{js,css,html,json,ico,svg,ttf,webmanifest}'],
			},
			srcDir: '',
			filename: 'custom-sw.js',
			strategies: 'injectManifest',
			includeAssets: ['favicon.ico', 'apple-icon-180.png', '**/*.{js,css,html,json,ico,svg,ttf,webmanifest}'],
			manifest: {
				//omitted
			}
		})

System Info

vite: 4.1.1
vue: 3.2.47
node:  19.6.0
npm: 9.4.2
@intlify/unplugin-vue-i18n: 0.8.2
vue-i18n: 9.2.2
vite-plugin-pwa: 0.14.4
workbox-precaching: 6.5.4

Screenshot

No response

Additional context

No response

Validations

@Polm90 Polm90 added the Status: Review Needed Request for review comments label Feb 15, 2023
@kazupon kazupon added the Type: Improvement Includes backwards-compatible fixes label Jun 5, 2023
@kazupon kazupon added ❗ p4-important Priority 4: bugs that violate documented behavior, or significantly impact perf and removed Status: Review Needed Request for review comments labels Jun 5, 2023 — with Volta.net
Copy link
Member

kazupon commented Aug 29, 2023

From v9.3.0-beta.20, vue-i18n can be compile like JIT style.
so you can integrate back-end that has locale messages.
https://vue-i18n.intlify.dev/guide/advanced/optimization.html#jit-compilation
example is here
https://github.com/intlify/vue-i18n-next/tree/master/examples/backend
so close.

@kazupon kazupon closed this as completed Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❗ p4-important Priority 4: bugs that violate documented behavior, or significantly impact perf Type: Improvement Includes backwards-compatible fixes
Projects
None yet
Development

No branches or pull requests

2 participants