import { NuxtConfig , NuxtOptions } from '@nuxt/types' ; import { ModuleThis } from '@nuxt/types/config/module' ; import { join , resolve } from 'upath' ; export function isFullStatic ( options ) { return ( ! options . dev && ! options . _legacyGenerate && options . target === 'static' && options . render ?. ssr ) ; } export function isUrl ( url ) { return [ 'http' , '//' ] . some ( str => url . startsWith ( str ) ) ; } export function resolveRelativePath ( ... path ) { return resolve ( __dirname , ... path ) ; } export function addResolvedTemplate ( this , template , options = { } ) { const nuxtOptions = this . nuxt . options ; const src = resolveRelativePath ( `../runtime/templates/${ template }` ) ; const filename = template . replace ( 'register.mjs' , 'register.js' ) ; const { dst } = this . addTemplate ( { src , fileName : join ( 'composition-api' , filename ) , options , } ) ; const templatePath = join ( nuxtOptions . buildDir , dst ) ; return templatePath ; } export function resolveCoreJsVersion ( this ) { let corejsPolyfill = this . nuxt . options . build . corejs ? String ( this . nuxt . options . build . corejs ) : undefined ; try { if ( ! [ '2' , '3' ] . includes ( corejsPolyfill || '' ) ) { const corejsPkg = this . nuxt . resolver . requireModule ( 'core-js/package.json' ) ; corejsPolyfill = corejsPkg . version . slice ( 0 , 1 ) ; } } catch { corejsPolyfill = undefined ; } return corejsPolyfill ; } export function getNuxtGlobals ( this ) { const nuxtOptions = this . nuxt . options ; const globalName = nuxtOptions . globalName ; const globalContextFactory = nuxtOptions . globals . context || ( ( globalName ) => `__${ globalName . toUpperCase ( ) }__` ) ; const globalNuxtFactory = nuxtOptions . globals . nuxt || ( ( globalName ) => `$${ globalName }` ) ; const globalContext = globalContextFactory ( globalName ) ; const globalNuxt = globalNuxtFactory ( globalName ) ; return { globalContext , globalNuxt } ; }