This repository has been archived by the owner on Apr 6, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bridge): use
useMeta
in bridge projects
* includes `nuxt.app` shim and `vue` module that exports composition api functions
- Loading branch information
Showing
13 changed files
with
143 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { resolve } from 'pathe' | ||
import defu from 'defu' | ||
import { resolveModule, defineNuxtModule, addTemplate, addPlugin } from '@nuxt/kit' | ||
import type { MetaObject } from '../../nuxt3/src/meta/runtime' | ||
import { distDir } from './dirs' | ||
|
||
const checkDocsMsg = 'Please see https://v3.nuxtjs.org for more information.' | ||
const msgPrefix = '[bridge] [meta]' | ||
|
||
export default defineNuxtModule({ | ||
name: 'meta', | ||
defaults: { | ||
charset: 'utf-8', | ||
viewport: 'width=device-width, initial-scale=1' | ||
}, | ||
setup (options, nuxt) { | ||
// Alias vue to a vue3-compat version of vue2 | ||
nuxt.options.alias['#vue'] = nuxt.options.alias.vue || resolveModule('vue/dist/vue.runtime.esm.js', { paths: nuxt.options.modulesDir }) | ||
nuxt.options.alias['@vue/shared'] = 'vue' | ||
nuxt.options.alias['@vue/reactivity'] = 'vue' | ||
nuxt.options.alias.vue = resolve(distDir, 'runtime/vue.mjs') | ||
|
||
// Turn off vue-meta and migrate configuration | ||
nuxt.options.features.meta = false | ||
if (nuxt.options.head) { | ||
if (typeof nuxt.options.head === 'function') { | ||
throw new TypeError(`${msgPrefix} Please move head() function from \`nuxt.config\` to \`app.vue\`. ${checkDocsMsg}`) | ||
} else { | ||
console.warn(`${msgPrefix} Please rename \`head\` to \`meta\` in your \`nuxt.config\`. ${checkDocsMsg}`) | ||
nuxt.options.meta = defu(nuxt.options.meta, nuxt.options.head) | ||
} | ||
} | ||
|
||
const runtimeDir = resolve(distDir, 'runtime/meta') | ||
|
||
// Transpile @nuxt/meta and @vueuse/head | ||
nuxt.options.build.transpile.push(runtimeDir, 'vue', '@vueuse/head') | ||
|
||
// Add #meta alias | ||
nuxt.options.alias['#meta'] = runtimeDir | ||
|
||
// Global meta | ||
const globalMeta: MetaObject = defu(nuxt.options.meta, { | ||
meta: [ | ||
{ charset: options.charset }, | ||
{ name: 'viewport', content: options.viewport } | ||
] | ||
}) | ||
|
||
// Add global meta configuration | ||
addTemplate({ | ||
filename: 'meta.config.mjs', | ||
getContents: () => 'export default ' + JSON.stringify({ globalMeta, mixinKey: 'setup' }) | ||
}) | ||
|
||
// Add generic plugin | ||
addPlugin({ src: resolve(runtimeDir, 'plugin') }) | ||
|
||
// Add library specific plugin | ||
addPlugin({ src: resolve(runtimeDir, 'lib/vueuse-head.plugin') }) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../nuxt3/src/meta/runtime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Vue from '#vue' | ||
|
||
export * from '@vue/composition-api' | ||
|
||
export const isFunction = fn => fn instanceof Function | ||
|
||
export { Vue as default } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters