refactor(schema): upgrade to untyped 0.5 (#7452)

This commit is contained in:
pooya parsa 2022-09-12 20:22:41 +02:00 committed by GitHub
parent 9382b42d7b
commit ceb61ada2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 144 additions and 144 deletions

View File

@ -20,7 +20,7 @@
"pathe": "^0.3.7",
"rimraf": "^3.0.2",
"scule": "^0.3.2",
"untyped": "^0.4.7",
"untyped": "^0.5.0",
"vue-mq": "^1.0.1",
"vue-plausible": "^1.3.2"
},

View File

@ -44,7 +44,7 @@
"nuxt": "link:./packages/nuxt",
"nuxt3": "link:./packages/nuxt",
"vite": "~3.1.0",
"unbuild": "^0.8.10"
"unbuild": "^0.8.11"
},
"devDependencies": {
"@nuxtjs/eslint-config-typescript": "^11.0.0",
@ -64,7 +64,7 @@
"pathe": "^0.3.7",
"rimraf": "^3.0.2",
"typescript": "^4.8.3",
"unbuild": "^0.8.10",
"unbuild": "^0.8.11",
"vitest": "~0.19.1",
"vue-tsc": "^0.39.5"
},

View File

@ -30,7 +30,7 @@
"semver": "^7.3.7",
"unctx": "^2.0.2",
"unimport": "^0.6.7",
"untyped": "^0.4.7"
"untyped": "^0.5.0"
},
"devDependencies": {
"@types/lodash.template": "^4",

View File

@ -46,5 +46,5 @@ export async function loadNuxtConfig (opts: LoadNuxtConfigOptions): Promise<Nuxt
}
// Resolve and apply defaults
return applyDefaults(NuxtConfigSchema, nuxtConfig) as NuxtOptions
return await applyDefaults(NuxtConfigSchema, nuxtConfig) as NuxtOptions
}

View File

