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.10.2 #6601

Merged
merged 21 commits into from
Oct 21, 2019
Merged

v2.10.2 #6601

Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ed4a222
chore(deps): update dependency postcss-import-resolver to v2 (#6552)
renovate[bot] Oct 13, 2019
a42453b
chore(deps): update all non-major dependencies (#6550)
renovate[bot] Oct 14, 2019
e99d5f6
chore: add saucelabs logo
Atinux Oct 15, 2019
3cde4c7
chore(deps): update all non-major dependencies (#6568)
renovate[bot] Oct 15, 2019
bda4a81
chore(deps): lock file maintenance (#6560)
renovate[bot] Oct 15, 2019
2b6589c
chore(deps): update all non-major dependencies (#6573)
renovate[bot] Oct 17, 2019
b031fac
fix: collapsed ssr log (#6590)
pimlie Oct 18, 2019
b8e1a71
examples(with-sockets): fix cannot read property 'app' of undefined o…
reskume Oct 18, 2019
99aba87
chore: lint error
clarkdo Oct 18, 2019
257ae22
fix(config): typo in `unsafeInlineCompatibility` name (#6583)
PedroD Oct 19, 2019
8391753
fix(webpack): normalize devtool for terser compatibility (#6566)
clarkdo Oct 19, 2019
de93484
fix(webpack): enable devtool for dev mode (#6495)
clarkdo Oct 19, 2019
ff6e6ef
chore(deps): update all non-major dependencies (#6591)
renovate[bot] Oct 19, 2019
a3f1957
chore(deps): update dependency execa to v3 (#6563)
renovate[bot] Oct 19, 2019
ec7428a
chore(deps): update devdependency rollup to ^1.25.1 (#6595)
renovate[bot] Oct 20, 2019
01e447e
chore(deps): update all non-major dependencies (#6599)
renovate[bot] Oct 21, 2019
92405b3
chore: sort changelog tags by date
pi0 Oct 21, 2019
9276c09
test: ssr log (#6596)
clarkdo Oct 21, 2019
437af14
chore(deps): lock file maintenance (#6598)
renovate[bot] Oct 21, 2019
3d51c03
chore(deps): update dependency glob to ^7.1.5 (#6602)
renovate[bot] Oct 21, 2019
f6aa45d
v2.10.2 [release]
pi0 Oct 21, 2019
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
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,16 @@ Please refer to our [Contribution Guide](https://nuxtjs.org/guide/contribution-g

## Cross-browser testing

Thanks to BrowserStack!
Thanks to [BrowserStack](http://browserstack.com)!

<a href="http://browserstack.com"><img height="70" src="https://nuxtjs.org/browserstack.svg" alt="BrowserStack"></a>

## Automated testing

Thanks to [SauceLabs](https://saucelabs.com) for supporting Open Source <3

<a href="https://saucelabs.com"><img height="70" src="https://nuxtjs.org/saucelabs.svg" alt="SauceLabs"></a>

## Security

If you discover a security vulnerability regarding Nuxt.js, please send an e-mail to the team via security@nuxtjs.org! All security vulnerabilities will be promptly addressed.
Expand Down
32 changes: 17 additions & 15 deletions examples/with-sockets/io/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@ import http from 'http'
import socketIO from 'socket.io'

export default function () {
const server = http.createServer(this.nuxt.renderer.app)
const io = socketIO(server)
this.nuxt.hook('render:before', (renderer) => {
const server = http.createServer(this.nuxt.renderer.app)
const io = socketIO(server)

// overwrite nuxt.server.listen()
this.nuxt.server.listen = (port, host) => new Promise(resolve => server.listen(port || 3000, host || 'localhost', resolve))
// close this server on 'close' event
this.nuxt.hook('close', () => new Promise(server.close))
// overwrite nuxt.server.listen()
this.nuxt.server.listen = (port, host) => new Promise(resolve => server.listen(port || 3000, host || 'localhost', resolve))
// close this server on 'close' event
this.nuxt.hook('close', () => new Promise(server.close))

// Add socket.io events
const messages = []
io.on('connection', (socket) => {
socket.on('last-messages', function (fn) {
fn(messages.slice(-50))
})
socket.on('send-message', function (message) {
messages.push(message)
socket.broadcast.emit('new-message', message)
// Add socket.io events
const messages = []
io.on('connection', (socket) => {
socket.on('last-messages', function (fn) {
fn(messages.slice(-50))
})
socket.on('send-message', function (message) {
messages.push(message)
socket.broadcast.emit('new-message', message)
})
})
})
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,28 @@
"eslint": "6.5.1",
"eslint-multiplexer": "^2.0.0",
"esm": "^3.2.25",
"execa": "^2.1.0",
"execa": "^3.2.0",
"express": "^4.17.1",
"finalhandler": "^1.1.2",
"fork-ts-checker-webpack-plugin": "^1.5.0",
"fork-ts-checker-webpack-plugin": "^1.5.1",
"fs-extra": "^8.1.0",
"get-port": "^5.0.0",
"glob": "^7.1.4",
"is-wsl": "^2.1.1",
"jest": "^24.9.0",
"jest-junit": "^8.0.0",
"jsdom": "^15.1.1",
"jsdom": "^15.2.0",
"klaw-sync": "^6.0.0",
"lerna": "^3.17.0",
"lerna": "^3.18.1",
"lodash": "^4.17.15",
"node-fetch": "^2.6.0",
"node-sass": "^4.12.0",
"puppeteer-core": "^1.20.0",
"request": "^2.88.0",
"request-promise-native": "^1.0.7",
"rimraf": "^3.0.0",
"rollup": "^1.23.1",
"rollup-plugin-alias": "^2.0.1",
"rollup": "^1.25.1",
"rollup-plugin-alias": "^2.2.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-json": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@nuxt/devalue": "^1.2.4",
"@nuxt/utils": "2.10.1",
"@nuxt/vue-app": "2.10.1",
"chokidar": "^3.2.1",
"chokidar": "^3.2.2",
"consola": "^2.10.1",
"fs-extra": "^8.1.0",
"glob": "^7.1.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"chalk": "^2.4.2",
"consola": "^2.10.1",
"esm": "^3.2.25",
"execa": "^2.1.0",
"execa": "^3.2.0",
"exit": "^0.1.2",
"fs-extra": "^8.1.0",
"hable": "^2.3.2",
Expand Down
9 changes: 8 additions & 1 deletion packages/config/src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,16 @@ export function getNuxtConfig (_options) {
allowedSources: undefined,
policies: undefined,
addMeta: Boolean(options._generate),
unsafeInlineCompatiblity: false,
unsafeInlineCompatibility: false,
reportOnly: options.debug
})

// TODO: Remove this if statement in Nuxt 3, we will stop supporting this typo (more on: https://github.com/nuxt/nuxt.js/pull/6583)
if (options.render.csp.unsafeInlineCompatiblity) {
consola.warn('Using `unsafeInlineCompatiblity` is deprecated and will be removed in Nuxt 3. Use `unsafeInlineCompatibility` instead.')
options.render.csp.unsafeInlineCompatibility = options.render.csp.unsafeInlineCompatiblity
delete options.render.csp.unsafeInlineCompatiblity
}
}

// cssSourceMap
Expand Down
16 changes: 15 additions & 1 deletion packages/config/test/options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,21 @@ describe('config: options', () => {
expect(csp).toEqual({
hashAlgorithm: 'sha256',
addMeta: false,
unsafeInlineCompatiblity: false,
unsafeInlineCompatibility: false,
allowedSources: true,
policies: undefined,
reportOnly: false,
test: true
})
})

// TODO: Remove this test in Nuxt 3, we will stop supporting this typo (more on: https://github.com/nuxt/nuxt.js/pull/6583)
test('should enable csp with old typo property name, avoiding breaking changes', () => {
const { render: { csp } } = getNuxtConfig({ render: { csp: { allowedSources: true, test: true, unsafeInlineCompatiblity: true } } })
expect(csp).toEqual({
hashAlgorithm: 'sha256',
addMeta: false,
unsafeInlineCompatibility: true,
allowedSources: true,
policies: undefined,
reportOnly: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-app/template/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Object.assign(Vue.config, <%= serialize(vue.config) %>)<%= isTest ? '// eslint-d
const logs = NUXT.logs || []
if (logs.length > 0) {
const ssrLogSyle = 'background: #2E495E;border-radius: 0.5em;color: white;font-weight: bold;padding: 2px 0.5em;'
console.group && console.group <%= nuxtOptions.render.ssrLog === 'collapsed' ? 'Collapsed' : '' %> ("%cNuxt SSR", ssrLogSyle)
console.group && console.group<%= nuxtOptions.render.ssrLog === 'collapsed' ? 'Collapsed' : '' %> ("%cNuxt SSR", ssrLogSyle)
logs.forEach(logObj => (console[logObj.type] || console.log)(...logObj.args))
delete NUXT.logs
console.groupEnd && console.groupEnd()
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-renderer/src/renderers/ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export default class SSRRenderer extends BaseRenderer {
if (csp) {
// Only add the hash if 'unsafe-inline' rule isn't present to avoid conflicts (#5387)
const containsUnsafeInlineScriptSrc = csp.policies && csp.policies['script-src'] && csp.policies['script-src'].includes(`'unsafe-inline'`)
if (csp.unsafeInlineCompatiblity || !containsUnsafeInlineScriptSrc) {
if (csp.unsafeInlineCompatibility || !containsUnsafeInlineScriptSrc) {
const hash = crypto.createHash(csp.hashAlgorithm)
hash.update(serializedSession)
cspScriptSrcHashes.push(`'${csp.hashAlgorithm}-${hash.digest('base64')}'`)
Expand Down
8 changes: 4 additions & 4 deletions packages/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@nuxt/utils": "2.10.1",
"babel-loader": "^8.0.6",
"cache-loader": "^4.1.0",
"caniuse-lite": "^1.0.30000999",
"caniuse-lite": "^1.0.30001002",
"chalk": "^2.4.2",
"consola": "^2.10.1",
"css-loader": "^3.2.0",
Expand All @@ -31,7 +31,7 @@
"pify": "^4.0.1",
"postcss": "^7.0.18",
"postcss-import": "^12.0.1",
"postcss-import-resolver": "^1.2.3",
"postcss-import-resolver": "^2.0.0",
"postcss-loader": "^3.0.0",
"postcss-preset-env": "^6.7.0",
"postcss-url": "^8.0.0",
Expand All @@ -43,8 +43,8 @@
"time-fix-plugin": "^2.0.6",
"url-loader": "^2.2.0",
"vue-loader": "^15.7.1",
"webpack": "^4.41.0",
"webpack-bundle-analyzer": "^3.5.2",
"webpack": "^4.41.2",
"webpack-bundle-analyzer": "^3.6.0",
"webpack-dev-middleware": "^3.7.2",
"webpack-hot-middleware": "^2.25.0",
"webpack-node-externals": "^1.7.2",
Expand Down
17 changes: 9 additions & 8 deletions packages/webpack/src/config/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ export default class WebpackBaseConfig {
return fileName
}

get devtool () {
return false
}

env () {
const env = {
'process.env.NODE_ENV': JSON.stringify(this.mode),
Expand Down Expand Up @@ -439,11 +435,16 @@ export default class WebpackBaseConfig {
if (typeof extend === 'function') {
const extendedConfig = extend.call(
this.builder, config, { loaders: this.loaders, ...this.nuxtEnv }
)
// Only overwrite config when something is returned for backwards compatibility
if (extendedConfig !== undefined) {
return extendedConfig
) || config

const pragma = /@|#/
const { devtool } = extendedConfig
if (typeof devtool === 'string' && pragma.test(devtool)) {
extendedConfig.devtool = devtool.replace(pragma, '')
consola.warn(`devtool has been normalized to ${extendedConfig.devtool} as webpack documented value`)
}

return extendedConfig
}
return config
}
Expand Down
4 changes: 4 additions & 0 deletions packages/webpack/src/config/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
this.isModern = false
}

get devtool () {
return this.dev ? 'cheap-module-eval-source-map' : false
}

getFileName (...args) {
if (this.buildContext.buildOptions.analyze) {
const [key] = args
Expand Down
2 changes: 1 addition & 1 deletion scripts/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function execCommand (cmd, args) {
}

async function getLastGitTag () {
const r = await execCommand('git', ['--no-pager', 'tag', '-l']).then(r => r.split('\n'))
const r = await execCommand('git', ['--no-pager', 'tag', '-l', '--sort=taggerdate']).then(r => r.split('\n'))
return r[r.length - 1]
}

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/with-config/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default {
transpile: 'vue-test',
extend (config, options) {
return Object.assign({}, config, {
devtool: '#source-map'
devtool: 'source-map'
})
}
},
Expand Down
30 changes: 30 additions & 0 deletions test/unit/basic.dev.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'path'
import jsdom from 'jsdom'
import consola from 'consola'
import { Builder, BundleBuilder, getPort, loadFixture, Nuxt, rp, waitFor } from '../utils'

Expand Down Expand Up @@ -51,6 +52,14 @@ describe('basic dev', () => {
postcssLoader = cssLoaders[cssLoaders.length - 1]
}
}
},
hooks: {
'vue-renderer:ssr:context': ({ nuxt }) => {
nuxt.logs = [{ type: 'log', args: ['This is a test ssr log'] }]
}
},
render: {
ssrLog: 'collapsed'
}
})

Expand Down Expand Up @@ -169,6 +178,27 @@ describe('basic dev', () => {
})
})

test('/ should display ssr log in collapsed group', async () => {
const virtualConsole = new jsdom.VirtualConsole()
const groupCollapsed = jest.fn()
const groupEnd = jest.fn()
const log = jest.fn()
virtualConsole.on('groupCollapsed', groupCollapsed)
virtualConsole.on('groupEnd', groupEnd)
virtualConsole.on('log', log)

await nuxt.server.renderAndGetWindow(url('/'), {
virtualConsole
})

expect(groupCollapsed).toHaveBeenCalledWith(
'%cNuxt SSR',
'background: #2E495E;border-radius: 0.5em;color: white;font-weight: bold;padding: 2px 0.5em;'
)
expect(groupEnd).toHaveBeenCalled()
expect(log).toHaveBeenCalledWith('This is a test ssr log')
})

// Close server and ask nuxt to stop listening to file changes
afterAll(async () => {
await nuxt.close()
Expand Down
58 changes: 56 additions & 2 deletions test/unit/basic.ssr.csp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,34 @@ describe('basic ssr csp', () => {
)

test(
'Contain hash and \'unsafe-inline\' when unsafeInlineCompatiblity is enabled',
'Contain hash and \'unsafe-inline\' when unsafeInlineCompatibility is enabled',
async () => {
const policies = {
'script-src': [`'unsafe-inline'`]
}

nuxt = await startCspServer({
unsafeInlineCompatibility: true,
policies
})

for (let i = 0; i < 5; i++) {
await rp(url('/stateless'), {
resolveWithFullResponse: true
})
}

const { headers } = await rp(url('/stateful'), {
resolveWithFullResponse: true
})

expect(headers[cspHeader]).toMatch(/script-src 'sha256-.*' 'self' 'unsafe-inline'$/)
}
)

// TODO: Remove this test in Nuxt 3, we will stop supporting this typo (more on: https://github.com/nuxt/nuxt.js/pull/6583)
test(
'Contain hash and \'unsafe-inline\' when the typo property unsafeInlineCompatiblity is enabled',
async () => {
const policies = {
'script-src': [`'unsafe-inline'`]
Expand Down Expand Up @@ -419,7 +446,34 @@ describe('basic ssr csp', () => {
)

test(
'Contain hash and \'unsafe-inline\' when unsafeInlineCompatiblity is enabled',
'Contain hash and \'unsafe-inline\' when unsafeInlineCompatibility is enabled',
async () => {
const policies = {
'script-src': [`'unsafe-inline'`]
}

nuxt = await startCspServer({
unsafeInlineCompatibility: true,
policies
})

for (let i = 0; i < 5; i++) {
await rp(url('/stateless'), {
resolveWithFullResponse: true
})
}

const { headers } = await rp(url('/stateful'), {
resolveWithFullResponse: true
})

expect(headers[cspHeader]).toMatch(/script-src 'sha256-.*' 'self' 'unsafe-inline'$/)
}
)

// TODO: Remove this test in Nuxt 3, we will stop supporting this typo (more on: https://github.com/nuxt/nuxt.js/pull/6583)
test(
'Contain hash and \'unsafe-inline\' when the typo property unsafeInlineCompatiblity is enabled',
async () => {
const policies = {
'script-src': [`'unsafe-inline'`]
Expand Down