Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.14.5 #8041

Merged
merged 15 commits into from
Sep 10, 2020
Merged

v2.14.5 #8041

Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion distributions/nuxt-start/package.json
Expand Up @@ -58,7 +58,7 @@
"@nuxt/cli": "2.14.4",
"@nuxt/core": "2.14.4",
"@nuxt/telemetry": "^1.2.3",
"node-fetch": "^2.6.0",
"node-fetch": "^2.6.1",
"vue": "^2.6.12",
"vue-client-only": "^2.0.0",
"vue-meta": "^2.4.0",
Expand Down
16 changes: 8 additions & 8 deletions package.json
Expand Up @@ -33,23 +33,23 @@
"test:unit": "jest packages --forceExit"
},
"devDependencies": {
"@babel/core": "^7.11.4",
"@babel/preset-env": "^7.11.0",
"@babel/core": "^7.11.6",
"@babel/preset-env": "^7.11.5",
"@ls-lint/ls-lint": "^1.9.2",
"@nuxtjs/eslint-config": "^3.1.0",
"@rollup/plugin-alias": "^3.1.1",
"@rollup/plugin-commonjs": "^15.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-replace": "^2.3.3",
"@vue/server-test-utils": "^1.0.4",
"@vue/test-utils": "^1.0.4",
"@vue/server-test-utils": "^1.0.5",
"@vue/test-utils": "^1.0.5",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.3.0",
"consola": "^2.15.0",
"create-require": "^1.0.2",
"cross-spawn": "^7.0.3",
"eslint": "^7.7.0",
"eslint": "^7.8.1",
"eslint-multiplexer": "^2.0.0",
"esm": "^3.2.25",
"execa": "^3.4.0",
Expand All @@ -58,7 +58,7 @@
"fs-extra": "^8.1.0",
"get-port": "^5.1.1",
"glob": "^7.1.6",
"got": "^11.5.2",
"got": "^11.6.1",
"improved-yarn-audit": "^2.3.1",
"is-wsl": "^2.2.0",
"jest": "^26.4.2",
Expand All @@ -67,12 +67,12 @@
"klaw-sync": "^6.0.0",
"lerna": "^3.22.1",
"lodash": "^4.17.20",
"node-fetch": "^2.6.0",
"node-fetch": "^2.6.1",
"node-sass": "^4.14.1",
"puppeteer-core": "^5.2.1",
"request": "^2.88.2",
"rimraf": "^3.0.2",
"rollup": "2.26.6",
"rollup": "2.26.11",
"rollup-plugin-license": "^2.2.0",
"sass-loader": "^8.0.2",
"sort-package-json": "^1.44.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/babel-preset-app/package.json
Expand Up @@ -10,12 +10,12 @@
],
"main": "src/index.js",
"dependencies": {
"@babel/core": "^7.11.4",
"@babel/core": "^7.11.6",
"@babel/helper-compilation-targets": "^7.10.4",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/plugin-proposal-decorators": "^7.10.5",
"@babel/plugin-transform-runtime": "^7.11.0",
"@babel/preset-env": "^7.11.0",
"@babel/plugin-transform-runtime": "^7.11.5",
"@babel/preset-env": "^7.11.5",
"@babel/runtime": "^7.11.2",
"@vue/babel-preset-jsx": "^1.1.2",
"core-js": "^2.6.5"
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Expand Up @@ -29,8 +29,8 @@
"globby": "^11.0.1",
"hable": "^3.0.0",
"minimist": "^1.2.5",
"opener": "1.5.1",
"pretty-bytes": "^5.3.0",
"opener": "1.5.2",
"pretty-bytes": "^5.4.1",
"serve-static": "^1.14.1",
"std-env": "^2.2.1",
"upath": "^1.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/config/src/config/build.js
Expand Up @@ -14,8 +14,8 @@ export default () => ({
serverURLPolyfill: 'url',
filenames: {
// { isDev, isClient, isServer }
app: ({ isDev, isModern }) => isDev ? `[name]${isModern ? '.modern' : ''}.js` : `[name].[contenthash:7]${isModern ? '.modern' : ''}.js`,
chunk: ({ isDev, isModern }) => isDev ? `[name]${isModern ? '.modern' : ''}.js` : `[name].[contenthash:7]${isModern ? '.modern' : ''}.js`,
app: ({ isDev, isModern }) => isDev ? `[name]${isModern ? '.modern' : ''}.js` : `[contenthash:7]${isModern ? '.modern' : ''}.js`,
chunk: ({ isDev, isModern }) => isDev ? `[name]${isModern ? '.modern' : ''}.js` : `[contenthash:7]${isModern ? '.modern' : ''}.js`,
css: ({ isDev }) => isDev ? '[name].css' : '[name].[contenthash:7].css',
img: ({ isDev }) => isDev ? '[path][name].[ext]' : 'img/[name].[contenthash:7].[ext]',
font: ({ isDev }) => isDev ? '[path][name].[ext]' : 'fonts/[name].[contenthash:7].[ext]',
Expand Down
12 changes: 9 additions & 3 deletions packages/config/src/load.js
Expand Up @@ -153,7 +153,7 @@ function expand (target, source = {}, parse = v => v) {
return source[key] !== undefined ? source[key] : target[key]
}

function interpolate (value) {
function interpolate (value, parents = []) {
if (typeof value !== 'string') {
return value
}
Expand All @@ -171,13 +171,19 @@ function expand (target, source = {}, parse = v => v) {
const key = parts[2]
replacePart = parts[0].substring(prefix.length)

// Avoid recursion
if (parents.includes(key)) {
consola.warn(`Please avoid recursive environment variables ( loop: ${parents.join(' > ')} > ${key} )`)
return ''
}

value = getValue(key)

// Resolve recursive interpolations
value = interpolate(value)
value = interpolate(value, [...parents, key])
}

return newValue.replace(replacePart, value)
return value !== undefined ? newValue.replace(replacePart, value) : newValue
}, value))
}

Expand Down
6 changes: 6 additions & 0 deletions packages/config/src/options.js
Expand Up @@ -470,6 +470,12 @@ export function getNuxtConfig (_options) {
options.createRequire = module => createRequire(module.filename)
}

// Indicator
// Change boolean true to default nuxt value
if (options.build.indicator === true) {
options.build.indicator = nuxtConfig.build.indicator
}

// ----- Builtin modules -----

// Loading screen
Expand Down
4 changes: 2 additions & 2 deletions packages/config/test/config/build.test.js
Expand Up @@ -15,8 +15,8 @@ describe('config: build', () => {
test('should return prod filenames', () => {
const { filenames } = buildConfig()
const env = { isDev: false }
expect(filenames.app(env)).toEqual('[name].[contenthash:7].js')
expect(filenames.chunk(env)).toEqual('[name].[contenthash:7].js')
expect(filenames.app(env)).toEqual('[contenthash:7].js')
expect(filenames.chunk(env)).toEqual('[contenthash:7].js')
expect(filenames.css(env)).toEqual('[name].[contenthash:7].css')
expect(filenames.img(env)).toEqual('img/[name].[contenthash:7].[ext]')
expect(filenames.font(env)).toEqual('fonts/[name].[contenthash:7].[ext]')
Expand Down
3 changes: 2 additions & 1 deletion packages/types/app/index.d.ts
Expand Up @@ -50,7 +50,8 @@ export interface Context {
}

export type Middleware = string | ((ctx: Context, cb: Function) => Promise<void> | void)
export type Plugin = (ctx: Context, inject: (key: string, value: any) => void) => Promise<void> | void
export type Inject = (key: string, value: any) => void
export type Plugin = (ctx: Context, inject: Inject) => Promise<void> | void

export interface Transition {
name?: string
Expand Down
4 changes: 2 additions & 2 deletions packages/types/package.json
Expand Up @@ -17,13 +17,13 @@
"@types/file-loader": "^4.2.0",
"@types/html-minifier": "^4.0.0",
"@types/less": "^3.0.1",
"@types/node": "^12.12.54",
"@types/node": "^12.12.56",
"@types/node-sass": "^4.11.1",
"@types/optimize-css-assets-webpack-plugin": "^5.0.1",
"@types/pug": "^2.0.4",
"@types/serve-static": "^1.13.5",
"@types/terser-webpack-plugin": "^2.2.0",
"@types/webpack": "^4.41.21",
"@types/webpack": "^4.41.22",
"@types/webpack-bundle-analyzer": "^3.8.0",
"@types/webpack-dev-middleware": "^3.7.2",
"@types/webpack-hot-middleware": "^2.25.3"
Expand Down
38 changes: 21 additions & 17 deletions packages/utils/src/task.js
Expand Up @@ -13,24 +13,28 @@ export const chainFn = function chainFn (base, fn) {
if (typeof fn !== 'function') {
return base
}
return function (...args) {
if (typeof base !== 'function') {
return fn.apply(this, args)
}
let baseResult = base.apply(this, args)
// Allow function to mutate the first argument instead of returning the result
if (baseResult === undefined) {
[baseResult] = args

if (typeof base !== 'function') {
return fn
}

return function (arg0, ...args) {
const next = (previous = arg0) => {
const fnResult = fn.call(this, previous, ...args)

if (fnResult && typeof fnResult.then === 'function') {
return fnResult.then(res => res || previous)
}

return fnResult || previous
}
const fnResult = fn.call(
this,
baseResult,
...Array.prototype.slice.call(args, 1)
)
// Return mutated argument if no result was returned
if (fnResult === undefined) {
return baseResult

const baseResult = base.call(this, arg0, ...args)

if (baseResult && typeof baseResult.then === 'function') {
return baseResult.then(res => next(res))
}
return fnResult

return next(baseResult)
}
}
11 changes: 11 additions & 0 deletions packages/utils/test/task.test.js
Expand Up @@ -103,4 +103,15 @@ describe('util: task', () => {
const chainedFn = chainFn(firstFn, secondFn)
expect(chainedFn({}, 10)).toEqual({ bar: 12 })
})

test('chainFn (promise)', async () => {
const firstFn = () => Promise.resolve({ foo: 1 })
const secondFn = function (obj) {
obj.foo++
return Promise.resolve()
}

const chainedFn = chainFn(firstFn, secondFn)
expect(await chainedFn()).toEqual({ foo: 2 })
})
})
2 changes: 1 addition & 1 deletion packages/vue-app/package.json
Expand Up @@ -13,7 +13,7 @@
"index.d.ts"
],
"dependencies": {
"node-fetch": "^2.6.0",
"node-fetch": "^2.6.1",
"unfetch": "^4.1.0",
"vue": "^2.6.12",
"vue-client-only": "^2.0.0",
Expand Down
29 changes: 19 additions & 10 deletions packages/vue-app/template/App.js
Expand Up @@ -129,11 +129,9 @@ export default {
<% } %>
},
<% } %>
<% if (loading) { %>
watch: {
'nuxt.err': 'errorChanged'
},
<% } %>
<% if (features.clientOnline) { %>
computed: {
isOffline () {
Expand Down Expand Up @@ -215,18 +213,29 @@ export default {
<% if (loading) { %>this.$loading.finish()<% } %>
<% } %>
},
<% if (loading) { %>
errorChanged () {
if (this.nuxt.err && this.$loading) {
if (this.$loading.fail) {
this.$loading.fail(this.nuxt.err)
<% if (splitChunks.layouts) { %>async <% } %>errorChanged () {
if (this.nuxt.err) {
<% if (loading) { %>
if (this.$loading) {
if (this.$loading.fail) {
this.$loading.fail(this.nuxt.err)
}
if (this.$loading.finish) {
this.$loading.finish()
}
}
if (this.$loading.finish) {
this.$loading.finish()
<% } %>
let errorLayout = (NuxtError.options || NuxtError).layout;

if (typeof errorLayout === 'function') {
errorLayout = errorLayout(this.context)
}
<% if (splitChunks.layouts) { %>
await this.loadLayout(errorLayout)
<% } %>
this.setLayout(errorLayout)
}
},
<% } %>
<% if (features.layouts) { %>
<% if (splitChunks.layouts) { %>
setLayout (layout) {
Expand Down
5 changes: 4 additions & 1 deletion packages/vue-app/template/client.js
Expand Up @@ -613,7 +613,7 @@ function normalizeComponents (to, ___) {
}

<% if (features.layouts) { %>
function setLayoutForNextPage (to) {
<% if (splitChunks.layouts) { %>async <% } %>function setLayoutForNextPage (to) {
// Set layout
let hasError = Boolean(this.$options.nuxt.err)
if (this._hadError && this._dateLastError === this.$options.nuxt.dateErr) {
Expand All @@ -626,6 +626,9 @@ function setLayoutForNextPage (to) {
if (typeof layout === 'function') {
layout = layout(app.context)
}
<% if (splitChunks.layouts) { %>
await this.loadLayout(layout)
<% } %>
this.setLayout(layout)
}
<% } %>
Expand Down
8 changes: 4 additions & 4 deletions packages/webpack/package.json
Expand Up @@ -8,13 +8,13 @@
"dist"
],
"dependencies": {
"@babel/core": "^7.11.4",
"@babel/core": "^7.11.6",
"@nuxt/babel-preset-app": "2.14.4",
"@nuxt/friendly-errors-webpack-plugin": "^2.5.0",
"@nuxt/utils": "2.14.4",
"babel-loader": "^8.1.0",
"cache-loader": "^4.1.0",
"caniuse-lite": "^1.0.30001118",
"caniuse-lite": "^1.0.30001125",
"chalk": "^3.0.0",
"consola": "^2.15.0",
"create-require": "^1.0.2",
Expand All @@ -26,9 +26,9 @@
"glob": "^7.1.6",
"hard-source-webpack-plugin": "^0.13.1",
"hash-sum": "^2.0.0",
"html-webpack-plugin": "^4.3.0",
"html-webpack-plugin": "^4.4.1",
"memory-fs": "^0.4.1",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"optimize-css-assets-webpack-plugin": "^5.0.4",
"pify": "^4.0.1",
"postcss": "^7.0.32",
"postcss-import": "^12.0.1",
Expand Down
3 changes: 3 additions & 0 deletions packages/webpack/src/config/base.js
Expand Up @@ -167,6 +167,9 @@ export default class WebpackBaseConfig {
consola.warn(`Notice: Please do not use ${hash[1]} in dev mode to prevent memory leak`)
}
}
if (this.buildContext.buildOptions.analyze && !fileName.includes('[name]')) {
fileName = '[name].' + fileName
}
return fileName
}

Expand Down