From 3a79aa417a90fba76e32457323878219d5f12fbd Mon Sep 17 00:00:00 2001 From: grunghi Date: Fri, 15 Apr 2022 10:18:44 +0200 Subject: [PATCH 1/2] Add Nuxt 3 section to README --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index 863ffbf..8aa52c3 100644 --- a/README.md +++ b/README.md @@ -238,5 +238,33 @@ See [MapOptions](https://developers.google.com/maps/documentation/javascript/ref Many other components are also supported. Checkout [docs](https://vue-map.netlify.app) for more. +### Nuxt 3 usage + +First add `@fawmi/vue-google-maps` to `build.transpile` property in your `nuxt.config.ts`. + + ```ts +export default defineNuxtConfig({ + build: { + transpile: ['@fawmi/vue-google-maps'] + }, +}) + ``` + +Then create a plugin `~/plugin/vueGoogleMaps.ts`, you can store the API key in publicRuntimeConfig, checkout [nuxt docs](https://nuxtjs.org/docs/directory-structure/nuxt-config#runtimeconfig). + +```ts +import { defineNuxtPlugin } from '#app' +import VueGoogleMaps from '@fawmi/vue-google-maps' + +export default defineNuxtPlugin((nuxtApp) => { + nuxtApp.vueApp.use(VueGoogleMaps, { + load: { + key: nuxtApp.$config.googleApiKey, + }, + }) +}) +``` + + ## Contributions The best way to contribute is to report reproducible bugs, but feature requests and improvement suggestions are always welcome too. And definitely bug fixes and PR are welcome. From 1fc8cf3c5ecccb948f35531f143e8aa329691d57 Mon Sep 17 00:00:00 2001 From: grunghi Date: Fri, 15 Apr 2022 10:58:33 +0200 Subject: [PATCH 2/2] Use ESM export instead of CJS in utils/lazyValue.js to prevent build error in nuxt3 --- src/utils/lazyValue.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/lazyValue.js b/src/utils/lazyValue.js index 6c25151..fbec207 100644 --- a/src/utils/lazyValue.js +++ b/src/utils/lazyValue.js @@ -1,6 +1,6 @@ // lazy-value by sindresorhus -module.exports = fn => { +export default fn => { let called = false; let result;