mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-17 06:01:34 +00:00
chore: cleanup (#4529)
This commit is contained in:
parent
683dbba4f7
commit
c60b1945e8
@ -1,7 +1,9 @@
|
||||
<template>
|
||||
<div>
|
||||
<p>Hi from {{ name }}</p>
|
||||
<n-link to="/">Home page</n-link>
|
||||
<NLink to="/">
|
||||
Home page
|
||||
</NLink>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>Welcome!</h1>
|
||||
<n-link to="/about">About Page</n-link>
|
||||
<NLink to="/about">
|
||||
About Page
|
||||
</NLink>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -314,7 +314,7 @@ export default class Builder {
|
||||
})).forEach((f) => {
|
||||
const key = f.replace(/\.(js|vue)$/, '')
|
||||
if (/\.vue$/.test(f) || !files[key]) {
|
||||
files[key] = f.replace(/('|")/g, '\\$1')
|
||||
files[key] = f.replace(/(['"])/g, '\\$1')
|
||||
}
|
||||
})
|
||||
templateVars.router.routes = createRoutes(
|
||||
|
@ -18,7 +18,7 @@ export default async function listCommands() {
|
||||
maxLength = Math.max(maxLength, _commands[name].usage.length)
|
||||
}
|
||||
|
||||
const _cmmds = commandsHelp.map(([cmd, description]) => {
|
||||
const _cmds = commandsHelp.map(([cmd, description]) => {
|
||||
const i = indent(maxLength + optionSpaces - cmd.length)
|
||||
return foldLines(
|
||||
chalk.green(cmd) + i + description,
|
||||
@ -28,7 +28,7 @@ export default async function listCommands() {
|
||||
}).join('\n')
|
||||
|
||||
const usage = foldLines(`Usage: nuxt <command> [--help|-h]`, startSpaces)
|
||||
const cmmds = foldLines(`Commands:`, startSpaces) + '\n\n' + _cmmds
|
||||
const cmds = foldLines(`Commands:`, startSpaces) + '\n\n' + _cmds
|
||||
|
||||
process.stderr.write(colorize(`${usage}\n\n${cmmds}\n\n`))
|
||||
process.stderr.write(colorize(`${usage}\n\n${cmds}\n\n`))
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ export function foldLines(string, spaces, firstLineSpaces, maxCharsPerLine) {
|
||||
|
||||
export function colorize(text) {
|
||||
return text
|
||||
.replace(/\[[^ ]+\]/g, m => chalk.grey(m))
|
||||
.replace(/\[[^ ]+]/g, m => chalk.grey(m))
|
||||
.replace(/<[^ ]+>/g, m => chalk.green(m))
|
||||
.replace(/ (-[-\w,]+)/g, m => chalk.bold(m))
|
||||
.replace(/`(.+)`/g, (_, m) => chalk.bold.cyan(m))
|
||||
|
@ -256,7 +256,7 @@ function cleanChildrenRoutes(routes, isChild = false) {
|
||||
return routes
|
||||
}
|
||||
|
||||
const DYNAMIC_ROUTE_REGEX = /^\/(:|\*)/
|
||||
const DYNAMIC_ROUTE_REGEX = /^\/([:*])/
|
||||
|
||||
const sortRoutes = function sortRoutes(routes) {
|
||||
routes.sort((a, b) => {
|
||||
|
@ -70,7 +70,7 @@ export function getNuxtConfig(_options) {
|
||||
|
||||
defaultsDeep(options, nuxtConfig)
|
||||
|
||||
// Check srcDir and generate.dir excistence
|
||||
// Check srcDir and generate.dir existence
|
||||
const hasSrcDir = isNonEmptyString(options.srcDir)
|
||||
const hasGenerateDir = isNonEmptyString(options.generate.dir)
|
||||
|
||||
|
@ -22,10 +22,9 @@ export default class Resolver {
|
||||
|
||||
resolveModule(path) {
|
||||
try {
|
||||
const resolvedPath = Module._resolveFilename(path, {
|
||||
return Module._resolveFilename(path, {
|
||||
paths: this.options.modulesDir
|
||||
})
|
||||
return resolvedPath
|
||||
} catch (error) {
|
||||
if (error.code === 'MODULE_NOT_FOUND') {
|
||||
return undefined
|
||||
|
@ -104,8 +104,8 @@ export default {
|
||||
},
|
||||
loadLayout(layout) {
|
||||
const undef = !layout
|
||||
const inexisting = !(layouts['_' + layout] || resolvedLayouts['_' + layout])
|
||||
let _layout = '_' + ((undef || inexisting) ? 'default' : layout)
|
||||
const nonexistent = !(layouts['_' + layout] || resolvedLayouts['_' + layout])
|
||||
let _layout = '_' + ((undef || nonexistent) ? 'default' : layout)
|
||||
if (resolvedLayouts[_layout]) {
|
||||
return Promise.resolve(resolvedLayouts[_layout])
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ export default class SPAMetaRenderer {
|
||||
})
|
||||
}
|
||||
|
||||
async getMeta(url) {
|
||||
async getMeta() {
|
||||
const vm = new Vue({
|
||||
render: h => h(), // Render empty html tag
|
||||
head: this.options.head || {}
|
||||
@ -45,7 +45,7 @@ export default class SPAMetaRenderer {
|
||||
}
|
||||
|
||||
// Get vue-meta context
|
||||
const m = await this.getMeta(url)
|
||||
const m = await this.getMeta()
|
||||
|
||||
// HTML_ATTRS
|
||||
meta.HTML_ATTRS = m.htmlAttrs.text()
|
||||
|
@ -31,7 +31,7 @@ export class WebpackBundler {
|
||||
if (this.context.options.dev) {
|
||||
this.mfs = new MFS()
|
||||
|
||||
// TODO: Enable when async FS rquired
|
||||
// TODO: Enable when async FS required
|
||||
// this.mfs.exists = function (...args) { return Promise.resolve(this.existsSync(...args)) }
|
||||
// this.mfs.readFile = function (...args) { return Promise.resolve(this.readFileSync(...args)) }
|
||||
}
|
||||
@ -108,7 +108,7 @@ export class WebpackBundler {
|
||||
return compiler
|
||||
})
|
||||
|
||||
// Warmup perfLoader before build
|
||||
// Warm up perfLoader before build
|
||||
if (options.build.parallel) {
|
||||
consola.info('Warming up worker pools')
|
||||
PerfLoader.warmupAll({ dev: options.dev })
|
||||
@ -172,7 +172,7 @@ export class WebpackBundler {
|
||||
if (options.build.quiet === true) {
|
||||
return Promise.reject(stats.toString(options.build.stats))
|
||||
} else {
|
||||
// Actual error will be printet by webpack
|
||||
// Actual error will be printed by webpack
|
||||
throw new Error('Nuxt Build Error')
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ export default class WebpackBaseConfig {
|
||||
fileName = fileName(this.nuxtEnv)
|
||||
}
|
||||
if (this.options.dev) {
|
||||
const hash = /\[(chunkhash|contenthash|hash)(?::(\d+))?\]/.exec(fileName)
|
||||
const hash = /\[(chunkhash|contenthash|hash)(?::(\d+))?]/.exec(fileName)
|
||||
if (hash) {
|
||||
consola.warn(`Notice: Please do not use ${hash[1]} in dev mode to prevent memory leak`)
|
||||
}
|
||||
|
@ -1,16 +1,10 @@
|
||||
export default class WarnFixPlugin {
|
||||
apply(compiler) /* istanbul ignore next */ {
|
||||
compiler.hooks.done.tap('warnfix-plugin', (stats) => {
|
||||
stats.compilation.warnings = stats.compilation.warnings.filter((warn) => {
|
||||
if (
|
||||
warn.name === 'ModuleDependencyWarning' &&
|
||||
stats.compilation.warnings = stats.compilation.warnings.filter(warn =>
|
||||
!(warn.name === 'ModuleDependencyWarning' &&
|
||||
warn.message.includes(`export 'default'`) &&
|
||||
warn.message.includes('nuxt_plugin_')
|
||||
) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
warn.message.includes('nuxt_plugin_')))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -118,8 +118,7 @@ export default class PostcssConfig {
|
||||
if (opts === false) {
|
||||
return // Disabled
|
||||
}
|
||||
const instance = plugin(opts)
|
||||
return instance
|
||||
return plugin(opts)
|
||||
})
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
4
test/fixtures/spa/layouts/custom.vue
vendored
4
test/fixtures/spa/layouts/custom.vue
vendored
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
Custom layout
|
||||
<br>
|
||||
<Nuxt />
|
||||
<br>
|
||||
<Nuxt />
|
||||
</div>
|
||||
</template>
|
||||
|
4
test/fixtures/spa/layouts/default.vue
vendored
4
test/fixtures/spa/layouts/default.vue
vendored
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
Default layout
|
||||
<br>
|
||||
<Nuxt />
|
||||
<br>
|
||||
<Nuxt />
|
||||
</div>
|
||||
</template>
|
||||
|
Loading…
Reference in New Issue
Block a user