@ -30,12 +30,12 @@ export function defineNuxtModule<OptionsT extends ModuleOptions> (definition: Mo
}
// Resolves module options from inline options, [configKey] in nuxt.config, defaults and schema
function getOptions (inlineOptions?: OptionsT, nuxt: Nuxt = useNuxt()) {
async function getOptions (inlineOptions?: OptionsT, nuxt: Nuxt = useNuxt()) {
const configKey = definition.meta!.configKey || definition.meta!.name!
const _defaults = definition.defaults instanceof Function ? definition.defaults(nuxt) : definition.defaults
let _options = defu(inlineOptions, nuxt.options[configKey as keyof NuxtOptions], _defaults) as OptionsT
if (definition.schema) {
_options = applyDefaults(definition.schema, _options) as OptionsT
_options = await applyDefaults(definition.schema, _options) as OptionsT
}
return Promise.resolve(_options)
}

View File

@ -65,7 +65,7 @@
"unenv": "^0.6.2",
"unimport": "^0.6.7",
"unplugin": "^0.9.2",
"untyped": "^0.4.7",
"untyped": "^0.5.0",
"vue": "^3.2.39",
"vue-bundle-renderer": "^0.4.2",
"vue-devtools-stub": "^0.1.0",

View File

@ -114,7 +114,7 @@ export { }
const adHocModules = ['router', 'pages', 'imports', 'meta', 'components']
export const schemaTemplate: NuxtTemplate<TemplateContext> = {
filename: 'types/schema.d.ts',
getContents: ({ nuxt }) => {
getContents: async ({ nuxt }) => {
const moduleInfo = nuxt.options._installedModules.map(m => ({
...m.meta || {},
importName: m.entryPath || m.meta?.name
@ -128,7 +128,7 @@ export const schemaTemplate: NuxtTemplate<TemplateContext> = {
` [${genString(meta.configKey)}]?: typeof ${genDynamicImport(meta.importName, { wrapper: false })}.default extends NuxtModule<infer O> ? Partial<O> : Record<string, any>`
),
' }',
generateTypes(resolveSchema(Object.fromEntries(Object.entries(nuxt.options.runtimeConfig).filter(([key]) => key !== 'public'))),
generateTypes(await resolveSchema(Object.fromEntries(Object.entries(nuxt.options.runtimeConfig).filter(([key]) => key !== 'public'))),
{
interfaceName: 'RuntimeConfig',
addExport: false,
@ -136,7 +136,7 @@ export const schemaTemplate: NuxtTemplate<TemplateContext> = {
allowExtraKeys: false,
indentation: 2
}),
generateTypes(resolveSchema(nuxt.options.runtimeConfig.public),
generateTypes(await resolveSchema(nuxt.options.runtimeConfig.public),
{
interfaceName: 'PublicRuntimeConfig',
addExport: false,

View File

@ -17,7 +17,7 @@
"@types/lodash.template": "^4",
"@types/semver": "^7",
"unbuild": "latest",
"untyped": "^0.4.7",
"untyped": "^0.5.0",
"vite": "~3.1.0"
},
"dependencies": {

View File

@ -15,7 +15,7 @@ export default defineUntypedSchema({
* @version 3
*/
components: {
$resolve: (val, get) => {
$resolve: (val) => {
if (Array.isArray(val)) {
return { dirs: val }
}

View File

@ -21,10 +21,10 @@ export default defineUntypedSchema({
*/
config: {
silent: {
$resolve: (val, get) => val ?? !get('dev')
$resolve: async (val, get) => val ?? !(await get('dev'))
},
performance: {
$resolve: (val, get) => val ?? get('dev')
$resolve: async (val, get) => val ?? await get('dev')
},
},
/**
@ -62,7 +62,7 @@ export default defineUntypedSchema({
* @version 2
*/
assetsPath: {
$resolve: (val, get) => val ?? get('buildAssetsDir')
$resolve: async (val, get) => val ?? (await get('buildAssetsDir'))
},
/**
* An absolute URL to serve the public folder from (production-only).
@ -74,7 +74,7 @@ export default defineUntypedSchema({
* ```
*/
cdnURL: {
$resolve: (val, get) => get('dev') ? '' : (process.env.NUXT_APP_CDN_URL ?? val) || ''
$resolve: async (val, get) => (await get('dev')) ? '' : (process.env.NUXT_APP_CDN_URL ?? val) || ''
},
/**
* Set default configuration for `<head>` on every page.
@ -111,8 +111,8 @@ export default defineUntypedSchema({
* @version 3
*/
head: {
$resolve: (val, get) => {
const resolved: Required<MetaObject> = defu(val, get('meta'), {
$resolve: async (val, get) => {
const resolved: Required<MetaObject> = defu(val, await get('meta'), {
meta: [],
link: [],
style: [],
@ -181,14 +181,14 @@ export default defineUntypedSchema({
* @version 2
*/
appTemplatePath: {
$resolve: (val, get) => {
$resolve: async (val, get) => {
if (val) {
return resolve(get('srcDir'), val)
return resolve(await get('srcDir'), val)
}
if (existsSync(join(get('srcDir'), 'app.html'))) {
return join(get('srcDir'), 'app.html')
if (existsSync(join(await get('srcDir'), 'app.html'))) {
return join(await get('srcDir'), 'app.html')
}
return resolve(get('buildDir'), 'views/app.template.html')
return resolve(await get('buildDir'), 'views/app.template.html')
}
},
@ -199,9 +199,9 @@ export default defineUntypedSchema({
* @version 2
*/
store: {
$resolve: (val, get) => val !== false &&
existsSync(join(get('srcDir'), get('dir.store'))) &&
readdirSync(join(get('srcDir'), get('dir.store')))
$resolve: async (val, get) => val !== false &&
existsSync(join(await get('srcDir'), await get('dir.store'))) &&
readdirSync(join(await get('srcDir'), await get('dir.store')))
.find(filename => filename !== 'README.md' && filename[0] !== '.')
},
@ -378,15 +378,15 @@ export default defineUntypedSchema({
* @version 2
*/
loadingIndicator: {
$resolve: (val, get) => {
$resolve: async (val, get) => {
val = typeof val === 'string' ? { name: val } : val
return defu(val, {
name: 'default',
color: get('loading.color') || '#D3D3D3',
color: await get('loading.color') || '#D3D3D3',
color2: '#F5F5F5',
background: (get('manifest') && get('manifest.theme_color')) || 'white',
dev: get('dev'),
loading: get('messages.loading')
background: (await get('manifest') && await get('manifest.theme_color')) || 'white',
dev: await get('dev'),
loading: await get('messages.loading')
})
}
},
@ -402,12 +402,12 @@ export default defineUntypedSchema({
* @version 2
*/
pageTransition: {
$resolve: (val, get) => {
$resolve: async (val, get) => {
val = typeof val === 'string' ? { name: val } : val
return defu(val, {
name: 'page',
mode: 'out-in',
appear: get('render.ssr') === false || Boolean(val),
appear: await get('render.ssr') === false || Boolean(val),
appearClass: 'appear',
appearActiveClass: 'appear-active',
appearToClass: 'appear-to'

View File

@ -82,7 +82,7 @@ export default defineUntypedSchema({
* @version 3
*/
srcDir: {
$resolve: (val, get) => resolve(get('rootDir'), val || '.')
$resolve: async (val, get) => resolve(await get('rootDir'), val || '.')
},
/**
@ -101,7 +101,7 @@ export default defineUntypedSchema({
* @version 3
*/
buildDir: {
$resolve: (val, get) => resolve(get('rootDir'), val || '.nuxt')
$resolve: async (val, get) => resolve(await get('rootDir'), val || '.nuxt')
},
/**
@ -126,7 +126,7 @@ export default defineUntypedSchema({
* @version 2
*/
debug: {
$resolve: (val, get) => val ?? get('dev')
$resolve: async (val, get) => val ?? await get('dev')
},
/**
@ -207,7 +207,7 @@ export default defineUntypedSchema({
* @deprecated use `ssr` option
*/
mode: {
$resolve: (val, get) => val || (get('ssr') ? 'spa' : 'universal'),
$resolve: async (val, get) => val || ((await get('ssr')) ? 'spa' : 'universal'),
$schema: { deprecated: '`mode` option is deprecated' }
},
@ -446,8 +446,8 @@ export default defineUntypedSchema({
*/
modulesDir: {
$default: ['node_modules'],
$resolve: (val, get) => [
...val.map((dir: string) => resolve(get('rootDir'), dir)),
$resolve: async (val, get) => [
...await Promise.all(val.map(async (dir: string) => resolve(await get('rootDir'), dir))),
resolve(process.cwd(), 'node_modules')
]
},
@ -494,12 +494,12 @@ export default defineUntypedSchema({
* @version 3
*/
public: {
$resolve: (val, get) => val || get('dir.static') || 'public',
$resolve: async (val, get) => val || await get('dir.static') || 'public',
},
/** @version 2 */
static: {
$schema: { deprecated: 'use `dir.public` option instead' },
$resolve: (val, get) => val || get('dir.public') || 'public',
$resolve: async (val, get) => val || await get('dir.public') || 'public',
},
/**
* The folder which will be used to auto-generate your Vuex store structure.
@ -570,13 +570,13 @@ export default defineUntypedSchema({
* @version 3
*/
alias: {
$resolve: (val, get) => ({
'~~': get('rootDir'),
'@@': get('rootDir'),
'~': get('srcDir'),
'@': get('srcDir'),
[get('dir.assets')]: join(get('srcDir'), get('dir.assets')),
[get('dir.public')]: join(get('srcDir'), get('dir.public')),
$resolve: async (val, get) => ({
'~~': await get('rootDir'),
'@@': await get('rootDir'),
'~': await get('srcDir'),
'@': await get('srcDir'),
[await get('dir.assets')]: join(await get('srcDir'), await get('dir.assets')),
[await get('dir.public')]: join(await get('srcDir'), await get('dir.public')),
...val
})
},
@ -612,11 +612,11 @@ export default defineUntypedSchema({
* @version 3
*/
ignore: {
$resolve: (val, get) => [
$resolve: async (val, get) => [
'**/*.stories.{js,ts,jsx,tsx}', // ignore storybook files
'**/*.{spec,test}.{js,ts,jsx,tsx}', // ignore tests
'.output',
get('ignorePrefix') && `**/${get('ignorePrefix')}*.*`
await get('ignorePrefix') && `**/${await get('ignorePrefix')}*.*`
].concat(val).filter(Boolean)
},
@ -636,9 +636,9 @@ export default defineUntypedSchema({
* @version 2
*/
watch: {
$resolve: (val, get) => {
const rootDir = get('rootDir')
return Array.from(new Set([].concat(val, get('_nuxtConfigFiles'))
$resolve: async (val, get) => {
const rootDir = await get('rootDir')
return Array.from(new Set([].concat(val, await get('_nuxtConfigFiles'))
.filter(Boolean).map(p => resolve(rootDir, p))
))
}
@ -740,14 +740,14 @@ export default defineUntypedSchema({
* @version 3
*/
runtimeConfig: {
$resolve: (val: RuntimeConfig, get) => defu(val, {
...get('publicRuntimeConfig'),
...get('privateRuntimeConfig'),
public: get('publicRuntimeConfig'),
$resolve: async (val: RuntimeConfig, get) => defu(val, {
...await get('publicRuntimeConfig'),
...await get('privateRuntimeConfig'),
public: await get('publicRuntimeConfig'),
app: {
baseURL: get('app').baseURL,
buildAssetsDir: get('app').buildAssetsDir,
cdnURL: get('app').cdnURL,
baseURL: (await get('app')).baseURL,
buildAssetsDir: (await get('app')).buildAssetsDir,
cdnURL: (await get('app')).cdnURL,
}
})
},

View File

@ -12,7 +12,7 @@ export default defineUntypedSchema({
* @version 3
*/
builder: {
$resolve: (val, get) => {
$resolve: async (val, get) => {
if (typeof val === 'object') {
return val
}
@ -20,7 +20,7 @@ export default defineUntypedSchema({
vite: '@nuxt/vite-builder',
webpack: '@nuxt/webpack-builder',
}
return map[val] || (get('vite') === false ? map.webpack : map.vite)
return map[val] || (await get('vite') === false ? map.webpack : map.vite)
}
},
/**
@ -30,13 +30,13 @@ export default defineUntypedSchema({
* @version 3
*/
sourcemap: {
$resolve: (val, get) => {
$resolve: async (val, get) => {
if (typeof val === 'boolean') {
return { server: val, client: val }
}
return defu(val, {
server: true,
client: get('dev')
client: await get('dev')
})
},
},
@ -71,11 +71,11 @@ export default defineUntypedSchema({
* @type {boolean | typeof import('webpack-bundle-analyzer').BundleAnalyzerPlugin.Options | typeof import('rollup-plugin-visualizer').PluginVisualizerOptions}
*/
analyze: {
$resolve: (val, get) => {
$resolve: async (val, get) => {
if (val !== true) {
return val ?? false
}
const rootDir = get('rootDir')
const rootDir = await get('rootDir')
return {
template: 'treemap',
projectRoot: rootDir,
@ -150,7 +150,7 @@ export default defineUntypedSchema({
* @version 2
*/
cssSourceMap: {
$resolve: (val, get) => val ?? get('sourcemap') ?? get('dev')
$resolve: async (val, get) => val ?? await get('sourcemap') ?? await get('dev')
},
/**
@ -166,7 +166,7 @@ export default defineUntypedSchema({
* @version 2
*/
parallel: {
$resolve: (val, get) => get('build.extractCSS') ? false : Boolean(val)
$resolve: async (val, get) => await get('build.extractCSS') ? false : Boolean(val)
},
/**
@ -210,7 +210,7 @@ export default defineUntypedSchema({
* @version 2
*/
publicPath: {
$resolve: (val, get) => val ? withTrailingSlash(normalizeURL(val)) : get('app').buildAssetsDir
$resolve: async (val, get) => val ? withTrailingSlash(normalizeURL(val)) : (await get('app').buildAssetsDir)
},
/**
@ -254,7 +254,7 @@ export default defineUntypedSchema({
* @version 2
*/
loaders: {
$resolve: (val, get) => {
$resolve: async (val, get) => {
const styleLoaders = [
'css', 'cssModules', 'less',
'sass', 'scss', 'stylus', 'vueStyle'
@ -262,7 +262,7 @@ export default defineUntypedSchema({
for (const name of styleLoaders) {
const loader = val[name]
if (loader && loader.sourcemap === undefined) {
loader.sourcemap = Boolean(get('build.cssSourceMap'))
loader.sourcemap = Boolean(await get('build.cssSourceMap'))
}
}
return val
@ -272,14 +272,14 @@ export default defineUntypedSchema({
imgUrl: { esModule: false, limit: 1000 },
pugPlain: {},
vue: {
productionMode: { $resolve: (val, get) => val ?? !get('dev') },
productionMode: { $resolve: async (val, get) => val ?? !(await get('dev')) },
transformAssetUrls: {
video: 'src',
source: 'src',
object: 'src',
embed: 'src'
},
compilerOptions: { $resolve: (val, get) => val ?? get('vue.compilerOptions') },
compilerOptions: { $resolve: async (val, get) => val ?? await get('vue.compilerOptions') },
},
css: {
importLoaders: 0,
@ -363,7 +363,7 @@ export default defineUntypedSchema({
* @version 2
*/
optimizeCSS: {
$resolve: (val, get) => val ?? (get('build.extractCSS') ? {} : false)
$resolve: async (val, get) => val ?? (await get('build.extractCSS') ? {} : false)
},
/**
@ -374,7 +374,7 @@ export default defineUntypedSchema({
runtimeChunk: 'single',
/** Set minimize to false to disable all minimizers. (It is disabled in development by default) */
minimize: {
$resolve: (val, get) => val ?? !get('dev')
$resolve: async (val, get) => val ?? !(await get('dev'))
},
/** You can set minimizer to a customized array of plugins. */
minimizer: undefined,
@ -475,7 +475,7 @@ export default defineUntypedSchema({
*/
presets: {},
cacheDirectory: {
$resolve: (val, get) => val ?? get('dev')
$resolve: async (val, get) => val ?? (await get('dev'))
}
},
@ -506,10 +506,10 @@ export default defineUntypedSchema({
postcss: {
execute: undefined,
postcssOptions: {
$resolve: (val, get) => {
$resolve: async (val, get) => {
// Ensure we return the same object in `build.postcss.postcssOptions as `postcss`
// so modules which modify the configuration continue to work.
const postcssOptions = get('postcss')
const postcssOptions = await get('postcss')
Object.assign(postcssOptions, defu(postcssOptions, val))
return postcssOptions
}
@ -625,7 +625,7 @@ export default defineUntypedSchema({
* @version 2
*/
stats: {
$resolve: (val, get) => (val === 'none' || get('build.quiet')) ? false : val,
$resolve: async (val, get) => (val === 'none' || (await get('build.quiet'))) ? false : val,
excludeAssets: [
/.map$/,
/index\..+\.html$/,

View File

@ -61,8 +61,8 @@ export default defineUntypedSchema({
* @type {boolean | ((id?: string) => boolean)}
*/
inlineSSRStyles: {
$resolve (val, get) {
if (val === false || get('dev') || get('ssr') === false || get('builder') === '@nuxt/webpack-builder') {
async $resolve (val, get) {
if (val === false || (await get('dev')) || (await get('ssr')) === false || (await get('builder')) === '@nuxt/webpack-builder') {
return false
}
// Enabled by default for vite prod with ssr

View File

@ -10,7 +10,7 @@ export default <SchemaDefinition>{
* Directory name that holds all the assets and generated pages for a `static` build.
*/
dir: {
$resolve: (val = 'dist', get) => resolve(get('rootDir'), val)
$resolve: async (val = 'dist', get) => resolve((await get('rootDir')), val)
},
/**
@ -162,11 +162,11 @@ export default <SchemaDefinition>{
* (payload, state and manifest files) will live.
*/
base: {
$resolve: (val, get) => val || joinURL(get('app').buildAssetsDir, get('generate.dir'))
$resolve: async (val, get) => val || joinURL((await get('app')).buildAssetsDir, (await get('generate.dir')))
},
/** The full path to the versioned directory where static assets for the current build are located. */
versionBase: {
$resolve: (val, get) => val || joinURL(get('generate.base'), get('generate.version'))
$resolve: async (val, get) => val || joinURL((await get('generate.base')), (await get('generate.version')))
},
/** A unique string to uniquely identify payload versions (defaults to the current timestamp). */
version: {

View File

@ -19,13 +19,13 @@ export default defineUntypedSchema({
* https://github.com/postcss/postcss-import
*/
'postcss-import': {
$resolve: (val, get) => val !== false ? defu(val || {}, {
$resolve: async (val, get) => val !== false ? defu(val || {}, {
resolve: createResolver({
alias: { ...get('alias') },
alias: { ...(await get('alias')) },
modules: [
get('srcDir'),
get('rootDir'),
...get('modulesDir')
await get('srcDir'),
await get('rootDir'),
...(await get('modulesDir'))
]
})
}) : val,
@ -42,7 +42,7 @@ export default defineUntypedSchema({
autoprefixer: {},
cssnano: {
$resolve: (val, get) => val ?? (!get('dev') && {
$resolve: async (val, get) => val ?? !(await get('dev') && {
preset: ['default', {
// Keep quotes in font values to prevent from HEX conversion
// https://github.com/nuxt/nuxt.js/issues/6306

View File

@ -15,7 +15,7 @@ export default <SchemaDefinition>{
shouldPreload: (_fileWithoutQuery: string, asType: string) => ['script', 'style'].includes(asType),
/** enabled by default for development */
runInNewContext: {
$resolve: (val, get) => val ?? get('dev')
$resolve: async (val, get) => val ?? (await get('dev'))
}
},
@ -46,7 +46,7 @@ export default <SchemaDefinition>{
* Set to `collapsed` to collapse the logs, or `false` to disable.
*/
ssrLog: {
$resolve: (val, get) => get('dev') ? Boolean(val) : false
$resolve: async (val, get) => (await get('dev')) ? Boolean(val) : false
},
/**
@ -213,7 +213,7 @@ export default <SchemaDefinition>{
* ```
*/
csp: {
$resolve: (val, get) => {
$resolve: async (val, get) => {
if (!val) { return false }
return {
hashAlgorithm: 'sha256',
@ -230,7 +230,7 @@ export default <SchemaDefinition>{
* if hashes are present. (Set option `unsafeInlineCompatibility` to true to
* disable this behavior.)
*/
addMeta: Boolean(get('target') === 'static'),
addMeta: Boolean((await get('target')) === 'static'),
/**
* Set option `unsafeInlineCompatibility` to `true` if you want both hashes and
* 'unsafe-inline' for CSPv1 compatibility. In that case the `<meta>` tag will
@ -239,7 +239,7 @@ export default <SchemaDefinition>{
* HTTP response header.
*/
unsafeInlineCompatibility: false,
reportOnly: get('debug'),
reportOnly: (await get('debug')),
...val
}
}

View File

@ -33,12 +33,12 @@ export default defineUntypedSchema({
* @version 2
*/
base: {
$resolve: (val, get) => val ? withTrailingSlash(normalizeURL(val)) : get('app').baseURL
$resolve: async (val, get) => val ? withTrailingSlash(normalizeURL(val)) : (await get('app')).baseURL
},
/** @private */
_routerBaseSpecified: {
$resolve: (_val, get) => typeof get('router.base') === 'string'
$resolve: async (_val, get) => typeof (await get('router.base')) === 'string'
},
/** @version 2 */

View File

@ -14,15 +14,15 @@ export default defineUntypedSchema({
*/
vite: {
root: {
$resolve: (val, get) => val ?? get('srcDir')
$resolve: async (val, get) => val ?? (await get('srcDir'))
},
mode: {
$resolve: (val, get) => val ?? (get('dev') ? 'development' : 'production')
$resolve: async (val, get) => val ?? (await get('dev') ? 'development' : 'production')
},
logLevel: 'warn',
define: {
$resolve: (val, get) => ({
'process.dev': get('dev'),
$resolve: async (val, get) => ({
'process.dev': await get('dev'),
...val || {}
})
},
@ -30,23 +30,23 @@ export default defineUntypedSchema({
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
},
publicDir: {
$resolve: (val, get) => val ?? resolve(get('srcDir'), get('dir').public)
$resolve: async (val, get) => val ?? resolve((await get('srcDir')), (await get('dir')).public)
},
vue: {
isProduction: {
$resolve: (val, get) => val ?? !get('dev')
$resolve: async (val, get) => val ?? !(await get('dev'))
},
template: {
compilerOptions: {
$resolve: (val, get) => val ?? get('vue').compilerOptions
$resolve: async (val, get) => val ?? (await get('vue')).compilerOptions
}
}
},
optimizeDeps: {
exclude: {
$resolve: (val, get) => [
$resolve: async (val, get) => [
...val || [],
...get('build.transpile').filter((i: string) => typeof i === 'string'),
...(await get('build.transpile')).filter((i: string) => typeof i === 'string'),
'vue-demi'
]
}
@ -59,7 +59,7 @@ export default defineUntypedSchema({
clearScreen: false,
build: {
assetsDir: {
$resolve: (val, get) => val ?? withoutLeadingSlash(get('app').buildAssetsDir)
$resolve: async (val, get) => val ?? withoutLeadingSlash((await get('app')).buildAssetsDir)
},
emptyOutDir: false
},
@ -67,11 +67,11 @@ export default defineUntypedSchema({
fs: {
strict: false,
allow: {
$resolve: (val, get) => [
get('buildDir'),
get('srcDir'),
get('rootDir'),
...get('modulesDir'),
$resolve: async (val, get) => [
await get('buildDir'),
await get('srcDir'),
await get('rootDir'),
...(await get('modulesDir')),
...val ?? []
]
}

View File

@ -18,11 +18,11 @@ export default defineUntypedSchema({
* @type {boolean | typeof import('webpack-bundle-analyzer').BundleAnalyzerPlugin.Options}
*/
analyze: {
$resolve: (val, get) => {
$resolve: async (val, get) => {
if (val !== true) {
return val ?? false
}
const rootDir = get('rootDir')
const rootDir = await get('rootDir')
return {
template: 'treemap',
projectRoot: rootDir,
@ -95,7 +95,7 @@ export default defineUntypedSchema({
* Enables CSS source map support (defaults to `true` in development).
*/
cssSourceMap: {
$resolve: (val, get) => val ?? get('dev')
$resolve: async (val, get) => val ?? await get('dev')
},
/**
@ -135,7 +135,7 @@ export default defineUntypedSchema({
* Customize the options of Nuxt's integrated webpack loaders.
*/
loaders: {
$resolve: (val, get) => {
$resolve: async (val, get) => {
const styleLoaders = [
'css', 'cssModules', 'less',
'sass', 'scss', 'stylus', 'vueStyle'
@ -143,7 +143,7 @@ export default defineUntypedSchema({
for (const name of styleLoaders) {
const loader = val[name]
if (loader && loader.sourceMap === undefined) {
loader.sourceMap = Boolean(get('build.cssSourceMap'))
loader.sourceMap = Boolean(await get('build.cssSourceMap'))
}
}
return val
@ -153,14 +153,14 @@ export default defineUntypedSchema({
imgUrl: { esModule: false, limit: 1000 },
pugPlain: {},
vue: {
productionMode: { $resolve: (val, get) => val ?? !get('dev') },
productionMode: { $resolve: async (val, get) => val ?? !(await get('dev')) },
transformAssetUrls: {
video: 'src',
source: 'src',
object: 'src',
embed: 'src'
},
compilerOptions: { $resolve: (val, get) => val ?? get('vue.compilerOptions') },
compilerOptions: { $resolve: async (val, get) => val ?? (await get('vue.compilerOptions')) },
},
css: {
importLoaders: 0,
@ -238,7 +238,7 @@ export default defineUntypedSchema({
* @type {false | typeof import('css-minimizer-webpack-plugin').BasePluginOptions & typeof import('css-minimizer-webpack-plugin').DefinedDefaultMinimizerAndOptions<any>}
*/
optimizeCSS: {
$resolve: (val, get) => val ?? (get('build.extractCSS') ? {} : false)
$resolve: async (val, get) => val ?? (await get('build.extractCSS') ? {} : false)
},
/**
@ -248,7 +248,7 @@ export default defineUntypedSchema({
optimization: {
runtimeChunk: 'single',
/** Set minimize to `false` to disable all minimizers. (It is disabled in development by default). */
minimize: { $resolve: (val, get) => val ?? !get('dev') },
minimize: { $resolve: async (val, get) => val ?? !(await get('dev')) },
/** You can set minimizer to a customized array of plugins. */
minimizer: undefined,
splitChunks: {
@ -265,10 +265,10 @@ export default defineUntypedSchema({
execute: undefined,
postcssOptions: {
config: {
$resolve: (val, get) => val ?? get('postcss.config')
$resolve: async (val, get) => val ?? (await get('postcss.config'))
},
plugins: {
$resolve: (val, get) => val ?? get('postcss.plugins')
$resolve: async (val, get) => val ?? (await get('postcss.plugins'))
}
},
sourceMap: undefined,

View File

@ -428,10 +428,10 @@ __metadata:
languageName: node
linkType: hard
"@babel/standalone@npm:^7.18.13":
version: 7.18.13
resolution: "@babel/standalone@npm:7.18.13"
checksum: da010b1ef0d53f7888d01b3ef93aac9a17af5711979e7bc048b80bf08ae6dfa6b637bf92fee0c5753b4ff1bc3639a5b82925f9234d4e2150fc6d4d5c2ccc1f89
"@babel/standalone@npm:^7.19.0":
version: 7.19.0
resolution: "@babel/standalone@npm:7.19.0"
checksum: 02f808a938b8e3978fb203edfdfa0cc9ee567df173f1659de5b41a0480c857070865e45753d3ba8669d0ab26b218ab56d4ffcb05d7c5a75f7671d193331be732
languageName: node
linkType: hard
@ -1798,7 +1798,7 @@ __metadata:
unbuild: latest
unctx: ^2.0.2
unimport: ^0.6.7
untyped: ^0.4.7
untyped: ^0.5.0
languageName: unknown
linkType: soft
@ -1825,7 +1825,7 @@ __metadata:
ufo: ^0.8.5
unbuild: latest
unimport: ^0.6.7
untyped: ^0.4.7
untyped: ^0.5.0
vite: ~3.1.0
languageName: unknown
linkType: soft
@ -10207,7 +10207,7 @@ __metadata:
pathe: ^0.3.7
rimraf: ^3.0.2
typescript: ^4.8.3
unbuild: ^0.8.10
unbuild: ^0.8.11
vitest: ~0.19.1
vue-tsc: ^0.39.5
languageName: unknown
@ -10267,7 +10267,7 @@ __metadata:
unenv: ^0.6.2
unimport: ^0.6.7
unplugin: ^0.9.2
untyped: ^0.4.7
untyped: ^0.5.0
vue: ^3.2.39
vue-bundle-renderer: ^0.4.2
vue-devtools-stub: ^0.1.0
@ -13166,9 +13166,9 @@ __metadata:
languageName: node
linkType: hard
"unbuild@npm:^0.8.10":
version: 0.8.10
resolution: "unbuild@npm:0.8.10"
"unbuild@npm:^0.8.11":
version: 0.8.11
resolution: "unbuild@npm:0.8.11"
dependencies:
"@rollup/plugin-alias": ^3.1.9
"@rollup/plugin-commonjs": ^22.0.2
@ -13197,10 +13197,10 @@ __metadata:
rollup-plugin-esbuild: ^4.10.1
scule: ^0.3.2
typescript: ^4.8.2
untyped: ^0.4.7
untyped: ^0.5.0
bin:
unbuild: dist/cli.mjs
checksum: 77a4fde0fe1f6f7dae394be473877a5a94bf18aa992a8b79eacd7e0435bac077930f91f5a5693bd8f5d9f544e3df3b2d039d287de5d8735cfcc9191ffbb3a3d8
checksum: 40bcdd54d460b6d1e170a62fb71ea0eda32ca557b715d11f51acf8a2afadc4d457aecc45a00fd8ec2fba7906845cd49823720bef90000df343c8c6599ca7a52b
languageName: node
linkType: hard
@ -13370,15 +13370,15 @@ __metadata:
languageName: node
linkType: hard
"untyped@npm:^0.4.7":
version: 0.4.7
resolution: "untyped@npm:0.4.7"
"untyped@npm:^0.5.0":
version: 0.5.0
resolution: "untyped@npm:0.5.0"
dependencies:
"@babel/core": ^7.18.13
"@babel/standalone": ^7.18.13
"@babel/types": ^7.18.13
"@babel/core": ^7.19.0
"@babel/standalone": ^7.19.0
"@babel/types": ^7.19.0
scule: ^0.3.2
checksum: d5b189b19e114c4d60e122da9234c68a93d71b312a64bd8303e3aaa96f7a677befa8519ce003dec8cb587ed3e5503046131532196257ed10e647bc741532b1bc
checksum: db04ec68d7de032c3d6bc063bd4764dc43d0a71a275c6f854c928f589f12214e91d39dbecf119e1de84c4ba09b087e8c483c80302b4308242723d258efaddf80
languageName: node
linkType: hard