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 all 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
18 changes: 9 additions & 9 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.1.0",
"@vue/test-utils": "^1.1.0",
"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,16 +67,16 @@
"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",
"typescript": "~4.0",
"vue-jest": "^4.0.0-beta.5"
"vue-jest": "^4.0.0-beta.6"
}
}
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
2 changes: 1 addition & 1 deletion packages/builder/package.json
Expand Up @@ -22,7 +22,7 @@
"lodash": "^4.17.20",
"pify": "^4.0.1",
"semver": "^7.3.2",
"serialize-javascript": "^4.0.0",
"serialize-javascript": "^5.0.0",
"upath": "^1.2.0"
},
"publishConfig": {
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
9 changes: 5 additions & 4 deletions packages/config/src/config/_common.js
@@ -1,6 +1,6 @@
import capitalize from 'lodash/capitalize'
import env from 'std-env'
import { TARGETS, MODES } from '@nuxt/utils'
import { TARGETS } from '@nuxt/utils'

export default () => ({
// Env
Expand All @@ -17,9 +17,10 @@ export default () => ({
// Rendering
ssr: true,

// TODO: remove in Nuxt 3
// Mode
mode: MODES.universal,
// Mode (deprecated)
mode: undefined,

// Modern
modern: undefined,

// Modules
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
18 changes: 18 additions & 0 deletions packages/config/src/options.js
Expand Up @@ -97,6 +97,18 @@ export function getNuxtConfig (_options) {
options.target = 'server'
}

// Deprecate Mode
if (options.mode) {
if ((options.mode === MODES.universal && options.ssr) || (options.mode === MODES.spa && !options.ssr)) {
consola.warn('`mode` option is deprecated. You can safely remove it from `nuxt.config`')
} else {
consola.warn('`mode` option is deprecated. Please use `ssr: true` for universal mode or `ssr: false` for spa mode and remove `mode` from `nuxt.config`')
}
} else {
// For backward compat we need default value
options.mode = MODES.universal
}

// SSR root option
if (options.ssr === false) {
options.mode = MODES.spa
Expand Down Expand Up @@ -470,6 +482,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/__snapshots__/index.test.js.snap
Expand Up @@ -241,7 +241,7 @@ Object {
"server_error": "Server error",
"server_error_details": "An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.",
},
"mode": "universal",
"mode": undefined,
"modern": undefined,
"modes": Object {
"spa": Object {
Expand Down Expand Up @@ -617,7 +617,7 @@ Object {
"server_error": "Server error",
"server_error_details": "An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.",
},
"mode": "universal",
"mode": undefined,
"modern": undefined,
"modes": Object {
"spa": Object {
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
1 change: 1 addition & 0 deletions packages/types/config/index.d.ts
Expand Up @@ -50,6 +50,7 @@ export interface NuxtOptions extends Configuration {
layoutTransition: Transition
loading: NuxtOptionsLoading | false | string
loadingIndicator: NuxtOptionsLoadingIndicator | false | string
/** @deprecated Use ssr option instead */
mode: 'spa' | 'universal'
target: 'server' | 'static'
modern: 'client' | 'server' | boolean
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
2 changes: 1 addition & 1 deletion packages/utils/package.json
Expand Up @@ -13,7 +13,7 @@
"hash-sum": "^2.0.0",
"proper-lockfile": "^4.1.1",
"semver": "^7.3.2",
"serialize-javascript": "^4.0.0",
"serialize-javascript": "^5.0.0",
"signal-exit": "^3.0.3",
"ua-parser-js": "^0.7.21"
},
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