refactor(nuxt): deprecate <Script> component tag in template (#8197)

This commit is contained in:
Daniel Roe 2022-10-15 12:20:24 +01:00 committed by GitHub
parent 256c1fd4fc
commit 5e7dfc2338
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,6 +66,10 @@ const globalProps = {
} }
// <script> // <script>
let scriptDeprecated = false
/** @deprecated */
export const Script = defineComponent({ export const Script = defineComponent({
// eslint-disable-next-line vue/no-reserved-component-names // eslint-disable-next-line vue/no-reserved-component-names
name: 'Script', name: 'Script',
@ -93,6 +97,11 @@ export const Script = defineComponent({
renderPriority: [String, Number] renderPriority: [String, Number]
}, },
setup: setupForUseMeta((props, { slots }) => { setup: setupForUseMeta((props, { slots }) => {
if (process.dev && !scriptDeprecated) {
console.log('[nuxt] `<Script>` is deprecated and may be removed in a future release. We advise using `useHead()` directly.')
scriptDeprecated = true
}
const script = { ...props } const script = { ...props }
const textContent = (slots.default?.() || []) const textContent = (slots.default?.() || [])
.filter(({ children }) => children) .filter(({ children }) => children)