Date: Thu, 25 Oct 2018 12:33:07 +0100
Subject: [PATCH 047/149] Set up CI with Azure Pipelines (#4190)
---
README.md | 2 +-
appveyor.yml | 38 -----------------------------
azure-pipelines.yml | 32 ++++++++++++++++++++++++
test/fixtures/cli/cli.build.test.js | 2 +-
test/fixtures/cli/cli.gen.test.js | 2 +-
test/unit/cli.test.js | 2 +-
test/utils/setup.js | 4 ---
7 files changed, 36 insertions(+), 46 deletions(-)
delete mode 100644 appveyor.yml
create mode 100644 azure-pipelines.yml
diff --git a/README.md b/README.md
index c95e46774b..985e6d93db 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
-
+
Β
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index 797ed4cfa2..0000000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,38 +0,0 @@
-# Test against the latest version of this Node.js version
-environment:
- nodejs_version: "Current"
-
-cache:
- - 'node_modules -> yarn.lock'
- - '%LOCALAPPDATA%\\Yarn -> yarn.lock'
-
-image: Visual Studio 2017
-
-shallow_clone: true
-
-# Install scripts. (runs after repo cloning)
-install:
- # Get the latest stable version of Node.js or io.js
- - ps: Install-Product node $env:nodejs_version
- # Install modules
- - yarn install
- # Link dependencies
- - yarn lerna link
- # Build packages
- - yarn build
-
-# Post-install test scripts.
-test_script:
- # Output useful info for debugging.
- - node --version
- # - npm --version
- - yarn --version
- # run tests
- - yarn test:fixtures -w=2
- - yarn test:unit -w=2
-
-# Don't actually build.
-build: off
-
-# Do not build feature branch with open Pull Requests
-skip_branch_with_pr: true
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
new file mode 100644
index 0000000000..1d82aa01ef
--- /dev/null
+++ b/azure-pipelines.yml
@@ -0,0 +1,32 @@
+# Node.js
+# Build a general Node.js project with npm.
+# Add steps that analyze code, save build artifacts, deploy, and more:
+# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
+
+pool:
+ vmImage: 'vs2017-win2016'
+
+trigger:
+- dev
+
+steps:
+- task: NodeTool@0
+ inputs:
+ versionSpec: '^10.10.0'
+ displayName: 'Install Node.js'
+
+- script: |
+ yarn
+ displayName: 'Install dependencies'
+
+- script: |
+ yarn build
+ displayName: 'Build Nuxt'
+
+- script: |
+ yarn test:fixtures -w=2
+ displayName: 'Test: Build Fixtures'
+
+- script: |
+ yarn test:unit -w=2
+ displayName: 'Test: Run unit tests'
diff --git a/test/fixtures/cli/cli.build.test.js b/test/fixtures/cli/cli.build.test.js
index 6f09c469d5..32aa75caee 100644
--- a/test/fixtures/cli/cli.build.test.js
+++ b/test/fixtures/cli/cli.build.test.js
@@ -6,7 +6,7 @@ const execify = promisify(exec)
const rootDir = __dirname
const nuxtBin = resolve(__dirname, '../../../packages/cli/bin/nuxt.js')
-describe.skip.appveyor('cli build', () => {
+describe('cli build', () => {
test('nuxt build', async () => {
const { stdout } = await execify(`node ${nuxtBin} build ${rootDir} -c cli.build.config.js`)
diff --git a/test/fixtures/cli/cli.gen.test.js b/test/fixtures/cli/cli.gen.test.js
index 1cefeafa2c..57c23c3761 100644
--- a/test/fixtures/cli/cli.gen.test.js
+++ b/test/fixtures/cli/cli.gen.test.js
@@ -6,7 +6,7 @@ const execify = promisify(exec)
const rootDir = __dirname
const nuxtBin = resolve(__dirname, '../../../packages/cli/bin/nuxt.js')
-describe.skip.appveyor('cli generate', () => {
+describe('cli generate', () => {
test('nuxt generate', async () => {
const { stdout } = await execify(`node -r esm ${nuxtBin} generate ${rootDir} -c cli.gen.config.js`)
diff --git a/test/unit/cli.test.js b/test/unit/cli.test.js
index 0659ecb4f2..cceb70170a 100644
--- a/test/unit/cli.test.js
+++ b/test/unit/cli.test.js
@@ -20,7 +20,7 @@ const close = async (nuxtInt) => {
}
}
-describe.skip.appveyor('cli', () => {
+describe('cli', () => {
test('nuxt dev', async () => {
let stdout = ''
const env = process.env
diff --git a/test/utils/setup.js b/test/utils/setup.js
index d5bc9d65ab..cba96cd992 100644
--- a/test/utils/setup.js
+++ b/test/utils/setup.js
@@ -1,7 +1,3 @@
-const isAppveyor = !!process.env.APPVEYOR
-describe.skip.appveyor = isAppveyor ? describe.skip : describe
-test.skip.appveyor = isAppveyor ? test.skip : test
-
const isWin = process.platform === 'win32'
describe.skip.win = isWin ? describe.skip : describe
test.skip.win = isWin ? test.skip : test
From 4b7afcc21860e9174731dc0ba39c370a655824c9 Mon Sep 17 00:00:00 2001
From: Pim
Date: Thu, 25 Oct 2018 17:40:55 +0200
Subject: [PATCH 048/149] feat(cli): add imports mock and cleanup (#4195)
---
packages/cli/src/command.js | 24 ++++---------------
packages/cli/test/unit/cli.test.js | 32 ++++++++++----------------
packages/cli/test/unit/command.test.js | 2 +-
packages/cli/test/unit/dev.test.js | 15 ++++++------
packages/cli/test/utils/index.js | 2 ++
packages/cli/test/utils/mocking.js | 28 +++++++++++++++++-----
6 files changed, 48 insertions(+), 55 deletions(-)
diff --git a/packages/cli/src/command.js b/packages/cli/src/command.js
index 954fdfa51f..fbc9552871 100644
--- a/packages/cli/src/command.js
+++ b/packages/cli/src/command.js
@@ -67,35 +67,19 @@ export default class NuxtCommand {
return options
}
- importCore() {
- return imports.core()
- }
-
- importBuilder() {
- return imports.builder()
- }
-
- importGenerator() {
- return imports.generator()
- }
-
- importWebpack() {
- return imports.webpack()
- }
-
async getNuxt(options) {
- const { Nuxt } = await this.importCore()
+ const { Nuxt } = await imports.core()
return new Nuxt(options)
}
async getBuilder(nuxt) {
- const { Builder } = await this.importBuilder()
- const { BundleBuilder } = await this.importWebpack()
+ const { Builder } = await imports.builder()
+ const { BundleBuilder } = await imports.webpack()
return new Builder(nuxt, BundleBuilder)
}
async getGenerator(nuxt) {
- const { Generator } = await this.importGenerator()
+ const { Generator } = await imports.generator()
const builder = await this.getBuilder(nuxt)
return new Generator(nuxt, builder)
}
diff --git a/packages/cli/test/unit/cli.test.js b/packages/cli/test/unit/cli.test.js
index 8150180fa4..fa283776bd 100644
--- a/packages/cli/test/unit/cli.test.js
+++ b/packages/cli/test/unit/cli.test.js
@@ -7,17 +7,7 @@ import * as commands from '../../src/commands'
const readDir = promisify(readdir)
-consola.add = jest.fn()
-
-const mockCommand = (cmd, p) => {
- commands[cmd] = jest.fn().mockImplementationOnce(() => { // eslint-disable-line import/namespace
- return Promise.resolve({
- default: () => {
- return p
- }
- })
- })
-}
+jest.mock('../../src/commands')
describe('cli', () => {
afterEach(() => {
@@ -33,26 +23,28 @@ describe('cli', () => {
}
cmd = cmd.substring(0, cmd.length - 3)
- expect(commands[cmd]).toBeDefined() // eslint-disable-line import/namespace
- expect(typeof commands[cmd]).toBe('function') // eslint-disable-line import/namespace
+ const cmdFn = commands[cmd] // eslint-disable-line import/namespace
+ expect(cmdFn).toBeDefined()
+ expect(typeof cmdFn).toBe('function')
}
})
test('calls expected method', async () => {
const argv = process.argv
process.argv = ['', '', 'dev']
- mockCommand('dev', Promise.resolve())
+ const defaultExport = jest.fn().mockImplementation(() => Promise.resolve())
+ commands.dev.mockImplementationOnce(() => Promise.resolve({ default: defaultExport }))
await run()
- expect(commands.dev).toHaveBeenCalled()
+ expect(defaultExport).toHaveBeenCalled()
process.argv = argv
})
test('unknown calls default method', async () => {
const argv = process.argv
process.argv = ['', '', 'test']
- mockCommand('dev', Promise.resolve())
+ commands.dev.mockImplementationOnce(() => Promise.resolve())
await run()
@@ -63,7 +55,7 @@ describe('cli', () => {
test('sets NODE_ENV=development for dev', async () => {
const nodeEnv = process.env.NODE_ENV
process.env.NODE_ENV = ''
- mockCommand('dev', Promise.resolve())
+ commands.dev.mockImplementationOnce(() => Promise.resolve())
await run()
@@ -71,12 +63,12 @@ describe('cli', () => {
process.env.NODE_ENV = nodeEnv
})
- test('sets ODE_ENV=production for build', async () => {
+ test('sets NODE_ENV=production for build', async () => {
const argv = process.argv
const nodeEnv = process.env.NODE_ENV
process.argv = ['', '', 'build']
process.env.NODE_ENV = ''
- mockCommand('build', Promise.resolve())
+ commands.build.mockImplementationOnce(() => Promise.resolve())
await run()
@@ -86,7 +78,7 @@ describe('cli', () => {
})
test('catches fatal error', async () => {
- mockCommand('dev', Promise.reject(new Error('Command Error')))
+ commands.dev.mockImplementationOnce(() => Promise.reject(new Error('Command Error')))
await run()
diff --git a/packages/cli/test/unit/command.test.js b/packages/cli/test/unit/command.test.js
index d8ff3e579f..cb0c05af7e 100644
--- a/packages/cli/test/unit/command.test.js
+++ b/packages/cli/test/unit/command.test.js
@@ -1,6 +1,6 @@
-import { consola } from '../utils'
import Command from '../../src/command'
import { options as Options } from '../../src/options'
+import { consola } from '../utils'
jest.mock('@nuxt/core')
jest.mock('@nuxt/builder')
diff --git a/packages/cli/test/unit/dev.test.js b/packages/cli/test/unit/dev.test.js
index b65a335120..30a623b350 100644
--- a/packages/cli/test/unit/dev.test.js
+++ b/packages/cli/test/unit/dev.test.js
@@ -1,7 +1,6 @@
-import { consola } from '../utils'
-import { mockNuxt, mockBuilder, mockGetNuxtConfig } from '../utils/mocking'
+import { consola, mockNuxt, mockBuilder, mockGetNuxtConfig } from '../utils'
-describe.skip('dev', () => {
+describe('dev', () => {
let dev
beforeAll(async () => {
@@ -10,7 +9,7 @@ describe.skip('dev', () => {
})
afterEach(() => {
- jest.resetAllMocks()
+ jest.clearAllMocks()
})
test('is function', () => {
@@ -30,7 +29,7 @@ describe.skip('dev', () => {
expect(Nuxt.prototype.showReady).toHaveBeenCalled()
expect(Builder.prototype.watchServer).toHaveBeenCalled()
- jest.resetAllMocks()
+ jest.clearAllMocks()
const builder = new Builder()
builder.nuxt = new Nuxt()
@@ -53,7 +52,7 @@ describe.skip('dev', () => {
const Builder = mockBuilder()
await dev()
- jest.resetAllMocks()
+ jest.clearAllMocks()
// Test error on second build so we cover oldInstance stuff
const builder = new Builder()
@@ -70,7 +69,7 @@ describe.skip('dev', () => {
const Builder = mockBuilder()
await dev()
- jest.resetAllMocks()
+ jest.clearAllMocks()
const builder = new Builder()
builder.nuxt = new Nuxt()
@@ -86,7 +85,7 @@ describe.skip('dev', () => {
const Builder = mockBuilder()
await dev()
- jest.resetAllMocks()
+ jest.clearAllMocks()
mockGetNuxtConfig().mockImplementationOnce(() => {
throw new Error('Config Error')
diff --git a/packages/cli/test/utils/index.js b/packages/cli/test/utils/index.js
index 8c36b338fe..e31e09d6c0 100644
--- a/packages/cli/test/utils/index.js
+++ b/packages/cli/test/utils/index.js
@@ -3,6 +3,8 @@ export * from './mocking'
jest.mock('consola')
+consola.add = jest.fn()
+
export {
consola
}
diff --git a/packages/cli/test/utils/mocking.js b/packages/cli/test/utils/mocking.js
index 7427a8b8be..63a83e3976 100644
--- a/packages/cli/test/utils/mocking.js
+++ b/packages/cli/test/utils/mocking.js
@@ -1,5 +1,23 @@
+import * as imports from '../../src/imports'
import Command from '../../src/command'
+jest.mock('../../src/imports', () => {
+ return {
+ core: jest.fn().mockImplementation(() => ({
+ Nuxt: function () {}
+ })),
+ builder: jest.fn().mockImplementation(() => ({
+ Builder: function () {}
+ })),
+ generator: jest.fn().mockImplementation(() => ({
+ Generator: function () {}
+ })),
+ webpack: jest.fn().mockImplementation(() => ({
+ BundleBuilder: function () {}
+ }))
+ }
+})
+
export const mockGetNuxt = (options, implementation) => {
Command.prototype.getNuxt = jest.fn().mockImplementationOnce(() => {
return Object.assign({
@@ -75,9 +93,8 @@ export const mockNuxt = (implementation) => {
showReady: jest.fn().mockImplementationOnce(() => Promise.resolve())
}, implementation || {})
- Command.prototype.importCore = jest.fn().mockImplementationOnce(() => {
- return { Nuxt }
- })
+ imports.core.mockImplementation(() => ({ Nuxt }))
+
return Nuxt
}
@@ -89,8 +106,7 @@ export const mockBuilder = (implementation) => {
watchServer: jest.fn().mockImplementationOnce(() => Promise.resolve())
}, implementation || {})
- Command.prototype.importBuilder = jest.fn().mockImplementationOnce(() => {
- return { Builder }
- })
+ imports.builder.mockImplementation(() => ({ Builder }))
+
return Builder
}
From 6c5d89dead9d3fe08cacad8f5cdaae60eb88fd67 Mon Sep 17 00:00:00 2001
From: "renovate[bot]"
Date: Thu, 25 Oct 2018 19:19:17 +0330
Subject: [PATCH 049/149] fix(deps): update all non-major dependencies (#4189)
---
package.json | 2 +-
packages/webpack/package.json | 4 +-
yarn.lock | 252 +++++++++++++++++-----------------
3 files changed, 129 insertions(+), 129 deletions(-)
diff --git a/package.json b/package.json
index 864a2e18ab..1d39a84950 100644
--- a/package.json
+++ b/package.json
@@ -38,7 +38,7 @@
"eslint-config-standard": "^12.0.0",
"eslint-multiplexer": "^1.0.2",
"eslint-plugin-import": "^2.14.0",
- "eslint-plugin-jest": "^21.26.0",
+ "eslint-plugin-jest": "^21.26.1",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
diff --git a/packages/webpack/package.json b/packages/webpack/package.json
index e696ed6304..53bd488578 100644
--- a/packages/webpack/package.json
+++ b/packages/webpack/package.json
@@ -15,7 +15,7 @@
"@nuxtjs/friendly-errors-webpack-plugin": "^2.0.2",
"babel-loader": "^8.0.4",
"cache-loader": "^1.2.2",
- "caniuse-lite": "^1.0.30000898",
+ "caniuse-lite": "^1.0.30000899",
"chalk": "^2.4.1",
"consola": "^1.4.4",
"css-loader": "^1.0.0",
@@ -41,7 +41,7 @@
"time-fix-plugin": "^2.0.4",
"url-loader": "^1.1.2",
"vue-loader": "^15.4.2",
- "webpack": "^4.22.0",
+ "webpack": "^4.23.1",
"webpack-bundle-analyzer": "^3.0.3",
"webpack-dev-middleware": "^3.4.0",
"webpack-hot-middleware": "^2.24.3",
diff --git a/yarn.lock b/yarn.lock
index 0c2502dfd3..c74fe7c89a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1427,147 +1427,147 @@
source-map "^0.5.6"
vue-template-es2015-compiler "^1.6.0"
-"@webassemblyjs/ast@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.7.8.tgz#f31f480debeef957f01b623f27eabc695fa4fe8f"
- integrity sha512-dOrtdtEyB8sInpl75yLPNksY4sRl0j/+t6aHyB/YA+ab9hV3Fo7FmG12FHzP+2MvWVAJtDb+6eXR5EZbZJ+uVg==
+"@webassemblyjs/ast@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.7.10.tgz#0cfc61d61286240b72fc522cb755613699eea40a"
+ integrity sha512-wTUeaByYN2EA6qVqhbgavtGc7fLTOx0glG2IBsFlrFG51uXIGlYBTyIZMf4SPLo3v1bgV/7lBN3l7Z0R6Hswew==
dependencies:
- "@webassemblyjs/helper-module-context" "1.7.8"
- "@webassemblyjs/helper-wasm-bytecode" "1.7.8"
- "@webassemblyjs/wast-parser" "1.7.8"
+ "@webassemblyjs/helper-module-context" "1.7.10"
+ "@webassemblyjs/helper-wasm-bytecode" "1.7.10"
+ "@webassemblyjs/wast-parser" "1.7.10"
-"@webassemblyjs/floating-point-hex-parser@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.7.8.tgz#1b3ed0e27e384032254e9322fc646dd3e70ef1b9"
- integrity sha512-kn2zNKGsbql5i56VAgRYkpG+VazqHhQQZQycT2uXAazrAEDs23gy+Odkh5VblybjnwX2/BITkDtNmSO76hdIvQ==
+"@webassemblyjs/floating-point-hex-parser@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.7.10.tgz#ee63d729c6311a85863e369a473f9983f984e4d9"
+ integrity sha512-gMsGbI6I3p/P1xL2UxqhNh1ga2HCsx5VBB2i5VvJFAaqAjd2PBTRULc3BpTydabUQEGlaZCzEUQhLoLG7TvEYQ==
-"@webassemblyjs/helper-api-error@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.7.8.tgz#a2b49c11f615e736f815ec927f035dcfa690d572"
- integrity sha512-xUwxDXsd1dUKArJEP5wWM5zxgCSwZApSOJyP1XO7M8rNUChUDblcLQ4FpzTpWG2YeylMwMl1MlP5Ztryiz1x4g==
+"@webassemblyjs/helper-api-error@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.7.10.tgz#bfcb3bbe59775357475790a2ad7b289f09b2f198"
+ integrity sha512-DoYRlPWtuw3yd5BOr9XhtrmB6X1enYF0/54yNvQWGXZEPDF5PJVNI7zQ7gkcKfTESzp8bIBWailaFXEK/jjCsw==
-"@webassemblyjs/helper-buffer@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.7.8.tgz#3fc66bfa09c1c60e824cf3d5887826fac062877d"
- integrity sha512-WXiIMnuvuwlhWvVOm8xEXU9DnHaa3AgAU0ZPfvY8vO1cSsmYb2WbGbHnMLgs43vXnA7XAob9b56zuZaMkxpCBg==
+"@webassemblyjs/helper-buffer@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.7.10.tgz#0a8c624c67ad0b214d2e003859921a1988cb151b"
+ integrity sha512-+RMU3dt/dPh4EpVX4u5jxsOlw22tp3zjqE0m3ftU2tsYxnPULb4cyHlgaNd2KoWuwasCQqn8Mhr+TTdbtj3LlA==
-"@webassemblyjs/helper-code-frame@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.7.8.tgz#cc5a7e9522b70e7580df056dfd34020cf29645b0"
- integrity sha512-TLQxyD9qGOIdX5LPQOPo0Ernd88U5rHkFb8WAjeMIeA0sPjCHeVPaGqUGGIXjUcblUkjuDAc07bruCcNHUrHDA==
+"@webassemblyjs/helper-code-frame@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.7.10.tgz#0ab7e22fad0241a173178c73976fc0edf50832ce"
+ integrity sha512-UiytbpKAULOEab2hUZK2ywXen4gWJVrgxtwY3Kn+eZaaSWaRM8z/7dAXRSoamhKFiBh1uaqxzE/XD9BLlug3gw==
dependencies:
- "@webassemblyjs/wast-printer" "1.7.8"
+ "@webassemblyjs/wast-printer" "1.7.10"
-"@webassemblyjs/helper-fsm@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/helper-fsm/-/helper-fsm-1.7.8.tgz#fe4607430af466912797c21acafd3046080182ea"
- integrity sha512-TjK0CnD8hAPkV5mbSp5aWl6SO1+H3WFcjWtixWoy8EMA99YnNzYhpc/WSYWhf7yrhpzkq5tZB0tvLK3Svr3IXA==
+"@webassemblyjs/helper-fsm@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/helper-fsm/-/helper-fsm-1.7.10.tgz#0915e7713fbbb735620a9d3e4fa3d7951f97ac64"
+ integrity sha512-w2vDtUK9xeSRtt5+RnnlRCI7wHEvLjF0XdnxJpgx+LJOvklTZPqWkuy/NhwHSLP19sm9H8dWxKeReMR7sCkGZA==
-"@webassemblyjs/helper-module-context@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/helper-module-context/-/helper-module-context-1.7.8.tgz#3c2e7ee93d14ff4768ba66fb1be42fdc9dc7160a"
- integrity sha512-uCutAKR7Nm0VsFixcvnB4HhAyHouNbj0Dx1p7eRjFjXGGZ+N7ftTaG1ZbWCasAEbtwGj54LP8+lkBZdTCPmLGg==
+"@webassemblyjs/helper-module-context@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/helper-module-context/-/helper-module-context-1.7.10.tgz#9beb83f72740f5ac8075313b5cac5e796510f755"
+ integrity sha512-yE5x/LzZ3XdPdREmJijxzfrf+BDRewvO0zl8kvORgSWmxpRrkqY39KZSq6TSgIWBxkK4SrzlS3BsMCv2s1FpsQ==
-"@webassemblyjs/helper-wasm-bytecode@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.7.8.tgz#89bdb78cd6dd5209ae2ed2925de78d0f0e00b6f0"
- integrity sha512-AdCCE3BMW6V34WYaKUmPgVHa88t2Z14P4/0LjLwuGkI0X6pf7nzp0CehzVVk51cKm2ymVXjl9dCG+gR1yhITIQ==
+"@webassemblyjs/helper-wasm-bytecode@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.7.10.tgz#797b1e734bbcfdea8399669cdc58308ef1c7ffc0"
+ integrity sha512-u5qy4SJ/OrxKxZqJ9N3qH4ZQgHaAzsopsYwLvoWJY6Q33r8PhT3VPyNMaJ7ZFoqzBnZlCcS/0f4Sp8WBxylXfg==
-"@webassemblyjs/helper-wasm-section@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.7.8.tgz#c68ef7d26a6fc12421b2e6e56f9bc810dfb33e87"
- integrity sha512-BkBhYQuzyl4hgTGOKo87Vdw6f9nj8HhI7WYpI0MCC5qFa5ahrAPOGgyETVdnRbv+Rjukl9MxxfDmVcVC435lDg==
+"@webassemblyjs/helper-wasm-section@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.7.10.tgz#c0ea3703c615d7bc3e3507c3b7991c8767b2f20e"
+ integrity sha512-Ecvww6sCkcjatcyctUrn22neSJHLN/TTzolMGG/N7S9rpbsTZ8c6Bl98GpSpV77EvzNijiNRHBG0+JO99qKz6g==
dependencies:
- "@webassemblyjs/ast" "1.7.8"
- "@webassemblyjs/helper-buffer" "1.7.8"
- "@webassemblyjs/helper-wasm-bytecode" "1.7.8"
- "@webassemblyjs/wasm-gen" "1.7.8"
+ "@webassemblyjs/ast" "1.7.10"
+ "@webassemblyjs/helper-buffer" "1.7.10"
+ "@webassemblyjs/helper-wasm-bytecode" "1.7.10"
+ "@webassemblyjs/wasm-gen" "1.7.10"
-"@webassemblyjs/ieee754@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.7.8.tgz#1f37974b13cb486a9237e73ce04cac7a2f1265ed"
- integrity sha512-tOarWChdG1a3y1yqCX0JMDKzrat5tQe4pV6K/TX19BcXsBLYxFQOL1DEDa5KG9syeyvCrvZ+i1+Mv1ExngvktQ==
+"@webassemblyjs/ieee754@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.7.10.tgz#62c1728b7ef0f66ef8221e2966a0afd75db430df"
+ integrity sha512-HRcWcY+YWt4+s/CvQn+vnSPfRaD4KkuzQFt5MNaELXXHSjelHlSEA8ZcqT69q0GTIuLWZ6JaoKar4yWHVpZHsQ==
dependencies:
"@xtuc/ieee754" "^1.2.0"
-"@webassemblyjs/leb128@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.7.8.tgz#1bee83426819192db2ea1a234b84c7ebc6d34c1f"
- integrity sha512-GCYeGPgUFWJiZuP4NICbcyUQNxNLJIf476Ei+K+jVuuebtLpfvwkvYT6iTUE7oZYehhkor4Zz2g7SJ/iZaPudQ==
+"@webassemblyjs/leb128@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.7.10.tgz#167e0bb4b06d7701585772a73fba9f4df85439f6"
+ integrity sha512-og8MciYlA8hvzCLR71hCuZKPbVBfLQeHv7ImKZ4nlyxrYbG7uJHYtHiHu6OV9SqrGuD03H/HtXC4Bgdjfm9FHw==
dependencies:
"@xtuc/long" "4.2.1"
-"@webassemblyjs/utf8@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.7.8.tgz#2b489d5cf43e0aebb93d8e2d792aff9879c61f05"
- integrity sha512-9X+f0VV+xNXW2ujfIRSXBJENGE6Qh7bNVKqu3yDjTFB3ar3nsThsGBBKdTG58aXOm2iUH6v28VIf88ymPXODHA==
+"@webassemblyjs/utf8@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.7.10.tgz#b6728f5b6f50364abc155be029f9670e6685605a"
+ integrity sha512-Ng6Pxv6siyZp635xCSnH3mKmIFgqWPCcGdoo0GBYgyGdxu7cUj4agV7Uu1a8REP66UYUFXJLudeGgd4RvuJAnQ==
-"@webassemblyjs/wasm-edit@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.7.8.tgz#f8bdbe7088718eca27b1c349bb7c06b8a457950c"
- integrity sha512-6D3Hm2gFixrfyx9XjSON4ml1FZTugqpkIz5Awvrou8fnpyprVzcm4X8pyGRtA2Piixjl3DqmX/HB1xdWyE097A==
+"@webassemblyjs/wasm-edit@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.7.10.tgz#83fe3140f5a58f5a30b914702be9f0e59a399092"
+ integrity sha512-e9RZFQlb+ZuYcKRcW9yl+mqX/Ycj9+3/+ppDI8nEE/NCY6FoK8f3dKBcfubYV/HZn44b+ND4hjh+4BYBt+sDnA==
dependencies:
- "@webassemblyjs/ast" "1.7.8"
- "@webassemblyjs/helper-buffer" "1.7.8"
- "@webassemblyjs/helper-wasm-bytecode" "1.7.8"
- "@webassemblyjs/helper-wasm-section" "1.7.8"
- "@webassemblyjs/wasm-gen" "1.7.8"
- "@webassemblyjs/wasm-opt" "1.7.8"
- "@webassemblyjs/wasm-parser" "1.7.8"
- "@webassemblyjs/wast-printer" "1.7.8"
+ "@webassemblyjs/ast" "1.7.10"
+ "@webassemblyjs/helper-buffer" "1.7.10"
+ "@webassemblyjs/helper-wasm-bytecode" "1.7.10"
+ "@webassemblyjs/helper-wasm-section" "1.7.10"
+ "@webassemblyjs/wasm-gen" "1.7.10"
+ "@webassemblyjs/wasm-opt" "1.7.10"
+ "@webassemblyjs/wasm-parser" "1.7.10"
+ "@webassemblyjs/wast-printer" "1.7.10"
-"@webassemblyjs/wasm-gen@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.7.8.tgz#7e8abf1545eae74ac6781d545c034af3cfd0c7d5"
- integrity sha512-a7O/wE6eBeVKKUYgpMK7NOHmMADD85rSXLe3CqrWRDwWff5y3cSVbzpN6Qv3z6C4hdkpq9qyij1Ga1kemOZGvQ==
+"@webassemblyjs/wasm-gen@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.7.10.tgz#4de003806ae29c97ab3707782469b53299570174"
+ integrity sha512-M0lb6cO2Y0PzDye/L39PqwV+jvO+2YxEG5ax+7dgq7EwXdAlpOMx1jxyXJTScQoeTpzOPIb+fLgX/IkLF8h2yw==
dependencies:
- "@webassemblyjs/ast" "1.7.8"
- "@webassemblyjs/helper-wasm-bytecode" "1.7.8"
- "@webassemblyjs/ieee754" "1.7.8"
- "@webassemblyjs/leb128" "1.7.8"
- "@webassemblyjs/utf8" "1.7.8"
+ "@webassemblyjs/ast" "1.7.10"
+ "@webassemblyjs/helper-wasm-bytecode" "1.7.10"
+ "@webassemblyjs/ieee754" "1.7.10"
+ "@webassemblyjs/leb128" "1.7.10"
+ "@webassemblyjs/utf8" "1.7.10"
-"@webassemblyjs/wasm-opt@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.7.8.tgz#7ada6e211914728fce02ff0ff9c344edc6d41f26"
- integrity sha512-3lbQ0PT81NHCdi1sR/7+SNpZadM4qYcTSr62nFFAA7e5lFwJr14M1Gi+A/Y3PgcDWOHYjsaNGPpPU0H03N6Blg==
+"@webassemblyjs/wasm-opt@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.7.10.tgz#d151e31611934a556c82789fdeec41a814993c2a"
+ integrity sha512-R66IHGCdicgF5ZliN10yn5HaC7vwYAqrSVJGjtJJQp5+QNPBye6heWdVH/at40uh0uoaDN/UVUfXK0gvuUqtVg==
dependencies:
- "@webassemblyjs/ast" "1.7.8"
- "@webassemblyjs/helper-buffer" "1.7.8"
- "@webassemblyjs/wasm-gen" "1.7.8"
- "@webassemblyjs/wasm-parser" "1.7.8"
+ "@webassemblyjs/ast" "1.7.10"
+ "@webassemblyjs/helper-buffer" "1.7.10"
+ "@webassemblyjs/wasm-gen" "1.7.10"
+ "@webassemblyjs/wasm-parser" "1.7.10"
-"@webassemblyjs/wasm-parser@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.7.8.tgz#dac47c291fb6a3e63529aecd647592cd34afbf94"
- integrity sha512-rZ/zlhp9DHR/05zh1MbAjT2t624sjrPP/OkJCjXqzm7ynH+nIdNcn9Ixc+qzPMFXhIrk0rBoQ3to6sEIvHh9jQ==
+"@webassemblyjs/wasm-parser@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.7.10.tgz#0367be7bf8f09e3e6abc95f8e483b9206487ec65"
+ integrity sha512-AEv8mkXVK63n/iDR3T693EzoGPnNAwKwT3iHmKJNBrrALAhhEjuPzo/lTE4U7LquEwyvg5nneSNdTdgrBaGJcA==
dependencies:
- "@webassemblyjs/ast" "1.7.8"
- "@webassemblyjs/helper-api-error" "1.7.8"
- "@webassemblyjs/helper-wasm-bytecode" "1.7.8"
- "@webassemblyjs/ieee754" "1.7.8"
- "@webassemblyjs/leb128" "1.7.8"
- "@webassemblyjs/utf8" "1.7.8"
+ "@webassemblyjs/ast" "1.7.10"
+ "@webassemblyjs/helper-api-error" "1.7.10"
+ "@webassemblyjs/helper-wasm-bytecode" "1.7.10"
+ "@webassemblyjs/ieee754" "1.7.10"
+ "@webassemblyjs/leb128" "1.7.10"
+ "@webassemblyjs/utf8" "1.7.10"
-"@webassemblyjs/wast-parser@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/wast-parser/-/wast-parser-1.7.8.tgz#f8aab9a450c048c1f9537695c89faeb92fabfba5"
- integrity sha512-Q/zrvtUvzWuSiJMcSp90fi6gp2nraiHXjTV2VgAluVdVapM4gy1MQn7akja2p6eSBDQpKJPJ6P4TxRkghRS5dg==
+"@webassemblyjs/wast-parser@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/wast-parser/-/wast-parser-1.7.10.tgz#058f598b52f730b23fc874d4775b6286b6247264"
+ integrity sha512-YTPEtOBljkCL0VjDp4sHe22dAYSm3ZwdJ9+2NTGdtC7ayNvuip1wAhaAS8Zt9Q6SW9E5Jf5PX7YE3XWlrzR9cw==
dependencies:
- "@webassemblyjs/ast" "1.7.8"
- "@webassemblyjs/floating-point-hex-parser" "1.7.8"
- "@webassemblyjs/helper-api-error" "1.7.8"
- "@webassemblyjs/helper-code-frame" "1.7.8"
- "@webassemblyjs/helper-fsm" "1.7.8"
+ "@webassemblyjs/ast" "1.7.10"
+ "@webassemblyjs/floating-point-hex-parser" "1.7.10"
+ "@webassemblyjs/helper-api-error" "1.7.10"
+ "@webassemblyjs/helper-code-frame" "1.7.10"
+ "@webassemblyjs/helper-fsm" "1.7.10"
"@xtuc/long" "4.2.1"
-"@webassemblyjs/wast-printer@1.7.8":
- version "1.7.8"
- resolved "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.7.8.tgz#e7e965782c1912f6a965f14a53ff43d8ad0403a5"
- integrity sha512-GllIthRtwTxRDAURRNXscu7Napzmdf1jt1gpiZiK/QN4fH0lSGs3OTmvdfsMNP7tqI4B3ZtfaaWRlNIQug6Xyg==
+"@webassemblyjs/wast-printer@1.7.10":
+ version "1.7.10"
+ resolved "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.7.10.tgz#d817909d2450ae96c66b7607624d98a33b84223b"
+ integrity sha512-mJ3QKWtCchL1vhU/kZlJnLPuQZnlDOdZsyP0bbLWPGdYsQDnSBvyTLhzwBA3QAMlzEL9V4JHygEmK6/OTEyytA==
dependencies:
- "@webassemblyjs/ast" "1.7.8"
- "@webassemblyjs/wast-parser" "1.7.8"
+ "@webassemblyjs/ast" "1.7.10"
+ "@webassemblyjs/wast-parser" "1.7.10"
"@xtuc/long" "4.2.1"
"@xtuc/ieee754@^1.2.0":
@@ -2622,10 +2622,10 @@ caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000890, caniuse-lite@^1.0.30000892, can
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000893.tgz#284b20932bd41b93e21626975f2050cb01561986"
integrity sha512-kOddHcTEef+NgN/fs0zmX2brHTNATVOWMEIhlZHCuwQRtXobjSw9pAECc44Op4bTBcavRjkLaPrGomknH7+Jvg==
-caniuse-lite@^1.0.30000898:
- version "1.0.30000898"
- resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000898.tgz#651306e690ca83caca5814da5afa3eb4de0f86c2"
- integrity sha512-ytlTZqO4hYe4rNAJhMynUAIUI33jsP2Bb1two/9OVC39wZjPZ8exIO0eCLw5mqAtegOGiGF0kkTWTn3B02L+mw==
+caniuse-lite@^1.0.30000899:
+ version "1.0.30000899"
+ resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000899.tgz#6febdbbc388a7982f620ee0e3d09aab0c061389e"
+ integrity sha512-enC3zKfUCJxxwvUIsBkbHd54CtJw1KtIWvrK0JZxWD/fEN2knHaai45lndJ4xXAkyRAPyk60J3yagkKDWhfeMA==
capture-exit@^1.2.0:
version "1.2.0"
@@ -4107,10 +4107,10 @@ eslint-plugin-import@^2.14.0:
read-pkg-up "^2.0.0"
resolve "^1.6.0"
-eslint-plugin-jest@^21.26.0:
- version "21.26.0"
- resolved "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-21.26.0.tgz#3375de090cdd43af1971a4a93f5d332a13c10a6d"
- integrity sha512-zYePgbZaJsTfiJMb6XcsrrqgDpUB40AmGjjlwMZPEgVstrAsDNW8z7qQggD1lC24yR9h9VxTTb8qu6HRq3n6eg==
+eslint-plugin-jest@^21.26.1:
+ version "21.26.1"
+ resolved "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-21.26.1.tgz#73c5d6838d384fe6a9644077c27011bd99665ff2"
+ integrity sha512-utdtKV04jP8ZXnqbsrArI/7m0Bg819JYnP/f6zP3gwnU7hHGdUzlYPNW73wShVFIDmllgHnkpo49kOPNhbQwrg==
eslint-plugin-node@^7.0.1:
version "7.0.1"
@@ -10961,15 +10961,15 @@ webpack-sources@^1.1.0, webpack-sources@^1.3.0:
source-list-map "^2.0.0"
source-map "~0.6.1"
-webpack@^4.22.0:
- version "4.22.0"
- resolved "https://registry.npmjs.org/webpack/-/webpack-4.22.0.tgz#b168111e2e7b05f5169ac484e79e62093ec39e0d"
- integrity sha512-2+3EYFqyhPl12buLQ42QPHEEh8BHn3P9ipRvGRHhdfKJ1u9svhZ3QjhIoEdL5SeIhL5gfOZVbBnartYEabkEsg==
+webpack@^4.23.1:
+ version "4.23.1"
+ resolved "https://registry.npmjs.org/webpack/-/webpack-4.23.1.tgz#db7467b116771ae020c58bdfe2a0822785bb8239"
+ integrity sha512-iE5Cu4rGEDk7ONRjisTOjVHv3dDtcFfwitSxT7evtYj/rANJpt1OuC/Kozh1pBa99AUBr1L/LsaNB+D9Xz3CEg==
dependencies:
- "@webassemblyjs/ast" "1.7.8"
- "@webassemblyjs/helper-module-context" "1.7.8"
- "@webassemblyjs/wasm-edit" "1.7.8"
- "@webassemblyjs/wasm-parser" "1.7.8"
+ "@webassemblyjs/ast" "1.7.10"
+ "@webassemblyjs/helper-module-context" "1.7.10"
+ "@webassemblyjs/wasm-edit" "1.7.10"
+ "@webassemblyjs/wasm-parser" "1.7.10"
acorn "^5.6.2"
acorn-dynamic-import "^3.0.0"
ajv "^6.1.0"
From 5c0d12fb1385fddffb88af32c4e37c16cddf0253 Mon Sep 17 00:00:00 2001
From: Paul Gascou-Vaillancourt
Date: Thu, 25 Oct 2018 13:42:21 -0400
Subject: [PATCH 050/149] chore(examples): Add Jest + Vue Test Utils example
(#4116)
* chore(examples): Add Jest + Vue Test Utils example
* style: Lint
* refactor: Rename button component & fix lint errors
* refactor: Use export default
* refactor: Babel 7 setup
---
examples/jest-vtu-example/.eslintignore | 1 +
examples/jest-vtu-example/.gitignore | 14 ++++++
examples/jest-vtu-example/README.md | 9 ++++
examples/jest-vtu-example/babel.config.js | 7 +++
.../components/Btn/Btn.spec.js | 36 +++++++++++++++
.../jest-vtu-example/components/Btn/Btn.vue | 25 ++++++++++
.../Btn/__snapshots__/Btn.spec.js.snap | 7 +++
examples/jest-vtu-example/layouts/default.vue | 5 ++
examples/jest-vtu-example/nuxt.config.js | 3 ++
examples/jest-vtu-example/package.json | 46 +++++++++++++++++++
.../pages/__snapshots__/index.spec.js.snap | 12 +++++
examples/jest-vtu-example/pages/index.spec.js | 14 ++++++
examples/jest-vtu-example/pages/index.vue | 20 ++++++++
13 files changed, 199 insertions(+)
create mode 100644 examples/jest-vtu-example/.eslintignore
create mode 100644 examples/jest-vtu-example/.gitignore
create mode 100644 examples/jest-vtu-example/README.md
create mode 100644 examples/jest-vtu-example/babel.config.js
create mode 100644 examples/jest-vtu-example/components/Btn/Btn.spec.js
create mode 100644 examples/jest-vtu-example/components/Btn/Btn.vue
create mode 100644 examples/jest-vtu-example/components/Btn/__snapshots__/Btn.spec.js.snap
create mode 100644 examples/jest-vtu-example/layouts/default.vue
create mode 100644 examples/jest-vtu-example/nuxt.config.js
create mode 100644 examples/jest-vtu-example/package.json
create mode 100644 examples/jest-vtu-example/pages/__snapshots__/index.spec.js.snap
create mode 100644 examples/jest-vtu-example/pages/index.spec.js
create mode 100644 examples/jest-vtu-example/pages/index.vue
diff --git a/examples/jest-vtu-example/.eslintignore b/examples/jest-vtu-example/.eslintignore
new file mode 100644
index 0000000000..d6083f1e1a
--- /dev/null
+++ b/examples/jest-vtu-example/.eslintignore
@@ -0,0 +1 @@
+*.spec.js.snap
diff --git a/examples/jest-vtu-example/.gitignore b/examples/jest-vtu-example/.gitignore
new file mode 100644
index 0000000000..4da44f57b7
--- /dev/null
+++ b/examples/jest-vtu-example/.gitignore
@@ -0,0 +1,14 @@
+# dependencies
+node_modules
+
+# logs
+npm-debug.log
+
+# Nuxt build
+.nuxt
+
+# Nuxt generate
+dist
+
+# coverage report
+coverage/
diff --git a/examples/jest-vtu-example/README.md b/examples/jest-vtu-example/README.md
new file mode 100644
index 0000000000..03b5e9744e
--- /dev/null
+++ b/examples/jest-vtu-example/README.md
@@ -0,0 +1,9 @@
+# Jest + Vue Test Utils example
+
+```sh
+# Install dependencies
+npm i # or yarn
+
+# Run tests
+npm test
+```
diff --git a/examples/jest-vtu-example/babel.config.js b/examples/jest-vtu-example/babel.config.js
new file mode 100644
index 0000000000..5b9bf010f8
--- /dev/null
+++ b/examples/jest-vtu-example/babel.config.js
@@ -0,0 +1,7 @@
+module.exports = {
+ env: {
+ test: {
+ presets: ['@babel/preset-env']
+ }
+ }
+}
diff --git a/examples/jest-vtu-example/components/Btn/Btn.spec.js b/examples/jest-vtu-example/components/Btn/Btn.spec.js
new file mode 100644
index 0000000000..5ead735618
--- /dev/null
+++ b/examples/jest-vtu-example/components/Btn/Btn.spec.js
@@ -0,0 +1,36 @@
+import { shallowMount } from '@vue/test-utils'
+import Btn from './Btn'
+
+const factory = () => shallowMount(Btn, {
+ propsData: {
+ label: 'click me!'
+ }
+})
+
+describe('Btn', () => {
+ test('mounts properly', () => {
+ const wrapper = factory()
+ expect(wrapper.isVueInstance()).toBeTruthy()
+ })
+
+ test('renders properly', () => {
+ const wrapper = factory()
+ expect(wrapper.html()).toMatchSnapshot()
+ })
+
+ test('calls handleClick on click', () => {
+ const wrapper = factory()
+ const handleClickMock = jest.fn()
+ wrapper.setMethods({
+ handleClick: handleClickMock
+ })
+ wrapper.find('button').trigger('click')
+ expect(handleClickMock).toHaveBeenCalled()
+ })
+
+ test('clicked is true after click', () => {
+ const wrapper = factory()
+ wrapper.find('button').trigger('click')
+ expect(wrapper.vm.clicked).toBe(true)
+ })
+})
diff --git a/examples/jest-vtu-example/components/Btn/Btn.vue b/examples/jest-vtu-example/components/Btn/Btn.vue
new file mode 100644
index 0000000000..c6b2a7d38a
--- /dev/null
+++ b/examples/jest-vtu-example/components/Btn/Btn.vue
@@ -0,0 +1,25 @@
+
+
+ {{ label }}
+
+
+
+
diff --git a/examples/jest-vtu-example/components/Btn/__snapshots__/Btn.spec.js.snap b/examples/jest-vtu-example/components/Btn/__snapshots__/Btn.spec.js.snap
new file mode 100644
index 0000000000..93754d8280
--- /dev/null
+++ b/examples/jest-vtu-example/components/Btn/__snapshots__/Btn.spec.js.snap
@@ -0,0 +1,7 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Btn renders properly 1`] = `
+
+ click me!
+
+`;
diff --git a/examples/jest-vtu-example/layouts/default.vue b/examples/jest-vtu-example/layouts/default.vue
new file mode 100644
index 0000000000..9842575287
--- /dev/null
+++ b/examples/jest-vtu-example/layouts/default.vue
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/examples/jest-vtu-example/nuxt.config.js b/examples/jest-vtu-example/nuxt.config.js
new file mode 100644
index 0000000000..f4e276c341
--- /dev/null
+++ b/examples/jest-vtu-example/nuxt.config.js
@@ -0,0 +1,3 @@
+export default {
+ mode: 'universal'
+}
diff --git a/examples/jest-vtu-example/package.json b/examples/jest-vtu-example/package.json
new file mode 100644
index 0000000000..9cc395167a
--- /dev/null
+++ b/examples/jest-vtu-example/package.json
@@ -0,0 +1,46 @@
+{
+ "name": "example-jest-vtu",
+ "scripts": {
+ "dev": "nuxt",
+ "build": "nuxt build",
+ "start": "nuxt start",
+ "generate": "nuxt generate",
+ "test": "jest ."
+ },
+ "dependencies": {
+ "nuxt-edge": "latest"
+ },
+ "devDependencies": {
+ "@babel/core": "^7.1.2",
+ "@vue/test-utils": "^1.0.0-beta.25",
+ "babel-core": "^7.0.0-bridge.0",
+ "babel-jest": "^23.6.0",
+ "jest": "^23.6.0",
+ "jest-serializer-vue": "^2.0.2",
+ "vue-jest": "^2.6.0"
+ },
+ "jest": {
+ "moduleFileExtensions": [
+ "js",
+ "json",
+ "vue"
+ ],
+ "watchman": false,
+ "moduleNameMapper": {
+ "^~/(.*)$": "/$1",
+ "^~~/(.*)$": "/$1"
+ },
+ "transform": {
+ "^.+\\.js$": "/node_modules/babel-jest",
+ ".*\\.(vue)$": "/node_modules/vue-jest"
+ },
+ "snapshotSerializers": [
+ "/node_modules/jest-serializer-vue"
+ ],
+ "collectCoverage": true,
+ "collectCoverageFrom": [
+ "/components/**/*.vue",
+ "/pages/*.vue"
+ ]
+ }
+}
diff --git a/examples/jest-vtu-example/pages/__snapshots__/index.spec.js.snap b/examples/jest-vtu-example/pages/__snapshots__/index.spec.js.snap
new file mode 100644
index 0000000000..c4bca24d26
--- /dev/null
+++ b/examples/jest-vtu-example/pages/__snapshots__/index.spec.js.snap
@@ -0,0 +1,12 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`index renders properly 1`] = `
+
+
+
+ jest-vtu-example
+
+
+
+
+`;
diff --git a/examples/jest-vtu-example/pages/index.spec.js b/examples/jest-vtu-example/pages/index.spec.js
new file mode 100644
index 0000000000..9b1209abd5
--- /dev/null
+++ b/examples/jest-vtu-example/pages/index.spec.js
@@ -0,0 +1,14 @@
+import { shallowMount } from '@vue/test-utils'
+import index from './index'
+
+describe('index', () => {
+ test('mounts properly', () => {
+ const wrapper = shallowMount(index)
+ expect(wrapper.isVueInstance()).toBeTruthy()
+ })
+
+ test('renders properly', () => {
+ const wrapper = shallowMount(index)
+ expect(wrapper.html()).toMatchSnapshot()
+ })
+})
diff --git a/examples/jest-vtu-example/pages/index.vue b/examples/jest-vtu-example/pages/index.vue
new file mode 100644
index 0000000000..5a30dbb685
--- /dev/null
+++ b/examples/jest-vtu-example/pages/index.vue
@@ -0,0 +1,20 @@
+
+
+
+
+ jest-vtu-example
+
+
+
+
+
+
+
From 106141f74ca13166c63a54ea3498036844c6e23d Mon Sep 17 00:00:00 2001
From: awronski
Date: Thu, 25 Oct 2018 19:44:09 +0200
Subject: [PATCH 051/149] feat: jest-puppeteer example (#4163)
* feat: jest-puppeteer example
* - Refactor test
* - lint
* - lint
* - eslint-disable no-undef
---
examples/jest-puppeteer/README.md | 39 +++++++++++++++++++
.../jest-puppeteer/jest-puppeteer.config.js | 10 +++++
examples/jest-puppeteer/jest.config.js | 4 ++
examples/jest-puppeteer/package.json | 18 +++++++++
examples/jest-puppeteer/pages/about.vue | 19 +++++++++
examples/jest-puppeteer/pages/index.vue | 14 +++++++
.../test/__snapshots__/index.spec.js.snap | 5 +++
examples/jest-puppeteer/test/index.spec.js | 32 +++++++++++++++
8 files changed, 141 insertions(+)
create mode 100755 examples/jest-puppeteer/README.md
create mode 100755 examples/jest-puppeteer/jest-puppeteer.config.js
create mode 100755 examples/jest-puppeteer/jest.config.js
create mode 100755 examples/jest-puppeteer/package.json
create mode 100755 examples/jest-puppeteer/pages/about.vue
create mode 100755 examples/jest-puppeteer/pages/index.vue
create mode 100755 examples/jest-puppeteer/test/__snapshots__/index.spec.js.snap
create mode 100755 examples/jest-puppeteer/test/index.spec.js
diff --git a/examples/jest-puppeteer/README.md b/examples/jest-puppeteer/README.md
new file mode 100755
index 0000000000..c26eb37d90
--- /dev/null
+++ b/examples/jest-puppeteer/README.md
@@ -0,0 +1,39 @@
+# Example how to test Nuxt.js app with Jest and Puppeteer
+
+# Install deps
+```
+npm install
+```
+
+# Run tests
+```
+npm run test
+```
+
+## It will
+- Build app
+- Run server
+- Run tests
+
+### Output
+```
+ PASS test/index.spec.js
+ Index page
+ β test index title (53ms)
+ β test navigate to about page (2ms)
+
+Test Suites: 1 passed, 1 total
+Tests: 2 passed, 2 total
+Snapshots: 2 passed, 2 total
+Time: 0.992s, estimated 1s
+Ran all test suites.
+```
+
+## Check configuration files:
+- `jest.config.js`
+- `jest-puppeteer.config.js`
+
+## Documentation
+- [jest-puppeteer](https://github.com/smooth-code/jest-puppeteer)
+- [jest]()
+- [puppeteer](https://pptr.dev/)
diff --git a/examples/jest-puppeteer/jest-puppeteer.config.js b/examples/jest-puppeteer/jest-puppeteer.config.js
new file mode 100755
index 0000000000..70c11b412f
--- /dev/null
+++ b/examples/jest-puppeteer/jest-puppeteer.config.js
@@ -0,0 +1,10 @@
+module.exports = {
+ launch: {
+ headless: process.env.HEADLESS !== 'false'
+ },
+ server: {
+ command: 'npm run testServer',
+ port: 3000,
+ launchTimeout: 50000
+ }
+}
diff --git a/examples/jest-puppeteer/jest.config.js b/examples/jest-puppeteer/jest.config.js
new file mode 100755
index 0000000000..77b369b61d
--- /dev/null
+++ b/examples/jest-puppeteer/jest.config.js
@@ -0,0 +1,4 @@
+module.exports = {
+ verbose: true,
+ preset: 'jest-puppeteer'
+}
diff --git a/examples/jest-puppeteer/package.json b/examples/jest-puppeteer/package.json
new file mode 100755
index 0000000000..82bd0e0ad3
--- /dev/null
+++ b/examples/jest-puppeteer/package.json
@@ -0,0 +1,18 @@
+{
+ "name": "example-jest-puppeteer",
+ "dependencies": {
+ "nuxt": "latest"
+ },
+ "scripts": {
+ "dev": "nuxt",
+ "build": "nuxt build",
+ "start": "nuxt start",
+ "test": "jest -w=4",
+ "testServer": "nuxt build & nuxt start"
+ },
+ "devDependencies": {
+ "jest": "latest",
+ "jest-puppeteer": "latest",
+ "puppeteer": "latest"
+ }
+}
diff --git a/examples/jest-puppeteer/pages/about.vue b/examples/jest-puppeteer/pages/about.vue
new file mode 100755
index 0000000000..bc3b28766f
--- /dev/null
+++ b/examples/jest-puppeteer/pages/about.vue
@@ -0,0 +1,19 @@
+
+
+
Hi from {{ name }}
+
Home page
+
+
+
+
diff --git a/examples/jest-puppeteer/pages/index.vue b/examples/jest-puppeteer/pages/index.vue
new file mode 100755
index 0000000000..4b5f9be0d7
--- /dev/null
+++ b/examples/jest-puppeteer/pages/index.vue
@@ -0,0 +1,14 @@
+
+
+
Welcome!
+ About page
+
+
+
+
diff --git a/examples/jest-puppeteer/test/__snapshots__/index.spec.js.snap b/examples/jest-puppeteer/test/__snapshots__/index.spec.js.snap
new file mode 100755
index 0000000000..7ad881e3b1
--- /dev/null
+++ b/examples/jest-puppeteer/test/__snapshots__/index.spec.js.snap
@@ -0,0 +1,5 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Index page test index title: index.title 1`] = `"Home page"`;
+
+exports[`Index page test navigation to about page: about.msg 1`] = `"Hi from client"`;
diff --git a/examples/jest-puppeteer/test/index.spec.js b/examples/jest-puppeteer/test/index.spec.js
new file mode 100755
index 0000000000..00aa5f16ff
--- /dev/null
+++ b/examples/jest-puppeteer/test/index.spec.js
@@ -0,0 +1,32 @@
+const devices = require('puppeteer/DeviceDescriptors')
+const iPhone = devices['iPhone 6']
+
+const BASE_URL = 'http://127.0.0.1:3000'
+
+describe('Index page', () => {
+ let page
+ beforeAll(async () => {
+ // eslint-disable-next-line no-undef
+ page = await browser.newPage()
+ await page.emulate(iPhone)
+ await page.goto(BASE_URL)
+ })
+
+ afterAll(async () => {
+ await page.close()
+ })
+
+ it('test index title', async () => {
+ expect.assertions(1)
+ const title = await page.evaluate(() => document.title)
+ expect(title).toMatchSnapshot('index.title')
+ })
+
+ it('test navigation to about page', async () => {
+ expect.assertions(1)
+ await page.click('a#about-link')
+ await page.waitForSelector('p#hello-msg')
+ const msg = await page.$eval('p#hello-msg', e => e.textContent)
+ expect(msg).toMatchSnapshot('about.msg')
+ })
+})
From ae9de93a45dc45edb57532f205112fee606c1446 Mon Sep 17 00:00:00 2001
From: Clark Du
Date: Fri, 26 Oct 2018 18:58:21 +0100
Subject: [PATCH 052/149] feat: move @nuxtjs/babel-preset-app into nuxt
mono-repo (#4205)
---
packages/babel-preset-app/package.json | 24 +++++
packages/babel-preset-app/src/index.js | 97 +++++++++++++++++++
.../babel-preset-app/src/polyfills-plugin.js | 24 +++++
packages/webpack/package.json | 2 +-
packages/webpack/src/config/base.js | 2 +-
scripts/dev | 2 +-
yarn.lock | 16 ---
7 files changed, 148 insertions(+), 19 deletions(-)
create mode 100644 packages/babel-preset-app/package.json
create mode 100644 packages/babel-preset-app/src/index.js
create mode 100644 packages/babel-preset-app/src/polyfills-plugin.js
diff --git a/packages/babel-preset-app/package.json b/packages/babel-preset-app/package.json
new file mode 100644
index 0000000000..b3466d6efd
--- /dev/null
+++ b/packages/babel-preset-app/package.json
@@ -0,0 +1,24 @@
+{
+ "name": "@nuxt/babel-preset-app",
+ "version": "2.2.0",
+ "description": "babel-preset-app for nuxt.js",
+ "repository": "nuxt/nuxt.js",
+ "license": "MIT",
+ "author": "Evan You",
+ "contributors": [
+ "Clark Du"
+ ],
+ "main": "src/index.js",
+ "dependencies": {
+ "@babel/core": "^7.1.0",
+ "@babel/plugin-proposal-class-properties": "^7.1.0",
+ "@babel/plugin-proposal-decorators": "^7.1.0",
+ "@babel/plugin-syntax-dynamic-import": "^7.0.0",
+ "@babel/plugin-syntax-jsx": "^7.0.0",
+ "@babel/plugin-transform-runtime": "^7.1.0",
+ "@babel/preset-env": "^7.1.0",
+ "@babel/runtime": "^7.0.0",
+ "babel-helper-vue-jsx-merge-props": "^2.0.3",
+ "babel-plugin-transform-vue-jsx": "^4.0.1"
+ }
+}
diff --git a/packages/babel-preset-app/src/index.js b/packages/babel-preset-app/src/index.js
new file mode 100644
index 0000000000..db9673d723
--- /dev/null
+++ b/packages/babel-preset-app/src/index.js
@@ -0,0 +1,97 @@
+const defaultPolyfills = [
+ // Promise polyfill alone doesn't work in IE,
+ // Needs this as well. see: #1642
+ 'es6.array.iterator',
+ // This is required for webpack code splitting, vuex etc.
+ 'es6.promise',
+ // #2012 es6.promise replaces native Promise in FF and causes missing finally
+ 'es7.promise.finally'
+]
+
+function getPolyfills(targets, includes, { ignoreBrowserslistConfig, configPath }) {
+ const { isPluginRequired } = require('@babel/preset-env')
+ const builtInsList = require('@babel/preset-env/data/built-ins.json')
+ const getTargets = require('@babel/preset-env/lib/targets-parser').default
+ const builtInTargets = getTargets(targets, {
+ ignoreBrowserslistConfig,
+ configPath
+ })
+
+ return includes.filter(item => isPluginRequired(builtInTargets, builtInsList[item]))
+}
+
+module.exports = (context, options = {}) => {
+ const presets = []
+ const plugins = []
+
+ // JSX
+ if (options.jsx !== false) {
+ plugins.push(
+ require('@babel/plugin-syntax-jsx'),
+ require('babel-plugin-transform-vue-jsx')
+ // require('babel-plugin-jsx-event-modifiers'),
+ // require('babel-plugin-jsx-v-model')
+ )
+ }
+
+ const modern = !!options.modern
+
+ const {
+ buildTarget,
+ loose = false,
+ useBuiltIns = 'usage',
+ modules = false,
+ polyfills: userPolyfills,
+ ignoreBrowserslistConfig = modern,
+ configPath,
+ forceAllTransforms,
+ decoratorsLegacy
+ } = options
+
+ let targets = options.targets
+ if (modern === true) {
+ targets = { esmodules: true }
+ } else if (targets === undefined) {
+ targets = buildTarget === 'server' ? { node: 'current' } : { ie: 9 }
+ }
+
+ let polyfills
+ if (modern === false && useBuiltIns === 'usage' && buildTarget === 'client') {
+ polyfills = getPolyfills(targets, userPolyfills || defaultPolyfills, {
+ ignoreBrowserslistConfig,
+ configPath
+ })
+ plugins.push([require('./polyfills-plugin'), { polyfills }])
+ } else {
+ polyfills = []
+ }
+
+ // Pass options along to babel-preset-env
+ presets.push([
+ require('@babel/preset-env'), {
+ loose,
+ modules,
+ targets,
+ useBuiltIns,
+ forceAllTransforms,
+ ignoreBrowserslistConfig,
+ exclude: polyfills
+ }
+ ])
+
+ plugins.push(
+ require('@babel/plugin-syntax-dynamic-import'),
+ [require('@babel/plugin-proposal-decorators'), { legacy: decoratorsLegacy !== false }],
+ [require('@babel/plugin-proposal-class-properties'), { loose }]
+ )
+
+ // Transform runtime, but only for helpers
+ plugins.push([require('@babel/plugin-transform-runtime'), {
+ regenerator: useBuiltIns !== 'usage'
+ }])
+
+ return {
+ presets,
+ plugins
+ }
+}
diff --git a/packages/babel-preset-app/src/polyfills-plugin.js b/packages/babel-preset-app/src/polyfills-plugin.js
new file mode 100644
index 0000000000..8ff6350d68
--- /dev/null
+++ b/packages/babel-preset-app/src/polyfills-plugin.js
@@ -0,0 +1,24 @@
+// Add polyfill imports to the first file encountered.
+module.exports = ({ types }) => {
+ let entryFile
+ return {
+ name: 'inject-polyfills',
+ visitor: {
+ Program(path, state) {
+ if (!entryFile) {
+ entryFile = state.filename
+ } else if (state.filename !== entryFile) {
+ return
+ }
+
+ const { polyfills } = state.opts
+ const { createImport } = require('@babel/preset-env/lib/utils')
+
+ // Imports are injected in reverse order
+ polyfills.slice().reverse().forEach((p) => {
+ createImport(path, p)
+ })
+ }
+ }
+ }
+}
diff --git a/packages/webpack/package.json b/packages/webpack/package.json
index 53bd488578..a9274c6e69 100644
--- a/packages/webpack/package.json
+++ b/packages/webpack/package.json
@@ -10,8 +10,8 @@
"dependencies": {
"@babel/core": "^7.1.2",
"@babel/polyfill": "^7.0.0",
+ "@nuxt/babel-preset-app": "^2.2.0",
"@nuxt/common": "^2.2.0",
- "@nuxtjs/babel-preset-app": "^0.7.0",
"@nuxtjs/friendly-errors-webpack-plugin": "^2.0.2",
"babel-loader": "^8.0.4",
"cache-loader": "^1.2.2",
diff --git a/packages/webpack/src/config/base.js b/packages/webpack/src/config/base.js
index d98762fd8e..106ce56374 100644
--- a/packages/webpack/src/config/base.js
+++ b/packages/webpack/src/config/base.js
@@ -43,7 +43,7 @@ export default class WebpackBaseConfig {
if (!options.babelrc && !options.presets) {
options.presets = [
[
- require.resolve('@nuxtjs/babel-preset-app'),
+ require.resolve('@nuxt/babel-preset-app'),
{
buildTarget: this.isServer ? 'server' : 'client'
}
diff --git a/scripts/dev b/scripts/dev
index a0d428793a..890acce2fe 100755
--- a/scripts/dev
+++ b/scripts/dev
@@ -12,7 +12,7 @@ async function main() {
// Create a dev-only entrypoint to the src
for (const pkg of workspacePackages) {
- if (!pkg.pkg.main) {
+ if (!pkg.pkg.main || !pkg.options.build) {
continue
}
consola.info(pkg.pkg.main)
diff --git a/yarn.lock b/yarn.lock
index c74fe7c89a..faa98098b0 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1333,22 +1333,6 @@
resolved "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-1.1.2.tgz#54c5a964462be3d4d78af631363c18d6fa91ac26"
integrity sha512-yprFYuno9FtNsSHVlSWd+nRlmGoAbqbeCwOryP6sC/zoCjhpArcRMYp19EvpSUSizJAlsXEwJv+wcWS9XaXdMw==
-"@nuxtjs/babel-preset-app@^0.7.0":
- version "0.7.0"
- resolved "https://registry.npmjs.org/@nuxtjs/babel-preset-app/-/babel-preset-app-0.7.0.tgz#b208a95e0a053259c29b99a9e4ca9ea2604dbdd2"
- integrity sha512-gYyFNa+etbsYs5SN7KT2SJxARPgKptBh5N3r66TzSE4kerFdSn7Gd324FoNKfqAnkXv7FsHZflKWoLFxYgn8UQ==
- dependencies:
- "@babel/core" "^7.1.0"
- "@babel/plugin-proposal-class-properties" "^7.1.0"
- "@babel/plugin-proposal-decorators" "^7.1.0"
- "@babel/plugin-syntax-dynamic-import" "^7.0.0"
- "@babel/plugin-syntax-jsx" "^7.0.0"
- "@babel/plugin-transform-runtime" "^7.1.0"
- "@babel/preset-env" "^7.1.0"
- "@babel/runtime" "^7.0.0"
- babel-helper-vue-jsx-merge-props "^2.0.3"
- babel-plugin-transform-vue-jsx "^4.0.1"
-
"@nuxtjs/devalue@^1.0.1":
version "1.0.1"
resolved "https://registry.npmjs.org/@nuxtjs/devalue/-/devalue-1.0.1.tgz#661f16ed4c5d4bf64ab8b6e66fa1aa16bc57d504"
From c9fd78048ff1f17242e8e743b2cf93030ba2e4ab Mon Sep 17 00:00:00 2001
From: awronski
Date: Fri, 26 Oct 2018 19:59:12 +0200
Subject: [PATCH 053/149] feat(core): custom pushAssets function to control
http2 push headers (#4198)
Resolves #4011
Resolves #4161
---
packages/core/src/middleware/nuxt.js | 45 +++++++++++++++++-----------
1 file changed, 28 insertions(+), 17 deletions(-)
diff --git a/packages/core/src/middleware/nuxt.js b/packages/core/src/middleware/nuxt.js
index 03c31a1e5a..3136354756 100644
--- a/packages/core/src/middleware/nuxt.js
+++ b/packages/core/src/middleware/nuxt.js
@@ -44,30 +44,18 @@ export default async function nuxtMiddleware(req, res, next) {
if (!error && this.options.render.http2.push) {
// Parse resourceHints to extract HTTP.2 prefetch/push headers
// https://w3c.github.io/preload/#server-push-http-2
- const pushAssets = []
const preloadFiles = getPreloadFiles()
- const { shouldPush } = this.options.render.http2
+ const { shouldPush, pushAssets } = this.options.render.http2
const { publicPath } = this.resources.clientManifest
- preloadFiles.forEach(({ file, asType, fileWithoutQuery }) => {
- // By default, we only preload scripts or css
- /* istanbul ignore if */
- if (!shouldPush && asType !== 'script' && asType !== 'style') {
- return
- }
-
- // User wants to explicitly control what to preload
- if (shouldPush && !shouldPush(fileWithoutQuery, asType)) {
- return
- }
-
- pushAssets.push(`<${publicPath}${file}>; rel=preload; as=${asType}`)
- })
+ const links = pushAssets ? pushAssets(req, res, publicPath, preloadFiles) : defaultPushAssets(preloadFiles, shouldPush, publicPath, this.options.dev)
// Pass with single Link header
// https://blog.cloudflare.com/http-2-server-push-with-multiple-assets-per-link-header
// https://www.w3.org/Protocols/9707-link-header.html
- res.setHeader('Link', pushAssets.join(','))
+ if (links.length > 0) {
+ res.setHeader('Link', links.join(', '))
+ }
}
if (this.options.render.csp) {
@@ -94,6 +82,29 @@ export default async function nuxtMiddleware(req, res, next) {
}
}
+const defaultPushAssets = (preloadFiles, shouldPush, publicPath, isDev) => {
+ if (shouldPush && isDev) {
+ consola.warn('http2.shouldPush is deprecated. User http2.pushAssets function')
+ }
+
+ const links = []
+ preloadFiles.forEach(({ file, asType, fileWithoutQuery }) => {
+ // By default, we only preload scripts or css
+ /* istanbul ignore if */
+ if (!shouldPush && asType !== 'script' && asType !== 'style') {
+ return
+ }
+
+ // User wants to explicitly control what to preload
+ if (shouldPush && !shouldPush(fileWithoutQuery, asType)) {
+ return
+ }
+
+ links.push(`<${publicPath}${file}>; rel=preload; as=${asType}`)
+ })
+ return links
+}
+
const getCspString = ({ cspScriptSrcHashSet, allowedSources, policies, isDev }) => {
const joinedHashSet = Array.from(cspScriptSrcHashSet).join(' ')
const baseCspStr = `script-src 'self'${isDev ? ` 'unsafe-eval'` : ''} ${joinedHashSet}`
From ad020e66fd9703dfad68310dc51e9be0831cdc6e Mon Sep 17 00:00:00 2001
From: Sibbngheid
Date: Fri, 26 Oct 2018 22:41:28 +0300
Subject: [PATCH 054/149] fix(common): set defaults for port and host values
(#4207)
---
packages/common/src/nuxt.config.js | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/packages/common/src/nuxt.config.js b/packages/common/src/nuxt.config.js
index 51566a9433..9d8f2ed90c 100644
--- a/packages/common/src/nuxt.config.js
+++ b/packages/common/src/nuxt.config.js
@@ -32,10 +32,12 @@ export default {
https: false,
port: process.env.NUXT_PORT ||
process.env.PORT ||
- process.env.npm_package_config_nuxt_port,
+ process.env.npm_package_config_nuxt_port ||
+ '3000',
host: process.env.NUXT_HOST ||
process.env.HOST ||
- process.env.npm_package_config_nuxt_host
+ process.env.npm_package_config_nuxt_host ||
+ 'localhost'
},
// Dirs
From 930f8b273c2cf9282ea8e672b3e262f003a2f1a0 Mon Sep 17 00:00:00 2001
From: "renovate[bot]"
Date: Sat, 27 Oct 2018 00:17:37 +0330
Subject: [PATCH 055/149] fix(deps): update all non-major dependencies (#4200)
---
package.json | 4 +--
packages/babel-preset-app/package.json | 6 ++--
packages/generator/package.json | 2 +-
packages/webpack/package.json | 2 +-
yarn.lock | 47 ++++++++++++++++----------
5 files changed, 37 insertions(+), 24 deletions(-)
diff --git a/package.json b/package.json
index 1d39a84950..f226d3618a 100644
--- a/package.json
+++ b/package.json
@@ -34,11 +34,11 @@
"consola": "^1.4.4",
"cross-env": "^5.2.0",
"cross-spawn": "^6.0.5",
- "eslint": "^5.7.0",
+ "eslint": "^5.8.0",
"eslint-config-standard": "^12.0.0",
"eslint-multiplexer": "^1.0.2",
"eslint-plugin-import": "^2.14.0",
- "eslint-plugin-jest": "^21.26.1",
+ "eslint-plugin-jest": "^21.26.2",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
diff --git a/packages/babel-preset-app/package.json b/packages/babel-preset-app/package.json
index b3466d6efd..464c320651 100644
--- a/packages/babel-preset-app/package.json
+++ b/packages/babel-preset-app/package.json
@@ -10,14 +10,14 @@
],
"main": "src/index.js",
"dependencies": {
- "@babel/core": "^7.1.0",
+ "@babel/core": "^7.1.2",
"@babel/plugin-proposal-class-properties": "^7.1.0",
- "@babel/plugin-proposal-decorators": "^7.1.0",
+ "@babel/plugin-proposal-decorators": "^7.1.2",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-jsx": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.1.0",
"@babel/preset-env": "^7.1.0",
- "@babel/runtime": "^7.0.0",
+ "@babel/runtime": "^7.1.2",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-plugin-transform-vue-jsx": "^4.0.1"
}
diff --git a/packages/generator/package.json b/packages/generator/package.json
index 461204da0b..ac2952220e 100644
--- a/packages/generator/package.json
+++ b/packages/generator/package.json
@@ -12,7 +12,7 @@
"chalk": "^2.4.1",
"consola": "^1.4.4",
"fs-extra": "^7.0.0",
- "html-minifier": "^3.5.20"
+ "html-minifier": "^3.5.21"
},
"publishConfig": {
"access": "public"
diff --git a/packages/webpack/package.json b/packages/webpack/package.json
index a9274c6e69..755425b8bd 100644
--- a/packages/webpack/package.json
+++ b/packages/webpack/package.json
@@ -12,7 +12,7 @@
"@babel/polyfill": "^7.0.0",
"@nuxt/babel-preset-app": "^2.2.0",
"@nuxt/common": "^2.2.0",
- "@nuxtjs/friendly-errors-webpack-plugin": "^2.0.2",
+ "@nuxtjs/friendly-errors-webpack-plugin": "^2.1.0",
"babel-loader": "^8.0.4",
"cache-loader": "^1.2.2",
"caniuse-lite": "^1.0.30000899",
diff --git a/yarn.lock b/yarn.lock
index faa98098b0..287346b07a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -16,7 +16,7 @@
dependencies:
"@babel/highlight" "^7.0.0"
-"@babel/core@^7.1.0", "@babel/core@^7.1.2":
+"@babel/core@^7.1.2":
version "7.1.2"
resolved "https://registry.npmjs.org/@babel/core/-/core-7.1.2.tgz#f8d2a9ceb6832887329a7b60f9d035791400ba4e"
integrity sha512-IFeSSnjXdhDaoysIlev//UzHZbdEmm7D0EIH2qtse9xK7mXEZQpYjs2P00XlP1qYsYvid79p+Zgg6tz1mp6iVw==
@@ -289,7 +289,7 @@
"@babel/helper-replace-supers" "^7.1.0"
"@babel/plugin-syntax-class-properties" "^7.0.0"
-"@babel/plugin-proposal-decorators@^7.1.0":
+"@babel/plugin-proposal-decorators@^7.1.2":
version "7.1.2"
resolved "https://registry.npmjs.org/@babel/plugin-proposal-decorators/-/plugin-proposal-decorators-7.1.2.tgz#79829bd75fced6581ec6c7ab1930e8d738e892e7"
integrity sha512-YooynBO6PmBgHvAd0fl5e5Tq/a0pEC6RqF62ouafme8FzdIVH41Mz/u1dn8fFVm4jzEJ+g/MsOxouwybJPuP8Q==
@@ -681,7 +681,7 @@
pirates "^4.0.0"
source-map-support "^0.5.9"
-"@babel/runtime@^7.0.0":
+"@babel/runtime@^7.1.2":
version "7.1.2"
resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.1.2.tgz#81c89935f4647706fc54541145e6b4ecfef4b8e3"
integrity sha512-Y3SCjmhSupzFB6wcv1KmmFucH6gDVnI30WjOcicV10ju0cZjak3Jcs67YLIXBrmZYw1xCrVeJPbycFwrqNyxpg==
@@ -1345,10 +1345,10 @@
resolved "https://registry.npmjs.org/@nuxtjs/eslint-config/-/eslint-config-0.0.1.tgz#3aeed1cc6a2e01331c7e6b56bfa7152ce8bb2d90"
integrity sha512-Scz5oYNtVwePF1ebXcWPrFxBpNF5wAkYh8L++6f2ZdLyUb1mCOwzE2+oVZxS25hGCYUyecFEshbqeSwkC+ktqA==
-"@nuxtjs/friendly-errors-webpack-plugin@^2.0.2":
- version "2.0.2"
- resolved "http://registry.npmjs.org/@nuxtjs/friendly-errors-webpack-plugin/-/friendly-errors-webpack-plugin-2.0.2.tgz#80fd4c4276e87c09a9157a6f433724235eaaaf6e"
- integrity sha512-M/XBdrNKpM9fsGSKCPq981Q+KjvenOql2k+XzBNlaxrBekGJXz3Brz5psYb0TYWawDJCOvPbC4bX428pBST1hw==
+"@nuxtjs/friendly-errors-webpack-plugin@^2.1.0":
+ version "2.1.0"
+ resolved "https://registry.npmjs.org/@nuxtjs/friendly-errors-webpack-plugin/-/friendly-errors-webpack-plugin-2.1.0.tgz#90d0b587b2f118f7f54e3da3d79329ffc72a8578"
+ integrity sha512-FI8uTmMeA+xnPIfiLFwq3aZ4PzIdTRN5uw9oa7JHPtB1DM9WgiJeJTBLEzz16yIuDrjRAMOim1BQK3bOOhKANg==
dependencies:
chalk "^2.3.2"
error-stack-parser "^2.0.0"
@@ -4091,10 +4091,10 @@ eslint-plugin-import@^2.14.0:
read-pkg-up "^2.0.0"
resolve "^1.6.0"
-eslint-plugin-jest@^21.26.1:
- version "21.26.1"
- resolved "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-21.26.1.tgz#73c5d6838d384fe6a9644077c27011bd99665ff2"
- integrity sha512-utdtKV04jP8ZXnqbsrArI/7m0Bg819JYnP/f6zP3gwnU7hHGdUzlYPNW73wShVFIDmllgHnkpo49kOPNhbQwrg==
+eslint-plugin-jest@^21.26.2:
+ version "21.26.2"
+ resolved "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-21.26.2.tgz#5b24413970e83e2c5b87c5c047a08a4881783605"
+ integrity sha512-SCTBC6q182D4qQlQAN81D351jdte/YwTMo4f+l19Gvh1VemaNZP7ak3MLLvw6xkL9dO2FxVjCLk5DCdl1KfdLw==
eslint-plugin-node@^7.0.1:
version "7.0.1"
@@ -4151,10 +4151,10 @@ eslint-visitor-keys@^1.0.0:
resolved "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d"
integrity sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==
-eslint@^5.7.0:
- version "5.7.0"
- resolved "https://registry.npmjs.org/eslint/-/eslint-5.7.0.tgz#55c326d6fb2ad45fcbd0ce17c3846f025d1d819c"
- integrity sha512-zYCeFQahsxffGl87U2aJ7DPyH8CbWgxBC213Y8+TCanhUTf2gEvfq3EKpHmEcozTLyPmGe9LZdMAwC/CpJBM5A==
+eslint@^5.8.0:
+ version "5.8.0"
+ resolved "https://registry.npmjs.org/eslint/-/eslint-5.8.0.tgz#91fbf24f6e0471e8fdf681a4d9dd1b2c9f28309b"
+ integrity sha512-Zok6Bru3y2JprqTNm14mgQ15YQu/SMDkWdnmHfFg770DIUlmMFd/gqqzCHekxzjHZJxXv3tmTpH0C1icaYJsRQ==
dependencies:
"@babel/code-frame" "^7.0.0"
ajv "^6.5.3"
@@ -5094,7 +5094,7 @@ he@1.1.x:
resolved "https://registry.npmjs.org/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd"
integrity sha1-k0EP0hsAlzUVH4howvJx80J+I/0=
-he@^1.1.0:
+he@1.2.x, he@^1.1.0:
version "1.2.0"
resolved "https://registry.npmjs.org/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
@@ -5163,7 +5163,7 @@ html-entities@^1.2.0:
resolved "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz#0df29351f0721163515dfb9e5543e5f6eed5162f"
integrity sha1-DfKTUfByEWNRXfueVUPl9u7VFi8=
-html-minifier@^3.2.3, html-minifier@^3.5.20:
+html-minifier@^3.2.3:
version "3.5.20"
resolved "https://registry.npmjs.org/html-minifier/-/html-minifier-3.5.20.tgz#7b19fd3caa0cb79f7cde5ee5c3abdf8ecaa6bb14"
integrity sha512-ZmgNLaTp54+HFKkONyLFEfs5dd/ZOtlquKaTnqIWFmx3Av5zG6ZPcV2d0o9XM2fXOTxxIf6eDcwzFFotke/5zA==
@@ -5176,6 +5176,19 @@ html-minifier@^3.2.3, html-minifier@^3.5.20:
relateurl "0.2.x"
uglify-js "3.4.x"
+html-minifier@^3.5.21:
+ version "3.5.21"
+ resolved "https://registry.npmjs.org/html-minifier/-/html-minifier-3.5.21.tgz#d0040e054730e354db008463593194015212d20c"
+ integrity sha512-LKUKwuJDhxNa3uf/LPR/KVjm/l3rBqtYeCOAekvG8F1vItxMUpueGd94i/asDDr8/1u7InxzFA5EeGjhhG5mMA==
+ dependencies:
+ camel-case "3.0.x"
+ clean-css "4.2.x"
+ commander "2.17.x"
+ he "1.2.x"
+ param-case "2.1.x"
+ relateurl "0.2.x"
+ uglify-js "3.4.x"
+
html-webpack-plugin@^3.2.0:
version "3.2.0"
resolved "http://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-3.2.0.tgz#b01abbd723acaaa7b37b6af4492ebda03d9dd37b"
From 1adad4676b7780af6877888f7670953a6a8108f2 Mon Sep 17 00:00:00 2001
From: Pooya Parsa
Date: Sat, 27 Oct 2018 00:20:41 +0330
Subject: [PATCH 056/149] hotfix: add missing publishConfig for
@nuxt/babel-preset-app
---
packages/babel-preset-app/package.json | 3 +++
1 file changed, 3 insertions(+)
diff --git a/packages/babel-preset-app/package.json b/packages/babel-preset-app/package.json
index 464c320651..fbda384793 100644
--- a/packages/babel-preset-app/package.json
+++ b/packages/babel-preset-app/package.json
@@ -20,5 +20,8 @@
"@babel/runtime": "^7.1.2",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-plugin-transform-vue-jsx": "^4.0.1"
+ },
+ "publishConfig": {
+ "access": "public"
}
}
From 208eba386739a70c41b11818f85d1568ce8362b9 Mon Sep 17 00:00:00 2001
From: Paul Gascou-Vaillancourt
Date: Sat, 27 Oct 2018 12:41:42 -0400
Subject: [PATCH 057/149] fix(app): Throw error only if value is undefined
(#4206)
---
packages/app/template/index.js | 2 +-
test/fixtures/basic/nuxt.config.js | 3 ++-
test/fixtures/basic/plugins/inject.js | 16 ++++++++++++++++
test/unit/basic.plugins.test.js | 16 ++++++++++++++++
4 files changed, 35 insertions(+), 2 deletions(-)
create mode 100644 test/fixtures/basic/plugins/inject.js
diff --git a/packages/app/template/index.js b/packages/app/template/index.js
index 0bc2d42729..ce2212935e 100644
--- a/packages/app/template/index.js
+++ b/packages/app/template/index.js
@@ -130,7 +130,7 @@ async function createApp(ssrContext) {
<% if (plugins.length) { %>
const inject = function (key, value) {
if (!key) throw new Error('inject(key, value) has no key provided')
- if (!value) throw new Error('inject(key, value) has no value provided')
+ if (typeof value === 'undefined') throw new Error('inject(key, value) has no value provided')
key = '$' + key
// Add into app
app[key] = value
diff --git a/test/fixtures/basic/nuxt.config.js b/test/fixtures/basic/nuxt.config.js
index cd338b5b4c..b5c802eb60 100644
--- a/test/fixtures/basic/nuxt.config.js
+++ b/test/fixtures/basic/nuxt.config.js
@@ -63,7 +63,8 @@ export default {
transition: false,
plugins: [
'~/plugins/vuex-module',
- '~/plugins/dir-plugin'
+ '~/plugins/dir-plugin',
+ '~/plugins/inject'
],
build: {
scopeHoisting: true,
diff --git a/test/fixtures/basic/plugins/inject.js b/test/fixtures/basic/plugins/inject.js
new file mode 100644
index 0000000000..5ff0ae604a
--- /dev/null
+++ b/test/fixtures/basic/plugins/inject.js
@@ -0,0 +1,16 @@
+export default ({ route, params }, inject) => {
+ const { injectValue } = route.query
+ if (typeof injectValue === 'undefined') {
+ return
+ }
+ const key = 'injectedProperty'
+ const map = {
+ 'undefined': undefined,
+ 'null': null,
+ 'false': false,
+ '0': 0,
+ 'empty': ''
+ }
+ const value = map[injectValue]
+ inject(key, value)
+}
diff --git a/test/unit/basic.plugins.test.js b/test/unit/basic.plugins.test.js
index 2964435ad4..2399d54a95 100644
--- a/test/unit/basic.plugins.test.js
+++ b/test/unit/basic.plugins.test.js
@@ -18,6 +18,22 @@ describe('with-config', () => {
expect(window.__test_plugin).toBe(true)
})
+ test('inject fails if value is undefined', async () => {
+ // inject('injectedProperty', undefined)
+ await expect(nuxt.renderRoute('/?injectValue=undefined')).rejects.toThrowError('inject(key, value) has no value provided')
+ })
+
+ test('inject succeeds if value is defined but evaluates to false', async () => {
+ // inject('injectedProperty', null)
+ await expect(nuxt.renderRoute('/?injectValue=null')).resolves.not.toThrowError()
+ // inject('injectedProperty', false)
+ await expect(nuxt.renderRoute('/?injectValue=false')).resolves.not.toThrowError()
+ // inject('injectedProperty', 0)
+ await expect(nuxt.renderRoute('/?injectValue=0')).resolves.not.toThrowError()
+ // inject('injectedProperty', '')
+ await expect(nuxt.renderRoute('/?injectValue=empty')).resolves.not.toThrowError()
+ })
+
// Close server and ask nuxt to stop listening to file changes
afterAll(async () => {
await nuxt.close()
From 00e83e38744cb665e746428423c3a31395351f3f Mon Sep 17 00:00:00 2001
From: "renovate[bot]"
Date: Sat, 27 Oct 2018 20:12:27 +0330
Subject: [PATCH 058/149] fix(deps): update dependency time-fix-plugin to
^2.0.5 (#4210)
---
packages/webpack/package.json | 2 +-
yarn.lock | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/packages/webpack/package.json b/packages/webpack/package.json
index 755425b8bd..b76b38f6a6 100644
--- a/packages/webpack/package.json
+++ b/packages/webpack/package.json
@@ -38,7 +38,7 @@
"style-resources-loader": "^1.2.1",
"terser-webpack-plugin": "^1.1.0",
"thread-loader": "^1.2.0",
- "time-fix-plugin": "^2.0.4",
+ "time-fix-plugin": "^2.0.5",
"url-loader": "^1.1.2",
"vue-loader": "^15.4.2",
"webpack": "^4.23.1",
diff --git a/yarn.lock b/yarn.lock
index 287346b07a..966f9a4642 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -10331,10 +10331,10 @@ through@2, "through@>=2.2.7 <3", through@^2.3.4, through@^2.3.6:
resolved "http://registry.npmjs.org/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=
-time-fix-plugin@^2.0.4:
- version "2.0.4"
- resolved "https://registry.npmjs.org/time-fix-plugin/-/time-fix-plugin-2.0.4.tgz#2436f837279e105902c985cd4c29eacbe9c51c0a"
- integrity sha512-AXKqo4NI2ZrRAnO+9OYn8LwV3rwLiJHlEn9S1Ov86+i0RI4p6nR/uVjNasozJMTLs7fq/TWgPSsa7nI/kbV4UQ==
+time-fix-plugin@^2.0.5:
+ version "2.0.5"
+ resolved "https://registry.npmjs.org/time-fix-plugin/-/time-fix-plugin-2.0.5.tgz#41c76e734217cc91a08ea525fdde56de119fb683"
+ integrity sha512-veHRiEsQ50KSrfdhkZiFvZIjRoyfyfxpgskD+P7uVQAcNe6rIMLZ8vhjFRE2XrPqQdy+4CF+jXsWAlgVy9Bfcg==
timers-browserify@^2.0.4:
version "2.0.10"
From ec7794c5cda9acf93aec6ccc9a87cd72e81c511f Mon Sep 17 00:00:00 2001
From: Jonas Galvez
Date: Sat, 27 Oct 2018 13:48:23 -0300
Subject: [PATCH 059/149] refactor(common): nuxt.config.js and dynamic server
options to use latest process.env (#4208)
---
packages/cli/src/utils.js | 33 +--
packages/cli/test/unit/utils.test.js | 24 +-
packages/common/src/config/build.js | 112 ++++++++++
packages/common/src/config/index.js | 128 +++++++++++
packages/common/src/config/messages.js | 12 +
packages/common/src/config/render.js | 27 +++
packages/common/src/config/router.js | 13 ++
packages/common/src/config/server.js | 13 ++
packages/common/src/index.js | 1 +
packages/common/src/nuxt.config.js | 289 +------------------------
10 files changed, 325 insertions(+), 327 deletions(-)
create mode 100644 packages/common/src/config/build.js
create mode 100644 packages/common/src/config/index.js
create mode 100644 packages/common/src/config/messages.js
create mode 100644 packages/common/src/config/render.js
create mode 100644 packages/common/src/config/router.js
create mode 100644 packages/common/src/config/server.js
diff --git a/packages/cli/src/utils.js b/packages/cli/src/utils.js
index 47dcc27bee..8a8b6a6ce7 100644
--- a/packages/cli/src/utils.js
+++ b/packages/cli/src/utils.js
@@ -3,6 +3,8 @@ import { existsSync } from 'fs'
import consola from 'consola'
import esm from 'esm'
import wrapAnsi from 'wrap-ansi'
+import defaultsDeep from 'lodash/defaultsDeep'
+import { nuxtServerConfig } from '@nuxt/common'
const _require = esm(module, {
cache: false,
@@ -15,24 +17,6 @@ const _require = esm(module, {
const getRootDir = argv => path.resolve(argv._[0] || '.')
const getNuxtConfigFile = argv => path.resolve(getRootDir(argv), argv['config-file'])
-const getLatestHost = (argv) => {
- const port =
- argv.port ||
- process.env.NUXT_PORT ||
- process.env.PORT ||
- process.env.npm_package_config_nuxt_port
- const host =
- argv.hostname ||
- process.env.NUXT_HOST ||
- process.env.HOST ||
- process.env.npm_package_config_nuxt_host
- const socket =
- argv['unix-socket'] ||
- process.env.UNIX_SOCKET ||
- process.env.npm_package_config_unix_socket
-
- return { port, host, socket }
-}
export async function loadNuxtConfig(argv) {
const rootDir = getRootDir(argv)
@@ -70,14 +54,11 @@ export async function loadNuxtConfig(argv) {
(argv.spa && 'spa') || (argv.universal && 'universal') || options.mode
// Server options
- if (!options.server) {
- options.server = {}
- }
-
- const { port, host, socket } = getLatestHost(argv)
- options.server.port = port || options.server.port || 3000
- options.server.host = host || options.server.host || 'localhost'
- options.server.socket = socket || options.server.socket
+ options.server = defaultsDeep({
+ port: argv.port || undefined,
+ host: argv.hostname || undefined,
+ socket: argv['unix-socket'] || undefined
+ }, options.server || {}, nuxtServerConfig(process.env))
return options
}
diff --git a/packages/cli/test/unit/utils.test.js b/packages/cli/test/unit/utils.test.js
index f111aeb932..443cab528c 100644
--- a/packages/cli/test/unit/utils.test.js
+++ b/packages/cli/test/unit/utils.test.js
@@ -1,3 +1,4 @@
+import { nuxtServerConfig } from '@nuxt/common'
import { consola } from '../utils'
import * as utils from '../../src/utils'
@@ -81,24 +82,19 @@ describe('cli/utils', () => {
expect(consola.fatal).toHaveBeenCalledWith('Error while fetching async configuration')
})
- test('loadNuxtConfig: server env', async () => {
- const env = process.env
-
- process.env.HOST = 'env-host'
- process.env.PORT = 3003
- process.env.UNIX_SOCKET = '/var/run/env.sock'
-
- const argv = {
- _: [__dirname],
- 'config-file': '../fixtures/nuxt.config.js'
+ test('nuxtServerConfig: server env', () => {
+ const options = {
+ server: nuxtServerConfig({
+ ...process.env,
+ HOST: 'env-host',
+ PORT: 3003,
+ UNIX_SOCKET: '/var/run/env.sock'
+ })
}
- const options = await utils.loadNuxtConfig(argv)
expect(options.server.host).toBe('env-host')
- expect(options.server.port).toBe('3003')
+ expect(options.server.port).toBe(3003)
expect(options.server.socket).toBe('/var/run/env.sock')
-
- process.env = env
})
test('indent', () => {
diff --git a/packages/common/src/config/build.js b/packages/common/src/config/build.js
new file mode 100644
index 0000000000..70846ea9ed
--- /dev/null
+++ b/packages/common/src/config/build.js
@@ -0,0 +1,112 @@
+import env from 'std-env'
+
+export default {
+ quiet: Boolean(env.ci || env.test),
+ analyze: false,
+ profile: process.argv.includes('--profile'),
+ extractCSS: false,
+ cssSourceMap: undefined,
+ ssr: undefined,
+ parallel: false,
+ cache: false,
+ publicPath: '/_nuxt/',
+ filenames: {
+ // { isDev, isClient, isServer }
+ app: ({ isDev }) => isDev ? '[name].js' : '[chunkhash].js',
+ chunk: ({ isDev }) => isDev ? '[name].js' : '[chunkhash].js',
+ css: ({ isDev }) => isDev ? '[name].css' : '[contenthash].css',
+ img: ({ isDev }) => isDev ? '[path][name].[ext]' : 'img/[hash:7].[ext]',
+ font: ({ isDev }) => isDev ? '[path][name].[ext]' : 'fonts/[hash:7].[ext]',
+ video: ({ isDev }) => isDev ? '[path][name].[ext]' : 'videos/[hash:7].[ext]'
+ },
+ loaders: {
+ file: {},
+ fontUrl: { limit: 1000 },
+ imgUrl: { limit: 1000 },
+ pugPlain: {},
+ vue: {
+ transformAssetUrls: {
+ video: 'src',
+ source: 'src',
+ object: 'src',
+ embed: 'src'
+ }
+ },
+ css: {},
+ cssModules: {
+ localIdentName: '[local]_[hash:base64:5]'
+ },
+ less: {},
+ sass: {
+ indentedSyntax: true
+ },
+ scss: {},
+ stylus: {},
+ vueStyle: {}
+ },
+ styleResources: {},
+ plugins: [],
+ terser: {},
+ optimizeCSS: undefined,
+ optimization: {
+ runtimeChunk: 'single',
+ minimize: undefined,
+ minimizer: undefined,
+ splitChunks: {
+ chunks: 'all',
+ automaticNameDelimiter: '.',
+ name: undefined,
+ cacheGroups: {}
+ }
+ },
+ splitChunks: {
+ layouts: false,
+ pages: true,
+ commons: true
+ },
+ babel: {
+ babelrc: false,
+ cacheDirectory: undefined
+ },
+ transpile: [], // Name of NPM packages to be transpiled
+ postcss: {
+ preset: {
+ // https://cssdb.org/#staging-process
+ stage: 2
+ }
+ },
+ html: {
+ minify: {
+ collapseBooleanAttributes: true,
+ decodeEntities: true,
+ minifyCSS: true,
+ minifyJS: true,
+ processConditionalComments: true,
+ removeEmptyAttributes: true,
+ removeRedundantAttributes: true,
+ trimCustomFragments: true,
+ useShortDoctype: true
+ }
+ },
+
+ template: undefined,
+ templates: [],
+
+ watch: [],
+ devMiddleware: {},
+ hotMiddleware: {},
+
+ stats: {
+ chunks: false,
+ children: false,
+ modules: false,
+ colors: true,
+ warnings: true,
+ errors: true,
+ excludeAssets: [
+ /.map$/,
+ /index\..+\.html$/,
+ /vue-ssr-client-manifest.json/
+ ]
+ }
+}
diff --git a/packages/common/src/config/index.js b/packages/common/src/config/index.js
new file mode 100644
index 0000000000..c9bd2a93dd
--- /dev/null
+++ b/packages/common/src/config/index.js
@@ -0,0 +1,128 @@
+import path from 'path'
+import fs from 'fs'
+import capitalize from 'lodash/capitalize'
+import env from 'std-env'
+
+import render from './render'
+import build from './build'
+import router from './router'
+import messages from './messages'
+import server from './server'
+
+const nuxtDir = fs.existsSync(path.resolve(__dirname, '..', '..', 'package.js'))
+ ? path.resolve(__dirname, '..', '..') // src
+ : path.resolve(__dirname, '..') // dist
+
+export default {
+ // Information about running environment
+ dev: Boolean(env.dev),
+ test: Boolean(env.test),
+ debug: undefined, // = dev
+
+ // Mode
+ mode: 'universal',
+
+ // Global name
+ globalName: `nuxt`,
+ globals: {
+ id: globalName => `__${globalName}`,
+ nuxt: globalName => `$${globalName}`,
+ context: globalName => `__${globalName.toUpperCase()}__`,
+ pluginPrefix: globalName => globalName,
+ readyCallback: globalName => `on${capitalize(globalName)}Ready`,
+ loadedCallback: globalName => `_on${capitalize(globalName)}Loaded`
+ },
+
+ render,
+ build,
+ router,
+ messages,
+
+ // Server options
+ server: server(process.env),
+
+ // Dirs
+ srcDir: undefined,
+ buildDir: '.nuxt',
+ nuxtDir,
+ modulesDir: [
+ 'node_modules'
+ ],
+
+ // Ignore
+ ignorePrefix: '-',
+ ignore: [
+ '**/*.test.*',
+ '**/*.spec.*'
+ ],
+
+ extensions: [],
+
+ generate: {
+ dir: 'dist',
+ routes: [],
+ concurrency: 500,
+ interval: 0,
+ subFolders: true,
+ fallback: '200.html'
+ },
+ env: {},
+ head: {
+ meta: [],
+ link: [],
+ style: [],
+ script: []
+ },
+ plugins: [],
+ css: [],
+ modules: [],
+ layouts: {},
+ serverMiddleware: [],
+ ErrorPage: null,
+ loading: {
+ color: 'black',
+ failedColor: 'red',
+ height: '2px',
+ throttle: 200,
+ duration: 5000,
+ rtl: false
+ },
+ loadingIndicator: 'default',
+ transition: {
+ name: 'page',
+ mode: 'out-in',
+ appear: false,
+ appearClass: 'appear',
+ appearActiveClass: 'appear-active',
+ appearToClass: 'appear-to'
+ },
+ layoutTransition: {
+ name: 'layout',
+ mode: 'out-in'
+ },
+ dir: {
+ assets: 'assets',
+ layouts: 'layouts',
+ middleware: 'middleware',
+ pages: 'pages',
+ static: 'static',
+ store: 'store'
+ },
+ vue: {
+ config: {
+ silent: undefined, // = !dev
+ performance: undefined // = dev
+ }
+ },
+
+ // User-defined changes
+ watch: [],
+ watchers: {
+ webpack: {},
+ chokidar: {
+ ignoreInitial: true
+ }
+ },
+ editor: undefined,
+ hooks: null
+}
diff --git a/packages/common/src/config/messages.js b/packages/common/src/config/messages.js
new file mode 100644
index 0000000000..34a2dda4bf
--- /dev/null
+++ b/packages/common/src/config/messages.js
@@ -0,0 +1,12 @@
+export default {
+ loading: 'Loading...',
+ error_404: 'This page could not be found',
+ server_error: 'Server error',
+ nuxtjs: 'Nuxt.js',
+ back_to_home: 'Back to the home page',
+ 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.',
+ client_error: 'Error',
+ client_error_details:
+ 'An error occurred while rendering the page. Check developer tools console for details.'
+}
diff --git a/packages/common/src/config/render.js b/packages/common/src/config/render.js
new file mode 100644
index 0000000000..da9dd2c4d0
--- /dev/null
+++ b/packages/common/src/config/render.js
@@ -0,0 +1,27 @@
+export default {
+ bundleRenderer: {
+ shouldPrefetch: () => false
+ },
+ resourceHints: true,
+ ssr: undefined,
+ http2: {
+ push: false,
+ shouldPush: null
+ },
+ static: {
+ prefix: true
+ },
+ compressor: {
+ threshold: 0
+ },
+ etag: {
+ weak: false
+ },
+ csp: false,
+ dist: {
+ // Don't serve index.html template
+ index: false,
+ // 1 year in production
+ maxAge: '1y'
+ }
+}
diff --git a/packages/common/src/config/router.js b/packages/common/src/config/router.js
new file mode 100644
index 0000000000..8d3c8fcb53
--- /dev/null
+++ b/packages/common/src/config/router.js
@@ -0,0 +1,13 @@
+export default {
+ mode: 'history',
+ base: '/',
+ routes: [],
+ middleware: [],
+ linkActiveClass: 'nuxt-link-active',
+ linkExactActiveClass: 'nuxt-link-exact-active',
+ extendRoutes: null,
+ scrollBehavior: null,
+ parseQuery: false,
+ stringifyQuery: false,
+ fallback: false
+}
diff --git a/packages/common/src/config/server.js b/packages/common/src/config/server.js
new file mode 100644
index 0000000000..9bdbaef1a9
--- /dev/null
+++ b/packages/common/src/config/server.js
@@ -0,0 +1,13 @@
+export default env => ({
+ https: false,
+ port: env.NUXT_PORT ||
+ env.PORT ||
+ env.npm_package_config_nuxt_port ||
+ 3000,
+ host: env.NUXT_HOST ||
+ env.HOST ||
+ env.npm_package_config_nuxt_host ||
+ 'localhost',
+ socket: env.UNIX_SOCKET ||
+ env.npm_package_config_unix_socket
+})
diff --git a/packages/common/src/index.js b/packages/common/src/index.js
index 80f0717de8..ce636223c6 100644
--- a/packages/common/src/index.js
+++ b/packages/common/src/index.js
@@ -1,5 +1,6 @@
export { default as Modes } from './modes'
export { default as NuxtConfig } from './nuxt.config'
+export { default as nuxtServerConfig } from './config/server'
export { default as Options } from './options'
export { default as BuildContext } from './build/context'
export * from './utils'
diff --git a/packages/common/src/nuxt.config.js b/packages/common/src/nuxt.config.js
index 9d8f2ed90c..657adb95f7 100644
--- a/packages/common/src/nuxt.config.js
+++ b/packages/common/src/nuxt.config.js
@@ -1,288 +1,3 @@
-import path from 'path'
-import fs from 'fs'
-import capitalize from 'lodash/capitalize'
-import env from 'std-env'
+import config from './config'
-const nuxtDir = fs.existsSync(path.resolve(__dirname, '..', '..', 'package.js'))
- ? path.resolve(__dirname, '..', '..') // src
- : path.resolve(__dirname, '..') // dist
-
-export default {
- // Information about running environment
- dev: Boolean(env.dev),
- test: Boolean(env.test),
- debug: undefined, // = dev
-
- // Mode
- mode: 'universal',
-
- // Global name
- globalName: `nuxt`,
- globals: {
- id: globalName => `__${globalName}`,
- nuxt: globalName => `$${globalName}`,
- context: globalName => `__${globalName.toUpperCase()}__`,
- pluginPrefix: globalName => globalName,
- readyCallback: globalName => `on${capitalize(globalName)}Ready`,
- loadedCallback: globalName => `_on${capitalize(globalName)}Loaded`
- },
-
- // Server options
- server: {
- https: false,
- port: process.env.NUXT_PORT ||
- process.env.PORT ||
- process.env.npm_package_config_nuxt_port ||
- '3000',
- host: process.env.NUXT_HOST ||
- process.env.HOST ||
- process.env.npm_package_config_nuxt_host ||
- 'localhost'
- },
-
- // Dirs
- srcDir: undefined,
- buildDir: '.nuxt',
- nuxtDir,
- modulesDir: [
- 'node_modules'
- ],
-
- // Ignore
- ignorePrefix: '-',
- ignore: [
- '**/*.test.*',
- '**/*.spec.*'
- ],
-
- extensions: [],
-
- build: {
- quiet: Boolean(env.ci || env.test),
- analyze: false,
- profile: process.argv.includes('--profile'),
- extractCSS: false,
- cssSourceMap: undefined,
- ssr: undefined,
- parallel: false,
- cache: false,
- publicPath: '/_nuxt/',
- filenames: {
- // { isDev, isClient, isServer }
- app: ({ isDev }) => isDev ? '[name].js' : '[chunkhash].js',
- chunk: ({ isDev }) => isDev ? '[name].js' : '[chunkhash].js',
- css: ({ isDev }) => isDev ? '[name].css' : '[contenthash].css',
- img: ({ isDev }) => isDev ? '[path][name].[ext]' : 'img/[hash:7].[ext]',
- font: ({ isDev }) => isDev ? '[path][name].[ext]' : 'fonts/[hash:7].[ext]',
- video: ({ isDev }) => isDev ? '[path][name].[ext]' : 'videos/[hash:7].[ext]'
- },
- loaders: {
- file: {},
- fontUrl: { limit: 1000 },
- imgUrl: { limit: 1000 },
- pugPlain: {},
- vue: {
- transformAssetUrls: {
- video: 'src',
- source: 'src',
- object: 'src',
- embed: 'src'
- }
- },
- css: {},
- cssModules: {
- localIdentName: '[local]_[hash:base64:5]'
- },
- less: {},
- sass: {
- indentedSyntax: true
- },
- scss: {},
- stylus: {},
- vueStyle: {}
- },
- styleResources: {},
- plugins: [],
- terser: {},
- optimizeCSS: undefined,
- optimization: {
- runtimeChunk: 'single',
- minimize: undefined,
- minimizer: undefined,
- splitChunks: {
- chunks: 'all',
- automaticNameDelimiter: '.',
- name: undefined,
- cacheGroups: {}
- }
- },
- splitChunks: {
- layouts: false,
- pages: true,
- commons: true
- },
- babel: {
- babelrc: false,
- cacheDirectory: undefined
- },
- transpile: [], // Name of NPM packages to be transpiled
- postcss: {
- preset: {
- // https://cssdb.org/#staging-process
- stage: 2
- }
- },
- html: {
- minify: {
- collapseBooleanAttributes: true,
- decodeEntities: true,
- minifyCSS: true,
- minifyJS: true,
- processConditionalComments: true,
- removeEmptyAttributes: true,
- removeRedundantAttributes: true,
- trimCustomFragments: true,
- useShortDoctype: true
- }
- },
-
- template: undefined,
- templates: [],
-
- watch: [],
- devMiddleware: {},
- hotMiddleware: {},
-
- stats: {
- chunks: false,
- children: false,
- modules: false,
- colors: true,
- warnings: true,
- errors: true,
- excludeAssets: [
- /.map$/,
- /index\..+\.html$/,
- /vue-ssr-client-manifest.json/
- ]
- }
- },
- generate: {
- dir: 'dist',
- routes: [],
- concurrency: 500,
- interval: 0,
- subFolders: true,
- fallback: '200.html'
- },
- env: {},
- head: {
- meta: [],
- link: [],
- style: [],
- script: []
- },
- plugins: [],
- css: [],
- modules: [],
- layouts: {},
- serverMiddleware: [],
- ErrorPage: null,
- loading: {
- color: 'black',
- failedColor: 'red',
- height: '2px',
- throttle: 200,
- duration: 5000,
- rtl: false
- },
- loadingIndicator: 'default',
- transition: {
- name: 'page',
- mode: 'out-in',
- appear: false,
- appearClass: 'appear',
- appearActiveClass: 'appear-active',
- appearToClass: 'appear-to'
- },
- layoutTransition: {
- name: 'layout',
- mode: 'out-in'
- },
- dir: {
- assets: 'assets',
- layouts: 'layouts',
- middleware: 'middleware',
- pages: 'pages',
- static: 'static',
- store: 'store'
- },
- vue: {
- config: {
- silent: undefined, // = !dev
- performance: undefined // = dev
- }
- },
- router: {
- mode: 'history',
- base: '/',
- routes: [],
- middleware: [],
- linkActiveClass: 'nuxt-link-active',
- linkExactActiveClass: 'nuxt-link-exact-active',
- extendRoutes: null,
- scrollBehavior: null,
- parseQuery: false,
- stringifyQuery: false,
- fallback: false
- },
- render: {
- bundleRenderer: {
- shouldPrefetch: () => false
- },
- resourceHints: true,
- ssr: undefined,
- http2: {
- push: false,
- shouldPush: null
- },
- static: {
- prefix: true
- },
- compressor: {
- threshold: 0
- },
- etag: {
- weak: false
- },
- csp: false,
- dist: {
- // Don't serve index.html template
- index: false,
- // 1 year in production
- maxAge: '1y'
- }
- },
- // User-defined changes
- watch: [],
- watchers: {
- webpack: {},
- chokidar: {
- ignoreInitial: true
- }
- },
- editor: undefined,
- hooks: null,
- messages: {
- loading: 'Loading...',
- error_404: 'This page could not be found',
- server_error: 'Server error',
- nuxtjs: 'Nuxt.js',
- back_to_home: 'Back to the home page',
- 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.',
- client_error: 'Error',
- client_error_details:
- 'An error occurred while rendering the page. Check developer tools console for details.'
- }
-}
+export default config
From 007ca051743f68d0655ae8669dd62dfe5e95df00 Mon Sep 17 00:00:00 2001
From: Jonas Galvez
Date: Sat, 27 Oct 2018 17:27:16 -0300
Subject: [PATCH 060/149] refactor: move config files to @nuxt/config (#4212)
---
packages/cli/src/utils.js | 2 +-
packages/cli/test/unit/utils.test.js | 2 +-
packages/common/package.json | 3 +--
packages/common/src/index.js | 3 ---
packages/common/src/nuxt.config.js | 3 ---
packages/common/src/options.js | 5 ++---
packages/config/package.js | 3 +++
packages/config/package.json | 18 ++++++++++++++++++
.../{common => config}/src/config/build.js | 0
.../{common => config}/src/config/index.js | 0
.../{common => config}/src/config/messages.js | 0
.../{common => config}/src/config/render.js | 0
.../{common => config}/src/config/router.js | 0
.../{common => config}/src/config/server.js | 0
packages/config/src/index.js | 11 +++++++++++
packages/{common => config}/src/modes.js | 0
packages/core/src/renderer.js | 3 ++-
17 files changed, 39 insertions(+), 14 deletions(-)
delete mode 100644 packages/common/src/nuxt.config.js
create mode 100644 packages/config/package.js
create mode 100644 packages/config/package.json
rename packages/{common => config}/src/config/build.js (100%)
rename packages/{common => config}/src/config/index.js (100%)
rename packages/{common => config}/src/config/messages.js (100%)
rename packages/{common => config}/src/config/render.js (100%)
rename packages/{common => config}/src/config/router.js (100%)
rename packages/{common => config}/src/config/server.js (100%)
create mode 100644 packages/config/src/index.js
rename packages/{common => config}/src/modes.js (100%)
diff --git a/packages/cli/src/utils.js b/packages/cli/src/utils.js
index 8a8b6a6ce7..5810e4d792 100644
--- a/packages/cli/src/utils.js
+++ b/packages/cli/src/utils.js
@@ -4,7 +4,7 @@ import consola from 'consola'
import esm from 'esm'
import wrapAnsi from 'wrap-ansi'
import defaultsDeep from 'lodash/defaultsDeep'
-import { nuxtServerConfig } from '@nuxt/common'
+import { server as nuxtServerConfig } from '@nuxt/config'
const _require = esm(module, {
cache: false,
diff --git a/packages/cli/test/unit/utils.test.js b/packages/cli/test/unit/utils.test.js
index 443cab528c..e7a5cd50e1 100644
--- a/packages/cli/test/unit/utils.test.js
+++ b/packages/cli/test/unit/utils.test.js
@@ -1,4 +1,4 @@
-import { nuxtServerConfig } from '@nuxt/common'
+import { server as nuxtServerConfig } from '@nuxt/config'
import { consola } from '../utils'
import * as utils from '../../src/utils'
diff --git a/packages/common/package.json b/packages/common/package.json
index bb4d1428d7..28440995fc 100644
--- a/packages/common/package.json
+++ b/packages/common/package.json
@@ -9,8 +9,7 @@
"main": "dist/common.js",
"dependencies": {
"consola": "^1.4.4",
- "lodash": "^4.17.11",
- "std-env": "^2.0.2"
+ "lodash": "^4.17.11"
},
"publishConfig": {
"access": "public"
diff --git a/packages/common/src/index.js b/packages/common/src/index.js
index ce636223c6..67718e1adf 100644
--- a/packages/common/src/index.js
+++ b/packages/common/src/index.js
@@ -1,6 +1,3 @@
-export { default as Modes } from './modes'
-export { default as NuxtConfig } from './nuxt.config'
-export { default as nuxtServerConfig } from './config/server'
export { default as Options } from './options'
export { default as BuildContext } from './build/context'
export * from './utils'
diff --git a/packages/common/src/nuxt.config.js b/packages/common/src/nuxt.config.js
deleted file mode 100644
index 657adb95f7..0000000000
--- a/packages/common/src/nuxt.config.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import config from './config'
-
-export default config
diff --git a/packages/common/src/options.js b/packages/common/src/options.js
index 7d674cdfec..d6e918303e 100644
--- a/packages/common/src/options.js
+++ b/packages/common/src/options.js
@@ -5,10 +5,9 @@ import defaults from 'lodash/defaults'
import pick from 'lodash/pick'
import isObject from 'lodash/isObject'
import consola from 'consola'
-
+// eslint-disable-next-line
+import { default as NuxtConfig, Modes } from '@nuxt/config'
import { isPureObject, isUrl, guardDir, isString } from './utils'
-import Modes from './modes'
-import NuxtConfig from './nuxt.config'
// hasValue utility
const hasValue = v => typeof v === 'string' && v
diff --git a/packages/config/package.js b/packages/config/package.js
new file mode 100644
index 0000000000..19d0ef6e2d
--- /dev/null
+++ b/packages/config/package.js
@@ -0,0 +1,3 @@
+export default {
+ build: true
+}
diff --git a/packages/config/package.json b/packages/config/package.json
new file mode 100644
index 0000000000..045596e9ef
--- /dev/null
+++ b/packages/config/package.json
@@ -0,0 +1,18 @@
+{
+ "name": "@nuxt/config",
+ "version": "2.2.0",
+ "repository": "nuxt/nuxt.js",
+ "license": "MIT",
+ "files": [
+ "dist"
+ ],
+ "main": "dist/config.js",
+ "dependencies": {
+ "consola": "^1.4.4",
+ "lodash": "^4.17.11",
+ "std-env": "^2.0.2"
+ },
+ "publishConfig": {
+ "access": "public"
+ }
+}
diff --git a/packages/common/src/config/build.js b/packages/config/src/config/build.js
similarity index 100%
rename from packages/common/src/config/build.js
rename to packages/config/src/config/build.js
diff --git a/packages/common/src/config/index.js b/packages/config/src/config/index.js
similarity index 100%
rename from packages/common/src/config/index.js
rename to packages/config/src/config/index.js
diff --git a/packages/common/src/config/messages.js b/packages/config/src/config/messages.js
similarity index 100%
rename from packages/common/src/config/messages.js
rename to packages/config/src/config/messages.js
diff --git a/packages/common/src/config/render.js b/packages/config/src/config/render.js
similarity index 100%
rename from packages/common/src/config/render.js
rename to packages/config/src/config/render.js
diff --git a/packages/common/src/config/router.js b/packages/config/src/config/router.js
similarity index 100%
rename from packages/common/src/config/router.js
rename to packages/config/src/config/router.js
diff --git a/packages/common/src/config/server.js b/packages/config/src/config/server.js
similarity index 100%
rename from packages/common/src/config/server.js
rename to packages/config/src/config/server.js
diff --git a/packages/config/src/index.js b/packages/config/src/index.js
new file mode 100644
index 0000000000..e8406c6ab3
--- /dev/null
+++ b/packages/config/src/index.js
@@ -0,0 +1,11 @@
+import NuxtConfig from './config'
+
+// Export individual bundles for easier access
+export { default as Modes } from './modes'
+export { default as build } from './config/build'
+export { default as messages } from './config/messages'
+export { default as render } from './config/render'
+export { default as router } from './config/router'
+export { default as server } from './config/server'
+
+export default NuxtConfig
diff --git a/packages/common/src/modes.js b/packages/config/src/modes.js
similarity index 100%
rename from packages/common/src/modes.js
rename to packages/config/src/modes.js
diff --git a/packages/core/src/renderer.js b/packages/core/src/renderer.js
index 33348b7aba..c783ac7885 100644
--- a/packages/core/src/renderer.js
+++ b/packages/core/src/renderer.js
@@ -9,7 +9,8 @@ import connect from 'connect'
import launchMiddleware from 'launch-editor-middleware'
import consola from 'consola'
-import { NuxtConfig, isUrl, timeout, waitFor, determineGlobals } from '@nuxt/common'
+import { isUrl, timeout, waitFor, determineGlobals } from '@nuxt/common'
+import NuxtConfig from '@nuxt/config'
import MetaRenderer from './meta'
import errorMiddleware from './middleware/error'
From f90110af269bc773a3e316c54e858ab71adf50a0 Mon Sep 17 00:00:00 2001
From: Jonas Galvez
Date: Sat, 27 Oct 2018 19:02:43 -0300
Subject: [PATCH 061/149] fix: nuxt/config imports/exports (#4217)
---
packages/common/src/options.js | 3 +--
packages/config/src/index.js | 4 +---
packages/core/src/renderer.js | 2 +-
3 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/packages/common/src/options.js b/packages/common/src/options.js
index d6e918303e..795cf6c666 100644
--- a/packages/common/src/options.js
+++ b/packages/common/src/options.js
@@ -5,8 +5,7 @@ import defaults from 'lodash/defaults'
import pick from 'lodash/pick'
import isObject from 'lodash/isObject'
import consola from 'consola'
-// eslint-disable-next-line
-import { default as NuxtConfig, Modes } from '@nuxt/config'
+import { NuxtConfig, Modes } from '@nuxt/config'
import { isPureObject, isUrl, guardDir, isString } from './utils'
// hasValue utility
diff --git a/packages/config/src/index.js b/packages/config/src/index.js
index e8406c6ab3..e632c83881 100644
--- a/packages/config/src/index.js
+++ b/packages/config/src/index.js
@@ -1,4 +1,3 @@
-import NuxtConfig from './config'
// Export individual bundles for easier access
export { default as Modes } from './modes'
@@ -7,5 +6,4 @@ export { default as messages } from './config/messages'
export { default as render } from './config/render'
export { default as router } from './config/router'
export { default as server } from './config/server'
-
-export default NuxtConfig
+export { default as NuxtConfig } from './config'
diff --git a/packages/core/src/renderer.js b/packages/core/src/renderer.js
index c783ac7885..7726209da6 100644
--- a/packages/core/src/renderer.js
+++ b/packages/core/src/renderer.js
@@ -10,7 +10,7 @@ import launchMiddleware from 'launch-editor-middleware'
import consola from 'consola'
import { isUrl, timeout, waitFor, determineGlobals } from '@nuxt/common'
-import NuxtConfig from '@nuxt/config'
+import { NuxtConfig } from '@nuxt/config'
import MetaRenderer from './meta'
import errorMiddleware from './middleware/error'
From e49764c720236e5d660673530a93ff44d512e59e Mon Sep 17 00:00:00 2001
From: Alexander Lichter
Date: Sat, 27 Oct 2018 23:14:46 +0100
Subject: [PATCH 062/149] chore(contribution-guide): remove duplicate guide and
refer to docs (#4216)
---
CONTRIBUTING.md | 116 ------------------------------------------------
README.md | 2 +-
2 files changed, 1 insertion(+), 117 deletions(-)
delete mode 100644 CONTRIBUTING.md
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
deleted file mode 100644
index be9696ecc3..0000000000
--- a/CONTRIBUTING.md
+++ /dev/null
@@ -1,116 +0,0 @@
-# Contributing to Nuxt.js
-
-First of all, thank you for considering to contribute to Nuxt.js! :heart:
-
-## Reporting Issues
-
-A great way to contribute to the project is to send a detailed report when you encounter an issue.
-To make things easier for contributors and maintainers, we use [CMTY](https://cmty.nuxtjs.org/).
-
-Please make sure to include a reproduction repository or [CodeSandBox](https://template.nuxtjs.org/)
-so that bugs can be reproduced without great efforts. The better a bug can be reproduced, the faster we can start fixing it!
-
-## Pull Requests
-
-We'd love to see your pull requests, even if it's just to fix a typo!
-
-However, any significant improvement should be associated to an existing
-[feature request](https://feature.nuxtjs.org/)
-or [bug report](https://bug.nuxtjs.org/).
-
-### Getting started
-
-1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device.
-2. Run `npm install` or `yarn install` to install the dependencies.
-
-> _Note that both **npm** and **yarn** have been seen to miss installing dependencies. To remedy that, you can either delete the `node_modules` folder in your example app and install again or do a local install of the missing dependencies._
-
-> If you are adding a dependency, please use `yarn add`. The `yarn.lock` file is the source of truth for all Nuxt dependencies.
-
-### Test structure
-
-A great PR, whether it includes a bug fix or a new feature, will often include tests.
-To write great tests, let us explain our test structure:
-
-### Setup
-
-Before running any tests, make sure all dependencies are met and build all packages:
-
-```sh
-yarn
-```
-
-`yarn` is the only supported package manager, as it will, among other things, properly resolve all dependencies from sub-packages and eliminate the need to `npm link` all required packages.
-
-#### Fixtures
-
-The fixtures (found under `tests/fixtures`) contain several Nuxt applications. To keep build time as short as possible,
-we don't build an own Nuxt application per test. Instead, the fixtures are built (`yarn test:fixtures`) before running
-the actual unit tests.
-
-Please make sure to **alter** or **add a new fixture** when submitting a PR to reflect the changes properly (if applicable).
-
-Also, don't forget to **rebuild** a fixture after changing it by running the corresponding test
-with `jest test/fixtures/my-fixture/my-fixture.test.js`!
-
-#### Unit tests
-
-The unit tests can be found in `tests/unit` and will be executed after building the fixtures. A fresh Nuxt server will be used
-per test so that no shared state (except the initial state from the build step) is present.
-
-After adding your unit tests, you can run them directly:
-
-```sh
-jest test/unit/test.js
-```
-
-Or you can run the whole unit test suite:
-
-```sh
-yarn test:unit
-```
-
-Again, please be aware that you might have to rebuild your fixtures before!
-
-### Testing your changes
-
-While working on your PR you will likely want to check if your fixture is set up correctly or debug your current changes.
-
-To do so you can use the Nuxt script itself to launch for example your fixture or an example app:
-
-```sh
-bin/nuxt examples/your-app
-bin/nuxt test/fixtures/your-fixture-app
-```
-
-> `npm link` could also (and does, to some extent) work for this, but it has been known to exhibit some issues. That is why we recommend calling `bin/nuxt` directly to run examples.
-
-### Examples
-
-If you are working on a larger feature, please set up an example app in `examples/`.
-This will help greatly in understanding changes and also help Nuxt users to understand the feature you've built in-depth.
-
-### Linting
-
-As you might have noticed already, we are using ESLint to enforce a code standard. Please run `yarn lint` before committing
-your changes to verify that the code style is correct. If not, you can use `yarn lint --fix` or `npm run lint -- --fix` (no typo!) to fix most of the
-style changes. If there are still errors left, you must correct them manually.
-
-### Documentation
-
-If you are adding a new feature, do a refactoring or change the behavior of Nuxt in any other manner, you'll likely
-want to document the changes. Please do so with a PR to the [docs](https://github.com/nuxt/docs/pulls) repository.
-You don't have to write documentation up immediately (but please do so as soon as your pull request is mature enough).
-
-### Final checklist
-
-When submitting your PR, there is a simple template that you have to fill out.
-Please tick all appropriate "answers" in the checklists.
-
-### Troubleshooting
-
-#### Debugging tests on macOS
-
-Searching for `getPort()` will reveal it's used to start new Nuxt processes during tests. It's been seen to stop working on macOS at times and may require you to manually set a port for testing.
-
-Another common issue is Nuxt processes that may hang in memory when running fixture tests. A ghost process will often prevent subsequent tests from working. Run `ps aux | grep -i node` to inspect any hanging test processes if you suspect this is happening.
diff --git a/README.md b/README.md
index 985e6d93db..a6526bc339 100644
--- a/README.md
+++ b/README.md
@@ -219,7 +219,7 @@ Thank you to all our [contributors](https://github.com/nuxt/nuxt.js/graphs/contr
## Contributing
-Please see our [CONTRIBUTING.md](./CONTRIBUTING.md)
+Please refer to our [Contribution Guide](https://nuxtjs.org/guide/contribution-guide#codefund_ad)
## Cross-browser testing
From a9b68c5e61b4388789bb9b8f15fa13816affe537 Mon Sep 17 00:00:00 2001
From: "renovate[bot]"
Date: Sun, 28 Oct 2018 21:44:14 +0330
Subject: [PATCH 063/149] chore(deps): update dependency eslint-plugin-node to
v8 (#4218)
---
package.json | 2 +-
scripts/builtins.js | 2 +-
yarn.lock | 17 +++++++++++------
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/package.json b/package.json
index f226d3618a..d888c5e575 100644
--- a/package.json
+++ b/package.json
@@ -39,7 +39,7 @@
"eslint-multiplexer": "^1.0.2",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jest": "^21.26.2",
- "eslint-plugin-node": "^7.0.1",
+ "eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^5.0.0-beta.3",
diff --git a/scripts/builtins.js b/scripts/builtins.js
index b2b792a7f4..4d6fa11f07 100644
--- a/scripts/builtins.js
+++ b/scripts/builtins.js
@@ -8,7 +8,7 @@ const blacklist = [
'sys'
]
-export const builtins = (Module.builtinModules || Object.keys(process.binding('natives')))
+export const builtins = Module.builtinModules
.filter(x => !/^_|^(internal|v8|node-inspect)\/|\//.test(x) && !blacklist.includes(x))
.sort()
diff --git a/yarn.lock b/yarn.lock
index 966f9a4642..a9a0185bec 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4096,14 +4096,14 @@ eslint-plugin-jest@^21.26.2:
resolved "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-21.26.2.tgz#5b24413970e83e2c5b87c5c047a08a4881783605"
integrity sha512-SCTBC6q182D4qQlQAN81D351jdte/YwTMo4f+l19Gvh1VemaNZP7ak3MLLvw6xkL9dO2FxVjCLk5DCdl1KfdLw==
-eslint-plugin-node@^7.0.1:
- version "7.0.1"
- resolved "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-7.0.1.tgz#a6e054e50199b2edd85518b89b4e7b323c9f36db"
- integrity sha512-lfVw3TEqThwq0j2Ba/Ckn2ABdwmL5dkOgAux1rvOk6CO7A6yGyPI2+zIxN6FyNkp1X1X/BSvKOceD6mBWSj4Yw==
+eslint-plugin-node@^8.0.0:
+ version "8.0.0"
+ resolved "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-8.0.0.tgz#fb9e8911f4543514f154bb6a5924b599aa645568"
+ integrity sha512-Y+ln8iQ52scz9+rSPnSWRaAxeWaoJZ4wIveDR0vLHkuSZGe44Vk1J4HX7WvEP5Cm+iXPE8ixo7OM7gAO3/OKpQ==
dependencies:
eslint-plugin-es "^1.3.1"
eslint-utils "^1.3.1"
- ignore "^4.0.2"
+ ignore "^5.0.2"
minimatch "^3.0.4"
resolve "^1.8.1"
semver "^5.5.0"
@@ -5312,11 +5312,16 @@ ignore@^3.3.5:
resolved "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043"
integrity sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==
-ignore@^4.0.2, ignore@^4.0.6:
+ignore@^4.0.6:
version "4.0.6"
resolved "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==
+ignore@^5.0.2:
+ version "5.0.2"
+ resolved "https://registry.npmjs.org/ignore/-/ignore-5.0.2.tgz#42ae2651beb40c8c53b1e16b2af1c8387d492f88"
+ integrity sha512-ilxkgh36cTqJxlipxQdCOxkbQae5dIeCwo5fSw6pBDW8m8GiMTnadClKST2+aATqjs9BTHsi0IqOsTp0jiihAw==
+
import-cwd@^2.0.0:
version "2.1.0"
resolved "https://registry.npmjs.org/import-cwd/-/import-cwd-2.1.0.tgz#aa6cf36e722761285cb371ec6519f53e2435b0a9"
From 10aeaef1102d42bcf8895aed982fbc087fc92fbe Mon Sep 17 00:00:00 2001
From: Pooya Parsa
Date: Mon, 29 Oct 2018 14:21:34 +0330
Subject: [PATCH 064/149] hotfix(cli, common, core): add missing @nuxt/config
dependency
---
packages/cli/package.json | 1 +
packages/common/package.json | 1 +
packages/core/package.json | 1 +
3 files changed, 3 insertions(+)
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 83b0dcf27b..f08b3843f8 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -12,6 +12,7 @@
"nuxt": "bin/nuxt.js"
},
"dependencies": {
+ "@nuxt/config": "^2.2.0",
"consola": "^1.4.4",
"esm": "^3.0.84",
"minimist": "^1.2.0",
diff --git a/packages/common/package.json b/packages/common/package.json
index 28440995fc..2918e1cf54 100644
--- a/packages/common/package.json
+++ b/packages/common/package.json
@@ -8,6 +8,7 @@
],
"main": "dist/common.js",
"dependencies": {
+ "@nuxt/config": "^2.2.0",
"consola": "^1.4.4",
"lodash": "^4.17.11"
},
diff --git a/packages/core/package.json b/packages/core/package.json
index 3e89fafcc7..3f55bf33c2 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -9,6 +9,7 @@
"main": "dist/core.js",
"dependencies": {
"@nuxt/common": "^2.2.0",
+ "@nuxt/config": "^2.2.0",
"@nuxtjs/devalue": "^1.0.1",
"@nuxtjs/opencollective": "^0.1.0",
"@nuxtjs/youch": "^4.2.3",
From d4a370cecc0d2bd479fde5cd1ae78000918dcf05 Mon Sep 17 00:00:00 2001
From: Pooya Parsa
Date: Mon, 29 Oct 2018 14:22:11 +0330
Subject: [PATCH 065/149] fix(webpack): add missing glob dependency
---
packages/webpack/package.json | 1 +
1 file changed, 1 insertion(+)
diff --git a/packages/webpack/package.json b/packages/webpack/package.json
index b76b38f6a6..8999cdd224 100644
--- a/packages/webpack/package.json
+++ b/packages/webpack/package.json
@@ -22,6 +22,7 @@
"cssnano": "^4.1.7",
"file-loader": "^2.0.0",
"fs-extra": "^7.0.0",
+ "glob": "^7.1.3",
"hash-sum": "^1.0.2",
"html-webpack-plugin": "^3.2.0",
"lodash": "^4.17.11",
From 72961acabd9d7be22d494d155f14b6ed270d8057 Mon Sep 17 00:00:00 2001
From: Pim
Date: Mon, 29 Oct 2018 16:48:40 +0100
Subject: [PATCH 066/149] feat: nuxt-loading enhancenments (#3891)
---
jest.config.js | 5 +
package.json | 3 +-
.../app/template/components/nuxt-loading.vue | 184 ++++++++++++------
packages/config/src/config/index.js | 4 +-
test/e2e/basic.browser.test.js | 8 +-
test/unit/components.test.js | 130 +++++++++++++
yarn.lock | 142 +++++++++++++-
7 files changed, 401 insertions(+), 75 deletions(-)
create mode 100644 test/unit/components.test.js
diff --git a/jest.config.js b/jest.config.js
index fed3f02f49..f4706457af 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -30,6 +30,11 @@ module.exports = {
'examples/.*'
],
+ transform: {
+ '^.+\\.js$': 'babel-jest',
+ '.*\\.(vue)$': 'vue-jest'
+ },
+
transformIgnorePatterns: [
'/node_modules/',
'/dist/'
diff --git a/package.json b/package.json
index d888c5e575..8ffd0f9296 100644
--- a/package.json
+++ b/package.json
@@ -68,6 +68,7 @@
"rollup-plugin-license": "^0.7.0",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-replace": "^2.1.0",
- "sort-package-json": "^1.16.0"
+ "sort-package-json": "^1.16.0",
+ "vue-jest": "^2.6.0"
}
}
diff --git a/packages/app/template/components/nuxt-loading.vue b/packages/app/template/components/nuxt-loading.vue
index 5e4ca5f0e3..a6d69a4e1f 100644
--- a/packages/app/template/components/nuxt-loading.vue
+++ b/packages/app/template/components/nuxt-loading.vue
@@ -1,115 +1,177 @@
-
-
-
-
-
+<% if (loading && loading.css) { %>
+
+.nuxt-progress.nuxt-progress-notransition {
+ transition: none;
+}
+
+.nuxt-progress-failed {
+ background-color: <%= loading.failedColor %>;
+}
+<% } %>
diff --git a/packages/config/src/config/index.js b/packages/config/src/config/index.js
index c9bd2a93dd..8a16689662 100644
--- a/packages/config/src/config/index.js
+++ b/packages/config/src/config/index.js
@@ -85,7 +85,9 @@ export default {
height: '2px',
throttle: 200,
duration: 5000,
- rtl: false
+ continuous: false,
+ rtl: false,
+ css: true
},
loadingIndicator: 'default',
transition: {
diff --git a/test/e2e/basic.browser.test.js b/test/e2e/basic.browser.test.js
index 4dcf5b504e..86cdc222d3 100644
--- a/test/e2e/basic.browser.test.js
+++ b/test/e2e/basic.browser.test.js
@@ -1,5 +1,5 @@
import Browser from '../utils/browser'
-import { loadFixture, getPort, Nuxt } from '../utils'
+import { loadFixture, getPort, Nuxt, waitFor } from '../utils'
let port
const browser = new Browser()
@@ -28,10 +28,12 @@ describe('basic browser', () => {
})
test('/noloading', async () => {
- const { hook } = await page.nuxt.navigate('/noloading')
- const loading = await page.nuxt.loadingData()
+ const { hook } = await page.nuxt.navigate('/noloading', false)
+ await waitFor(nuxt.options.loading.throttle + 100)
+ let loading = await page.nuxt.loadingData()
expect(loading.show).toBe(true)
await hook
+ loading = await page.nuxt.loadingData()
expect(loading.show).toBe(true)
await page.waitForFunction(
`$nuxt.$loading.$data.show === false`
diff --git a/test/unit/components.test.js b/test/unit/components.test.js
new file mode 100644
index 0000000000..db9e3fa898
--- /dev/null
+++ b/test/unit/components.test.js
@@ -0,0 +1,130 @@
+import { resolve } from 'path'
+import { promisify } from 'util'
+import Vue from 'vue'
+import { loadFixture, waitFor } from '../utils'
+
+const renderer = require('vue-server-renderer').createRenderer()
+const renderToString = promisify(renderer.renderToString)
+
+let componentDir
+
+describe('components', () => {
+ beforeAll(async () => {
+ const config = await loadFixture('basic')
+ componentDir = resolve(config.rootDir, '.nuxt/components')
+ })
+
+ describe('nuxt-loading', () => {
+ let VueComponent
+
+ beforeAll(async () => {
+ const Component = (await import(resolve(componentDir, 'nuxt-loading.vue'))).default
+ VueComponent = Vue.extend(Component)
+ })
+
+ test('removed when not loading', async () => {
+ const component = new VueComponent().$mount()
+ const str = await renderToString(component)
+ expect(str).toBe('')
+ })
+
+ test('added when loading', async () => {
+ const component = new VueComponent().$mount()
+ component.throttle = 0
+ component.start()
+ const str = await renderToString(component)
+ expect(str).toBe('
')
+ component.clear()
+ })
+
+ test('percentage changed after 1s', async () => {
+ jest.useRealTimers()
+ const component = new VueComponent().$mount()
+ component.duration = 2000
+ component.throttle = 0
+ component.start()
+ await waitFor(250)
+ const str = await renderToString(component)
+ expect(str).not.toBe('')
+ expect(str).not.toBe('
')
+ expect(component.$data.percent).not.toBe(0)
+ component.clear()
+ })
+
+ test('can be finished', async () => {
+ jest.useFakeTimers()
+ const component = new VueComponent().$mount()
+ component.throttle = 0
+ component.start()
+ component.finish()
+ let str = await renderToString(component)
+ expect(str).toBe('
')
+ expect(component.$data.percent).toBe(100)
+ jest.runAllTimers()
+ str = await renderToString(component)
+ expect(str).toBe('')
+ expect(component.$data.percent).toBe(0)
+ component.clear()
+ jest.useRealTimers()
+ })
+
+ test('can fail', async () => {
+ const component = new VueComponent().$mount()
+ component.set(50)
+ component.fail()
+ const str = await renderToString(component)
+ expect(str).toBe('
')
+ })
+
+ test('not shown until throttle', async () => {
+ const component = new VueComponent().$mount()
+ component.duration = 2000
+ component.throttle = 1000
+ component.start()
+ await waitFor(300)
+ let str = await renderToString(component)
+ expect(str).toBe('')
+ await waitFor(1000)
+ str = await renderToString(component)
+ expect(str).not.toBe('')
+ expect(str).not.toBe('
')
+ component.clear()
+ })
+
+ test('can pause and resume', async () => {
+ const component = new VueComponent().$mount()
+ component.duration = 2000
+ component.throttle = 0
+ component.start()
+ await waitFor(250)
+ let str = await renderToString(component)
+ expect(str).not.toBe('')
+ component.pause()
+ await waitFor(500)
+ const str2 = await renderToString(component)
+ expect(str2).toBe(str)
+ component.resume()
+ await waitFor(500)
+ str = await renderToString(component)
+ expect(str).not.toBe('')
+ expect(str).not.toBe(str2)
+ component.clear()
+ })
+
+ test('continues after duration', async () => {
+ const component = new VueComponent().$mount()
+ component.continuous = true
+ component.duration = 500
+ component.throttle = 0
+ component.start()
+ await waitFor(850)
+ const str = await renderToString(component)
+ expect(str).not.toBe('')
+ expect(str).not.toBe('
')
+ expect(str).not.toBe('
')
+ expect(str).not.toBe('
')
+ expect(str).not.toBe('
')
+ component.clear()
+ })
+ })
+})
diff --git a/yarn.lock b/yarn.lock
index a9a0185bec..c816802c6d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1391,11 +1391,26 @@
resolved "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==
-"@types/node@*":
+"@types/node@*", "@types/node@^10.11.7":
version "10.12.0"
resolved "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz#ea6dcbddbc5b584c83f06c60e82736d8fbb0c235"
integrity sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ==
+"@types/semver@^5.5.0":
+ version "5.5.0"
+ resolved "https://registry.npmjs.org/@types/semver/-/semver-5.5.0.tgz#146c2a29ee7d3bae4bf2fcb274636e264c813c45"
+ integrity sha512-41qEJgBH/TWgo5NFSvBCJ1qkoi3Q6ONSF2avrHq1LVEZfYpdHmj0y9SuTK+u9ZhG1sYQKBL1AWXKyLWP4RaUoQ==
+
+"@types/strip-bom@^3.0.0":
+ version "3.0.0"
+ resolved "http://registry.npmjs.org/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2"
+ integrity sha1-FKjsOVbC6B7bdSB5CuzyHCkK69I=
+
+"@types/strip-json-comments@0.0.30":
+ version "0.0.30"
+ resolved "https://registry.npmjs.org/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz#9aa30c04db212a9a0649d6ae6fd50accc40748a1"
+ integrity sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ==
+
"@vue/component-compiler-utils@^2.0.0":
version "2.2.0"
resolved "https://registry.npmjs.org/@vue/component-compiler-utils/-/component-compiler-utils-2.2.0.tgz#bbbb7ed38a9a8a7c93abe7ef2e54a90a04b631b4"
@@ -2107,6 +2122,24 @@ babel-plugin-syntax-object-rest-spread@^6.13.0:
resolved "http://registry.npmjs.org/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz#fd6536f2bce13836ffa3a5458c4903a597bb3bf5"
integrity sha1-/WU28rzhODb/o6VFjEkDpZe7O/U=
+babel-plugin-transform-es2015-modules-commonjs@^6.26.0:
+ version "6.26.2"
+ resolved "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.2.tgz#58a793863a9e7ca870bdc5a881117ffac27db6f3"
+ integrity sha512-CV9ROOHEdrjcwhIaJNBGMBCodN+1cfkwtM1SbUHmvyy35KGT7fohbpOxkE2uLz1o6odKK2Ck/tz47z+VqQfi9Q==
+ dependencies:
+ babel-plugin-transform-strict-mode "^6.24.1"
+ babel-runtime "^6.26.0"
+ babel-template "^6.26.0"
+ babel-types "^6.26.0"
+
+babel-plugin-transform-strict-mode@^6.24.1:
+ version "6.24.1"
+ resolved "https://registry.npmjs.org/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz#d5faf7aa578a65bbe591cf5edae04a0c67020758"
+ integrity sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g=
+ dependencies:
+ babel-runtime "^6.22.0"
+ babel-types "^6.24.1"
+
babel-plugin-transform-vue-jsx@^4.0.1:
version "4.0.1"
resolved "https://registry.npmjs.org/babel-plugin-transform-vue-jsx/-/babel-plugin-transform-vue-jsx-4.0.1.tgz#2c8bddce87a6ef09eaa59869ff1bfbeeafc5f88d"
@@ -2169,7 +2202,7 @@ babel-traverse@^6.0.0, babel-traverse@^6.18.0, babel-traverse@^6.26.0:
invariant "^2.2.2"
lodash "^4.17.4"
-babel-types@^6.0.0, babel-types@^6.18.0, babel-types@^6.26.0:
+babel-types@^6.0.0, babel-types@^6.18.0, babel-types@^6.24.1, babel-types@^6.26.0:
version "6.26.0"
resolved "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497"
integrity sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=
@@ -2765,6 +2798,11 @@ cliui@^4.0.0:
strip-ansi "^4.0.0"
wrap-ansi "^2.0.0"
+clone@2.x:
+ version "2.1.2"
+ resolved "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f"
+ integrity sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=
+
clone@^1.0.2:
version "1.0.4"
resolved "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e"
@@ -2872,7 +2910,7 @@ commander@2.17.x, commander@~2.17.1:
resolved "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
integrity sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==
-commander@^2.18.0:
+commander@^2.18.0, commander@^2.19.0:
version "2.19.0"
resolved "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a"
integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==
@@ -2940,7 +2978,7 @@ concat-stream@1.6.2, concat-stream@^1.5.0, concat-stream@^1.6.0:
readable-stream "^2.2.2"
typedarray "^0.0.6"
-config-chain@^1.1.11:
+config-chain@^1.1.11, config-chain@~1.1.5:
version "1.1.12"
resolved "https://registry.npmjs.org/config-chain/-/config-chain-1.1.12.tgz#0fde8d091200eb5e808caf25fe618c02f48e4efa"
integrity sha512-a1eOIcu8+7lUInge4Rpf/n4Krkf3Dd9lqhljRzII1/Zno/kRtUWnznPO3jOKBmTEktkt3fkxisUcivoj0ebzoA==
@@ -3335,6 +3373,16 @@ css-what@2.1:
resolved "https://registry.npmjs.org/css-what/-/css-what-2.1.0.tgz#9467d032c38cfaefb9f2d79501253062f87fa1bd"
integrity sha1-lGfQMsOM+u+58teVASUwYvh/ob0=
+css@^2.1.0:
+ version "2.2.4"
+ resolved "https://registry.npmjs.org/css/-/css-2.2.4.tgz#c646755c73971f2bba6a601e2cf2fd71b1298929"
+ integrity sha512-oUnjmWpy0niI3x/mPL8dVEI1l7MnG3+HHyRPHf+YFSbK+svOhXpmSOcDURUh2aOCgl2grzrOPt1nHLuCVFULLw==
+ dependencies:
+ inherits "^2.0.3"
+ source-map "^0.6.1"
+ source-map-resolve "^0.5.2"
+ urix "^0.1.0"
+
cssdb@^3.2.1:
version "3.2.1"
resolved "https://registry.npmjs.org/cssdb/-/cssdb-3.2.1.tgz#65e7dc90be476ce5b6e567b19f3bd73a8c66bcb5"
@@ -3876,6 +3924,18 @@ ecc-jsbn@~0.1.1:
jsbn "~0.1.0"
safer-buffer "^2.1.0"
+editorconfig@^0.15.0:
+ version "0.15.2"
+ resolved "https://registry.npmjs.org/editorconfig/-/editorconfig-0.15.2.tgz#047be983abb9ab3c2eefe5199cb2b7c5689f0702"
+ integrity sha512-GWjSI19PVJAM9IZRGOS+YKI8LN+/sjkSjNyvxL5ucqP9/IqtYNXBaQ/6c/hkPNYQHyOHra2KoXZI/JVpuqwmcQ==
+ dependencies:
+ "@types/node" "^10.11.7"
+ "@types/semver" "^5.5.0"
+ commander "^2.19.0"
+ lru-cache "^4.1.3"
+ semver "^5.6.0"
+ sigmund "^1.0.1"
+
ee-first@1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
@@ -4441,6 +4501,13 @@ extglob@^2.0.4:
snapdragon "^0.8.1"
to-regex "^3.0.1"
+extract-from-css@^0.4.4:
+ version "0.4.4"
+ resolved "https://registry.npmjs.org/extract-from-css/-/extract-from-css-0.4.4.tgz#1ea7df2e7c7c6eb9922fa08e8adaea486f6f8f92"
+ integrity sha1-HqffLnx8brmSL6COitrqSG9vj5I=
+ dependencies:
+ css "^2.1.0"
+
extract-zip@^1.6.6:
version "1.6.7"
resolved "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz#a840b4b8af6403264c8db57f4f1a74333ef81fe9"
@@ -4605,6 +4672,14 @@ finalhandler@1.1.1, finalhandler@^1.1.1:
statuses "~1.4.0"
unpipe "~1.0.0"
+find-babel-config@^1.1.0:
+ version "1.1.0"
+ resolved "https://registry.npmjs.org/find-babel-config/-/find-babel-config-1.1.0.tgz#acc01043a6749fec34429be6b64f542ebb5d6355"
+ integrity sha1-rMAQQ6Z0n+w0Qpvmtk9ULrtdY1U=
+ dependencies:
+ json5 "^0.5.1"
+ path-exists "^3.0.0"
+
find-cache-dir@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-1.0.0.tgz#9288e3e9e3cc3748717d39eade17cf71fc30ee6f"
@@ -6207,6 +6282,16 @@ jest@^23.6.0:
import-local "^1.0.0"
jest-cli "^23.6.0"
+js-beautify@^1.6.14:
+ version "1.8.8"
+ resolved "https://registry.npmjs.org/js-beautify/-/js-beautify-1.8.8.tgz#1eb175b73a3571a5f1ed8d98e7cf2b05bfa98471"
+ integrity sha512-qVNq7ZZ7ZbLdzorvSlRDadS0Rh5oyItaE95v6I4wbbuSiijxn7SnnsV6dvKlcXuO2jX7lK8tn9fBulx34K/Ejg==
+ dependencies:
+ config-chain "~1.1.5"
+ editorconfig "^0.15.0"
+ mkdirp "~0.5.0"
+ nopt "~4.0.1"
+
js-levenshtein@^1.1.3:
version "1.1.4"
resolved "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.4.tgz#3a56e3cbf589ca0081eb22cd9ba0b1290a16d26e"
@@ -6643,7 +6728,7 @@ lodash@4.17.9:
resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.9.tgz#9c056579af0bdbb4322e23c836df13ef2b271cb7"
integrity sha512-vuRLquvot5sKUldMBumG0YqLvX6m/RGBBOmqb3CWR/MC/QvvD1cTH1fOqxz2FJAQeoExeUdX5Gu9vP2EP6ik+Q==
-lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1:
+lodash@4.x, lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1:
version "4.17.11"
resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==
@@ -7171,6 +7256,14 @@ no-case@^2.2.0:
dependencies:
lower-case "^1.1.1"
+node-cache@^4.1.1:
+ version "4.2.0"
+ resolved "https://registry.npmjs.org/node-cache/-/node-cache-4.2.0.tgz#48ac796a874e762582692004a376d26dfa875811"
+ integrity sha512-obRu6/f7S024ysheAjoYFEEBqqDWv4LOMNJEuO8vMeEw2AT4z+NCzO4hlc2lhI4vATzbCQv6kke9FVdx0RbCOw==
+ dependencies:
+ clone "2.x"
+ lodash "4.x"
+
node-fetch-npm@^2.0.2:
version "2.0.2"
resolved "https://registry.npmjs.org/node-fetch-npm/-/node-fetch-npm-2.0.2.tgz#7258c9046182dca345b4208eda918daf33697ff7"
@@ -7282,7 +7375,7 @@ node-releases@^1.0.0-alpha.14:
dependencies:
abbrev "1"
-nopt@^4.0.1:
+nopt@^4.0.1, nopt@~4.0.1:
version "4.0.1"
resolved "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d"
integrity sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=
@@ -9580,7 +9673,7 @@ schema-utils@^1.0.0:
ajv-errors "^1.0.0"
ajv-keywords "^3.1.0"
-"semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1:
+"semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0:
version "5.6.0"
resolved "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004"
integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==
@@ -9699,6 +9792,11 @@ shellwords@^0.1.1:
resolved "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==
+sigmund@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590"
+ integrity sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=
+
signal-exit@^3.0.0, signal-exit@^3.0.2:
version "3.0.2"
resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
@@ -9809,7 +9907,7 @@ source-list-map@^2.0.0:
resolved "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34"
integrity sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw==
-source-map-resolve@^0.5.0:
+source-map-resolve@^0.5.0, source-map-resolve@^0.5.2:
version "0.5.2"
resolved "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz#72e2cc34095543e43b2c62b2c4c10d4a9054f259"
integrity sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==
@@ -10115,7 +10213,7 @@ strip-indent@^2.0.0:
resolved "https://registry.npmjs.org/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68"
integrity sha1-XvjbKV0B5u1sv3qrlpmNeCJSe2g=
-strip-json-comments@^2.0.1, strip-json-comments@~2.0.1:
+strip-json-comments@^2.0.0, strip-json-comments@^2.0.1, strip-json-comments@~2.0.1:
version "2.0.1"
resolved "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo=
@@ -10455,6 +10553,16 @@ tryer@^1.0.0:
resolved "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"
integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==
+tsconfig@^7.0.0:
+ version "7.0.0"
+ resolved "https://registry.npmjs.org/tsconfig/-/tsconfig-7.0.0.tgz#84538875a4dc216e5c4a5432b3a4dec3d54e91b7"
+ integrity sha512-vZXmzPrL+EmC4T/4rVlT2jNVMWCi/O4DIiSj3UHg1OE5kCKbk4mfrXc6dZksLgRM/TZlKnousKH9bbTazUWRRw==
+ dependencies:
+ "@types/strip-bom" "^3.0.0"
+ "@types/strip-json-comments" "0.0.30"
+ strip-bom "^3.0.0"
+ strip-json-comments "^2.0.0"
+
tslib@^1.9.0:
version "1.9.3"
resolved "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
@@ -10786,6 +10894,22 @@ vue-hot-reload-api@^2.3.0:
resolved "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.1.tgz#b2d3d95402a811602380783ea4f566eb875569a2"
integrity sha512-AA86yKZ5uOKz87/q1UpngEXhbRkaYg1b7HMMVRobNV1IVKqZe8oLIzo6iMocVwZXnYitlGwf2k4ZRLOZlS8oPQ==
+vue-jest@^2.6.0:
+ version "2.6.0"
+ resolved "https://registry.npmjs.org/vue-jest/-/vue-jest-2.6.0.tgz#23dc99a4dce0bb59fea3946e1317b234968cf12a"
+ integrity sha512-kVgKGcycJ1ce3tUc48JKFSSXsbRNy5QOCAcK9k1aYDRD0m6tTbbFm8Q8yGkfsXLyFeUsvO1OEgsCYxZeD5GL2g==
+ dependencies:
+ babel-plugin-transform-es2015-modules-commonjs "^6.26.0"
+ chalk "^2.1.0"
+ extract-from-css "^0.4.4"
+ find-babel-config "^1.1.0"
+ js-beautify "^1.6.14"
+ node-cache "^4.1.1"
+ object-assign "^4.1.1"
+ source-map "^0.5.6"
+ tsconfig "^7.0.0"
+ vue-template-es2015-compiler "^1.6.0"
+
vue-loader@^15.4.2:
version "15.4.2"
resolved "https://registry.npmjs.org/vue-loader/-/vue-loader-15.4.2.tgz#812bb26e447dd3b84c485eb634190d914ce125e2"
From f284f7c1498c2ba363064df1a9be52ebcec1a27a Mon Sep 17 00:00:00 2001
From: "renovate[bot]"
Date: Tue, 30 Oct 2018 01:27:39 +0330
Subject: [PATCH 067/149] [skip ci] update dependency jsdom to v13 (#4227)
---
package.json | 2 +-
yarn.lock | 18 ++++++++++++++----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/package.json b/package.json
index 8ffd0f9296..35c30b742b 100644
--- a/package.json
+++ b/package.json
@@ -50,7 +50,7 @@
"get-port": "^4.0.0",
"glob": "^7.1.3",
"jest": "^23.6.0",
- "jsdom": "^12.2.0",
+ "jsdom": "^13.0.0",
"klaw-sync": "^6.0.0",
"lerna": "^3.4.3",
"lodash": "^4.17.11",
diff --git a/yarn.lock b/yarn.lock
index c816802c6d..2ee790fd04 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -6357,10 +6357,10 @@ jsdom@^11.5.1:
ws "^5.2.0"
xml-name-validator "^3.0.0"
-jsdom@^12.2.0:
- version "12.2.0"
- resolved "https://registry.npmjs.org/jsdom/-/jsdom-12.2.0.tgz#7cf3f5b5eafd47f8f09ca52315d367ff6e95de23"
- integrity sha512-QPOggIJ8fquWPLaYYMoh+zqUmdphDtu1ju0QGTitZT1Yd8I5qenPpXM1etzUegu3MjVp8XPzgZxdn8Yj7e40ig==
+jsdom@^13.0.0:
+ version "13.0.0"
+ resolved "https://registry.npmjs.org/jsdom/-/jsdom-13.0.0.tgz#f1df2411b714a4e08d1bdc343c0a0889c688210f"
+ integrity sha512-Kmq4ASMNkgpY+YufE322EnIKoiz0UWY2DRkKlU7d5YrIW4xiVRhWFrZV1fr6w/ZNxQ50wGAH5gGRzydgnmkkvw==
dependencies:
abab "^2.0.0"
acorn "^6.0.2"
@@ -6381,6 +6381,7 @@ jsdom@^12.2.0:
symbol-tree "^3.2.2"
tough-cookie "^2.4.3"
w3c-hr-time "^1.0.1"
+ w3c-xmlserializer "^1.0.0"
webidl-conversions "^4.0.2"
whatwg-encoding "^1.0.5"
whatwg-mimetype "^2.2.0"
@@ -10992,6 +10993,15 @@ w3c-hr-time@^1.0.1:
dependencies:
browser-process-hrtime "^0.1.2"
+w3c-xmlserializer@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-1.0.0.tgz#d23e20de595b892056f20a359fc2622908d48695"
+ integrity sha512-0et1+9uXYiIRAecx1D5Z1nk60+vimniGdIKl4XjeqkWi6acoHNlXMv1VR5jV+jF4ooeO08oWbYxeAJOcon1oMA==
+ dependencies:
+ domexception "^1.0.1"
+ webidl-conversions "^4.0.2"
+ xml-name-validator "^3.0.0"
+
walker@~1.0.5:
version "1.0.7"
resolved "https://registry.npmjs.org/walker/-/walker-1.0.7.tgz#2f7f9b8fd10d677262b18a884e28d19618e028fb"
From 30c68bfa77a092fbbd981ad19f5dffa3010051f4 Mon Sep 17 00:00:00 2001
From: "renovate[bot]"
Date: Tue, 30 Oct 2018 01:30:34 +0330
Subject: [PATCH 068/149] [skip ci] update dependency vue-jest to v3 (#4228)
---
package.json | 2 +-
yarn.lock | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/package.json b/package.json
index 35c30b742b..947fc51cb0 100644
--- a/package.json
+++ b/package.json
@@ -69,6 +69,6 @@
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-replace": "^2.1.0",
"sort-package-json": "^1.16.0",
- "vue-jest": "^2.6.0"
+ "vue-jest": "^3.0.0"
}
}
diff --git a/yarn.lock b/yarn.lock
index 2ee790fd04..1d94b40959 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -10895,10 +10895,10 @@ vue-hot-reload-api@^2.3.0:
resolved "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.1.tgz#b2d3d95402a811602380783ea4f566eb875569a2"
integrity sha512-AA86yKZ5uOKz87/q1UpngEXhbRkaYg1b7HMMVRobNV1IVKqZe8oLIzo6iMocVwZXnYitlGwf2k4ZRLOZlS8oPQ==
-vue-jest@^2.6.0:
- version "2.6.0"
- resolved "https://registry.npmjs.org/vue-jest/-/vue-jest-2.6.0.tgz#23dc99a4dce0bb59fea3946e1317b234968cf12a"
- integrity sha512-kVgKGcycJ1ce3tUc48JKFSSXsbRNy5QOCAcK9k1aYDRD0m6tTbbFm8Q8yGkfsXLyFeUsvO1OEgsCYxZeD5GL2g==
+vue-jest@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.npmjs.org/vue-jest/-/vue-jest-3.0.0.tgz#e5b0ad60c37bbeebe214124420de9eb911596cdc"
+ integrity sha512-naYRHx600YmwfUCoCUsbNlgQ6uk8L0Nn76bVZyMIJYOLlvS+f/1BqOX7ASXlYnNqNobYSC5AtWSlNzRBtYz/mw==
dependencies:
babel-plugin-transform-es2015-modules-commonjs "^6.26.0"
chalk "^2.1.0"
From 2e2b32b5479d7c04b5e72ac302f83ec12cf82dea Mon Sep 17 00:00:00 2001
From: "renovate[bot]"
Date: Tue, 30 Oct 2018 01:31:32 +0330
Subject: [PATCH 069/149] [skip ci] update all non-major dependencies (#4223)
---
packages/webpack/package.json | 6 +--
yarn.lock | 98 ++++++++++++++++++++---------------
2 files changed, 60 insertions(+), 44 deletions(-)
diff --git a/packages/webpack/package.json b/packages/webpack/package.json
index 8999cdd224..56c116f56d 100644
--- a/packages/webpack/package.json
+++ b/packages/webpack/package.json
@@ -15,10 +15,10 @@
"@nuxtjs/friendly-errors-webpack-plugin": "^2.1.0",
"babel-loader": "^8.0.4",
"cache-loader": "^1.2.2",
- "caniuse-lite": "^1.0.30000899",
+ "caniuse-lite": "^1.0.30000900",
"chalk": "^2.4.1",
"consola": "^1.4.4",
- "css-loader": "^1.0.0",
+ "css-loader": "^1.0.1",
"cssnano": "^4.1.7",
"file-loader": "^2.0.0",
"fs-extra": "^7.0.0",
@@ -34,7 +34,7 @@
"postcss-import": "^12.0.1",
"postcss-import-resolver": "^1.1.0",
"postcss-loader": "^3.0.0",
- "postcss-preset-env": "^6.2.0",
+ "postcss-preset-env": "^6.3.0",
"postcss-url": "^8.0.0",
"style-resources-loader": "^1.2.1",
"terser-webpack-plugin": "^1.1.0",
diff --git a/yarn.lock b/yarn.lock
index 1d94b40959..357bd22cab 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1958,13 +1958,13 @@ atob@^2.1.1:
resolved "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
-autoprefixer@^9.2.1:
- version "9.2.1"
- resolved "https://registry.npmjs.org/autoprefixer/-/autoprefixer-9.2.1.tgz#1f2f1179ceed4711b7ab064dbd5c3f9e83d9dc62"
- integrity sha512-qlK4GnZk8OXLK+8kBn9ttfzu2PkhRe8kVYoWcc9HsrZEMWiBkQuRYdXyJg9cIIKxfMzhh6UbvlJ1CsstMIzxwA==
+autoprefixer@^9.3.1:
+ version "9.3.1"
+ resolved "https://registry.npmjs.org/autoprefixer/-/autoprefixer-9.3.1.tgz#71b622174de2b783d5fd99f9ad617b7a3c78443e"
+ integrity sha512-DY9gOh8z3tnCbJ13JIWaeQsoYncTGdsrgCceBaQSIL4nvdrLxgbRSBPevg2XbX7u4QCSfLheSJEEIUUSlkbx6Q==
dependencies:
- browserslist "^4.2.1"
- caniuse-lite "^1.0.30000892"
+ browserslist "^4.3.3"
+ caniuse-lite "^1.0.30000898"
normalize-range "^0.1.2"
num2fraction "^1.2.2"
postcss "^7.0.5"
@@ -2419,7 +2419,7 @@ browserify-zlib@^0.2.0:
dependencies:
pako "~1.0.5"
-browserslist@^4.0.0, browserslist@^4.1.0, browserslist@^4.2.1:
+browserslist@^4.0.0, browserslist@^4.1.0:
version "4.2.1"
resolved "https://registry.npmjs.org/browserslist/-/browserslist-4.2.1.tgz#257a24c879d1cd4016348eee5c25de683260b21d"
integrity sha512-1oO0c7Zhejwd+LXihS89WqtKionSbz298rJZKJgfrHIZhrV8AC15gw553VcB0lcEugja7IhWD7iAlrsamfYVPA==
@@ -2428,14 +2428,14 @@ browserslist@^4.0.0, browserslist@^4.1.0, browserslist@^4.2.1:
electron-to-chromium "^1.3.79"
node-releases "^1.0.0-alpha.14"
-browserslist@^4.3.1:
- version "4.3.1"
- resolved "https://registry.npmjs.org/browserslist/-/browserslist-4.3.1.tgz#453e46e74b0663ec5d764cdac3e5ac52bd776038"
- integrity sha512-rlvbN4EERDFJcwI8qzmRz48a1zqvwE4L0G4d05EjH2nlswJqBxCXByafWhhCpVrHOsnOrDMtVjibPHdBElb8sg==
+browserslist@^4.3.3, browserslist@^4.3.4:
+ version "4.3.4"
+ resolved "https://registry.npmjs.org/browserslist/-/browserslist-4.3.4.tgz#4477b737db6a1b07077275b24791e680d4300425"
+ integrity sha512-u5iz+ijIMUlmV8blX82VGFrB9ecnUg5qEt55CMZ/YJEhha+d8qpBfOFuutJ6F/VKRXjZoD33b6uvarpPxcl3RA==
dependencies:
- caniuse-lite "^1.0.30000893"
- electron-to-chromium "^1.3.80"
- node-releases "^1.0.0-alpha.14"
+ caniuse-lite "^1.0.30000899"
+ electron-to-chromium "^1.3.82"
+ node-releases "^1.0.1"
bser@^2.0.0:
version "2.0.0"
@@ -2634,11 +2634,16 @@ caniuse-api@^3.0.0:
lodash.memoize "^4.1.2"
lodash.uniq "^4.5.0"
-caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000890, caniuse-lite@^1.0.30000892, caniuse-lite@^1.0.30000893:
+caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000890:
version "1.0.30000893"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000893.tgz#284b20932bd41b93e21626975f2050cb01561986"
integrity sha512-kOddHcTEef+NgN/fs0zmX2brHTNATVOWMEIhlZHCuwQRtXobjSw9pAECc44Op4bTBcavRjkLaPrGomknH7+Jvg==
+caniuse-lite@^1.0.30000898, caniuse-lite@^1.0.30000900:
+ version "1.0.30000900"
+ resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000900.tgz#015cfe37897a3386a3075a914498800c29afe77e"
+ integrity sha512-xDVs8pBFr6bzq9pXUkLKpGQQnzsF/l6/yX38UnCkTcUcwC0rDl1NGZGildcJVTU+uGBxfsyniK/ZWagPNn1Oqw==
+
caniuse-lite@^1.0.30000899:
version "1.0.30000899"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000899.tgz#6febdbbc388a7982f620ee0e3d09aab0c061389e"
@@ -3290,16 +3295,16 @@ css-declaration-sorter@^4.0.1:
postcss "^7.0.1"
timsort "^0.3.0"
-css-loader@^1.0.0:
- version "1.0.0"
- resolved "https://registry.npmjs.org/css-loader/-/css-loader-1.0.0.tgz#9f46aaa5ca41dbe31860e3b62b8e23c42916bf56"
- integrity sha512-tMXlTYf3mIMt3b0dDCOQFJiVvxbocJ5Ho577WiGPYPZcqVEO218L2iU22pDXzkTZCLDE+9AmGSUkWxeh/nZReA==
+css-loader@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.npmjs.org/css-loader/-/css-loader-1.0.1.tgz#6885bb5233b35ec47b006057da01cc640b6b79fe"
+ integrity sha512-+ZHAZm/yqvJ2kDtPne3uX0C+Vr3Zn5jFn2N4HywtS5ujwvsVkyg0VArEXpl3BgczDA8anieki1FIzhchX4yrDw==
dependencies:
babel-code-frame "^6.26.0"
css-selector-tokenizer "^0.7.0"
icss-utils "^2.1.0"
loader-utils "^1.0.2"
- lodash.camelcase "^4.3.0"
+ lodash "^4.17.11"
postcss "^6.0.23"
postcss-modules-extract-imports "^1.2.0"
postcss-modules-local-by-default "^1.2.0"
@@ -3383,10 +3388,10 @@ css@^2.1.0:
source-map-resolve "^0.5.2"
urix "^0.1.0"
-cssdb@^3.2.1:
- version "3.2.1"
- resolved "https://registry.npmjs.org/cssdb/-/cssdb-3.2.1.tgz#65e7dc90be476ce5b6e567b19f3bd73a8c66bcb5"
- integrity sha512-I0IS8zvxED8sQtFZnV7M+AkhWqTgp1HIyfMQJBbjdn4GgurBt7NCZaDgrWiAN2kNJN34mhF1p50aZIMQu290mA==
+cssdb@^4.1.0:
+ version "4.1.0"
+ resolved "https://registry.npmjs.org/cssdb/-/cssdb-4.1.0.tgz#5eff01703b3380256a6d2fd0dfa42de383b5f0e7"
+ integrity sha512-qaEHVEtScIHoBgdTEHNUMKQw7GXfVYHiaFcL8jerXWJ47lNBy2PgApHdHbR4yovVJsZK6Zq+YkBw8MuhAOvixg==
cssesc@^0.1.0:
version "0.1.0"
@@ -3951,10 +3956,10 @@ electron-to-chromium@^1.3.79:
resolved "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.79.tgz#774718f06284a4bf8f578ac67e74508fe659f13a"
integrity sha512-LQdY3j4PxuUl6xfxiFruTSlCniTrTrzAd8/HfsLEMi0PUpaQ0Iy+Pr4N4VllDYjs0Hyu2lkTbvzqlG+PX9NsNw==
-electron-to-chromium@^1.3.80:
- version "1.3.80"
- resolved "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.80.tgz#e99ec7efe64c2c6a269d3885ff411ea88852fa53"
- integrity sha512-WClidEWEUNx7OfwXehB0qaxCuetjbKjev2SmXWgybWPLKAThBiMTF/2Pd8GSUDtoGOavxVzdkKwfFAPRSWlkLw==
+electron-to-chromium@^1.3.82:
+ version "1.3.82"
+ resolved "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.82.tgz#7d13ae4437d2a783de3f4efba96b186c540b67b1"
+ integrity sha512-NI4nB2IWGcU4JVT1AE8kBb/dFor4zjLHMLsOROPahppeHrR0FG5uslxMmkp/thO1MvPjM2xhlKoY29/I60s0ew==
elliptic@^6.0.0:
version "6.4.1"
@@ -6679,11 +6684,6 @@ lodash._reinterpolate@~3.0.0:
resolved "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=
-lodash.camelcase@^4.3.0:
- version "4.3.0"
- resolved "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6"
- integrity sha1-soqmKIorn8ZRA1x3EfZathkDMaY=
-
lodash.debounce@^4.0.8:
version "4.0.8"
resolved "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
@@ -7369,6 +7369,13 @@ node-releases@^1.0.0-alpha.14:
dependencies:
semver "^5.3.0"
+node-releases@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.npmjs.org/node-releases/-/node-releases-1.0.1.tgz#957a2735d2ca737d7005588f8e85e6c27032555b"
+ integrity sha512-/kOv7jA26OBwkBPx6B9xR/FzJzs2OkMtcWjS8uPQRMHE7IELdSfN0QKZvmiWnf5P1QJ8oYq/e9qe0aCZISB1pQ==
+ dependencies:
+ semver "^5.3.0"
+
"nopt@2 || 3":
version "3.0.6"
resolved "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9"
@@ -8177,6 +8184,14 @@ postcss-discard-overridden@^4.0.1:
dependencies:
postcss "^7.0.0"
+postcss-double-position-gradients@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.npmjs.org/postcss-double-position-gradients/-/postcss-double-position-gradients-1.0.0.tgz#fc927d52fddc896cb3a2812ebc5df147e110522e"
+ integrity sha512-G+nV8EnQq25fOI8CH/B6krEohGWnF5+3A6H/+JEpOncu5dCnkS1QQ6+ct3Jkaepw1NGVqqOZH6lqrm244mCftA==
+ dependencies:
+ postcss "^7.0.5"
+ postcss-values-parser "^2.0.0"
+
postcss-env-function@^2.0.2:
version "2.0.2"
resolved "https://registry.npmjs.org/postcss-env-function/-/postcss-env-function-2.0.2.tgz#0f3e3d3c57f094a92c2baf4b6241f0b0da5365d7"
@@ -8509,15 +8524,15 @@ postcss-place@^4.0.1:
postcss "^7.0.2"
postcss-values-parser "^2.0.0"
-postcss-preset-env@^6.2.0:
- version "6.2.0"
- resolved "https://registry.npmjs.org/postcss-preset-env/-/postcss-preset-env-6.2.0.tgz#e513e11cd4037fcb54ad6dac773c918e728f2180"
- integrity sha512-gzqwaI32UBxWSjz2Rs8TAwRfDuDYlB9bGZWHMhjhrIegWNbOyohRsGO7ZrL8mNQ+4uN4k7XYOnoik9Cbczu06Q==
+postcss-preset-env@^6.3.0:
+ version "6.3.0"
+ resolved "https://registry.npmjs.org/postcss-preset-env/-/postcss-preset-env-6.3.0.tgz#726f033fb81607cabd2e35deb26a56bb976ab1e7"
+ integrity sha512-3iTlt9tuD7QsQ9wdJwr7E7hjVlNKrN6Fk/nChxJAtHHTLbtVdD25W6ogM7bgkv1xCjClU5w33Hb28dBG435FLQ==
dependencies:
- autoprefixer "^9.2.1"
- browserslist "^4.3.1"
- caniuse-lite "^1.0.30000893"
- cssdb "^3.2.1"
+ autoprefixer "^9.3.1"
+ browserslist "^4.3.4"
+ caniuse-lite "^1.0.30000899"
+ cssdb "^4.1.0"
postcss "^7.0.5"
postcss-attribute-case-insensitive "^4.0.0"
postcss-color-functional-notation "^2.0.1"
@@ -8529,6 +8544,7 @@ postcss-preset-env@^6.2.0:
postcss-custom-properties "^8.0.8"
postcss-custom-selectors "^5.1.2"
postcss-dir-pseudo-class "^5.0.0"
+ postcss-double-position-gradients "^1.0.0"
postcss-env-function "^2.0.2"
postcss-focus-visible "^4.0.0"
postcss-focus-within "^3.0.0"
From 4503d42d5423ef544dae8272ca6d177b10524f5e Mon Sep 17 00:00:00 2001
From: Jonas Galvez
Date: Mon, 29 Oct 2018 19:16:16 -0300
Subject: [PATCH 070/149] refactor(cli): cleanups and improvements (#4222)
---
packages/cli/src/command.js | 78 ++++++------
packages/cli/src/commands/build.js | 113 +++++++++++-------
packages/cli/src/commands/dev.js | 107 +++++++++--------
packages/cli/src/commands/generate.js | 45 ++++---
packages/cli/src/commands/start.js | 77 ++++++------
packages/cli/src/index.js | 2 +-
packages/cli/src/options.js | 101 ----------------
packages/cli/src/options/common.js | 27 +++++
packages/cli/src/options/index.js | 2 +
packages/cli/src/options/server.js | 29 +++++
packages/cli/src/run.js | 5 +-
packages/cli/src/utils.js | 4 +-
.../unit/__snapshots__/command.test.js.snap | 23 ++++
packages/cli/test/unit/build.test.js | 25 ++--
packages/cli/test/unit/cli.test.js | 10 +-
packages/cli/test/unit/command.test.js | 66 ++++------
packages/cli/test/unit/dev.test.js | 23 ++--
packages/cli/test/unit/generate.test.js | 25 ++--
packages/cli/test/unit/start.test.js | 20 ++--
packages/cli/test/unit/utils.test.js | 4 +-
packages/cli/test/utils/index.js | 1 +
21 files changed, 391 insertions(+), 396 deletions(-)
delete mode 100644 packages/cli/src/options.js
create mode 100644 packages/cli/src/options/common.js
create mode 100644 packages/cli/src/options/index.js
create mode 100644 packages/cli/src/options/server.js
create mode 100644 packages/cli/test/unit/__snapshots__/command.test.js.snap
diff --git a/packages/cli/src/command.js b/packages/cli/src/command.js
index fbc9552871..d1908f46ac 100644
--- a/packages/cli/src/command.js
+++ b/packages/cli/src/command.js
@@ -1,19 +1,26 @@
import parseArgs from 'minimist'
-import wrapAnsi from 'wrap-ansi'
import { name, version } from '../package.json'
-import { loadNuxtConfig, indent, indentLines, foldLines } from './utils'
-import { options as Options, defaultOptions as DefaultOptions } from './options'
+import { loadNuxtConfig, indent, foldLines } from './utils'
import * as imports from './imports'
-const startSpaces = 6
+const startSpaces = 2
const optionSpaces = 2
const maxCharsPerLine = 80
export default class NuxtCommand {
- constructor({ description, usage, options } = {}) {
+ constructor({ name, description, usage, options, run } = {}) {
+ this.name = name || ''
this.description = description || ''
this.usage = usage || ''
- this.options = Array.from(new Set((options || []).concat(DefaultOptions)))
+ this.options = Object.assign({}, options)
+ this._run = run
+ }
+
+ static from(options) {
+ if (options instanceof NuxtCommand) {
+ return options
+ }
+ return new NuxtCommand(options)
}
_getMinimistOptions() {
@@ -24,8 +31,8 @@ export default class NuxtCommand {
default: {}
}
- for (const name of this.options) {
- const option = Options[name]
+ for (const name of Object.keys(this.options)) {
+ const option = this.options[name]
if (option.alias) {
minimistOptions.alias[option.alias] = name
@@ -54,13 +61,17 @@ export default class NuxtCommand {
return argv
}
+ run() {
+ return this._run(this)
+ }
+
async getNuxtConfig(argv, extraOptions) {
const config = await loadNuxtConfig(argv)
const options = Object.assign(config, extraOptions || {})
- for (const name of this.options) {
- if (Options[name].handle) {
- Options[name].handle(options, argv)
+ for (const name of Object.keys(this.options)) {
+ if (this.options[name].prepare) {
+ this.options[name].prepare(this, options, argv)
}
}
@@ -86,38 +97,37 @@ export default class NuxtCommand {
_getHelp() {
const options = []
-
let maxOptionLength = 0
- // For consistency Options determines order
- for (const name in Options) {
- const option = Options[name]
- if (this.options.includes(name)) {
- let optionHelp = '--'
- optionHelp += option.type === 'boolean' && option.default ? 'no-' : ''
- optionHelp += name
- if (option.alias) {
- optionHelp += `, -${option.alias}`
- }
- maxOptionLength = Math.max(maxOptionLength, optionHelp.length)
- options.push([ optionHelp, option.description ])
+ for (const name in this.options) {
+ const option = this.options[name]
+
+ let optionHelp = '--'
+ optionHelp += option.type === 'boolean' && option.default ? 'no-' : ''
+ optionHelp += name
+ if (option.alias) {
+ optionHelp += `, -${option.alias}`
}
+
+ maxOptionLength = Math.max(maxOptionLength, optionHelp.length)
+ options.push([ optionHelp, option.description ])
}
- const optionStr = options.map(([option, description]) => {
- const line = option +
- indent(maxOptionLength + optionSpaces - option.length) +
- wrapAnsi(description, maxCharsPerLine - startSpaces - maxOptionLength - optionSpaces)
- return indentLines(line, startSpaces + maxOptionLength + optionSpaces, startSpaces)
+ const _opts = options.map(([option, description]) => {
+ const i = indent(maxOptionLength + optionSpaces - option.length)
+ return foldLines(
+ option + i + description,
+ maxCharsPerLine,
+ startSpaces + maxOptionLength + optionSpaces * 2,
+ startSpaces + optionSpaces
+ )
}).join('\n')
+ const usage = foldLines(`Usage: nuxt ${this.usage} [options]`, maxCharsPerLine, startSpaces)
const description = foldLines(this.description, maxCharsPerLine, startSpaces)
+ const opts = foldLines(`Options:`, maxCharsPerLine, startSpaces) + '\n\n' + _opts
- return `
- Description\n${description}
- Usage
- $ nuxt ${this.usage}
- Options\n${optionStr}\n\n`
+ return `${usage}\n\n${description}\n\n${opts}\n\n`
}
showVersion() {
diff --git a/packages/cli/src/commands/build.js b/packages/cli/src/commands/build.js
index 2868b81ab8..c55e45b0a0 100644
--- a/packages/cli/src/commands/build.js
+++ b/packages/cli/src/commands/build.js
@@ -1,46 +1,77 @@
import consola from 'consola'
-import NuxtCommand from '../command'
+import { common } from '../options'
-export default async function build() {
- const nuxtCmd = new NuxtCommand({
- description: 'Compiles the application for production deployment',
- usage: 'build ',
- options: [ 'analyze', 'quiet' ]
- })
-
- const argv = nuxtCmd.getArgv()
-
- // Create production build when calling `nuxt build` (dev: false)
- const nuxt = await nuxtCmd.getNuxt(
- await nuxtCmd.getNuxtConfig(argv, { dev: false })
- )
-
- // Setup hooks
- nuxt.hook('error', err => consola.fatal(err))
-
- let builderOrGenerator
- if (nuxt.options.mode !== 'spa' || argv.generate === false) {
- // Build only
- builderOrGenerator = (await nuxtCmd.getBuilder(nuxt)).build()
- } else {
- // Build + Generate for static deployment
- builderOrGenerator = (await nuxtCmd.getGenerator(nuxt)).generate({
- build: true
- })
- }
-
- return builderOrGenerator
- .then(() => {
- // In analyze mode wait for plugin
- // emitting assets and opening browser
- if (
- nuxt.options.build.analyze === true ||
- typeof nuxt.options.build.analyze === 'object'
- ) {
- return
+export default {
+ name: 'build',
+ description: 'Compiles the application for production deployment',
+ usage: 'build ',
+ options: {
+ ...common,
+ analyze: {
+ alias: 'a',
+ type: 'boolean',
+ description: 'Launch webpack-bundle-analyzer to optimize your bundles',
+ prepare(cmd, options, argv) {
+ // Analyze option
+ options.build = options.build || {}
+ if (argv.analyze && typeof options.build.analyze !== 'object') {
+ options.build.analyze = true
+ }
}
+ },
+ generate: {
+ type: 'boolean',
+ default: true,
+ description: 'Don\'t generate static version for SPA mode (useful for nuxt start)'
+ },
+ quiet: {
+ alias: 'q',
+ type: 'boolean',
+ description: 'Disable output except for errors',
+ handle(options, argv) {
+ // Silence output when using --quiet
+ options.build = options.build || {}
+ if (argv.quiet) {
+ options.build.quiet = !!argv.quiet
+ }
+ }
+ }
+ },
+ async run(nuxtCmd) {
+ const argv = nuxtCmd.getArgv()
- process.exit(0)
- })
- .catch(err => consola.fatal(err))
+ // Create production build when calling `nuxt build` (dev: false)
+ const nuxt = await nuxtCmd.getNuxt(
+ await nuxtCmd.getNuxtConfig(argv, { dev: false })
+ )
+
+ // Setup hooks
+ nuxt.hook('error', err => consola.fatal(err))
+
+ let builderOrGenerator
+ if (nuxt.options.mode !== 'spa' || argv.generate === false) {
+ // Build only
+ builderOrGenerator = (await nuxtCmd.getBuilder(nuxt)).build()
+ } else {
+ // Build + Generate for static deployment
+ builderOrGenerator = (await nuxtCmd.getGenerator(nuxt)).generate({
+ build: true
+ })
+ }
+
+ return builderOrGenerator
+ .then(() => {
+ // In analyze mode wait for plugin
+ // emitting assets and opening browser
+ if (
+ nuxt.options.build.analyze === true ||
+ typeof nuxt.options.build.analyze === 'object'
+ ) {
+ return
+ }
+
+ process.exit(0)
+ })
+ .catch(err => consola.fatal(err))
+ }
}
diff --git a/packages/cli/src/commands/dev.js b/packages/cli/src/commands/dev.js
index d6e0f23772..c6c81594d9 100644
--- a/packages/cli/src/commands/dev.js
+++ b/packages/cli/src/commands/dev.js
@@ -1,59 +1,62 @@
import consola from 'consola'
-import NuxtCommand from '../command'
+import { common, server } from '../options'
-export default async function dev() {
- const nuxtCmd = new NuxtCommand({
- description: 'Start the application in development mode (e.g. hot-code reloading, error reporting)',
- usage: 'dev -p -H ',
- options: [ 'hostname', 'port' ]
- })
+export default {
+ name: 'dev',
+ description: 'Start the application in development mode (e.g. hot-code reloading, error reporting)',
+ usage: 'dev ',
+ options: {
+ ...common,
+ ...server
+ },
+ async run(cmd) {
+ const argv = cmd.getArgv()
- const argv = nuxtCmd.getArgv()
-
- const errorHandler = (err, instance) => {
- instance && instance.builder.watchServer()
- consola.error(err)
- }
-
- // Start dev
- async function startDev(oldInstance) {
- let nuxt, builder
-
- try {
- nuxt = await nuxtCmd.getNuxt(
- await nuxtCmd.getNuxtConfig(argv, { dev: true })
- )
- builder = await nuxtCmd.getBuilder(nuxt)
- nuxt.hook('watch:fileChanged', async (builder, fname) => {
- consola.debug(`[${fname}] changed, Rebuilding the app...`)
- await startDev({ nuxt: builder.nuxt, builder })
- })
- } catch (err) {
- return errorHandler(err, oldInstance)
+ const errorHandler = (err, instance) => {
+ instance && instance.builder.watchServer()
+ consola.error(err)
}
- return (
- Promise.resolve()
- .then(() => oldInstance && oldInstance.nuxt.clearHook('watch:fileChanged'))
- .then(() => oldInstance && oldInstance.builder.unwatch())
- // Start build
- .then(() => builder.build())
- // Close old nuxt no matter if build successfully
- .catch((err) => {
- oldInstance && oldInstance.nuxt.close()
- // Jump to errorHandler
- throw err
- })
- .then(() => oldInstance && oldInstance.nuxt.close())
- // Start listening
- .then(() => nuxt.listen())
- // Show ready message first time, others will be shown through WebpackBar
- .then(() => !oldInstance && nuxt.showReady(false))
- .then(() => builder.watchServer())
- // Handle errors
- .catch(err => errorHandler(err, { builder, nuxt }))
- )
- }
+ // Start dev
+ async function startDev(oldInstance) {
+ let nuxt, builder
- await startDev()
+ try {
+ nuxt = await cmd.getNuxt(
+ await cmd.getNuxtConfig(argv, { dev: true })
+ )
+ builder = await cmd.getBuilder(nuxt)
+ nuxt.hook('watch:fileChanged', async (builder, fname) => {
+ consola.debug(`[${fname}] changed, Rebuilding the app...`)
+ await startDev({ nuxt: builder.nuxt, builder })
+ })
+ } catch (err) {
+ return errorHandler(err, oldInstance)
+ }
+
+ return (
+ Promise.resolve()
+ .then(() => oldInstance && oldInstance.nuxt.clearHook('watch:fileChanged'))
+ .then(() => oldInstance && oldInstance.builder.unwatch())
+ // Start build
+ .then(() => builder.build())
+ // Close old nuxt no matter if build successfully
+ .catch((err) => {
+ oldInstance && oldInstance.nuxt.close()
+ // Jump to errorHandler
+ throw err
+ })
+ .then(() => oldInstance && oldInstance.nuxt.close())
+ // Start listening
+ .then(() => nuxt.listen())
+ // Show ready message first time, others will be shown through WebpackBar
+ .then(() => !oldInstance && nuxt.showReady(false))
+ .then(() => builder.watchServer())
+ // Handle errors
+ .catch(err => errorHandler(err, { builder, nuxt }))
+ )
+ }
+
+ await startDev()
+ }
}
diff --git a/packages/cli/src/commands/generate.js b/packages/cli/src/commands/generate.js
index a2d79697ed..c2e406f96c 100644
--- a/packages/cli/src/commands/generate.js
+++ b/packages/cli/src/commands/generate.js
@@ -1,25 +1,32 @@
import consola from 'consola'
-import NuxtCommand from '../command'
+import { common } from '../options'
-export default async function generate() {
- const nuxtCmd = new NuxtCommand({
- description: 'Generate a static web application (server-rendered)',
- usage: 'generate ',
- options: [ 'build' ]
- })
+export default {
+ name: 'generate',
+ description: 'Generate a static web application (server-rendered)',
+ usage: 'generate ',
+ options: {
+ ...common,
+ build: {
+ type: 'boolean',
+ default: true,
+ description: 'Only generate pages for dynamic routes. Nuxt has to be built once before using this option'
+ }
+ },
+ async run(cmd) {
+ const argv = cmd.getArgv()
- const argv = nuxtCmd.getArgv()
-
- const generator = await nuxtCmd.getGenerator(
- await nuxtCmd.getNuxt(
- await nuxtCmd.getNuxtConfig(argv, { dev: false })
+ const generator = await cmd.getGenerator(
+ await cmd.getNuxt(
+ await cmd.getNuxtConfig(argv, { dev: false })
+ )
)
- )
- return generator.generate({
- init: true,
- build: argv.build
- }).then(() => {
- process.exit(0)
- }).catch(err => consola.fatal(err))
+ return generator.generate({
+ init: true,
+ build: argv.build
+ }).then(() => {
+ process.exit(0)
+ }).catch(err => consola.fatal(err))
+ }
}
diff --git a/packages/cli/src/commands/start.js b/packages/cli/src/commands/start.js
index 2498a06a87..e08e08ffcc 100644
--- a/packages/cli/src/commands/start.js
+++ b/packages/cli/src/commands/start.js
@@ -1,49 +1,52 @@
import fs from 'fs'
import path from 'path'
import consola from 'consola'
-import NuxtCommand from '../command'
+import { common, server } from '../options'
-export default async function start() {
- const nuxtCmd = new NuxtCommand({
- description: 'Start the application in production mode (the application should be compiled with `nuxt build` first)',
- usage: 'start -p -H ',
- options: [ 'hostname', 'port', 'unix-socket' ]
- })
+export default {
+ name: 'start',
+ description: 'Start the application in production mode (the application should be compiled with `nuxt build` first)',
+ usage: 'start ',
+ options: {
+ ...common,
+ ...server
+ },
+ async run(cmd) {
+ const argv = cmd.getArgv()
- const argv = nuxtCmd.getArgv()
-
- // Create production build when calling `nuxt build`
- const nuxt = await nuxtCmd.getNuxt(
- await nuxtCmd.getNuxtConfig(argv, { dev: false })
- )
-
- // Setup hooks
- nuxt.hook('error', err => consola.fatal(err))
-
- // Check if project is built for production
- const distDir = path.resolve(
- nuxt.options.rootDir,
- nuxt.options.buildDir || '.nuxt',
- 'dist',
- 'server'
- )
- if (!fs.existsSync(distDir)) {
- consola.fatal(
- 'No build files found, please run `nuxt build` before launching `nuxt start`'
+ // Create production build when calling `nuxt build`
+ const nuxt = await cmd.getNuxt(
+ await cmd.getNuxtConfig(argv, { dev: false })
)
- }
- // Check if SSR Bundle is required
- if (nuxt.options.render.ssr === true) {
- const ssrBundlePath = path.resolve(distDir, 'server-bundle.json')
- if (!fs.existsSync(ssrBundlePath)) {
+ // Setup hooks
+ nuxt.hook('error', err => consola.fatal(err))
+
+ // Check if project is built for production
+ const distDir = path.resolve(
+ nuxt.options.rootDir,
+ nuxt.options.buildDir || '.nuxt',
+ 'dist',
+ 'server'
+ )
+ if (!fs.existsSync(distDir)) {
consola.fatal(
- 'No SSR build! Please start with `nuxt start --spa` or build using `nuxt build --universal`'
+ 'No build files found, please run `nuxt build` before launching `nuxt start`'
)
}
- }
- return nuxt.listen().then(() => {
- nuxt.showReady(false)
- })
+ // Check if SSR Bundle is required
+ if (nuxt.options.render.ssr === true) {
+ const ssrBundlePath = path.resolve(distDir, 'server-bundle.json')
+ if (!fs.existsSync(ssrBundlePath)) {
+ consola.fatal(
+ 'No SSR build! Please start with `nuxt start --spa` or build using `nuxt build --universal`'
+ )
+ }
+ }
+
+ return nuxt.listen().then(() => {
+ nuxt.showReady(false)
+ })
+ }
}
diff --git a/packages/cli/src/index.js b/packages/cli/src/index.js
index 5c39b23a97..3ee655ce7c 100644
--- a/packages/cli/src/index.js
+++ b/packages/cli/src/index.js
@@ -4,7 +4,7 @@ import * as _imports from './imports'
export const commands = _commands
export const imports = _imports
+export { default as NuxtCommand } from './command'
export { default as setup } from './setup'
export { default as run } from './run'
-
export { loadNuxtConfig } from './utils'
diff --git a/packages/cli/src/options.js b/packages/cli/src/options.js
deleted file mode 100644
index 2afd911650..0000000000
--- a/packages/cli/src/options.js
+++ /dev/null
@@ -1,101 +0,0 @@
-import consola from 'consola'
-
-export const defaultOptions = [
- 'spa',
- 'universal',
- 'config-file',
- 'version',
- 'help'
-]
-
-export const options = {
- port: {
- alias: 'p',
- type: 'string',
- description: 'Port number on which to start the application',
- handle(options, argv) {
- if (argv.port) {
- options.server.port = +argv.port
- }
- }
- },
- hostname: {
- alias: 'H',
- type: 'string',
- description: 'Hostname on which to start the application',
- handle(options, argv) {
- if (argv.hostname === '') {
- consola.fatal('Provided hostname argument has no value')
- }
- }
- },
- 'unix-socket': {
- alias: 'n',
- type: 'string',
- description: 'Path to a UNIX socket'
- },
- analyze: {
- alias: 'a',
- type: 'boolean',
- description: 'Launch webpack-bundle-analyzer to optimize your bundles',
- handle(options, argv) {
- // Analyze option
- options.build = options.build || {}
- if (argv.analyze && typeof options.build.analyze !== 'object') {
- options.build.analyze = true
- }
- }
- },
- build: {
- type: 'boolean',
- default: true,
- description: 'Only generate pages for dynamic routes. Nuxt has to be built once before using this option'
- },
- generate: {
- type: 'boolean',
- default: true,
- description: 'Don\'t generate static version for SPA mode (useful for nuxt start)'
- },
- spa: {
- alias: 's',
- type: 'boolean',
- description: 'Launch in SPA mode'
- },
- universal: {
- alias: 'u',
- type: 'boolean',
- description: 'Launch in Universal mode (default)'
- },
- 'config-file': {
- alias: 'c',
- type: 'string',
- default: 'nuxt.config.js',
- description: 'Path to Nuxt.js config file (default: nuxt.config.js)'
- },
- quiet: {
- alias: 'q',
- type: 'boolean',
- description: 'Disable output except for errors',
- handle(options, argv) {
- // Silence output when using --quiet
- options.build = options.build || {}
- if (argv.quiet) {
- options.build.quiet = !!argv.quiet
- }
- }
- },
- verbose: {
- alias: 'v',
- type: 'boolean',
- description: 'Show debug information'
- },
- version: {
- type: 'boolean',
- description: 'Display the Nuxt version'
- },
- help: {
- alias: 'h',
- type: 'boolean',
- description: 'Display this message'
- }
-}
diff --git a/packages/cli/src/options/common.js b/packages/cli/src/options/common.js
new file mode 100644
index 0000000000..a1565a0950
--- /dev/null
+++ b/packages/cli/src/options/common.js
@@ -0,0 +1,27 @@
+export default {
+ spa: {
+ alias: 's',
+ type: 'boolean',
+ description: 'Launch in SPA mode'
+ },
+ universal: {
+ alias: 'u',
+ type: 'boolean',
+ description: 'Launch in Universal mode (default)'
+ },
+ 'config-file': {
+ alias: 'c',
+ type: 'string',
+ default: 'nuxt.config.js',
+ description: 'Path to Nuxt.js config file (default: nuxt.config.js)'
+ },
+ version: {
+ type: 'boolean',
+ description: 'Display the Nuxt version'
+ },
+ help: {
+ alias: 'h',
+ type: 'boolean',
+ description: 'Display this message'
+ }
+}
diff --git a/packages/cli/src/options/index.js b/packages/cli/src/options/index.js
new file mode 100644
index 0000000000..347fa2c72a
--- /dev/null
+++ b/packages/cli/src/options/index.js
@@ -0,0 +1,2 @@
+export { default as common } from './common'
+export { default as server } from './server'
diff --git a/packages/cli/src/options/server.js b/packages/cli/src/options/server.js
new file mode 100644
index 0000000000..91aad77c68
--- /dev/null
+++ b/packages/cli/src/options/server.js
@@ -0,0 +1,29 @@
+import consola from 'consola'
+
+export default {
+ port: {
+ alias: 'p',
+ type: 'string',
+ description: 'Port number on which to start the application',
+ prepare(cmd, options, argv) {
+ if (argv.port) {
+ options.server.port = +argv.port
+ }
+ }
+ },
+ hostname: {
+ alias: 'H',
+ type: 'string',
+ description: 'Hostname on which to start the application',
+ prepare(cmd, options, argv) {
+ if (argv.hostname === '') {
+ consola.fatal('Provided hostname argument has no value')
+ }
+ }
+ },
+ 'unix-socket': {
+ alias: 'n',
+ type: 'string',
+ description: 'Path to a UNIX socket'
+ }
+}
diff --git a/packages/cli/src/run.js b/packages/cli/src/run.js
index 97c322b53b..97976d71b6 100644
--- a/packages/cli/src/run.js
+++ b/packages/cli/src/run.js
@@ -1,4 +1,5 @@
import consola from 'consola'
+import NuxtCommand from './command'
import * as commands from './commands'
import setup from './setup'
@@ -26,7 +27,9 @@ export default function run() {
})
return commands[cmd]() // eslint-disable-line import/namespace
- .then(m => m.default())
+ .then(m => m.default)
+ .then(options => NuxtCommand.from(options))
+ .then(command => command.run())
.catch((error) => {
consola.fatal(error)
})
diff --git a/packages/cli/src/utils.js b/packages/cli/src/utils.js
index 5810e4d792..6b609005bf 100644
--- a/packages/cli/src/utils.js
+++ b/packages/cli/src/utils.js
@@ -76,11 +76,11 @@ export function indentLines(string, spaces, firstLineSpaces) {
}
if (lines.length) {
const i = indent(spaces)
- s += '\n' + lines.map(l => i + l.trim()).join('\n')
+ s += '\n' + lines.map(l => i + l).join('\n')
}
return s
}
export function foldLines(string, maxCharsPerLine, spaces, firstLineSpaces) {
- return indentLines(wrapAnsi(string, maxCharsPerLine), spaces, firstLineSpaces)
+ return indentLines(wrapAnsi(string, maxCharsPerLine, { trim: false }), spaces, firstLineSpaces)
}
diff --git a/packages/cli/test/unit/__snapshots__/command.test.js.snap b/packages/cli/test/unit/__snapshots__/command.test.js.snap
new file mode 100644
index 0000000000..20ef9648a3
--- /dev/null
+++ b/packages/cli/test/unit/__snapshots__/command.test.js.snap
@@ -0,0 +1,23 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`cli/command builds help text 1`] = `
+" Usage: nuxt this is how you do it [options]
+
+ a very long description that is longer than 80 chars and should wrap to the next
+ line while keeping indentation
+
+ Options:
+
+ --spa, -s Launch in SPA mode
+ --universal, -u Launch in Universal mode (default)
+ --config-file, -c Path to Nuxt.js config file (default: nuxt.config.js)
+ --version Display the Nuxt version
+ --help, -h Display this message
+ --port, -p Port number on which to start the application
+ --hostname, -H Hostname on which to start the application
+ --unix-socket, -n Path to a UNIX socket
+ --foo very long option that is longer than 80 chars and should wrap
+ to the next line while keeping indentation
+
+"
+`;
diff --git a/packages/cli/test/unit/build.test.js b/packages/cli/test/unit/build.test.js
index 5c501804ec..1ebc3ea7b4 100644
--- a/packages/cli/test/unit/build.test.js
+++ b/packages/cli/test/unit/build.test.js
@@ -1,25 +1,18 @@
-import { consola, mockGetNuxt, mockGetBuilder, mockGetGenerator } from '../utils'
+import { consola, mockGetNuxt, mockGetBuilder, mockGetGenerator, NuxtCommand } from '../utils'
describe('build', () => {
let build
beforeAll(async () => {
- build = await import('../../src/commands/build')
- build = build.default
-
+ build = await import('../../src/commands/build').then(m => m.default)
jest.spyOn(process, 'exit').mockImplementation(code => code)
})
- afterAll(() => {
- process.exit.mockRestore()
- })
+ afterAll(() => process.exit.mockRestore())
+ afterEach(() => jest.resetAllMocks())
- afterEach(() => {
- jest.resetAllMocks()
- })
-
- test('is function', () => {
- expect(typeof build).toBe('function')
+ test('has run function', () => {
+ expect(typeof build.run).toBe('function')
})
test('builds on universal mode', async () => {
@@ -31,7 +24,7 @@ describe('build', () => {
})
const builder = mockGetBuilder(Promise.resolve())
- await build()
+ await NuxtCommand.from(build).run()
expect(builder).toHaveBeenCalled()
})
@@ -45,7 +38,7 @@ describe('build', () => {
})
const generate = mockGetGenerator(Promise.resolve())
- await build()
+ await NuxtCommand.from(build).run()
expect(generate).toHaveBeenCalled()
expect(process.exit).toHaveBeenCalled()
@@ -55,7 +48,7 @@ describe('build', () => {
mockGetNuxt({ mode: 'universal' })
mockGetBuilder(Promise.reject(new Error('Builder Error')))
- await build()
+ await NuxtCommand.from(build).run()
expect(consola.fatal).toHaveBeenCalledWith(new Error('Builder Error'))
})
diff --git a/packages/cli/test/unit/cli.test.js b/packages/cli/test/unit/cli.test.js
index fa283776bd..8f597e7ba4 100644
--- a/packages/cli/test/unit/cli.test.js
+++ b/packages/cli/test/unit/cli.test.js
@@ -10,9 +10,7 @@ const readDir = promisify(readdir)
jest.mock('../../src/commands')
describe('cli', () => {
- afterEach(() => {
- jest.resetAllMocks()
- })
+ afterEach(() => jest.resetAllMocks())
test('exports for all commands defined', async () => {
const cmds = await readDir(resolve(__dirname, '..', '..', 'src', 'commands'))
@@ -32,12 +30,14 @@ describe('cli', () => {
test('calls expected method', async () => {
const argv = process.argv
process.argv = ['', '', 'dev']
- const defaultExport = jest.fn().mockImplementation(() => Promise.resolve())
+ const defaultExport = {
+ run: jest.fn().mockImplementation(() => Promise.resolve())
+ }
commands.dev.mockImplementationOnce(() => Promise.resolve({ default: defaultExport }))
await run()
- expect(defaultExport).toHaveBeenCalled()
+ expect(defaultExport.run).toHaveBeenCalled()
process.argv = argv
})
diff --git a/packages/cli/test/unit/command.test.js b/packages/cli/test/unit/command.test.js
index cb0c05af7e..07cbec1058 100644
--- a/packages/cli/test/unit/command.test.js
+++ b/packages/cli/test/unit/command.test.js
@@ -1,39 +1,31 @@
import Command from '../../src/command'
-import { options as Options } from '../../src/options'
+import { common, server } from '../../src/options'
import { consola } from '../utils'
jest.mock('@nuxt/core')
jest.mock('@nuxt/builder')
jest.mock('@nuxt/generator')
+const allOptions = {
+ ...common,
+ ...server
+}
+
describe('cli/command', () => {
- beforeEach(() => {
- jest.restoreAllMocks()
- })
-
- test('adds default options', () => {
- const cmd = new Command()
-
- expect(cmd.options.length).not.toBe(0)
- })
+ beforeEach(() => jest.restoreAllMocks())
test('builds minimist options', () => {
- const cmd = new Command({
- options: Object.keys(Options)
- })
-
+ const cmd = new Command({ options: allOptions })
const minimistOptions = cmd._getMinimistOptions()
expect(minimistOptions.string.length).toBe(4)
- expect(minimistOptions.boolean.length).toBe(9)
+ expect(minimistOptions.boolean.length).toBe(4)
expect(minimistOptions.alias.c).toBe('config-file')
- expect(minimistOptions.default.c).toBe(Options['config-file'].default)
+ expect(minimistOptions.default.c).toBe(common['config-file'].default)
})
test('parses args', () => {
- const cmd = new Command({
- options: Object.keys(Options)
- })
+ const cmd = new Command({ options: { ...common, ...server } })
let args = ['-c', 'test-file', '-s', '-p', '3001']
let argv = cmd.getArgv(args)
@@ -41,7 +33,6 @@ describe('cli/command', () => {
expect(argv['config-file']).toBe(args[1])
expect(argv.spa).toBe(true)
expect(argv.universal).toBe(false)
- expect(argv.build).toBe(true)
expect(argv.port).toBe('3001')
args = ['--no-build']
@@ -61,7 +52,7 @@ describe('cli/command', () => {
})
test('prints help automatically', () => {
- const cmd = new Command()
+ const cmd = new Command({ options: allOptions })
cmd.showHelp = jest.fn()
const args = ['-h']
@@ -71,9 +62,7 @@ describe('cli/command', () => {
})
test('returns nuxt config', async () => {
- const cmd = new Command({
- options: Object.keys(Options)
- })
+ const cmd = new Command({ options: allOptions })
const args = ['-c', 'test-file', '-a', '-p', '3001', '-q', '-H']
const argv = cmd.getArgv(args)
@@ -83,8 +72,6 @@ describe('cli/command', () => {
expect(options.testOption).toBe(true)
expect(options.server.port).toBe(3001)
- expect(options.build.quiet).toBe(true)
- expect(options.build.analyze).toBe(true)
expect(consola.fatal).toHaveBeenCalledWith('Provided hostname argument has no value') // hostname check
})
@@ -117,26 +104,17 @@ describe('cli/command', () => {
description: 'a very long description that is longer than 80 chars and ' +
'should wrap to the next line while keeping indentation',
usage: 'this is how you do it',
- options: ['build']
+ options: {
+ ...allOptions,
+ foo: {
+ type: 'boolean',
+ description: 'very long option that is longer than 80 chars and ' +
+ 'should wrap to the next line while keeping indentation'
+ }
+ }
})
- const expectedText = `
- Description
- a very long description that is longer than 80 chars and should wrap to the next
- line while keeping indentation
- Usage
- $ nuxt this is how you do it
- Options
- --no-build Only generate pages for dynamic routes. Nuxt has to be
- built once before using this option
- --spa, -s Launch in SPA mode
- --universal, -u Launch in Universal mode (default)
- --config-file, -c Path to Nuxt.js config file (default: nuxt.config.js)
- --version Display the Nuxt version
- --help, -h Display this message
-
-`
- expect(cmd._getHelp()).toBe(expectedText)
+ expect(cmd._getHelp()).toMatchSnapshot()
})
test('show version prints to stdout and exits', () => {
diff --git a/packages/cli/test/unit/dev.test.js b/packages/cli/test/unit/dev.test.js
index 30a623b350..dad9e2011b 100644
--- a/packages/cli/test/unit/dev.test.js
+++ b/packages/cli/test/unit/dev.test.js
@@ -1,26 +1,23 @@
-import { consola, mockNuxt, mockBuilder, mockGetNuxtConfig } from '../utils'
+import { consola, mockNuxt, mockBuilder, mockGetNuxtConfig, NuxtCommand } from '../utils'
describe('dev', () => {
let dev
beforeAll(async () => {
- dev = await import('../../src/commands/dev')
- dev = dev.default
+ dev = await import('../../src/commands/dev').then(m => m.default)
})
- afterEach(() => {
- jest.clearAllMocks()
- })
+ afterEach(() => jest.clearAllMocks())
- test('is function', () => {
- expect(typeof dev).toBe('function')
+ test('has run function', () => {
+ expect(typeof dev.run).toBe('function')
})
test('reloads on fileChanged hook', async () => {
const Nuxt = mockNuxt()
const Builder = mockBuilder()
- await dev()
+ await NuxtCommand.from(dev).run()
expect(consola.error).not.toHaveBeenCalled()
@@ -51,7 +48,7 @@ describe('dev', () => {
const Nuxt = mockNuxt()
const Builder = mockBuilder()
- await dev()
+ await NuxtCommand.from(dev).run()
jest.clearAllMocks()
// Test error on second build so we cover oldInstance stuff
@@ -68,7 +65,7 @@ describe('dev', () => {
const Nuxt = mockNuxt()
const Builder = mockBuilder()
- await dev()
+ await NuxtCommand.from(dev).run()
jest.clearAllMocks()
const builder = new Builder()
@@ -84,7 +81,7 @@ describe('dev', () => {
const Nuxt = mockNuxt()
const Builder = mockBuilder()
- await dev()
+ await NuxtCommand.from(dev).run()
jest.clearAllMocks()
mockGetNuxtConfig().mockImplementationOnce(() => {
@@ -106,7 +103,7 @@ describe('dev', () => {
})
mockBuilder()
- await dev()
+ await NuxtCommand.from(dev).run()
expect(consola.error).toHaveBeenCalledWith(new Error('Listen Error'))
})
diff --git a/packages/cli/test/unit/generate.test.js b/packages/cli/test/unit/generate.test.js
index 42b8f0d141..4e4cd9bfee 100644
--- a/packages/cli/test/unit/generate.test.js
+++ b/packages/cli/test/unit/generate.test.js
@@ -1,33 +1,26 @@
-import { consola, mockGetNuxt, mockGetGenerator } from '../utils'
+import { consola, mockGetNuxt, mockGetGenerator, NuxtCommand } from '../utils'
import Command from '../../src/command'
describe('generate', () => {
let generate
beforeAll(async () => {
- generate = await import('../../src/commands/generate')
- generate = generate.default
-
+ generate = await import('../../src/commands/generate').then(m => m.default)
jest.spyOn(process, 'exit').mockImplementation(code => code)
})
- afterAll(() => {
- process.exit.mockRestore()
- })
+ afterAll(() => process.exit.mockRestore())
+ afterEach(() => jest.resetAllMocks())
- afterEach(() => {
- jest.resetAllMocks()
- })
-
- test('is function', () => {
- expect(typeof generate).toBe('function')
+ test('has run function', () => {
+ expect(typeof generate.run).toBe('function')
})
test('builds by default', async () => {
mockGetNuxt()
const generator = mockGetGenerator(Promise.resolve())
- await generate()
+ await NuxtCommand.from(generate).run()
expect(generator).toHaveBeenCalled()
expect(generator.mock.calls[0][0].build).toBe(true)
@@ -46,7 +39,7 @@ describe('generate', () => {
})
const generator = mockGetGenerator(Promise.resolve())
- await generate()
+ await NuxtCommand.from(generate).run()
expect(generator).toHaveBeenCalled()
expect(generator.mock.calls[0][0].build).toBe(false)
@@ -57,7 +50,7 @@ describe('generate', () => {
mockGetNuxt()
mockGetGenerator(Promise.reject(new Error('Generator Error')))
- await generate()
+ await NuxtCommand.from(generate).run()
expect(consola.fatal).toHaveBeenCalledWith(new Error('Generator Error'))
})
diff --git a/packages/cli/test/unit/start.test.js b/packages/cli/test/unit/start.test.js
index 876b50eb6b..4568ac0eca 100644
--- a/packages/cli/test/unit/start.test.js
+++ b/packages/cli/test/unit/start.test.js
@@ -1,29 +1,27 @@
import fs from 'fs'
-import { consola, mockGetNuxtStart, mockGetNuxtConfig } from '../utils'
+import { consola, mockGetNuxtStart, mockGetNuxtConfig, NuxtCommand } from '../utils'
describe('start', () => {
let start
beforeAll(async () => {
- start = await import('../../src/commands/start')
- start = start.default
+ start = await import('../../src/commands/start').then(m => m.default)
})
afterEach(() => {
if (fs.existsSync.mockRestore) {
fs.existsSync.mockRestore()
}
-
jest.resetAllMocks()
})
- test('is function', () => {
- expect(typeof start).toBe('function')
+ test('has run function', () => {
+ expect(typeof start.run).toBe('function')
})
test('starts listening and calls showReady', async () => {
const { listen, showReady } = mockGetNuxtStart()
- await start()
+ await NuxtCommand.from(start).run()
expect(listen).toHaveBeenCalled()
expect(showReady).toHaveBeenCalled()
@@ -34,7 +32,7 @@ describe('start', () => {
mockGetNuxtConfig()
jest.spyOn(fs, 'existsSync').mockImplementationOnce(() => true)
- await start()
+ await NuxtCommand.from(start).run()
expect(consola.fatal).not.toHaveBeenCalled()
})
@@ -43,7 +41,7 @@ describe('start', () => {
mockGetNuxtStart()
jest.spyOn(fs, 'existsSync').mockImplementationOnce(() => false)
- await start()
+ await NuxtCommand.from(start).run()
expect(consola.fatal).toHaveBeenCalledWith('No build files found, please run `nuxt build` before launching `nuxt start`')
})
@@ -53,7 +51,7 @@ describe('start', () => {
mockGetNuxtConfig()
jest.spyOn(fs, 'existsSync').mockImplementation(() => true)
- await start()
+ await NuxtCommand.from(start).run()
expect(consola.fatal).not.toHaveBeenCalled()
})
@@ -62,7 +60,7 @@ describe('start', () => {
mockGetNuxtStart(true)
jest.spyOn(fs, 'existsSync').mockImplementation(() => false)
- await start()
+ await NuxtCommand.from(start).run()
expect(consola.fatal).toHaveBeenCalledWith('No SSR build! Please start with `nuxt start --spa` or build using `nuxt build --universal`')
})
diff --git a/packages/cli/test/unit/utils.test.js b/packages/cli/test/unit/utils.test.js
index e7a5cd50e1..b1a1bf00c5 100644
--- a/packages/cli/test/unit/utils.test.js
+++ b/packages/cli/test/unit/utils.test.js
@@ -3,9 +3,7 @@ import { consola } from '../utils'
import * as utils from '../../src/utils'
describe('cli/utils', () => {
- afterEach(() => {
- jest.resetAllMocks()
- })
+ afterEach(() => jest.resetAllMocks())
test('loadNuxtConfig: defaults', async () => {
const argv = {
diff --git a/packages/cli/test/utils/index.js b/packages/cli/test/utils/index.js
index e31e09d6c0..ba9acd8c08 100644
--- a/packages/cli/test/utils/index.js
+++ b/packages/cli/test/utils/index.js
@@ -1,5 +1,6 @@
import consola from 'consola'
export * from './mocking'
+export { NuxtCommand } from '../../src'
jest.mock('consola')
From 39b558f59c0ecb5aa40bf709ca5dff83a151b20b Mon Sep 17 00:00:00 2001
From: Pooya Parsa
Date: Wed, 31 Oct 2018 00:12:53 +0330
Subject: [PATCH 071/149] refactor core into sub-packages (#4202)
---
.circleci/config.yml | 19 +-
.eslintignore | 16 +-
azure-pipelines.yml | 4 -
examples/with-ava/test/index.test.js | 6 +-
examples/with-sockets/io/index.js | 4 +-
jest.config.js | 19 +-
package.json | 4 +-
packages/builder/package.json | 2 +-
packages/builder/src/builder.js | 26 +-
.../src/build => builder/src}/context.js | 0
packages/cli/src/commands/dev.js | 4 +-
packages/cli/src/commands/start.js | 4 +-
packages/cli/src/utils.js | 8 +-
.../unit/__snapshots__/command.test.js.snap | 4 +-
packages/cli/test/unit/dev.test.js | 16 +-
packages/cli/test/unit/utils.test.js | 10 +-
packages/cli/test/utils/mocking.js | 12 +-
packages/common/src/hookable.js | 67 +++
packages/common/src/index.js | 3 +-
packages/common/src/utils.js | 38 +-
packages/config/package.json | 1 +
packages/config/src/config/_app.js | 52 ++
packages/config/src/config/_common.js | 80 +++
packages/config/src/config/build.js | 4 +-
packages/config/src/config/index.js | 143 +-----
packages/config/src/config/messages.js | 4 +-
packages/config/src/{ => config}/modes.js | 4 +-
packages/config/src/config/render.js | 4 +-
packages/config/src/config/router.js | 4 +-
packages/config/src/config/server.js | 2 +-
packages/config/src/index.js | 11 +-
packages/{common => config}/src/options.js | 31 +-
packages/core/package.json | 22 +-
packages/core/src/index.js | 2 +-
packages/core/src/nuxt.js | 201 +-------
packages/core/src/renderer.js | 484 ------------------
packages/generator/src/generator.js | 4 +-
packages/{app => server}/package.js | 0
packages/server/package.json | 29 ++
packages/server/src/context.js | 8 +
packages/server/src/index.js | 1 +
packages/server/src/jsdom.js | 75 +++
.../{core => server}/src/middleware/error.js | 29 +-
.../{core => server}/src/middleware/nuxt.js | 35 +-
packages/server/src/server.js | 276 ++++++++++
packages/vue-app/package.js | 3 +
packages/{app => vue-app}/package.json | 4 +-
packages/{app => vue-app}/src/index.js | 0
.../{app => vue-app}/template/.eslintignore | 0
packages/{app => vue-app}/template/App.js | 0
packages/{app => vue-app}/template/client.js | 0
.../template/components/no-ssr.js | 0
.../template/components/nuxt-child.js | 0
.../template/components/nuxt-error.vue | 0
.../template/components/nuxt-link.js | 0
.../template/components/nuxt-loading.vue | 0
.../template/components/nuxt.js | 0
packages/{app => vue-app}/template/empty.js | 0
packages/{app => vue-app}/template/index.js | 0
.../template/layouts/default.vue | 0
.../{app => vue-app}/template/middleware.js | 0
.../{app => vue-app}/template/pages/index.vue | 0
packages/{app => vue-app}/template/router.js | 0
packages/{app => vue-app}/template/server.js | 0
packages/{app => vue-app}/template/store.js | 0
packages/{app => vue-app}/template/utils.js | 0
.../template/views/app.template.html | 0
.../template/views/error.html | 0
.../template/views/loading/chasing-dots.html | 0
.../template/views/loading/circle.html | 0
.../template/views/loading/cube-grid.html | 0
.../template/views/loading/default.html | 0
.../template/views/loading/fading-circle.html | 0
.../template/views/loading/folding-cube.html | 0
.../template/views/loading/nuxt.html | 0
.../template/views/loading/pulse.html | 0
.../views/loading/rectangle-bounce.html | 0
.../views/loading/rotating-plane.html | 0
.../template/views/loading/three-bounce.html | 0
.../views/loading/wandering-cubes.html | 0
packages/vue-renderer/package.js | 3 +
packages/vue-renderer/package.json | 27 +
packages/vue-renderer/src/index.js | 1 +
packages/vue-renderer/src/renderer.js | 297 +++++++++++
.../meta.js => vue-renderer/src/spa-meta.js} | 9 +-
packages/webpack/src/builder.js | 10 +-
packages/webpack/src/config/base.js | 2 +-
scripts/rollup.config.js | 5 +-
test/e2e/basic.browser.test.js | 2 +-
test/e2e/basic.vue-config.test.js | 2 +-
test/e2e/children.patch.browser.test.js | 2 +-
test/fixtures/cli/cli.build.test.js | 2 +-
test/unit/async-config.test.js | 4 +-
test/unit/basic.config.defaults.test.js | 14 +-
test/unit/basic.dev.test.js | 8 +-
test/unit/basic.generate.test.js | 18 +-
test/unit/basic.plugins.test.js | 4 +-
test/unit/basic.ssr.csp.test.js | 2 +-
test/unit/basic.ssr.test.js | 68 +--
test/unit/children.test.js | 14 +-
test/unit/custom-app-template.test.js | 4 +-
test/unit/custom-dirs.test.js | 8 +-
test/unit/dist-options.test.js | 2 +-
test/unit/error.test.js | 8 +-
test/unit/extract-css.test.js | 4 +-
test/unit/fallback.generate.test.js | 4 +-
test/unit/https.test.js | 4 +-
test/unit/module.test.js | 10 +-
test/unit/nuxt.test.js | 4 +-
test/unit/sockets.test.js | 4 +-
test/unit/spa.test.js | 4 +-
test/unit/ssr.test.js | 6 +-
test/unit/with-config.test.js | 44 +-
test/utils/index.js | 4 +-
114 files changed, 1286 insertions(+), 1097 deletions(-)
rename packages/{common/src/build => builder/src}/context.js (100%)
create mode 100644 packages/common/src/hookable.js
create mode 100644 packages/config/src/config/_app.js
create mode 100644 packages/config/src/config/_common.js
rename packages/config/src/{ => config}/modes.js (86%)
rename packages/{common => config}/src/options.js (90%)
delete mode 100644 packages/core/src/renderer.js
rename packages/{app => server}/package.js (100%)
create mode 100644 packages/server/package.json
create mode 100644 packages/server/src/context.js
create mode 100644 packages/server/src/index.js
create mode 100644 packages/server/src/jsdom.js
rename packages/{core => server}/src/middleware/error.js (80%)
rename packages/{core => server}/src/middleware/nuxt.js (75%)
create mode 100644 packages/server/src/server.js
create mode 100644 packages/vue-app/package.js
rename packages/{app => vue-app}/package.json (75%)
rename packages/{app => vue-app}/src/index.js (100%)
rename packages/{app => vue-app}/template/.eslintignore (100%)
rename packages/{app => vue-app}/template/App.js (100%)
rename packages/{app => vue-app}/template/client.js (100%)
rename packages/{app => vue-app}/template/components/no-ssr.js (100%)
rename packages/{app => vue-app}/template/components/nuxt-child.js (100%)
rename packages/{app => vue-app}/template/components/nuxt-error.vue (100%)
rename packages/{app => vue-app}/template/components/nuxt-link.js (100%)
rename packages/{app => vue-app}/template/components/nuxt-loading.vue (100%)
rename packages/{app => vue-app}/template/components/nuxt.js (100%)
rename packages/{app => vue-app}/template/empty.js (100%)
rename packages/{app => vue-app}/template/index.js (100%)
rename packages/{app => vue-app}/template/layouts/default.vue (100%)
rename packages/{app => vue-app}/template/middleware.js (100%)
rename packages/{app => vue-app}/template/pages/index.vue (100%)
rename packages/{app => vue-app}/template/router.js (100%)
rename packages/{app => vue-app}/template/server.js (100%)
rename packages/{app => vue-app}/template/store.js (100%)
rename packages/{app => vue-app}/template/utils.js (100%)
rename packages/{app => vue-app}/template/views/app.template.html (100%)
rename packages/{app => vue-app}/template/views/error.html (100%)
rename packages/{app => vue-app}/template/views/loading/chasing-dots.html (100%)
rename packages/{app => vue-app}/template/views/loading/circle.html (100%)
rename packages/{app => vue-app}/template/views/loading/cube-grid.html (100%)
rename packages/{app => vue-app}/template/views/loading/default.html (100%)
rename packages/{app => vue-app}/template/views/loading/fading-circle.html (100%)
rename packages/{app => vue-app}/template/views/loading/folding-cube.html (100%)
rename packages/{app => vue-app}/template/views/loading/nuxt.html (100%)
rename packages/{app => vue-app}/template/views/loading/pulse.html (100%)
rename packages/{app => vue-app}/template/views/loading/rectangle-bounce.html (100%)
rename packages/{app => vue-app}/template/views/loading/rotating-plane.html (100%)
rename packages/{app => vue-app}/template/views/loading/three-bounce.html (100%)
rename packages/{app => vue-app}/template/views/loading/wandering-cubes.html (100%)
create mode 100644 packages/vue-renderer/package.js
create mode 100644 packages/vue-renderer/package.json
create mode 100644 packages/vue-renderer/src/index.js
create mode 100644 packages/vue-renderer/src/renderer.js
rename packages/{core/src/meta.js => vue-renderer/src/spa-meta.js} (93%)
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 693d36d2c8..50781d8ed4 100755
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -26,26 +26,22 @@ jobs:
name: Install Dependencies
command: yarn --frozen-lockfile --non-interactive
- # Link
- - run:
- name: β Link
- command: yarn lerna link
-
# Save cache
- save_cache:
key: yarn-{{ checksum "yarn.lock" }}
paths:
- node_modules
- - distributions/*/node_modules
- packages/*/node_modules
+ - distributions/*/node_modules
# Persist workspace
- persist_to_workspace:
root: ~/project
paths:
- node_modules
- - distributions/*/node_modules
- packages/*/node_modules
+ - distributions/*/node_modules
+ - packages/*/dist
# --------------------------------------------------------------------------
# Phase 2: Lint + Audit + Build Nuxt and fixtures
@@ -76,18 +72,13 @@ jobs:
- checkout
- attach_workspace:
at: ~/project
- - run:
- name: Build Nuxt
- command: yarn build
- run:
name: Build Fixtures
- command: yarn build && yarn test:fixtures -w=4 --coverage && yarn coverage
+ command: yarn test:fixtures -w=4 --coverage && yarn coverage
- persist_to_workspace:
root: ~/project
paths:
- - test/fixtures # TODO
- - distributions/**/dist
- - packages/**/dist
+ - test/fixtures
# --------------------------------------------------------------------------
# Phase 3: Unit and E2E tests
diff --git a/.eslintignore b/.eslintignore
index afbcb62ebe..48de14efb0 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,8 +1,16 @@
-app
-!app/store.js
+# Common
node_modules
dist
.nuxt
-examples/coffeescript/pages/index.vue
-!examples/storybook/.storybook
coverage
+
+# Examples
+
+## cofeescript
+examples/coffeescript/pages/index.vue
+
+# Packages
+
+# vue-app
+packages/vue-app/template
+!packages/vue-app/template/store.js
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 1d82aa01ef..4fa4d6940d 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -19,10 +19,6 @@ steps:
yarn
displayName: 'Install dependencies'
-- script: |
- yarn build
- displayName: 'Build Nuxt'
-
- script: |
yarn test:fixtures -w=2
displayName: 'Test: Build Fixtures'
diff --git a/examples/with-ava/test/index.test.js b/examples/with-ava/test/index.test.js
index 7e1e414d11..fb25e5ec5f 100755
--- a/examples/with-ava/test/index.test.js
+++ b/examples/with-ava/test/index.test.js
@@ -15,20 +15,20 @@ test.before(async () => {
}
nuxt = new Nuxt(config)
await new Builder(nuxt).build()
- await nuxt.listen(4000, 'localhost')
+ await nuxt.server.listen(4000, 'localhost')
}, 30000)
// Example of testing only generated html
test('Route / exits and render HTML', async (t) => {
const context = {}
- const { html } = await nuxt.renderRoute('/', context)
+ const { html } = await nuxt.server.renderRoute('/', context)
t.true(html.includes('Hello world! '))
})
// Example of testing via dom checking
test('Route / exits and render HTML with CSS applied', async (t) => {
const context = {}
- const { html } = await nuxt.renderRoute('/', context)
+ const { html } = await nuxt.server.renderRoute('/', context)
const { window } = new JSDOM(html).window
const element = window.document.querySelector('.red')
t.not(element, null)
diff --git a/examples/with-sockets/io/index.js b/examples/with-sockets/io/index.js
index bcf53592de..941f7b2761 100644
--- a/examples/with-sockets/io/index.js
+++ b/examples/with-sockets/io/index.js
@@ -5,8 +5,8 @@ const server = http.createServer(this.nuxt.renderer.app)
const io = socketIO(server)
export default function () {
- // overwrite nuxt.listen()
- this.nuxt.listen = (port, host) => new Promise(resolve => server.listen(port || 3000, host || 'localhost', resolve))
+ // 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))
diff --git a/jest.config.js b/jest.config.js
index f4706457af..c2546d018f 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -14,32 +14,29 @@ module.exports = {
coverageDirectory: './coverage',
collectCoverageFrom: [
- 'packages/*/src/**/*.js',
- 'packages/cli/bin/*'
+ '**/packages/*/src/**/*.js'
],
coveragePathIgnorePatterns: [
- 'node_modules',
- 'packages/app',
- 'packages/webpack/plugins/vue'
+ 'node_modules/(?!(@nuxt|nuxt))',
+ 'packages/webpack/src/config/plugins/vue'
],
testPathIgnorePatterns: [
- 'node_modules',
+ 'node_modules/(?!(@nuxt|nuxt))',
'test/fixtures/.*/.*?/',
'examples/.*'
],
+ transformIgnorePatterns: [
+ 'node_modules/(?!(@nuxt|nuxt))'
+ ],
+
transform: {
'^.+\\.js$': 'babel-jest',
'.*\\.(vue)$': 'vue-jest'
},
- transformIgnorePatterns: [
- '/node_modules/',
- '/dist/'
- ],
-
moduleFileExtensions: [
'js',
'json'
diff --git a/package.json b/package.json
index 947fc51cb0..6b8bac1477 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,7 @@
"clean:build": "rimraf distributions/*/dist packages/*/dist",
"clean:examples": "rimraf examples/*/dist examples/*/.nuxt",
"clean:test": "rimraf test/fixtures/*/dist test/fixtures/*/.nuxt*",
- "dev": "yarn build --watch",
+ "dev": "node -r esm ./scripts/dev",
"coverage": "codecov",
"lint": "eslint --ext .js,.mjs,.vue .",
"lint:app": "eslint-multiplexer eslint --ignore-path packages/app/template/.eslintignore 'test/fixtures/!(missing-plugin)/.nuxt!(-dev)/**' | eslint-multiplexer -b",
@@ -20,7 +20,7 @@
"test:e2e": "jest -i test/e2e",
"test:lint": "yarn lint",
"test:unit": "jest test/unit",
- "postinstall": "lerna link && node -r esm ./scripts/dev"
+ "postinstall": "lerna link && yarn dev"
},
"devDependencies": {
"@babel/core": "^7.1.2",
diff --git a/packages/builder/package.json b/packages/builder/package.json
index 9cfacbd631..6b2fb0e120 100644
--- a/packages/builder/package.json
+++ b/packages/builder/package.json
@@ -8,8 +8,8 @@
],
"main": "dist/builder.js",
"dependencies": {
- "@nuxt/app": "^2.2.0",
"@nuxt/common": "^2.2.0",
+ "@nuxt/vue-app": "^2.2.0",
"@nuxtjs/devalue": "^1.0.1",
"chokidar": "^2.0.4",
"consola": "^1.4.4",
diff --git a/packages/builder/src/builder.js b/packages/builder/src/builder.js
index 15bc0865e2..224cea73d6 100644
--- a/packages/builder/src/builder.js
+++ b/packages/builder/src/builder.js
@@ -20,8 +20,6 @@ import values from 'lodash/values'
import devalue from '@nuxtjs/devalue'
import {
- Options,
- BuildContext,
r,
wp,
wChunk,
@@ -33,6 +31,8 @@ import {
isString
} from '@nuxt/common'
+import BuildContext from './context'
+
const glob = pify(Glob)
export default class Builder {
@@ -69,7 +69,7 @@ export default class Builder {
}
// Resolve template
- this.template = this.options.build.template || '@nuxt/app'
+ this.template = this.options.build.template || '@nuxt/vue-app'
if (typeof this.template === 'string') {
this.template = this.nuxt.resolver.requireModule(this.template)
}
@@ -476,16 +476,16 @@ export default class Builder {
consola.success('Nuxt files generated')
}
- // TODO: remove ignore when generateConfig enabled again
- async generateConfig() /* istanbul ignore next */ {
- const config = path.resolve(this.options.buildDir, 'build.config.js')
- const options = omit(this.options, Options.unsafeKeys)
- await fsExtra.writeFile(
- config,
- `export default ${JSON.stringify(options, null, ' ')}`,
- 'utf8'
- )
- }
+ // TODO: Uncomment when generateConfig enabled again
+ // async generateConfig() /* istanbul ignore next */ {
+ // const config = path.resolve(this.options.buildDir, 'build.config.js')
+ // const options = omit(this.options, Options.unsafeKeys)
+ // await fsExtra.writeFile(
+ // config,
+ // `export default ${JSON.stringify(options, null, ' ')}`,
+ // 'utf8'
+ // )
+ // }
watchClient() {
const src = this.options.srcDir
diff --git a/packages/common/src/build/context.js b/packages/builder/src/context.js
similarity index 100%
rename from packages/common/src/build/context.js
rename to packages/builder/src/context.js
diff --git a/packages/cli/src/commands/dev.js b/packages/cli/src/commands/dev.js
index c6c81594d9..0afd2b49b7 100644
--- a/packages/cli/src/commands/dev.js
+++ b/packages/cli/src/commands/dev.js
@@ -48,9 +48,9 @@ export default {
})
.then(() => oldInstance && oldInstance.nuxt.close())
// Start listening
- .then(() => nuxt.listen())
+ .then(() => nuxt.server.listen())
// Show ready message first time, others will be shown through WebpackBar
- .then(() => !oldInstance && nuxt.showReady(false))
+ .then(() => !oldInstance && nuxt.server.showReady(false))
.then(() => builder.watchServer())
// Handle errors
.catch(err => errorHandler(err, { builder, nuxt }))
diff --git a/packages/cli/src/commands/start.js b/packages/cli/src/commands/start.js
index e08e08ffcc..506f0fe47f 100644
--- a/packages/cli/src/commands/start.js
+++ b/packages/cli/src/commands/start.js
@@ -45,8 +45,8 @@ export default {
}
}
- return nuxt.listen().then(() => {
- nuxt.showReady(false)
+ return nuxt.server.listen().then(() => {
+ nuxt.server.showReady(false)
})
}
}
diff --git a/packages/cli/src/utils.js b/packages/cli/src/utils.js
index 6b609005bf..fd9e138230 100644
--- a/packages/cli/src/utils.js
+++ b/packages/cli/src/utils.js
@@ -4,7 +4,7 @@ import consola from 'consola'
import esm from 'esm'
import wrapAnsi from 'wrap-ansi'
import defaultsDeep from 'lodash/defaultsDeep'
-import { server as nuxtServerConfig } from '@nuxt/config'
+import { getDefaultNuxtConfig } from '@nuxt/config'
const _require = esm(module, {
cache: false,
@@ -58,7 +58,7 @@ export async function loadNuxtConfig(argv) {
port: argv.port || undefined,
host: argv.hostname || undefined,
socket: argv['unix-socket'] || undefined
- }, options.server || {}, nuxtServerConfig(process.env))
+ }, options.server || {}, getDefaultNuxtConfig().server)
return options
}
@@ -72,11 +72,11 @@ export function indentLines(string, spaces, firstLineSpaces) {
let s = ''
if (lines.length) {
const i0 = indent(firstLineSpaces === undefined ? spaces : firstLineSpaces)
- s = i0 + lines.shift()
+ s = i0 + lines.shift().trim()
}
if (lines.length) {
const i = indent(spaces)
- s += '\n' + lines.map(l => i + l).join('\n')
+ s += '\n' + lines.map(l => i + l.trim()).join('\n')
}
return s
}
diff --git a/packages/cli/test/unit/__snapshots__/command.test.js.snap b/packages/cli/test/unit/__snapshots__/command.test.js.snap
index 20ef9648a3..be77274aa6 100644
--- a/packages/cli/test/unit/__snapshots__/command.test.js.snap
+++ b/packages/cli/test/unit/__snapshots__/command.test.js.snap
@@ -3,7 +3,7 @@
exports[`cli/command builds help text 1`] = `
" Usage: nuxt this is how you do it [options]
- a very long description that is longer than 80 chars and should wrap to the next
+ a very long description that is longer than 80 chars and should wrap to the next
line while keeping indentation
Options:
@@ -16,7 +16,7 @@ exports[`cli/command builds help text 1`] = `
--port, -p Port number on which to start the application
--hostname, -H Hostname on which to start the application
--unix-socket, -n Path to a UNIX socket
- --foo very long option that is longer than 80 chars and should wrap
+ --foo very long option that is longer than 80 chars and should wrap
to the next line while keeping indentation
"
diff --git a/packages/cli/test/unit/dev.test.js b/packages/cli/test/unit/dev.test.js
index dad9e2011b..f975d967a9 100644
--- a/packages/cli/test/unit/dev.test.js
+++ b/packages/cli/test/unit/dev.test.js
@@ -22,8 +22,8 @@ describe('dev', () => {
expect(consola.error).not.toHaveBeenCalled()
expect(Builder.prototype.build).toHaveBeenCalled()
- expect(Nuxt.prototype.listen).toHaveBeenCalled()
- expect(Nuxt.prototype.showReady).toHaveBeenCalled()
+ expect(Nuxt.prototype.server.listen).toHaveBeenCalled()
+ expect(Nuxt.prototype.server.showReady).toHaveBeenCalled()
expect(Builder.prototype.watchServer).toHaveBeenCalled()
jest.clearAllMocks()
@@ -37,8 +37,8 @@ describe('dev', () => {
expect(Builder.prototype.unwatch).toHaveBeenCalled()
expect(Builder.prototype.build).toHaveBeenCalled()
expect(Nuxt.prototype.close).toHaveBeenCalled()
- expect(Nuxt.prototype.listen).toHaveBeenCalled()
- expect(Nuxt.prototype.showReady).not.toHaveBeenCalled()
+ expect(Nuxt.prototype.server.listen).toHaveBeenCalled()
+ expect(Nuxt.prototype.server.showReady).not.toHaveBeenCalled()
expect(Builder.prototype.watchServer).toHaveBeenCalled()
expect(consola.error).not.toHaveBeenCalled()
@@ -97,9 +97,11 @@ describe('dev', () => {
test('catches error on startDev', async () => {
mockNuxt({
- listen: jest.fn().mockImplementation(() => {
- throw new Error('Listen Error')
- })
+ server: {
+ listen: jest.fn().mockImplementation(() => {
+ throw new Error('Listen Error')
+ })
+ }
})
mockBuilder()
diff --git a/packages/cli/test/unit/utils.test.js b/packages/cli/test/unit/utils.test.js
index b1a1bf00c5..5eb385101b 100644
--- a/packages/cli/test/unit/utils.test.js
+++ b/packages/cli/test/unit/utils.test.js
@@ -1,4 +1,4 @@
-import { server as nuxtServerConfig } from '@nuxt/config'
+import { getDefaultNuxtConfig } from '@nuxt/config'
import { consola } from '../utils'
import * as utils from '../../src/utils'
@@ -81,14 +81,14 @@ describe('cli/utils', () => {
})
test('nuxtServerConfig: server env', () => {
- const options = {
- server: nuxtServerConfig({
+ const options = getDefaultNuxtConfig({
+ env: {
...process.env,
HOST: 'env-host',
PORT: 3003,
UNIX_SOCKET: '/var/run/env.sock'
- })
- }
+ }
+ })
expect(options.server.host).toBe('env-host')
expect(options.server.port).toBe(3003)
diff --git a/packages/cli/test/utils/mocking.js b/packages/cli/test/utils/mocking.js
index 63a83e3976..da4a9ba7d4 100644
--- a/packages/cli/test/utils/mocking.js
+++ b/packages/cli/test/utils/mocking.js
@@ -66,8 +66,10 @@ export const mockGetNuxtStart = (ssr) => {
ssr
}
}, {
- listen,
- showReady
+ server: {
+ listen,
+ showReady
+ }
})
return { listen, showReady }
@@ -89,8 +91,10 @@ export const mockNuxt = (implementation) => {
},
clearHook: jest.fn(),
close: jest.fn(),
- listen: jest.fn().mockImplementationOnce(() => Promise.resolve()),
- showReady: jest.fn().mockImplementationOnce(() => Promise.resolve())
+ server: {
+ listen: jest.fn().mockImplementationOnce(() => Promise.resolve()),
+ showReady: jest.fn().mockImplementationOnce(() => Promise.resolve())
+ }
}, implementation || {})
imports.core.mockImplementation(() => ({ Nuxt }))
diff --git a/packages/common/src/hookable.js b/packages/common/src/hookable.js
new file mode 100644
index 0000000000..658f25791b
--- /dev/null
+++ b/packages/common/src/hookable.js
@@ -0,0 +1,67 @@
+
+import consola from 'consola'
+
+import { sequence } from './utils'
+
+export default class Hookable {
+ constructor() {
+ this._hooks = {}
+ this._deprecatedHooks = {}
+
+ this.hook = this.hook.bind(this)
+ this.callHook = this.callHook.bind(this)
+ }
+
+ hook(name, fn) {
+ if (!name || typeof fn !== 'function') {
+ return
+ }
+
+ if (this._deprecatedHooks[name]) {
+ consola.warn(`${name} hook has been deprecated, please use ${this._deprecatedHooks[name]}`)
+ name = this._deprecatedHooks[name]
+ }
+
+ this._hooks[name] = this._hooks[name] || []
+ this._hooks[name].push(fn)
+ }
+
+ async callHook(name, ...args) {
+ if (!this._hooks[name]) {
+ return
+ }
+ consola.debug(`Call ${name} hooks (${this._hooks[name].length})`)
+ try {
+ await sequence(this._hooks[name], fn => fn(...args))
+ } catch (err) {
+ consola.error(err)
+ this.callHook('error', err)
+ }
+ }
+
+ clearHook(name) {
+ if (name) {
+ delete this._hooks[name]
+ }
+ }
+
+ flatHooks(configHooks, hooks = {}, parentName) {
+ Object.keys(configHooks).forEach((key) => {
+ const subHook = configHooks[key]
+ const name = parentName ? `${parentName}:${key}` : key
+ if (typeof subHook === 'object' && subHook !== null) {
+ this.flatHooks(subHook, hooks, name)
+ } else {
+ hooks[name] = subHook
+ }
+ })
+ return hooks
+ }
+
+ addHooks(configHooks) {
+ const hooks = this.flatHooks(configHooks)
+ Object.keys(hooks).filter(Boolean).forEach((key) => {
+ [].concat(hooks[key]).forEach(h => this.hook(key, h))
+ })
+ }
+}
diff --git a/packages/common/src/index.js b/packages/common/src/index.js
index 67718e1adf..6d33677a6a 100644
--- a/packages/common/src/index.js
+++ b/packages/common/src/index.js
@@ -1,3 +1,2 @@
-export { default as Options } from './options'
-export { default as BuildContext } from './build/context'
+export { default as Hookable } from './hookable'
export * from './utils'
diff --git a/packages/common/src/utils.js b/packages/common/src/utils.js
index 7efdc33450..58fd1df740 100644
--- a/packages/common/src/utils.js
+++ b/packages/common/src/utils.js
@@ -15,9 +15,10 @@ export const waitFor = function waitFor(ms) {
return new Promise(resolve => setTimeout(resolve, ms || 0))
}
-export const isString = function isString(obj) {
- return typeof obj === 'string' || obj instanceof String
-}
+export const isString = obj => typeof obj === 'string' || obj instanceof String
+
+export const isNonEmptyString = obj => obj && isString(obj)
+
export const startsWithAlias = aliasArray => str => aliasArray.some(c => str.startsWith(c))
export const startsWithSrcAlias = startsWithAlias(['@', '~'])
@@ -404,3 +405,34 @@ export const stripWhitespace = function stripWhitespace(string) {
})
return string
}
+
+export function defineAlias(src, target, prop, opts = {}) {
+ const { bind = true, warn = false } = opts
+
+ if (Array.isArray(prop)) {
+ for (const p of prop) {
+ defineAlias(src, target, p, opts)
+ }
+ return
+ }
+
+ let targetVal = target[prop]
+ if (bind && typeof targetVal === 'function') {
+ targetVal = targetVal.bind(target)
+ }
+
+ let warned = false
+
+ Object.defineProperty(src, prop, {
+ get: () => {
+ if (warn && !warned) {
+ warned = true
+ consola.warn({
+ message: `'${prop}' is deprecated'`,
+ additional: new Error().stack.split('\n').splice(2).join('\n')
+ })
+ }
+ return targetVal
+ }
+ })
+}
diff --git a/packages/config/package.json b/packages/config/package.json
index 045596e9ef..7cefff1e78 100644
--- a/packages/config/package.json
+++ b/packages/config/package.json
@@ -8,6 +8,7 @@
],
"main": "dist/config.js",
"dependencies": {
+ "@nuxt/common": "^2.2.0",
"consola": "^1.4.4",
"lodash": "^4.17.11",
"std-env": "^2.0.2"
diff --git a/packages/config/src/config/_app.js b/packages/config/src/config/_app.js
new file mode 100644
index 0000000000..c591728e9c
--- /dev/null
+++ b/packages/config/src/config/_app.js
@@ -0,0 +1,52 @@
+export default () => ({
+ vue: {
+ config: {
+ silent: undefined, // = !dev
+ performance: undefined // = dev
+ }
+ },
+
+ head: {
+ meta: [],
+ link: [],
+ style: [],
+ script: []
+ },
+
+ plugins: [],
+
+ css: [],
+
+ modules: [],
+
+ layouts: {},
+
+ ErrorPage: null,
+
+ loading: {
+ color: 'black',
+ failedColor: 'red',
+ height: '2px',
+ throttle: 200,
+ duration: 5000,
+ continuous: false,
+ rtl: false,
+ css: true
+ },
+
+ loadingIndicator: 'default',
+
+ transition: {
+ name: 'page',
+ mode: 'out-in',
+ appear: false,
+ appearClass: 'appear',
+ appearActiveClass: 'appear-active',
+ appearToClass: 'appear-to'
+ },
+
+ layoutTransition: {
+ name: 'layout',
+ mode: 'out-in'
+ }
+})
diff --git a/packages/config/src/config/_common.js b/packages/config/src/config/_common.js
new file mode 100644
index 0000000000..9b8dec7742
--- /dev/null
+++ b/packages/config/src/config/_common.js
@@ -0,0 +1,80 @@
+import path from 'path'
+import fs from 'fs'
+import capitalize from 'lodash/capitalize'
+import env from 'std-env'
+
+export default () => ({
+ // Env
+ dev: Boolean(env.dev),
+ test: Boolean(env.test),
+ debug: undefined, // = dev
+ env: {},
+
+ // Mode
+ mode: 'universal',
+
+ // Globals
+ globalName: `nuxt`,
+ globals: {
+ id: globalName => `__${globalName}`,
+ nuxt: globalName => `$${globalName}`,
+ context: globalName => `__${globalName.toUpperCase()}__`,
+ pluginPrefix: globalName => globalName,
+ readyCallback: globalName => `on${capitalize(globalName)}Ready`,
+ loadedCallback: globalName => `_on${capitalize(globalName)}Loaded`
+ },
+
+ // Server
+ serverMiddleware: [],
+
+ // Dirs and extensions
+ srcDir: undefined,
+ buildDir: '.nuxt',
+ nuxtDir: fs.existsSync(path.resolve(__dirname, '..', '..', 'package.js'))
+ ? path.resolve(__dirname, '..', '..') // src
+ : path.resolve(__dirname, '..'), // dist
+ modulesDir: [
+ 'node_modules'
+ ],
+ dir: {
+ assets: 'assets',
+ layouts: 'layouts',
+ middleware: 'middleware',
+ pages: 'pages',
+ static: 'static',
+ store: 'store'
+ },
+ extensions: [],
+
+ // Ignores
+ ignorePrefix: '-',
+ ignore: [
+ '**/*.test.*',
+ '**/*.spec.*'
+ ],
+
+ // Generate
+ generate: {
+ dir: 'dist',
+ routes: [],
+ concurrency: 500,
+ interval: 0,
+ subFolders: true,
+ fallback: '200.html'
+ },
+
+ // Watch
+ watch: [],
+ watchers: {
+ webpack: {},
+ chokidar: {
+ ignoreInitial: true
+ }
+ },
+
+ // Editor
+ editor: undefined,
+
+ // Hooks
+ hooks: null
+})
diff --git a/packages/config/src/config/build.js b/packages/config/src/config/build.js
index 70846ea9ed..af2037ab13 100644
--- a/packages/config/src/config/build.js
+++ b/packages/config/src/config/build.js
@@ -1,6 +1,6 @@
import env from 'std-env'
-export default {
+export default () => ({
quiet: Boolean(env.ci || env.test),
analyze: false,
profile: process.argv.includes('--profile'),
@@ -109,4 +109,4 @@ export default {
/vue-ssr-client-manifest.json/
]
}
-}
+})
diff --git a/packages/config/src/config/index.js b/packages/config/src/config/index.js
index 8a16689662..daf607ef6c 100644
--- a/packages/config/src/config/index.js
+++ b/packages/config/src/config/index.js
@@ -1,130 +1,27 @@
-import path from 'path'
-import fs from 'fs'
-import capitalize from 'lodash/capitalize'
-import env from 'std-env'
-import render from './render'
+import _app from './_app'
+import _common from './_common'
+
import build from './build'
-import router from './router'
import messages from './messages'
+import modes from './modes'
+import render from './render'
+import router from './router'
import server from './server'
-const nuxtDir = fs.existsSync(path.resolve(__dirname, '..', '..', 'package.js'))
- ? path.resolve(__dirname, '..', '..') // src
- : path.resolve(__dirname, '..') // dist
+export function getDefaultNuxtConfig(options = {}) {
+ if (!options.env) {
+ options.env = process.env
+ }
-export default {
- // Information about running environment
- dev: Boolean(env.dev),
- test: Boolean(env.test),
- debug: undefined, // = dev
-
- // Mode
- mode: 'universal',
-
- // Global name
- globalName: `nuxt`,
- globals: {
- id: globalName => `__${globalName}`,
- nuxt: globalName => `$${globalName}`,
- context: globalName => `__${globalName.toUpperCase()}__`,
- pluginPrefix: globalName => globalName,
- readyCallback: globalName => `on${capitalize(globalName)}Ready`,
- loadedCallback: globalName => `_on${capitalize(globalName)}Loaded`
- },
-
- render,
- build,
- router,
- messages,
-
- // Server options
- server: server(process.env),
-
- // Dirs
- srcDir: undefined,
- buildDir: '.nuxt',
- nuxtDir,
- modulesDir: [
- 'node_modules'
- ],
-
- // Ignore
- ignorePrefix: '-',
- ignore: [
- '**/*.test.*',
- '**/*.spec.*'
- ],
-
- extensions: [],
-
- generate: {
- dir: 'dist',
- routes: [],
- concurrency: 500,
- interval: 0,
- subFolders: true,
- fallback: '200.html'
- },
- env: {},
- head: {
- meta: [],
- link: [],
- style: [],
- script: []
- },
- plugins: [],
- css: [],
- modules: [],
- layouts: {},
- serverMiddleware: [],
- ErrorPage: null,
- loading: {
- color: 'black',
- failedColor: 'red',
- height: '2px',
- throttle: 200,
- duration: 5000,
- continuous: false,
- rtl: false,
- css: true
- },
- loadingIndicator: 'default',
- transition: {
- name: 'page',
- mode: 'out-in',
- appear: false,
- appearClass: 'appear',
- appearActiveClass: 'appear-active',
- appearToClass: 'appear-to'
- },
- layoutTransition: {
- name: 'layout',
- mode: 'out-in'
- },
- dir: {
- assets: 'assets',
- layouts: 'layouts',
- middleware: 'middleware',
- pages: 'pages',
- static: 'static',
- store: 'store'
- },
- vue: {
- config: {
- silent: undefined, // = !dev
- performance: undefined // = dev
- }
- },
-
- // User-defined changes
- watch: [],
- watchers: {
- webpack: {},
- chokidar: {
- ignoreInitial: true
- }
- },
- editor: undefined,
- hooks: null
+ return {
+ ..._app(options),
+ ..._common(options),
+ build: build(options),
+ messages: messages(options),
+ modes: modes(options),
+ render: render(options),
+ router: router(options),
+ server: server(options)
+ }
}
diff --git a/packages/config/src/config/messages.js b/packages/config/src/config/messages.js
index 34a2dda4bf..0c3694c2b5 100644
--- a/packages/config/src/config/messages.js
+++ b/packages/config/src/config/messages.js
@@ -1,4 +1,4 @@
-export default {
+export default () => ({
loading: 'Loading...',
error_404: 'This page could not be found',
server_error: 'Server error',
@@ -9,4 +9,4 @@ export default {
client_error: 'Error',
client_error_details:
'An error occurred while rendering the page. Check developer tools console for details.'
-}
+})
diff --git a/packages/config/src/modes.js b/packages/config/src/config/modes.js
similarity index 86%
rename from packages/config/src/modes.js
rename to packages/config/src/config/modes.js
index 676aea8b6d..b73a08fa62 100644
--- a/packages/config/src/modes.js
+++ b/packages/config/src/config/modes.js
@@ -1,4 +1,4 @@
-export default {
+export default () => ({
universal: {
build: {
ssr: true
@@ -15,4 +15,4 @@ export default {
ssr: false
}
}
-}
+})
diff --git a/packages/config/src/config/render.js b/packages/config/src/config/render.js
index da9dd2c4d0..28d96ca802 100644
--- a/packages/config/src/config/render.js
+++ b/packages/config/src/config/render.js
@@ -1,4 +1,4 @@
-export default {
+export default () => ({
bundleRenderer: {
shouldPrefetch: () => false
},
@@ -24,4 +24,4 @@ export default {
// 1 year in production
maxAge: '1y'
}
-}
+})
diff --git a/packages/config/src/config/router.js b/packages/config/src/config/router.js
index 8d3c8fcb53..28bbf404cd 100644
--- a/packages/config/src/config/router.js
+++ b/packages/config/src/config/router.js
@@ -1,4 +1,4 @@
-export default {
+export default () => ({
mode: 'history',
base: '/',
routes: [],
@@ -10,4 +10,4 @@ export default {
parseQuery: false,
stringifyQuery: false,
fallback: false
-}
+})
diff --git a/packages/config/src/config/server.js b/packages/config/src/config/server.js
index 9bdbaef1a9..a037ae80ea 100644
--- a/packages/config/src/config/server.js
+++ b/packages/config/src/config/server.js
@@ -1,4 +1,4 @@
-export default env => ({
+export default ({ env }) => ({
https: false,
port: env.NUXT_PORT ||
env.PORT ||
diff --git a/packages/config/src/index.js b/packages/config/src/index.js
index e632c83881..41a04bd804 100644
--- a/packages/config/src/index.js
+++ b/packages/config/src/index.js
@@ -1,9 +1,2 @@
-
-// Export individual bundles for easier access
-export { default as Modes } from './modes'
-export { default as build } from './config/build'
-export { default as messages } from './config/messages'
-export { default as render } from './config/render'
-export { default as router } from './config/router'
-export { default as server } from './config/server'
-export { default as NuxtConfig } from './config'
+export { getDefaultNuxtConfig } from './config'
+export { getNuxtConfig } from './options'
diff --git a/packages/common/src/options.js b/packages/config/src/options.js
similarity index 90%
rename from packages/common/src/options.js
rename to packages/config/src/options.js
index 795cf6c666..491eecebe7 100644
--- a/packages/common/src/options.js
+++ b/packages/config/src/options.js
@@ -5,17 +5,10 @@ import defaults from 'lodash/defaults'
import pick from 'lodash/pick'
import isObject from 'lodash/isObject'
import consola from 'consola'
-import { NuxtConfig, Modes } from '@nuxt/config'
-import { isPureObject, isUrl, guardDir, isString } from './utils'
+import { isPureObject, isUrl, guardDir, isNonEmptyString } from '@nuxt/common'
+import { getDefaultNuxtConfig } from './config'
-// hasValue utility
-const hasValue = v => typeof v === 'string' && v
-
-const Options = {}
-
-export default Options
-
-Options.from = function (_options) {
+export function getNuxtConfig(_options) {
// Clone options to prevent unwanted side-effects
const options = Object.assign({}, _options)
@@ -43,12 +36,12 @@ Options.from = function (_options) {
options.extensions = [options.extensions]
}
- options.globalName = (isString(options.globalName) && /^[a-zA-Z]+$/.test(options.globalName))
+ options.globalName = (isNonEmptyString(options.globalName) && /^[a-zA-Z]+$/.test(options.globalName))
? options.globalName.toLowerCase()
: `nuxt`
// Resolve rootDir
- options.rootDir = hasValue(options.rootDir) ? path.resolve(options.rootDir) : process.cwd()
+ options.rootDir = isNonEmptyString(options.rootDir) ? path.resolve(options.rootDir) : process.cwd()
// Apply defaults by ${buildDir}/dist/build.config.js
// TODO: Unsafe operation.
@@ -59,11 +52,13 @@ Options.from = function (_options) {
// }
// Apply defaults
- defaultsDeep(options, NuxtConfig)
+ const nuxtConfig = getDefaultNuxtConfig()
+ nuxtConfig.build._publicPath = nuxtConfig.build.publicPath
+ defaultsDeep(options, nuxtConfig)
// Check srcDir and generate.dir excistence
- const hasSrcDir = hasValue(options.srcDir)
- const hasGenerateDir = hasValue(options.generate.dir)
+ const hasSrcDir = isNonEmptyString(options.srcDir)
+ const hasGenerateDir = isNonEmptyString(options.generate.dir)
// Resolve srcDir
options.srcDir = hasSrcDir
@@ -97,7 +92,7 @@ Options.from = function (_options) {
// Populate modulesDir
options.modulesDir = []
.concat(options.modulesDir)
- .concat(path.join(options.nuxtDir, 'node_modules')).filter(hasValue)
+ .concat(path.join(options.nuxtDir, 'node_modules')).filter(isNonEmptyString)
.map(dir => path.resolve(options.rootDir, dir))
const mandatoryExtensions = ['js', 'mjs']
@@ -119,7 +114,7 @@ Options.from = function (_options) {
// Ignore publicPath on dev
/* istanbul ignore if */
if (options.dev && isUrl(options.build.publicPath)) {
- options.build.publicPath = NuxtConfig.build.publicPath
+ options.build.publicPath = options.build._publicPath
}
// If store defined, update store options to true unless explicitly disabled
@@ -218,7 +213,7 @@ Options.from = function (_options) {
}
// Apply mode preset
- const modePreset = Modes[options.mode || 'universal'] || Modes.universal
+ const modePreset = options.modes[options.mode || 'universal']
defaultsDeep(options, modePreset)
// If no server-side rendering, add appear true transition
diff --git a/packages/core/package.json b/packages/core/package.json
index 3f55bf33c2..fee32c3f1d 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -10,33 +10,17 @@
"dependencies": {
"@nuxt/common": "^2.2.0",
"@nuxt/config": "^2.2.0",
+ "@nuxt/server": "^2.2.0",
+ "@nuxt/vue-renderer": "^2.2.0",
"@nuxtjs/devalue": "^1.0.1",
"@nuxtjs/opencollective": "^0.1.0",
- "@nuxtjs/youch": "^4.2.3",
- "chalk": "^2.4.1",
- "compression": "^1.7.3",
- "connect": "^3.6.6",
"consola": "^1.4.4",
"debug": "^4.1.0",
"esm": "^3.0.84",
- "etag": "^1.8.1",
- "fresh": "^0.5.2",
"fs-extra": "^7.0.0",
"hash-sum": "^1.0.2",
- "ip": "^1.1.5",
- "launch-editor-middleware": "^2.2.1",
"lodash": "^4.17.11",
- "lru-cache": "^4.1.3",
- "serve-static": "^1.13.2",
- "server-destroy": "^1.0.1",
- "std-env": "^2.0.2",
- "vue": "^2.5.17",
- "vue-meta": "^1.5.5",
- "vue-no-ssr": "^1.0.0",
- "vue-router": "^3.0.1",
- "vue-server-renderer": "^2.5.17",
- "vue-template-compiler": "^2.5.17",
- "vuex": "^3.0.1"
+ "std-env": "^2.0.2"
},
"publishConfig": {
"access": "public"
diff --git a/packages/core/src/index.js b/packages/core/src/index.js
index 332498907e..38ef78e5cd 100644
--- a/packages/core/src/index.js
+++ b/packages/core/src/index.js
@@ -1,3 +1,3 @@
export { default as Module } from './module'
export { default as Nuxt } from './nuxt'
-export { default as Renderer } from './renderer'
+export { default as Resolver } from './resolver'
diff --git a/packages/core/src/nuxt.js b/packages/core/src/nuxt.js
index cdc9876833..e1570f075a 100644
--- a/packages/core/src/nuxt.js
+++ b/packages/core/src/nuxt.js
@@ -1,43 +1,40 @@
-import https from 'https'
-import enableDestroy from 'server-destroy'
+
import isPlainObject from 'lodash/isPlainObject'
import consola from 'consola'
-import chalk from 'chalk'
-import ip from 'ip'
-
-import { Options, sequence } from '@nuxt/common'
+import { Hookable, defineAlias } from '@nuxt/common'
+import { getNuxtConfig } from '@nuxt/config'
+import { Server } from '@nuxt/server'
import { version } from '../package.json'
import ModuleContainer from './module'
-import Renderer from './renderer'
import Resolver from './resolver'
-export default class Nuxt {
+export default class Nuxt extends Hookable {
constructor(options = {}) {
- this.options = Options.from(options)
+ super()
- this.readyMessage = null
- this.initialized = false
-
- // Hooks
- this._hooks = {}
- this.hook = this.hook.bind(this)
+ // Assign options and apply defaults
+ this.options = getNuxtConfig(options)
// Create instance of core components
- this.moduleContainer = new ModuleContainer(this)
- this.renderer = new Renderer(this)
this.resolver = new Resolver(this)
+ this.moduleContainer = new ModuleContainer(this)
+ this.server = new Server(this)
- // Backward compatibility
- this.render = this.renderer.app
- this.renderRoute = this.renderer.renderRoute.bind(this.renderer)
- this.renderAndGetWindow = this.renderer.renderAndGetWindow.bind(
- this.renderer
- )
- this.resolveAlias = this.resolver.resolveAlias.bind(this)
- this.resolvePath = this.resolver.resolvePath.bind(this)
+ // Deprecated hooks
+ this._deprecatedHooks = {
+ 'render:context': 'render:routeContext' // #3773
+ }
+ // Add Legacy aliases
+ this.renderer = this.server
+ this.render = this.server.app
+ defineAlias(this, this.server, [ 'renderRoute', 'renderAndGetWindow', 'showReady', 'listen' ])
+ defineAlias(this, this.resolver, [ 'resolveAlias', 'resolvePath' ])
+
+ // Wait for Nuxt to be ready
+ this.initialized = false
this._ready = this.ready().catch((err) => {
consola.fatal(err)
})
@@ -62,8 +59,8 @@ export default class Nuxt {
// Await for modules
await this.moduleContainer.ready()
- // Await for renderer to be ready
- await this.renderer.ready()
+ // Await for server to be ready
+ await this.server.ready()
this.initialized = true
@@ -73,156 +70,6 @@ export default class Nuxt {
return this
}
- hook(name, fn) {
- if (!name || typeof fn !== 'function') {
- return
- }
- if (name === 'render:context') {
- name = 'render:routeContext'
- consola.warn('render:context hook has been deprecated, please use render:routeContext')
- }
- this._hooks[name] = this._hooks[name] || []
- this._hooks[name].push(fn)
- }
-
- async callHook(name, ...args) {
- if (!this._hooks[name]) {
- return
- }
- consola.debug(`Call ${name} hooks (${this._hooks[name].length})`)
- try {
- await sequence(this._hooks[name], fn => fn(...args))
- } catch (err) {
- consola.error(err)
- this.callHook('error', err)
- }
- }
-
- clearHook(name) {
- if (name) {
- delete this._hooks[name]
- }
- }
-
- flatHooks(configHooks, hooks = {}, parentName) {
- Object.keys(configHooks).forEach((key) => {
- const subHook = configHooks[key]
- const name = parentName ? `${parentName}:${key}` : key
- if (typeof subHook === 'object' && subHook !== null) {
- this.flatHooks(subHook, hooks, name)
- } else {
- hooks[name] = subHook
- }
- })
- return hooks
- }
-
- addHooks(configHooks) {
- const hooks = this.flatHooks(configHooks)
- Object.keys(hooks).filter(Boolean).forEach((key) => {
- [].concat(hooks[key]).forEach(h => this.hook(key, h))
- })
- }
-
- showReady(clear = true) {
- if (!this.readyMessage) {
- return
- }
- consola.ready({
- message: this.readyMessage,
- badge: true,
- clear
- })
- this.readyMessage = null
- }
-
- listen(port, host, socket) {
- return this.ready().then(() => new Promise((resolve, reject) => {
- if (!socket && typeof this.options.server.socket === 'string') {
- socket = this.options.server.socket
- }
-
- const args = { exclusive: false }
-
- if (socket) {
- args.path = socket
- } else {
- args.port = port || this.options.server.port
- args.host = host || this.options.server.host
- }
-
- let appServer
- const isHttps = Boolean(this.options.server.https)
-
- if (isHttps) {
- let httpsOptions
-
- if (this.options.server.https === true) {
- httpsOptions = {}
- } else {
- httpsOptions = this.options.server.https
- }
-
- appServer = https.createServer(httpsOptions, this.renderer.app)
- } else {
- appServer = this.renderer.app
- }
-
- const server = appServer.listen(
- args,
- (err) => {
- /* istanbul ignore if */
- if (err) {
- return reject(err)
- }
-
- let listenURL
-
- if (!socket) {
- ({ address: host, port } = server.address())
- if (host === '127.0.0.1') {
- host = 'localhost'
- } else if (host === '0.0.0.0') {
- host = ip.address()
- }
-
- listenURL = chalk.underline.blue(`http${isHttps ? 's' : ''}://${host}:${port}`)
- this.readyMessage = `Listening on ${listenURL}`
- } else {
- listenURL = chalk.underline.blue(`unix+http://${socket}`)
- this.readyMessage = `Listening on ${listenURL}`
- }
-
- // Close server on nuxt close
- this.hook(
- 'close',
- () =>
- new Promise((resolve, reject) => {
- // Destroy server by forcing every connection to be closed
- server.listening && server.destroy((err) => {
- consola.debug('server closed')
- /* istanbul ignore if */
- if (err) {
- return reject(err)
- }
- resolve()
- })
- })
- )
-
- if (socket) {
- this.callHook('listen', server, { path: socket }).then(resolve)
- } else {
- this.callHook('listen', server, { port, host }).then(resolve)
- }
- }
- )
-
- // Add server.destroy(cb) method
- enableDestroy(server)
- }))
- }
-
async close(callback) {
await this.callHook('close', this)
diff --git a/packages/core/src/renderer.js b/packages/core/src/renderer.js
deleted file mode 100644
index 7726209da6..0000000000
--- a/packages/core/src/renderer.js
+++ /dev/null
@@ -1,484 +0,0 @@
-import path from 'path'
-import crypto from 'crypto'
-import devalue from '@nuxtjs/devalue'
-import serveStatic from 'serve-static'
-import template from 'lodash/template'
-import fs from 'fs-extra'
-import { createBundleRenderer } from 'vue-server-renderer'
-import connect from 'connect'
-import launchMiddleware from 'launch-editor-middleware'
-import consola from 'consola'
-
-import { isUrl, timeout, waitFor, determineGlobals } from '@nuxt/common'
-import { NuxtConfig } from '@nuxt/config'
-
-import MetaRenderer from './meta'
-import errorMiddleware from './middleware/error'
-import nuxtMiddleware from './middleware/nuxt'
-
-let jsdom = null
-
-export default class Renderer {
- constructor(nuxt) {
- this.nuxt = nuxt
- this.options = nuxt.options
- this.globals = determineGlobals(nuxt.options.globalName, nuxt.options.globals)
-
- // Will be set by createRenderer
- this.bundleRenderer = null
- this.metaRenderer = null
-
- // Will be available on dev
- this.webpackDevMiddleware = null
- this.webpackHotMiddleware = null
-
- // Create new connect instance
- this.app = connect()
-
- // Renderer runtime resources
- this.resources = {
- clientManifest: null,
- serverBundle: null,
- ssrTemplate: null,
- spaTemplate: null,
- errorTemplate: parseTemplate('Nuxt.js Internal Server Error')
- }
- }
-
- async ready() {
- await this.nuxt.callHook('render:before', this, this.options.render)
- // Setup nuxt middleware
- await this.setupMiddleware()
-
- // Production: Load SSR resources from fs
- if (!this.options.dev) {
- await this.loadResources()
- }
-
- // Call done hook
- await this.nuxt.callHook('render:done', this)
- }
-
- async loadResources(_fs = fs) {
- const distPath = path.resolve(this.options.buildDir, 'dist', 'server')
- const updated = []
-
- resourceMap.forEach(({ key, fileName, transform }) => {
- const rawKey = '$$' + key
- const _path = path.join(distPath, fileName)
-
- if (!_fs.existsSync(_path)) {
- return // Resource not exists
- }
- const rawData = _fs.readFileSync(_path, 'utf8')
- if (!rawData || rawData === this.resources[rawKey]) {
- return // No changes
- }
- this.resources[rawKey] = rawData
- const data = transform(rawData)
- /* istanbul ignore if */
- if (!data) {
- return // Invalid data ?
- }
- this.resources[key] = data
- updated.push(key)
- })
-
- // Reload error template
- const errorTemplatePath = path.resolve(this.options.buildDir, 'views/error.html')
- if (fs.existsSync(errorTemplatePath)) {
- this.resources.errorTemplate = parseTemplate(
- fs.readFileSync(errorTemplatePath, 'utf8')
- )
- }
-
- // Load loading template
- const loadingHTMLPath = path.resolve(this.options.buildDir, 'loading.html')
- if (fs.existsSync(loadingHTMLPath)) {
- this.resources.loadingHTML = fs.readFileSync(loadingHTMLPath, 'utf8')
- this.resources.loadingHTML = this.resources.loadingHTML
- .replace(/\r|\n|[\t\s]{3,}/g, '')
- } else {
- this.resources.loadingHTML = ''
- }
-
- // Call resourcesLoaded plugin
- await this.nuxt.callHook('render:resourcesLoaded', this.resources)
-
- if (updated.length > 0) {
- this.createRenderer()
- }
- }
-
- get noSSR() {
- return this.options.render.ssr === false
- }
-
- get isReady() {
- if (this.noSSR) {
- return Boolean(this.resources.spaTemplate)
- }
-
- return Boolean(this.bundleRenderer && this.resources.ssrTemplate)
- }
-
- get isResourcesAvailable() {
- // Required for both
- /* istanbul ignore if */
- if (!this.resources.clientManifest) {
- return false
- }
-
- // Required for SPA rendering
- if (this.noSSR) {
- return Boolean(this.resources.spaTemplate)
- }
-
- // Required for bundle renderer
- return Boolean(this.resources.ssrTemplate && this.resources.serverBundle)
- }
-
- createRenderer() {
- // Ensure resources are available
- if (!this.isResourcesAvailable) {
- return
- }
-
- // Create Meta Renderer
- this.metaRenderer = new MetaRenderer(this.nuxt, this)
-
- // Skip following steps if noSSR mode
- if (this.noSSR) {
- return
- }
-
- const hasModules = fs.existsSync(path.resolve(this.options.rootDir, 'node_modules'))
- // Create bundle renderer for SSR
- this.bundleRenderer = createBundleRenderer(
- this.resources.serverBundle,
- Object.assign(
- {
- clientManifest: this.resources.clientManifest,
- runInNewContext: false,
- // for globally installed nuxt command, search dependencies in global dir
- basedir: hasModules ? this.options.rootDir : __dirname
- },
- this.options.render.bundleRenderer
- )
- )
- }
-
- useMiddleware(m) {
- // Resolve
- const $m = m
- if (typeof m === 'string') {
- m = this.nuxt.resolver.requireModule(m)
- }
- if (typeof m.handler === 'string') {
- m.handler = this.nuxt.resolver.requireModule(m.handler)
- }
-
- const handler = m.handler || m
- const path = (
- (m.prefix !== false ? this.options.router.base : '') +
- (typeof m.path === 'string' ? m.path : '')
- ).replace(/\/\//g, '/')
-
- handler.$m = $m
-
- // Use middleware
- this.app.use(path, handler)
- }
-
- get publicPath() {
- return isUrl(this.options.build.publicPath)
- ? NuxtConfig.build.publicPath
- : this.options.build.publicPath
- }
-
- async setupMiddleware() {
- // Apply setupMiddleware from modules first
- await this.nuxt.callHook('render:setupMiddleware', this.app)
-
- // Compression middleware for production
- if (!this.options.dev) {
- const compressor = this.options.render.compressor
- if (typeof compressor === 'object') {
- // If only setting for `compression` are provided, require the module and insert
- // Prefer require instead of requireModule to keep dependency in nuxt-start
- const compression = require('compression')
- this.useMiddleware(compression(compressor))
- } else {
- // Else, require own compression middleware
- this.useMiddleware(compressor)
- }
- }
-
- // Add webpack middleware only for development
- if (this.options.dev) {
- this.useMiddleware(async (req, res, next) => {
- if (this.webpackDevMiddleware) {
- await this.webpackDevMiddleware(req, res)
- }
- if (this.webpackHotMiddleware) {
- await this.webpackHotMiddleware(req, res)
- }
- next()
- })
- }
-
- // open in editor for debug mode only
- if (this.options.debug && this.options.dev) {
- this.useMiddleware({
- path: '__open-in-editor',
- handler: launchMiddleware(this.options.editor)
- })
- }
-
- // For serving static/ files to /
- const staticMiddleware = serveStatic(
- path.resolve(this.options.srcDir, this.options.dir.static),
- this.options.render.static
- )
- staticMiddleware.prefix = this.options.render.static.prefix
- this.useMiddleware(staticMiddleware)
-
- // Serve .nuxt/dist/ files only for production
- // For dev they will be served with devMiddleware
- if (!this.options.dev) {
- const distDir = path.resolve(this.options.buildDir, 'dist', 'client')
- this.useMiddleware({
- path: this.publicPath,
- handler: serveStatic(
- distDir,
- this.options.render.dist
- )
- })
- }
-
- // Add User provided middleware
- this.options.serverMiddleware.forEach((m) => {
- this.useMiddleware(m)
- })
-
- // Finally use nuxtMiddleware
- this.useMiddleware(nuxtMiddleware.bind(this))
-
- // Error middleware for errors that occurred in middleware that declared above
- // Middleware should exactly take 4 arguments
- // https://github.com/senchalabs/connect#error-middleware
-
- // Apply errorMiddleware from modules first
- await this.nuxt.callHook('render:errorMiddleware', this.app)
-
- // Apply errorMiddleware from Nuxt
- this.useMiddleware(errorMiddleware.bind(this))
- }
-
- renderTemplate(ssr, opts) {
- // Fix problem with HTMLPlugin's minify option (#3392)
- opts.html_attrs = opts.HTML_ATTRS
- opts.body_attrs = opts.BODY_ATTRS
-
- const fn = ssr ? this.resources.ssrTemplate : this.resources.spaTemplate
-
- return fn(opts)
- }
-
- async renderRoute(url, context = {}) {
- /* istanbul ignore if */
- if (!this.isReady) {
- await waitFor(1000)
- return this.renderRoute(url, context)
- }
-
- // Log rendered url
- consola.debug(`Rendering url ${url}`)
-
- // Add url and isSever to the context
- context.url = url
-
- // Basic response if SSR is disabled or spa data provided
- const spa = context.spa || (context.res && context.res.spa)
- const ENV = this.options.env
-
- if (this.noSSR || spa) {
- const {
- HTML_ATTRS,
- BODY_ATTRS,
- HEAD,
- BODY_SCRIPTS,
- getPreloadFiles
- } = await this.metaRenderer.render(context)
- const APP =
- `${this.resources.loadingHTML}
` + BODY_SCRIPTS
-
- // Detect 404 errors
- if (
- url.includes(this.options.build.publicPath) ||
- url.includes('__webpack')
- ) {
- const err = {
- statusCode: 404,
- message: this.options.messages.error_404,
- name: 'ResourceNotFound'
- }
- throw err
- }
-
- const html = this.renderTemplate(false, {
- HTML_ATTRS,
- BODY_ATTRS,
- HEAD,
- APP,
- ENV
- })
-
- return { html, getPreloadFiles }
- }
-
- // Call renderToString from the bundleRenderer and generate the HTML (will update the context as well)
- let APP = await this.bundleRenderer.renderToString(context)
-
- if (!context.nuxt.serverRendered) {
- APP = `
`
- }
- const m = context.meta.inject()
- let HEAD =
- m.title.text() +
- m.meta.text() +
- m.link.text() +
- m.style.text() +
- m.script.text() +
- m.noscript.text()
- if (this.options._routerBaseSpecified) {
- HEAD += ` `
- }
-
- if (this.options.render.resourceHints) {
- HEAD += context.renderResourceHints()
- }
-
- await this.nuxt.callHook('render:routeContext', context.nuxt)
-
- const serializedSession = `window.${this.globals.context}=${devalue(context.nuxt)};`
-
- const cspScriptSrcHashSet = new Set()
- if (this.options.render.csp) {
- const { hashAlgorithm } = this.options.render.csp
- const hash = crypto.createHash(hashAlgorithm)
- hash.update(serializedSession)
- cspScriptSrcHashSet.add(`'${hashAlgorithm}-${hash.digest('base64')}'`)
- }
-
- APP += ``
- APP += context.renderScripts()
- APP += m.script.text({ body: true })
- APP += m.noscript.text({ body: true })
-
- HEAD += context.renderStyles()
-
- const html = this.renderTemplate(true, {
- HTML_ATTRS: 'data-n-head-ssr ' + m.htmlAttrs.text(),
- BODY_ATTRS: m.bodyAttrs.text(),
- HEAD,
- APP,
- ENV
- })
-
- return {
- html,
- cspScriptSrcHashSet,
- getPreloadFiles: context.getPreloadFiles,
- error: context.nuxt.error,
- redirected: context.redirected
- }
- }
-
- async renderAndGetWindow(url, opts = {}) {
- /* istanbul ignore if */
- if (!jsdom) {
- try {
- jsdom = require('jsdom')
- } catch (e) /* istanbul ignore next */ {
- consola.error(`
- Fail when calling nuxt.renderAndGetWindow(url)
- jsdom module is not installed
- Please install jsdom with: npm install --save-dev jsdom
- `)
- throw e
- }
- }
- const options = Object.assign({
- resources: 'usable', // load subresources (https://github.com/tmpvar/jsdom#loading-subresources)
- runScripts: 'dangerously',
- virtualConsole: true,
- beforeParse(window) {
- // Mock window.scrollTo
- window.scrollTo = () => {
- }
- }
- }, opts)
- const jsdomErrHandler = (err) => {
- throw err
- }
- if (options.virtualConsole) {
- if (options.virtualConsole === true) {
- options.virtualConsole = new jsdom.VirtualConsole().sendTo(consola)
- }
- // throw error when window creation failed
- options.virtualConsole.on('jsdomError', jsdomErrHandler)
- }
- url = url || 'http://localhost:3000'
- const { window } = await jsdom.JSDOM.fromURL(url, options)
- // If Nuxt could not be loaded (error from the server-side)
- const nuxtExists = window.document.body.innerHTML.includes(
- this.options.render.ssr ? `window.${this.globals.context}` : ``
- )
- /* istanbul ignore if */
- if (!nuxtExists) {
- const error = new Error('Could not load the nuxt app')
- error.body = window.document.body.innerHTML
- throw error
- }
- // Used by nuxt.js to say when the components are loaded and the app ready
- const onNuxtLoaded = this.globals.loadedCallback
- await timeout(new Promise((resolve) => {
- window[onNuxtLoaded] = () => resolve(window)
- }), 20000, 'Components loading in renderAndGetWindow was not completed in 20s')
- if (options.virtualConsole) {
- // after window initialized successfully
- options.virtualConsole.removeListener('jsdomError', jsdomErrHandler)
- }
- // Send back window object
- return window
- }
-}
-
-const parseTemplate = templateStr =>
- template(templateStr, {
- interpolate: /{{([\s\S]+?)}}/g
- })
-
-export const resourceMap = [
- {
- key: 'clientManifest',
- fileName: 'vue-ssr-client-manifest.json',
- transform: JSON.parse
- },
- {
- key: 'serverBundle',
- fileName: 'server-bundle.json',
- transform: JSON.parse
- },
- {
- key: 'ssrTemplate',
- fileName: 'index.ssr.html',
- transform: parseTemplate
- },
- {
- key: 'spaTemplate',
- fileName: 'index.spa.html',
- transform: parseTemplate
- }
-]
diff --git a/packages/generator/src/generator.js b/packages/generator/src/generator.js
index 2ca16d1c17..39ba8a2180 100644
--- a/packages/generator/src/generator.js
+++ b/packages/generator/src/generator.js
@@ -153,7 +153,7 @@ export default class Generator {
}
// Render and write the SPA template to the fallback path
- const { html } = await this.nuxt.renderRoute('/', { spa: true })
+ const { html } = await this.nuxt.server.renderRoute('/', { spa: true })
await fsExtra.writeFile(fallbackPath, html, 'utf8')
}
@@ -201,7 +201,7 @@ export default class Generator {
const pageErrors = []
try {
- const res = await this.nuxt.renderer.renderRoute(route, {
+ const res = await this.nuxt.server.renderRoute(route, {
_generate: true,
payload
})
diff --git a/packages/app/package.js b/packages/server/package.js
similarity index 100%
rename from packages/app/package.js
rename to packages/server/package.js
diff --git a/packages/server/package.json b/packages/server/package.json
new file mode 100644
index 0000000000..6c58be7c18
--- /dev/null
+++ b/packages/server/package.json
@@ -0,0 +1,29 @@
+{
+ "name": "@nuxt/server",
+ "version": "2.2.0",
+ "repository": "nuxt/nuxt.js",
+ "license": "MIT",
+ "files": [
+ "dist"
+ ],
+ "main": "dist/server.js",
+ "dependencies": {
+ "@nuxt/common": "^2.2.0",
+ "@nuxt/config": "^2.2.0",
+ "@nuxtjs/youch": "^4.2.3",
+ "chalk": "^2.4.1",
+ "compression": "^1.7.3",
+ "connect": "^3.6.6",
+ "consola": "^1.4.4",
+ "etag": "^1.8.1",
+ "fresh": "^0.5.2",
+ "fs-extra": "^7.0.0",
+ "ip": "^1.1.5",
+ "launch-editor-middleware": "^2.2.1",
+ "serve-static": "^1.13.2",
+ "server-destroy": "^1.0.1"
+ },
+ "publishConfig": {
+ "access": "public"
+ }
+}
diff --git a/packages/server/src/context.js b/packages/server/src/context.js
new file mode 100644
index 0000000000..dd8a0c3844
--- /dev/null
+++ b/packages/server/src/context.js
@@ -0,0 +1,8 @@
+export default class ServerContext {
+ constructor(server) {
+ this.nuxt = server.nuxt
+ this.globals = server.globals
+ this.options = server.options
+ this.resources = server.resources
+ }
+}
diff --git a/packages/server/src/index.js b/packages/server/src/index.js
new file mode 100644
index 0000000000..fcf1442ba3
--- /dev/null
+++ b/packages/server/src/index.js
@@ -0,0 +1 @@
+export { default as Server } from './server'
diff --git a/packages/server/src/jsdom.js b/packages/server/src/jsdom.js
new file mode 100644
index 0000000000..41410325eb
--- /dev/null
+++ b/packages/server/src/jsdom.js
@@ -0,0 +1,75 @@
+import consola from 'consola'
+import { timeout } from '@nuxt/common'
+
+export default async function renderAndGetWindow(
+ url = 'http://localhost:3000',
+ jsdomOpts = {},
+ {
+ loadedCallback,
+ loadingTimeout = 2000,
+ ssr,
+ globals
+ } = {}
+) {
+ const jsdom = await import('jsdom')
+ .then(m => m.default || m)
+ .catch((e) => {
+ consola.error(`
+ jsdom is not installed. Please install jsdom with:
+ $ yarn add --dev jsdom
+ OR
+ $ npm install --dev jsdom
+ `)
+ throw e
+ })
+
+ const options = Object.assign({
+ // Load subresources (https://github.com/tmpvar/jsdom#loading-subresources)
+ resources: 'usable',
+ runScripts: 'dangerously',
+ virtualConsole: true,
+ beforeParse(window) {
+ // Mock window.scrollTo
+ window.scrollTo = () => {}
+ }
+ }, jsdomOpts)
+
+ const jsdomErrHandler = (err) => {
+ throw err
+ }
+
+ if (options.virtualConsole) {
+ if (options.virtualConsole === true) {
+ options.virtualConsole = new jsdom.VirtualConsole().sendTo(consola)
+ }
+ // Throw error when window creation failed
+ options.virtualConsole.on('jsdomError', jsdomErrHandler)
+ }
+
+ const { window } = await jsdom.JSDOM.fromURL(url, options)
+
+ // If Nuxt could not be loaded (error from the server-side)
+ const nuxtExists = window.document.body.innerHTML.includes(
+ ssr ? `window.${globals.context}` : `
`
+ )
+
+ /* istanbul ignore if */
+ if (!nuxtExists) {
+ const error = new Error('Could not load the nuxt app')
+ error.body = window.document.body.innerHTML
+ throw error
+ }
+
+ // Used by Nuxt.js to say when the components are loaded and the app ready
+ await timeout(new Promise((resolve) => {
+ window[loadedCallback] = () => resolve(window)
+ }), loadingTimeout, `Components loading in renderAndGetWindow was not completed in ${timeout / 1000}s`)
+
+ if (options.virtualConsole) {
+ // After window initialized successfully
+ options.virtualConsole.removeListener('jsdomError', jsdomErrHandler)
+ }
+
+ // Send back window object
+ return window
+}
diff --git a/packages/core/src/middleware/error.js b/packages/server/src/middleware/error.js
similarity index 80%
rename from packages/core/src/middleware/error.js
rename to packages/server/src/middleware/error.js
index bec1bb45c2..01cf3a2b88 100644
--- a/packages/core/src/middleware/error.js
+++ b/packages/server/src/middleware/error.js
@@ -4,7 +4,7 @@ import consola from 'consola'
import Youch from '@nuxtjs/youch'
-export default function errorMiddleware(err, req, res, next) {
+export default ({ resources, options }) => function errorMiddleware(err, req, res, next) {
// ensure statusCode, message and name fields
err.statusCode = err.statusCode || 500
err.message = err.message || 'Nuxt Server Error'
@@ -35,7 +35,7 @@ export default function errorMiddleware(err, req, res, next) {
hasReqHeader('user-agent', 'curl/')
// Use basic errors when debug mode is disabled
- if (!this.options.debug) {
+ if (!options.debug) {
// Json format is compatible with Youch json responses
const json = {
status: err.statusCode,
@@ -46,7 +46,7 @@ export default function errorMiddleware(err, req, res, next) {
sendResponse(JSON.stringify(json, undefined, 2), 'text/json')
return
}
- const html = this.resources.errorTemplate(json)
+ const html = resources.errorTemplate(json)
sendResponse(html)
return
}
@@ -55,8 +55,13 @@ export default function errorMiddleware(err, req, res, next) {
const youch = new Youch(
err,
req,
- readSource.bind(this),
- this.options.router.base,
+ readSourceFactory({
+ srcDir: options.srcDir,
+ rootDir: options.rootDir,
+ buildDir: options.buildDir,
+ resources
+ }),
+ options.router.base,
true
)
if (isJson) {
@@ -68,7 +73,7 @@ export default function errorMiddleware(err, req, res, next) {
}
}
-async function readSource(frame) {
+const readSourceFactory = ({ srcDir, rootDir, buildDir, resources }) => async function readSource(frame) {
// Remove webpack:/// & query string from the end
const sanitizeName = name =>
name ? name.replace('webpack:///', '').split('?')[0] : null
@@ -82,10 +87,10 @@ async function readSource(frame) {
// Possible paths for file
const searchPath = [
- this.options.srcDir,
- this.options.rootDir,
- path.join(this.options.buildDir, 'dist', 'server'),
- this.options.buildDir,
+ srcDir,
+ rootDir,
+ path.join(buildDir, 'dist', 'server'),
+ buildDir,
process.cwd()
]
@@ -97,7 +102,7 @@ async function readSource(frame) {
frame.contents = source
frame.fullPath = fullPath
if (path.isAbsolute(frame.fileName)) {
- frame.fileName = path.relative(this.options.rootDir, fullPath)
+ frame.fileName = path.relative(rootDir, fullPath)
}
return
}
@@ -107,6 +112,6 @@ async function readSource(frame) {
// TODO: restore to if after https://github.com/istanbuljs/nyc/issues/595 fixed
/* istanbul ignore next */
if (!frame.contents) {
- frame.contents = this.resources.serverBundle.files[frame.fileName]
+ frame.contents = resources.serverBundle.files[frame.fileName]
}
}
diff --git a/packages/core/src/middleware/nuxt.js b/packages/server/src/middleware/nuxt.js
similarity index 75%
rename from packages/core/src/middleware/nuxt.js
rename to packages/server/src/middleware/nuxt.js
index 3136354756..c11250c210 100644
--- a/packages/core/src/middleware/nuxt.js
+++ b/packages/server/src/middleware/nuxt.js
@@ -4,14 +4,14 @@ import consola from 'consola'
import { getContext } from '@nuxt/common'
-export default async function nuxtMiddleware(req, res, next) {
+export default ({ options, nuxt, renderRoute, resources }) => async function nuxtMiddleware(req, res, next) {
// Get context
const context = getContext(req, res)
res.statusCode = 200
try {
- const result = await this.renderRoute(req.url, context)
- await this.nuxt.callHook('render:route', req.url, result, context)
+ const result = await renderRoute(req.url, context)
+ await nuxt.callHook('render:route', req.url, result, context)
const {
html,
cspScriptSrcHashSet,
@@ -21,7 +21,7 @@ export default async function nuxtMiddleware(req, res, next) {
} = result
if (redirected) {
- this.nuxt.callHook('render:routeDone', req.url, result, context)
+ nuxt.callHook('render:routeDone', req.url, result, context)
return html
}
if (error) {
@@ -29,26 +29,29 @@ export default async function nuxtMiddleware(req, res, next) {
}
// Add ETag header
- if (!error && this.options.render.etag) {
- const etag = generateETag(html, this.options.render.etag)
+ if (!error && options.render.etag) {
+ const etag = generateETag(html, options.render.etag)
if (fresh(req.headers, { etag })) {
res.statusCode = 304
res.end()
- this.nuxt.callHook('render:routeDone', req.url, result, context)
+ nuxt.callHook('render:routeDone', req.url, result, context)
return
}
res.setHeader('ETag', etag)
}
// HTTP2 push headers for preload assets
- if (!error && this.options.render.http2.push) {
+ if (!error && options.render.http2.push) {
// Parse resourceHints to extract HTTP.2 prefetch/push headers
// https://w3c.github.io/preload/#server-push-http-2
const preloadFiles = getPreloadFiles()
- const { shouldPush, pushAssets } = this.options.render.http2
- const { publicPath } = this.resources.clientManifest
- const links = pushAssets ? pushAssets(req, res, publicPath, preloadFiles) : defaultPushAssets(preloadFiles, shouldPush, publicPath, this.options.dev)
+ const { shouldPush, pushAssets } = options.render.http2
+ const { publicPath } = resources.clientManifest
+
+ const links = pushAssets
+ ? pushAssets(req, res, publicPath, preloadFiles)
+ : defaultPushAssets(preloadFiles, shouldPush, publicPath, options.dev)
// Pass with single Link header
// https://blog.cloudflare.com/http-2-server-push-with-multiple-assets-per-link-header
@@ -58,18 +61,18 @@ export default async function nuxtMiddleware(req, res, next) {
}
}
- if (this.options.render.csp) {
- const { allowedSources, policies } = this.options.render.csp
- const cspHeader = this.options.render.csp.reportOnly ? 'Content-Security-Policy-Report-Only' : 'Content-Security-Policy'
+ if (options.render.csp) {
+ const { allowedSources, policies } = options.render.csp
+ const cspHeader = options.render.csp.reportOnly ? 'Content-Security-Policy-Report-Only' : 'Content-Security-Policy'
- res.setHeader(cspHeader, getCspString({ cspScriptSrcHashSet, allowedSources, policies, isDev: this.options.dev }))
+ res.setHeader(cspHeader, getCspString({ cspScriptSrcHashSet, allowedSources, policies, isDev: options.dev }))
}
// Send response
res.setHeader('Content-Type', 'text/html; charset=utf-8')
res.setHeader('Content-Length', Buffer.byteLength(html))
res.end(html, 'utf8')
- this.nuxt.callHook('render:routeDone', req.url, result, context)
+ nuxt.callHook('render:routeDone', req.url, result, context)
return html
} catch (err) {
/* istanbul ignore if */
diff --git a/packages/server/src/server.js b/packages/server/src/server.js
new file mode 100644
index 0000000000..986234439d
--- /dev/null
+++ b/packages/server/src/server.js
@@ -0,0 +1,276 @@
+import https from 'https'
+import path from 'path'
+import enableDestroy from 'server-destroy'
+import launchMiddleware from 'launch-editor-middleware'
+import serveStatic from 'serve-static'
+import chalk from 'chalk'
+import ip from 'ip'
+import consola from 'consola'
+import connect from 'connect'
+import { determineGlobals, isUrl } from '@nuxt/common'
+
+import ServerContext from './context'
+import renderAndGetWindow from './jsdom'
+import nuxtMiddleware from './middleware/nuxt'
+import errorMiddleware from './middleware/error'
+
+export default class Server {
+ constructor(nuxt) {
+ this.nuxt = nuxt
+ this.options = nuxt.options
+
+ this.globals = determineGlobals(nuxt.options.globalName, nuxt.options.globals)
+
+ this.publicPath = isUrl(this.options.build.publicPath)
+ ? this.options.build._publicPath
+ : this.options.build.publicPath
+
+ // Runtime shared resources
+ this.resources = {}
+
+ // Will be available on dev
+ this.webpackDevMiddleware = null
+ this.webpackHotMiddleware = null
+
+ // Create new connect instance
+ this.app = connect()
+ }
+
+ async ready() {
+ await this.nuxt.callHook('render:before', this, this.options.render)
+
+ // Initialize vue-renderer
+ const { VueRenderer } = await import('@nuxt/vue-renderer')
+
+ const context = new ServerContext(this)
+ this.renderer = new VueRenderer(context)
+ await this.renderer.ready()
+
+ // Setup nuxt middleware
+ await this.setupMiddleware()
+
+ // Call done hook
+ await this.nuxt.callHook('render:done', this)
+ }
+
+ async setupMiddleware() {
+ // Apply setupMiddleware from modules first
+ await this.nuxt.callHook('render:setupMiddleware', this.app)
+
+ // Compression middleware for production
+ if (!this.options.dev) {
+ const compressor = this.options.render.compressor
+ if (typeof compressor === 'object') {
+ // If only setting for `compression` are provided, require the module and insert
+ const compression = this.nuxt.resolver.requireModule('compression')
+ this.useMiddleware(compression(compressor))
+ } else {
+ // Else, require own compression middleware
+ this.useMiddleware(compressor)
+ }
+ }
+
+ // Add webpack middleware support only for development
+ if (this.options.dev) {
+ this.useMiddleware(async (req, res, next) => {
+ if (this.webpackDevMiddleware) {
+ await this.webpackDevMiddleware(req, res)
+ }
+ if (this.webpackHotMiddleware) {
+ await this.webpackHotMiddleware(req, res)
+ }
+ next()
+ })
+ }
+
+ // open in editor for debug mode only
+ if (this.options.debug && this.options.dev) {
+ this.useMiddleware({
+ path: '__open-in-editor',
+ handler: launchMiddleware(this.options.editor)
+ })
+ }
+
+ // For serving static/ files to /
+ const staticMiddleware = serveStatic(
+ path.resolve(this.options.srcDir, this.options.dir.static),
+ this.options.render.static
+ )
+ staticMiddleware.prefix = this.options.render.static.prefix
+ this.useMiddleware(staticMiddleware)
+
+ // Serve .nuxt/dist/client files only for production
+ // For dev they will be served with devMiddleware
+ if (!this.options.dev) {
+ const distDir = path.resolve(this.options.buildDir, 'dist', 'client')
+ this.useMiddleware({
+ path: this.publicPath,
+ handler: serveStatic(
+ distDir,
+ this.options.render.dist
+ )
+ })
+ }
+
+ // Add User provided middleware
+ this.options.serverMiddleware.forEach((m) => {
+ this.useMiddleware(m)
+ })
+
+ // Finally use nuxtMiddleware
+ this.useMiddleware(nuxtMiddleware({
+ options: this.options,
+ nuxt: this.nuxt,
+ renderRoute: this.renderRoute.bind(this),
+ resources: this.resources
+ }))
+
+ // Error middleware for errors that occurred in middleware that declared above
+ // Middleware should exactly take 4 arguments
+ // https://github.com/senchalabs/connect#error-middleware
+
+ // Apply errorMiddleware from modules first
+ await this.nuxt.callHook('render:errorMiddleware', this.app)
+
+ // Apply errorMiddleware from Nuxt
+ this.useMiddleware(errorMiddleware({
+ resources: this.resources,
+ options: this.options
+ }))
+ }
+
+ useMiddleware(middleware) {
+ // Resolve middleware
+ if (typeof middleware === 'string') {
+ middleware = this.nuxt.resolver.requireModule(middleware)
+ }
+
+ // Resolve handler
+ if (typeof middleware.handler === 'string') {
+ middleware.handler = this.nuxt.resolver.requireModule(middleware.handler)
+ }
+ const handler = middleware.handler || middleware
+
+ // Resolve path
+ const path = (
+ (middleware.prefix !== false ? this.options.router.base : '') +
+ (typeof middleware.path === 'string' ? middleware.path : '')
+ ).replace(/\/\//g, '/')
+
+ // Use middleware
+ this.app.use(path, handler)
+ }
+
+ renderRoute() {
+ return this.renderer.renderRoute.apply(this.renderer, arguments)
+ }
+
+ loadResources() {
+ return this.renderer.loadResources.apply(this.renderer, arguments)
+ }
+
+ renderAndGetWindow(url, opts = {}) {
+ return renderAndGetWindow(url, opts, {
+ loadedCallback: this.globals.loadedCallback,
+ ssr: this.options.render.ssr,
+ globals: this.globals
+ })
+ }
+
+ showReady(clear = true) {
+ if (this.readyMessage) {
+ consola.ready({
+ message: this.readyMessage,
+ badge: true,
+ clear
+ })
+ }
+ }
+
+ listen(port, host, socket) {
+ return new Promise((resolve, reject) => {
+ if (!socket && typeof this.options.server.socket === 'string') {
+ socket = this.options.server.socket
+ }
+
+ const args = { exclusive: false }
+
+ if (socket) {
+ args.path = socket
+ } else {
+ args.port = port || this.options.server.port
+ args.host = host || this.options.server.host
+ }
+
+ let appServer
+ const isHttps = Boolean(this.options.server.https)
+
+ if (isHttps) {
+ let httpsOptions
+
+ if (this.options.server.https === true) {
+ httpsOptions = {}
+ } else {
+ httpsOptions = this.options.server.https
+ }
+
+ appServer = https.createServer(httpsOptions, this.app)
+ } else {
+ appServer = this.app
+ }
+
+ const server = appServer.listen(
+ args,
+ (err) => {
+ /* istanbul ignore if */
+ if (err) {
+ return reject(err)
+ }
+
+ let listenURL
+
+ if (!socket) {
+ ({ address: host, port } = server.address())
+ if (host === '127.0.0.1') {
+ host = 'localhost'
+ } else if (host === '0.0.0.0') {
+ host = ip.address()
+ }
+
+ listenURL = chalk.underline.blue(`http${isHttps ? 's' : ''}://${host}:${port}`)
+ this.readyMessage = `Listening on ${listenURL}`
+ } else {
+ listenURL = chalk.underline.blue(`unix+http://${socket}`)
+ this.readyMessage = `Listening on ${listenURL}`
+ }
+
+ // Close server on nuxt close
+ this.nuxt.hook(
+ 'close',
+ () =>
+ new Promise((resolve, reject) => {
+ // Destroy server by forcing every connection to be closed
+ server.listening && server.destroy((err) => {
+ consola.debug('server closed')
+ /* istanbul ignore if */
+ if (err) {
+ return reject(err)
+ }
+ resolve()
+ })
+ })
+ )
+
+ if (socket) {
+ this.nuxt.callHook('listen', server, { path: socket }).then(resolve)
+ } else {
+ this.nuxt.callHook('listen', server, { port, host }).then(resolve)
+ }
+ }
+ )
+
+ // Add server.destroy(cb) method
+ enableDestroy(server)
+ })
+ }
+}
diff --git a/packages/vue-app/package.js b/packages/vue-app/package.js
new file mode 100644
index 0000000000..19d0ef6e2d
--- /dev/null
+++ b/packages/vue-app/package.js
@@ -0,0 +1,3 @@
+export default {
+ build: true
+}
diff --git a/packages/app/package.json b/packages/vue-app/package.json
similarity index 75%
rename from packages/app/package.json
rename to packages/vue-app/package.json
index 1c121aeb0f..edf38a3c03 100644
--- a/packages/app/package.json
+++ b/packages/vue-app/package.json
@@ -1,5 +1,5 @@
{
- "name": "@nuxt/app",
+ "name": "@nuxt/vue-app",
"version": "2.2.0",
"repository": "nuxt/nuxt.js",
"license": "MIT",
@@ -7,7 +7,7 @@
"dist",
"template"
],
- "main": "dist/app.js",
+ "main": "dist/vue-app.js",
"publishConfig": {
"access": "public"
}
diff --git a/packages/app/src/index.js b/packages/vue-app/src/index.js
similarity index 100%
rename from packages/app/src/index.js
rename to packages/vue-app/src/index.js
diff --git a/packages/app/template/.eslintignore b/packages/vue-app/template/.eslintignore
similarity index 100%
rename from packages/app/template/.eslintignore
rename to packages/vue-app/template/.eslintignore
diff --git a/packages/app/template/App.js b/packages/vue-app/template/App.js
similarity index 100%
rename from packages/app/template/App.js
rename to packages/vue-app/template/App.js
diff --git a/packages/app/template/client.js b/packages/vue-app/template/client.js
similarity index 100%
rename from packages/app/template/client.js
rename to packages/vue-app/template/client.js
diff --git a/packages/app/template/components/no-ssr.js b/packages/vue-app/template/components/no-ssr.js
similarity index 100%
rename from packages/app/template/components/no-ssr.js
rename to packages/vue-app/template/components/no-ssr.js
diff --git a/packages/app/template/components/nuxt-child.js b/packages/vue-app/template/components/nuxt-child.js
similarity index 100%
rename from packages/app/template/components/nuxt-child.js
rename to packages/vue-app/template/components/nuxt-child.js
diff --git a/packages/app/template/components/nuxt-error.vue b/packages/vue-app/template/components/nuxt-error.vue
similarity index 100%
rename from packages/app/template/components/nuxt-error.vue
rename to packages/vue-app/template/components/nuxt-error.vue
diff --git a/packages/app/template/components/nuxt-link.js b/packages/vue-app/template/components/nuxt-link.js
similarity index 100%
rename from packages/app/template/components/nuxt-link.js
rename to packages/vue-app/template/components/nuxt-link.js
diff --git a/packages/app/template/components/nuxt-loading.vue b/packages/vue-app/template/components/nuxt-loading.vue
similarity index 100%
rename from packages/app/template/components/nuxt-loading.vue
rename to packages/vue-app/template/components/nuxt-loading.vue
diff --git a/packages/app/template/components/nuxt.js b/packages/vue-app/template/components/nuxt.js
similarity index 100%
rename from packages/app/template/components/nuxt.js
rename to packages/vue-app/template/components/nuxt.js
diff --git a/packages/app/template/empty.js b/packages/vue-app/template/empty.js
similarity index 100%
rename from packages/app/template/empty.js
rename to packages/vue-app/template/empty.js
diff --git a/packages/app/template/index.js b/packages/vue-app/template/index.js
similarity index 100%
rename from packages/app/template/index.js
rename to packages/vue-app/template/index.js
diff --git a/packages/app/template/layouts/default.vue b/packages/vue-app/template/layouts/default.vue
similarity index 100%
rename from packages/app/template/layouts/default.vue
rename to packages/vue-app/template/layouts/default.vue
diff --git a/packages/app/template/middleware.js b/packages/vue-app/template/middleware.js
similarity index 100%
rename from packages/app/template/middleware.js
rename to packages/vue-app/template/middleware.js
diff --git a/packages/app/template/pages/index.vue b/packages/vue-app/template/pages/index.vue
similarity index 100%
rename from packages/app/template/pages/index.vue
rename to packages/vue-app/template/pages/index.vue
diff --git a/packages/app/template/router.js b/packages/vue-app/template/router.js
similarity index 100%
rename from packages/app/template/router.js
rename to packages/vue-app/template/router.js
diff --git a/packages/app/template/server.js b/packages/vue-app/template/server.js
similarity index 100%
rename from packages/app/template/server.js
rename to packages/vue-app/template/server.js
diff --git a/packages/app/template/store.js b/packages/vue-app/template/store.js
similarity index 100%
rename from packages/app/template/store.js
rename to packages/vue-app/template/store.js
diff --git a/packages/app/template/utils.js b/packages/vue-app/template/utils.js
similarity index 100%
rename from packages/app/template/utils.js
rename to packages/vue-app/template/utils.js
diff --git a/packages/app/template/views/app.template.html b/packages/vue-app/template/views/app.template.html
similarity index 100%
rename from packages/app/template/views/app.template.html
rename to packages/vue-app/template/views/app.template.html
diff --git a/packages/app/template/views/error.html b/packages/vue-app/template/views/error.html
similarity index 100%
rename from packages/app/template/views/error.html
rename to packages/vue-app/template/views/error.html
diff --git a/packages/app/template/views/loading/chasing-dots.html b/packages/vue-app/template/views/loading/chasing-dots.html
similarity index 100%
rename from packages/app/template/views/loading/chasing-dots.html
rename to packages/vue-app/template/views/loading/chasing-dots.html
diff --git a/packages/app/template/views/loading/circle.html b/packages/vue-app/template/views/loading/circle.html
similarity index 100%
rename from packages/app/template/views/loading/circle.html
rename to packages/vue-app/template/views/loading/circle.html
diff --git a/packages/app/template/views/loading/cube-grid.html b/packages/vue-app/template/views/loading/cube-grid.html
similarity index 100%
rename from packages/app/template/views/loading/cube-grid.html
rename to packages/vue-app/template/views/loading/cube-grid.html
diff --git a/packages/app/template/views/loading/default.html b/packages/vue-app/template/views/loading/default.html
similarity index 100%
rename from packages/app/template/views/loading/default.html
rename to packages/vue-app/template/views/loading/default.html
diff --git a/packages/app/template/views/loading/fading-circle.html b/packages/vue-app/template/views/loading/fading-circle.html
similarity index 100%
rename from packages/app/template/views/loading/fading-circle.html
rename to packages/vue-app/template/views/loading/fading-circle.html
diff --git a/packages/app/template/views/loading/folding-cube.html b/packages/vue-app/template/views/loading/folding-cube.html
similarity index 100%
rename from packages/app/template/views/loading/folding-cube.html
rename to packages/vue-app/template/views/loading/folding-cube.html
diff --git a/packages/app/template/views/loading/nuxt.html b/packages/vue-app/template/views/loading/nuxt.html
similarity index 100%
rename from packages/app/template/views/loading/nuxt.html
rename to packages/vue-app/template/views/loading/nuxt.html
diff --git a/packages/app/template/views/loading/pulse.html b/packages/vue-app/template/views/loading/pulse.html
similarity index 100%
rename from packages/app/template/views/loading/pulse.html
rename to packages/vue-app/template/views/loading/pulse.html
diff --git a/packages/app/template/views/loading/rectangle-bounce.html b/packages/vue-app/template/views/loading/rectangle-bounce.html
similarity index 100%
rename from packages/app/template/views/loading/rectangle-bounce.html
rename to packages/vue-app/template/views/loading/rectangle-bounce.html
diff --git a/packages/app/template/views/loading/rotating-plane.html b/packages/vue-app/template/views/loading/rotating-plane.html
similarity index 100%
rename from packages/app/template/views/loading/rotating-plane.html
rename to packages/vue-app/template/views/loading/rotating-plane.html
diff --git a/packages/app/template/views/loading/three-bounce.html b/packages/vue-app/template/views/loading/three-bounce.html
similarity index 100%
rename from packages/app/template/views/loading/three-bounce.html
rename to packages/vue-app/template/views/loading/three-bounce.html
diff --git a/packages/app/template/views/loading/wandering-cubes.html b/packages/vue-app/template/views/loading/wandering-cubes.html
similarity index 100%
rename from packages/app/template/views/loading/wandering-cubes.html
rename to packages/vue-app/template/views/loading/wandering-cubes.html
diff --git a/packages/vue-renderer/package.js b/packages/vue-renderer/package.js
new file mode 100644
index 0000000000..19d0ef6e2d
--- /dev/null
+++ b/packages/vue-renderer/package.js
@@ -0,0 +1,3 @@
+export default {
+ build: true
+}
diff --git a/packages/vue-renderer/package.json b/packages/vue-renderer/package.json
new file mode 100644
index 0000000000..fa9cea0f98
--- /dev/null
+++ b/packages/vue-renderer/package.json
@@ -0,0 +1,27 @@
+{
+ "name": "@nuxt/vue-renderer",
+ "version": "2.2.0",
+ "repository": "nuxt/nuxt.js",
+ "license": "MIT",
+ "files": [
+ "dist"
+ ],
+ "main": "dist/vue-renderer.js",
+ "dependencies": {
+ "@nuxt/common": "^2.2.0",
+ "@nuxtjs/devalue": "^1.0.1",
+ "consola": "^1.4.4",
+ "fs-extra": "^7.0.0",
+ "lru-cache": "^4.1.3",
+ "vue": "^2.5.17",
+ "vue-meta": "^1.5.5",
+ "vue-no-ssr": "^1.0.0",
+ "vue-router": "^3.0.1",
+ "vue-server-renderer": "^2.5.17",
+ "vue-template-compiler": "^2.5.17",
+ "vuex": "^3.0.1"
+ },
+ "publishConfig": {
+ "access": "public"
+ }
+}
diff --git a/packages/vue-renderer/src/index.js b/packages/vue-renderer/src/index.js
new file mode 100644
index 0000000000..0567e6025f
--- /dev/null
+++ b/packages/vue-renderer/src/index.js
@@ -0,0 +1 @@
+export { default as VueRenderer } from './renderer'
diff --git a/packages/vue-renderer/src/renderer.js b/packages/vue-renderer/src/renderer.js
new file mode 100644
index 0000000000..832dda2dad
--- /dev/null
+++ b/packages/vue-renderer/src/renderer.js
@@ -0,0 +1,297 @@
+import path from 'path'
+import crypto from 'crypto'
+import devalue from '@nuxtjs/devalue'
+import template from 'lodash/template'
+import fs from 'fs-extra'
+import { createBundleRenderer } from 'vue-server-renderer'
+import consola from 'consola'
+
+import { waitFor } from '@nuxt/common'
+
+import SPAMetaRenderer from './spa-meta'
+
+export default class VueRenderer {
+ constructor(context) {
+ this.context = context
+
+ // Will be set by createRenderer
+ this.bundleRenderer = null
+ this.spaMetaRenderer = null
+
+ // Renderer runtime resources
+ Object.assign(this.context.resources, {
+ clientManifest: null,
+ serverBundle: null,
+ ssrTemplate: null,
+ spaTemplate: null,
+ errorTemplate: this.constructor.parseTemplate('Nuxt.js Internal Server Error')
+ })
+ }
+
+ async ready() {
+ // Production: Load SSR resources from fs
+ if (!this.context.options.dev) {
+ await this.loadResources()
+ }
+ }
+
+ async loadResources(_fs = fs) {
+ const distPath = path.resolve(this.context.options.buildDir, 'dist', 'server')
+ const updated = []
+
+ this.constructor.resourceMap.forEach(({ key, fileName, transform }) => {
+ const rawKey = '$$' + key
+ const _path = path.join(distPath, fileName)
+
+ if (!_fs.existsSync(_path)) {
+ return // Resource not exists
+ }
+ const rawData = _fs.readFileSync(_path, 'utf8')
+ if (!rawData || rawData === this.context.resources[rawKey]) {
+ return // No changes
+ }
+ this.context.resources[rawKey] = rawData
+ const data = transform(rawData)
+ /* istanbul ignore if */
+ if (!data) {
+ return // Invalid data ?
+ }
+ this.context.resources[key] = data
+ updated.push(key)
+ })
+
+ // Reload error template
+ const errorTemplatePath = path.resolve(this.context.options.buildDir, 'views/error.html')
+ if (fs.existsSync(errorTemplatePath)) {
+ this.context.resources.errorTemplate = this.constructor.parseTemplate(
+ fs.readFileSync(errorTemplatePath, 'utf8')
+ )
+ }
+
+ // Load loading template
+ const loadingHTMLPath = path.resolve(this.context.options.buildDir, 'loading.html')
+ if (fs.existsSync(loadingHTMLPath)) {
+ this.context.resources.loadingHTML = fs.readFileSync(loadingHTMLPath, 'utf8')
+ this.context.resources.loadingHTML = this.context.resources.loadingHTML
+ .replace(/\r|\n|[\t\s]{3,}/g, '')
+ } else {
+ this.context.resources.loadingHTML = ''
+ }
+
+ // Call resourcesLoaded plugin
+ await this.context.nuxt.callHook('render:resourcesLoaded', this.context.resources)
+
+ if (updated.length > 0) {
+ this.createRenderer()
+ }
+ }
+
+ get noSSR() {
+ return this.context.options.render.ssr === false
+ }
+
+ get isReady() {
+ if (this.noSSR) {
+ return Boolean(this.context.resources.spaTemplate)
+ }
+
+ return Boolean(this.bundleRenderer && this.context.resources.ssrTemplate)
+ }
+
+ get isResourcesAvailable() {
+ // Required for both
+ /* istanbul ignore if */
+ if (!this.context.resources.clientManifest) {
+ return false
+ }
+
+ // Required for SPA rendering
+ if (this.noSSR) {
+ return Boolean(this.context.resources.spaTemplate)
+ }
+
+ // Required for bundle renderer
+ return Boolean(this.context.resources.ssrTemplate && this.context.resources.serverBundle)
+ }
+
+ createRenderer() {
+ // Ensure resources are available
+ if (!this.isResourcesAvailable) {
+ return
+ }
+
+ // Create Meta Renderer
+ this.spaMetaRenderer = new SPAMetaRenderer(this)
+
+ // Skip following steps if noSSR mode
+ if (this.noSSR) {
+ return
+ }
+
+ const hasModules = fs.existsSync(path.resolve(this.context.options.rootDir, 'node_modules'))
+ // Create bundle renderer for SSR
+ this.bundleRenderer = createBundleRenderer(
+ this.context.resources.serverBundle,
+ Object.assign(
+ {
+ clientManifest: this.context.resources.clientManifest,
+ runInNewContext: false,
+ // for globally installed nuxt command, search dependencies in global dir
+ basedir: hasModules ? this.context.options.rootDir : __dirname
+ },
+ this.context.options.render.bundleRenderer
+ )
+ )
+ }
+
+ renderTemplate(ssr, opts) {
+ // Fix problem with HTMLPlugin's minify option (#3392)
+ opts.html_attrs = opts.HTML_ATTRS
+ opts.body_attrs = opts.BODY_ATTRS
+
+ const fn = ssr ? this.context.resources.ssrTemplate : this.context.resources.spaTemplate
+
+ return fn(opts)
+ }
+
+ async renderRoute(url, context = {}) {
+ /* istanbul ignore if */
+ if (!this.isReady) {
+ await waitFor(1000)
+ return this.renderRoute(url, context)
+ }
+
+ // Log rendered url
+ consola.debug(`Rendering url ${url}`)
+
+ // Add url and isSever to the context
+ context.url = url
+
+ // Basic response if SSR is disabled or spa data provided
+ const spa = context.spa || (context.res && context.res.spa)
+ const ENV = this.context.options.env
+
+ if (this.noSSR || spa) {
+ const {
+ HTML_ATTRS,
+ BODY_ATTRS,
+ HEAD,
+ BODY_SCRIPTS,
+ getPreloadFiles
+ } = await this.spaMetaRenderer.render(context)
+ const APP =
+ `
${this.context.resources.loadingHTML}
` + BODY_SCRIPTS
+
+ // Detect 404 errors
+ if (
+ url.includes(this.context.options.build.publicPath) ||
+ url.includes('__webpack')
+ ) {
+ const err = {
+ statusCode: 404,
+ message: this.context.options.messages.error_404,
+ name: 'ResourceNotFound'
+ }
+ throw err
+ }
+
+ const html = this.renderTemplate(false, {
+ HTML_ATTRS,
+ BODY_ATTRS,
+ HEAD,
+ APP,
+ ENV
+ })
+
+ return { html, getPreloadFiles }
+ }
+
+ // Call renderToString from the bundleRenderer and generate the HTML (will update the context as well)
+ let APP = await this.bundleRenderer.renderToString(context)
+
+ if (!context.nuxt.serverRendered) {
+ APP = `
`
+ }
+ const m = context.meta.inject()
+ let HEAD =
+ m.title.text() +
+ m.meta.text() +
+ m.link.text() +
+ m.style.text() +
+ m.script.text() +
+ m.noscript.text()
+ if (this.context.options._routerBaseSpecified) {
+ HEAD += `
`
+ }
+
+ if (this.context.options.render.resourceHints) {
+ HEAD += context.renderResourceHints()
+ }
+
+ await this.context.nuxt.callHook('render:routeContext', context.nuxt)
+
+ const serializedSession = `window.${this.context.globals.context}=${devalue(context.nuxt)};`
+
+ const cspScriptSrcHashSet = new Set()
+ if (this.context.options.render.csp) {
+ const { hashAlgorithm } = this.context.options.render.csp
+ const hash = crypto.createHash(hashAlgorithm)
+ hash.update(serializedSession)
+ cspScriptSrcHashSet.add(`'${hashAlgorithm}-${hash.digest('base64')}'`)
+ }
+
+ APP += ``
+ APP += context.renderScripts()
+ APP += m.script.text({ body: true })
+ APP += m.noscript.text({ body: true })
+
+ HEAD += context.renderStyles()
+
+ const html = this.renderTemplate(true, {
+ HTML_ATTRS: 'data-n-head-ssr ' + m.htmlAttrs.text(),
+ BODY_ATTRS: m.bodyAttrs.text(),
+ HEAD,
+ APP,
+ ENV
+ })
+
+ return {
+ html,
+ cspScriptSrcHashSet,
+ getPreloadFiles: context.getPreloadFiles,
+ error: context.nuxt.error,
+ redirected: context.redirected
+ }
+ }
+
+ static parseTemplate(templateStr) {
+ return template(templateStr, {
+ interpolate: /{{([\s\S]+?)}}/g
+ })
+ }
+
+ static get resourceMap() {
+ return [
+ {
+ key: 'clientManifest',
+ fileName: 'vue-ssr-client-manifest.json',
+ transform: JSON.parse
+ },
+ {
+ key: 'serverBundle',
+ fileName: 'server-bundle.json',
+ transform: JSON.parse
+ },
+ {
+ key: 'ssrTemplate',
+ fileName: 'index.ssr.html',
+ transform: this.parseTemplate
+ },
+ {
+ key: 'spaTemplate',
+ fileName: 'index.spa.html',
+ transform: this.parseTemplate
+ }
+ ]
+ }
+}
diff --git a/packages/core/src/meta.js b/packages/vue-renderer/src/spa-meta.js
similarity index 93%
rename from packages/core/src/meta.js
rename to packages/vue-renderer/src/spa-meta.js
index 510431a86d..4940477085 100644
--- a/packages/core/src/meta.js
+++ b/packages/vue-renderer/src/spa-meta.js
@@ -3,11 +3,10 @@ import VueMeta from 'vue-meta'
import { createRenderer } from 'vue-server-renderer'
import LRU from 'lru-cache'
-export default class MetaRenderer {
- constructor(nuxt, renderer) {
- this.nuxt = nuxt
+export default class SPAMetaRenderer {
+ constructor(renderer) {
this.renderer = renderer
- this.options = nuxt.options
+ this.options = this.renderer.context.options
this.vueRenderer = createRenderer()
this.cache = LRU({})
@@ -69,7 +68,7 @@ export default class MetaRenderer {
meta.resourceHints = ''
- const clientManifest = this.renderer.resources.clientManifest
+ const clientManifest = this.renderer.context.resources.clientManifest
const shouldPreload = this.options.render.bundleRenderer.shouldPreload || (() => true)
const shouldPrefetch = this.options.render.bundleRenderer.shouldPrefetch || (() => true)
diff --git a/packages/webpack/src/builder.js b/packages/webpack/src/builder.js
index 5c1bcf4458..118ef2b393 100644
--- a/packages/webpack/src/builder.js
+++ b/packages/webpack/src/builder.js
@@ -120,7 +120,7 @@ export class WebpackBuilder {
})
// Reload renderer if available
- nuxt.renderer.loadResources(this.mfs || fs)
+ nuxt.server.loadResources(this.mfs || fs)
// Resolve on next tick
process.nextTick(resolve)
@@ -166,7 +166,7 @@ export class WebpackBuilder {
webpackDev(compiler) {
consola.debug('Adding webpack middleware...')
- const { nuxt: { renderer }, options } = this.context
+ const { nuxt: { server }, options } = this.context
// Create webpack dev middleware
this.webpackDevMiddleware = pify(
@@ -200,9 +200,9 @@ export class WebpackBuilder {
)
// Inject to renderer instance
- if (renderer) {
- renderer.webpackDevMiddleware = this.webpackDevMiddleware
- renderer.webpackHotMiddleware = this.webpackHotMiddleware
+ if (server) {
+ server.webpackDevMiddleware = this.webpackDevMiddleware
+ server.webpackHotMiddleware = this.webpackHotMiddleware
}
}
diff --git a/packages/webpack/src/config/base.js b/packages/webpack/src/config/base.js
index 106ce56374..50ac2140b7 100644
--- a/packages/webpack/src/config/base.js
+++ b/packages/webpack/src/config/base.js
@@ -257,7 +257,7 @@ export default class WebpackBaseConfig {
const hasErrors = Object.values(states).some(state => state.stats.hasErrors())
if (!hasErrors) {
- this.nuxt.showReady(false)
+ this.nuxt.server.showReady(false)
}
}
}
diff --git a/scripts/rollup.config.js b/scripts/rollup.config.js
index 2c5790ee54..fbd31474c2 100644
--- a/scripts/rollup.config.js
+++ b/scripts/rollup.config.js
@@ -25,10 +25,9 @@ export default function rollupConfig({
return defaultsDeep({}, options, {
input: path.resolve(rootDir, input),
output: {
- format: 'cjs',
- sourcemap: false,
file: `${pkg.name.replace('-edge', '')}.js`,
- dir: path.resolve(rootDir, 'dist')
+ dir: path.resolve(rootDir, 'dist'),
+ format: 'cjs'
},
preferConst: true,
external: [
diff --git a/test/e2e/basic.browser.test.js b/test/e2e/basic.browser.test.js
index 86cdc222d3..c215a4f6fa 100644
--- a/test/e2e/basic.browser.test.js
+++ b/test/e2e/basic.browser.test.js
@@ -13,7 +13,7 @@ describe('basic browser', () => {
const config = await loadFixture('basic')
nuxt = new Nuxt(config)
port = await getPort()
- await nuxt.listen(port, 'localhost')
+ await nuxt.server.listen(port, 'localhost')
await browser.start({
// slowMo: 50,
diff --git a/test/e2e/basic.vue-config.test.js b/test/e2e/basic.vue-config.test.js
index 90e563f08e..61386f1e0e 100644
--- a/test/e2e/basic.vue-config.test.js
+++ b/test/e2e/basic.vue-config.test.js
@@ -12,7 +12,7 @@ const startServer = async (type = 'basic') => {
const config = await loadFixture(type)
nuxt = new Nuxt(config)
port = await getPort()
- await nuxt.listen(port, 'localhost')
+ await nuxt.server.listen(port, 'localhost')
return nuxt
}
diff --git a/test/e2e/children.patch.browser.test.js b/test/e2e/children.patch.browser.test.js
index 6a189bf370..02ad78da15 100644
--- a/test/e2e/children.patch.browser.test.js
+++ b/test/e2e/children.patch.browser.test.js
@@ -14,7 +14,7 @@ describe('children patch (browser)', () => {
const options = await loadFixture('children')
nuxt = new Nuxt(options)
port = await getPort()
- await nuxt.listen(port, 'localhost')
+ await nuxt.server.listen(port, 'localhost')
})
test('Start browser', async () => {
diff --git a/test/fixtures/cli/cli.build.test.js b/test/fixtures/cli/cli.build.test.js
index 32aa75caee..109891c06d 100644
--- a/test/fixtures/cli/cli.build.test.js
+++ b/test/fixtures/cli/cli.build.test.js
@@ -8,7 +8,7 @@ const nuxtBin = resolve(__dirname, '../../../packages/cli/bin/nuxt.js')
describe('cli build', () => {
test('nuxt build', async () => {
- const { stdout } = await execify(`node ${nuxtBin} build ${rootDir} -c cli.build.config.js`)
+ const { stdout } = await execify(`node -r esm ${nuxtBin} build ${rootDir} -c cli.build.config.js`)
expect(stdout.includes('Compiled successfully')).toBe(true)
}, 80000)
diff --git a/test/unit/async-config.test.js b/test/unit/async-config.test.js
index be54f33f2b..5e85754c3c 100644
--- a/test/unit/async-config.test.js
+++ b/test/unit/async-config.test.js
@@ -8,12 +8,12 @@ describe('basic ssr', () => {
const options = await loadFixture('async-config')
nuxt = new Nuxt(options)
port = await getPort()
- await nuxt.listen(port, '0.0.0.0')
+ await nuxt.server.listen(port, '0.0.0.0')
})
test('/', async () => {
expect(nuxt.options.head.title).toBe('Async Config!')
- const { html } = await nuxt.renderRoute('/')
+ const { html } = await nuxt.server.renderRoute('/')
expect(html.includes('
I am ALIVE! ')).toBe(true)
})
})
diff --git a/test/unit/basic.config.defaults.test.js b/test/unit/basic.config.defaults.test.js
index 8695fa0d2c..f0de55e406 100644
--- a/test/unit/basic.config.defaults.test.js
+++ b/test/unit/basic.config.defaults.test.js
@@ -1,7 +1,7 @@
import { resolve } from 'path'
import consola from 'consola'
-import { Nuxt, Options, version } from '../utils'
+import { Nuxt, getNuxtConfig, version } from '../utils'
describe('basic config defaults', () => {
test('Nuxt.version is same as package', () => {
@@ -9,13 +9,13 @@ describe('basic config defaults', () => {
})
test('modulesDir uses /node_modules as default if not set', () => {
- const options = Options.from({})
+ const options = getNuxtConfig({})
const currentNodeModulesDir = resolve(__dirname, '..', '..', 'node_modules')
expect(options.modulesDir.includes(currentNodeModulesDir)).toBe(true)
})
test('vendor has been deprecated', () => {
- const options = Options.from({
+ const options = getNuxtConfig({
build: { vendor: 'vue' }
})
expect(options.build.vendor).toBeUndefined()
@@ -23,18 +23,18 @@ describe('basic config defaults', () => {
})
test('globalName uses nuxt as default if not set', () => {
- const options = Options.from({})
+ const options = getNuxtConfig({})
expect(options.globalName).toEqual('nuxt')
})
test('globalName uses nuxt as default if set to something other than only letters', () => {
- let options = Options.from({ globalName: '12foo4' })
+ let options = getNuxtConfig({ globalName: '12foo4' })
expect(options.globalName).toEqual('nuxt')
- options = Options.from({ globalName: 'foo bar' })
+ options = getNuxtConfig({ globalName: 'foo bar' })
expect(options.globalName).toEqual('nuxt')
- options = Options.from({ globalName: 'foo?' })
+ options = getNuxtConfig({ globalName: 'foo?' })
expect(options.globalName).toEqual('nuxt')
})
})
diff --git a/test/unit/basic.dev.test.js b/test/unit/basic.dev.test.js
index cc9ab034e0..158edb964d 100644
--- a/test/unit/basic.dev.test.js
+++ b/test/unit/basic.dev.test.js
@@ -48,7 +48,7 @@ describe('basic dev', () => {
builder = new Builder(nuxt, BundleBuilder)
await builder.build()
port = await getPort()
- await nuxt.listen(port, 'localhost')
+ await nuxt.server.listen(port, 'localhost')
})
test('Check build:done hook called', () => {
@@ -83,7 +83,7 @@ describe('basic dev', () => {
})
test('/stateless', async () => {
- const window = await nuxt.renderAndGetWindow(url('/stateless'))
+ const window = await nuxt.server.renderAndGetWindow(url('/stateless'))
const html = window.document.body.innerHTML
expect(html.includes('
My component! ')).toBe(true)
})
@@ -117,7 +117,7 @@ describe('basic dev', () => {
})
test('/error should return error stack trace (Youch)', async () => {
- await expect(nuxt.renderAndGetWindow(url('/error'))).rejects.toMatchObject({
+ await expect(nuxt.server.renderAndGetWindow(url('/error'))).rejects.toMatchObject({
statusCode: 500
})
})
@@ -126,7 +126,7 @@ describe('basic dev', () => {
const sourceMaps = nuxt.renderer.resources.serverBundle.maps
nuxt.renderer.resources.serverBundle.maps = {}
- await expect(nuxt.renderAndGetWindow(url('/error'))).rejects.toMatchObject({
+ await expect(nuxt.server.renderAndGetWindow(url('/error'))).rejects.toMatchObject({
statusCode: 500
})
diff --git a/test/unit/basic.generate.test.js b/test/unit/basic.generate.test.js
index 5a274a7d8b..c4fb052451 100644
--- a/test/unit/basic.generate.test.js
+++ b/test/unit/basic.generate.test.js
@@ -85,19 +85,19 @@ describe('basic generate', () => {
})
test('/stateless', async () => {
- const window = await generator.nuxt.renderAndGetWindow(url('/stateless'))
+ const window = await generator.nuxt.server.renderAndGetWindow(url('/stateless'))
const html = window.document.body.innerHTML
expect(html.includes('
My component! ')).toBe(true)
})
test('/store-module', async () => {
- const window = await generator.nuxt.renderAndGetWindow(url('/store-module'))
+ const window = await generator.nuxt.server.renderAndGetWindow(url('/store-module'))
const html = window.document.body.innerHTML
expect(html.includes('
mutated ')).toBe(true)
})
test('/css', async () => {
- const window = await generator.nuxt.renderAndGetWindow(url('/css'))
+ const window = await generator.nuxt.server.renderAndGetWindow(url('/css'))
const headHtml = window.document.head.innerHTML
expect(headHtml.includes('.red{color:red')).toBe(true)
@@ -110,13 +110,13 @@ describe('basic generate', () => {
})
test('/stateful', async () => {
- const window = await generator.nuxt.renderAndGetWindow(url('/stateful'))
+ const window = await generator.nuxt.server.renderAndGetWindow(url('/stateful'))
const html = window.document.body.innerHTML
expect(html.includes('
')).toBe(true)
})
test('/head', async () => {
- const window = await generator.nuxt.renderAndGetWindow(url('/head'))
+ const window = await generator.nuxt.server.renderAndGetWindow(url('/head'))
const html = window.document.body.innerHTML
const metas = window.document.getElementsByTagName('meta')
expect(window.document.title).toBe('My title - Nuxt.js')
@@ -125,7 +125,7 @@ describe('basic generate', () => {
})
test('/async-data', async () => {
- const window = await generator.nuxt.renderAndGetWindow(url('/async-data'))
+ const window = await generator.nuxt.server.renderAndGetWindow(url('/async-data'))
const html = window.document.body.innerHTML
expect(html.includes('
Nuxt.js
')).toBe(true)
})
@@ -165,13 +165,13 @@ describe('basic generate', () => {
})
test('/validate -> should display a 404', async () => {
- const window = await generator.nuxt.renderAndGetWindow(url('/validate'))
+ const window = await generator.nuxt.server.renderAndGetWindow(url('/validate'))
const html = window.document.body.innerHTML
expect(html.includes('This page could not be found')).toBe(true)
})
test('/validate?valid=true', async () => {
- const window = await generator.nuxt.renderAndGetWindow(url('/validate?valid=true'))
+ const window = await generator.nuxt.server.renderAndGetWindow(url('/validate?valid=true'))
const html = window.document.body.innerHTML
expect(html.includes('I am valid')).toBe(true)
})
@@ -183,7 +183,7 @@ describe('basic generate', () => {
})
test('/redirect -> check redirected source', async () => {
- const window = await generator.nuxt.renderAndGetWindow(url('/redirect'))
+ const window = await generator.nuxt.server.renderAndGetWindow(url('/redirect'))
const html = window.document.body.innerHTML
expect(html.includes('
Index page ')).toBe(true)
})
diff --git a/test/unit/basic.plugins.test.js b/test/unit/basic.plugins.test.js
index 2399d54a95..4d1e470f1f 100644
--- a/test/unit/basic.plugins.test.js
+++ b/test/unit/basic.plugins.test.js
@@ -10,11 +10,11 @@ describe('with-config', () => {
const config = await loadFixture('basic')
nuxt = new Nuxt(config)
port = await getPort()
- await nuxt.listen(port, 'localhost')
+ await nuxt.server.listen(port, 'localhost')
})
test('/', async () => {
- const window = await nuxt.renderAndGetWindow(url('/'))
+ const window = await nuxt.server.renderAndGetWindow(url('/'))
expect(window.__test_plugin).toBe(true)
})
diff --git a/test/unit/basic.ssr.csp.test.js b/test/unit/basic.ssr.csp.test.js
index b3c7177f06..4048a640de 100644
--- a/test/unit/basic.ssr.csp.test.js
+++ b/test/unit/basic.ssr.csp.test.js
@@ -10,7 +10,7 @@ const startCspServer = async (csp, isProduction = true) => {
})
const nuxt = new Nuxt(options)
port = await getPort()
- await nuxt.listen(port, '0.0.0.0')
+ await nuxt.server.listen(port, '0.0.0.0')
return nuxt
}
diff --git a/test/unit/basic.ssr.test.js b/test/unit/basic.ssr.test.js
index a4fee24087..78b550d7fb 100644
--- a/test/unit/basic.ssr.test.js
+++ b/test/unit/basic.ssr.test.js
@@ -11,16 +11,16 @@ describe('basic ssr', () => {
const options = await loadFixture('basic')
nuxt = new Nuxt(options)
port = await getPort()
- await nuxt.listen(port, '0.0.0.0')
+ await nuxt.server.listen(port, '0.0.0.0')
})
test('/stateless', async () => {
- const { html } = await nuxt.renderRoute('/stateless')
+ const { html } = await nuxt.server.renderRoute('/stateless')
expect(html.includes('
My component! ')).toBe(true)
})
test('/store-module', async () => {
- const { html } = await nuxt.renderRoute('/store-module')
+ const { html } = await nuxt.server.renderRoute('/store-module')
expect(html.includes('
mutated ')).toBe(true)
})
@@ -28,7 +28,7 @@ describe('basic ssr', () => {
** Example of testing via dom checking
*/
test('/css', async () => {
- const window = await nuxt.renderAndGetWindow(url('/css'))
+ const window = await nuxt.server.renderAndGetWindow(url('/css'))
const headHtml = window.document.head.innerHTML
expect(headHtml.includes('color:red')).toBe(true)
@@ -41,7 +41,7 @@ describe('basic ssr', () => {
})
test('/postcss', async () => {
- const window = await nuxt.renderAndGetWindow(url('/css'))
+ const window = await nuxt.server.renderAndGetWindow(url('/css'))
const headHtml = window.document.head.innerHTML
expect(headHtml.includes('background-color:#00f')).toBe(true)
@@ -51,18 +51,18 @@ describe('basic ssr', () => {
})
test('/stateful', async () => {
- const { html } = await nuxt.renderRoute('/stateful')
+ const { html } = await nuxt.server.renderRoute('/stateful')
expect(html.includes('
')).toBe(true)
})
test('/store', async () => {
- const { html } = await nuxt.renderRoute('/store')
+ const { html } = await nuxt.server.renderRoute('/store')
expect(html.includes('
Vuex Nested Modules ')).toBe(true)
expect(html.includes('
1
')).toBe(true)
})
test('/head', async () => {
- const window = await nuxt.renderAndGetWindow(url('/head'))
+ const window = await nuxt.server.renderAndGetWindow(url('/head'))
expect(window.document.title).toBe('My title - Nuxt.js')
const html = window.document.body.innerHTML
@@ -77,64 +77,64 @@ describe('basic ssr', () => {
})
test('/async-data', async () => {
- const { html } = await nuxt.renderRoute('/async-data')
+ const { html } = await nuxt.server.renderRoute('/async-data')
expect(html.includes('
Nuxt.js
')).toBe(true)
})
test('/await-async-data', async () => {
- const { html } = await nuxt.renderRoute('/await-async-data')
+ const { html } = await nuxt.server.renderRoute('/await-async-data')
expect(html.includes('
Await Nuxt.js
')).toBe(true)
})
test('/callback-async-data', async () => {
- const { html } = await nuxt.renderRoute('/callback-async-data')
+ const { html } = await nuxt.server.renderRoute('/callback-async-data')
expect(html.includes('
Callback Nuxt.js
')).toBe(true)
})
test('/users/1', async () => {
- const { html } = await nuxt.renderRoute('/users/1')
+ const { html } = await nuxt.server.renderRoute('/users/1')
expect(html.includes('
User: 1 ')).toBe(true)
})
test('/validate should display a 404', async () => {
- const { html } = await nuxt.renderRoute('/validate')
+ const { html } = await nuxt.server.renderRoute('/validate')
expect(html.includes('This page could not be found')).toBe(true)
})
test('/validate-async should display a 404', async () => {
- const { html } = await nuxt.renderRoute('/validate-async')
+ const { html } = await nuxt.server.renderRoute('/validate-async')
expect(html.includes('This page could not be found')).toBe(true)
})
test('/validate?valid=true', async () => {
- const { html } = await nuxt.renderRoute('/validate?valid=true')
+ const { html } = await nuxt.server.renderRoute('/validate?valid=true')
expect(html.includes('
I am valid ')).toBe(true)
})
test('/validate-async?valid=true', async () => {
- const { html } = await nuxt.renderRoute('/validate-async?valid=true')
+ const { html } = await nuxt.server.renderRoute('/validate-async?valid=true')
expect(html.includes('
I am valid ')).toBe(true)
})
test('/validate?error=403', async () => {
- const { html, error } = await nuxt.renderRoute('/validate?error=403')
+ const { html, error } = await nuxt.server.renderRoute('/validate?error=403')
expect(error).toMatchObject({ statusCode: 403, message: 'Custom Error' })
expect(html.includes('Custom Error')).toBe(true)
})
test('/validate-async?error=503', async () => {
- const { html, error } = await nuxt.renderRoute('/validate-async?error=503')
+ const { html, error } = await nuxt.server.renderRoute('/validate-async?error=503')
expect(error).toMatchObject({ statusCode: 503, message: 'Custom Error' })
expect(html.includes('Custom Error')).toBe(true)
})
test('/before-enter', async () => {
- const { html } = await nuxt.renderRoute('/before-enter')
+ const { html } = await nuxt.server.renderRoute('/before-enter')
expect(html.includes('
Index page ')).toBe(true)
})
test('/redirect', async () => {
- const { html, redirected } = await nuxt.renderRoute('/redirect')
+ const { html, redirected } = await nuxt.server.renderRoute('/redirect')
expect(html.includes('
')).toBe(true)
expect(redirected.path === '/').toBe(true)
expect(redirected.status === 302).toBe(true)
@@ -142,14 +142,14 @@ describe('basic ssr', () => {
test('/redirect -> check redirected source', async () => {
// there are no transition properties in jsdom, ignore the error log
- const window = await nuxt.renderAndGetWindow(url('/redirect'))
+ const window = await nuxt.server.renderAndGetWindow(url('/redirect'))
const html = window.document.body.innerHTML
expect(html.includes('
Index page ')).toBe(true)
})
test('/redirect -> external link', async () => {
let _headers, _status
- const { html } = await nuxt.renderRoute('/redirect-external', {
+ const { html } = await nuxt.server.renderRoute('/redirect-external', {
res: {
writeHead(status, headers) {
_status = status
@@ -164,13 +164,13 @@ describe('basic ssr', () => {
})
test('/special-state -> check window.__NUXT__.test = true', async () => {
- const window = await nuxt.renderAndGetWindow(url('/special-state'))
+ const window = await nuxt.server.renderAndGetWindow(url('/special-state'))
expect(window.document.title).toBe('Nuxt.js')
expect(window.__NUXT__.test).toBe(true)
})
test('/error', async () => {
- await expect(nuxt.renderRoute('/error', { req: {}, res: {} }))
+ await expect(nuxt.server.renderRoute('/error', { req: {}, res: {} }))
.rejects.toThrow('Error mouahahah')
})
@@ -198,7 +198,7 @@ describe('basic ssr', () => {
})
test('/error2', async () => {
- const { html, error } = await nuxt.renderRoute('/error2')
+ const { html, error } = await nuxt.server.renderRoute('/error2')
expect(html.includes('Custom error')).toBe(true)
expect(error.message.includes('Custom error')).toBe(true)
expect(error.statusCode === undefined).toBe(true)
@@ -220,21 +220,21 @@ describe('basic ssr', () => {
})
test('/redirect-name', async () => {
- const { html, redirected } = await nuxt.renderRoute('/redirect-name')
+ const { html, redirected } = await nuxt.server.renderRoute('/redirect-name')
expect(html.includes('
')).toBe(true)
expect(redirected.path === '/stateless').toBe(true)
expect(redirected.status === 302).toBe(true)
})
test('/no-ssr', async () => {
- const { html } = await nuxt.renderRoute('/no-ssr')
+ const { html } = await nuxt.server.renderRoute('/no-ssr')
expect(html.includes(
'
Loading...
'
)).toBe(true)
})
test('/no-ssr (client-side)', async () => {
- const window = await nuxt.renderAndGetWindow(url('/no-ssr'))
+ const window = await nuxt.server.renderAndGetWindow(url('/no-ssr'))
const html = window.document.body.innerHTML
expect(html.includes('Displayed only on client-side')).toBe(true)
})
@@ -259,7 +259,7 @@ describe('basic ssr', () => {
})
test('/meta', async () => {
- const { html } = await nuxt.renderRoute('/meta')
+ const { html } = await nuxt.server.renderRoute('/meta')
expect(/
.*"works": true.*<\/pre>/s.test(html)).toBe(true)
})
@@ -269,28 +269,28 @@ describe('basic ssr', () => {
})
test('/fn-midd?please=true', async () => {
- const { html } = await nuxt.renderRoute('/fn-midd?please=true')
+ const { html } = await nuxt.server.renderRoute('/fn-midd?please=true')
expect(html.includes('Date:')).toBe(true)
})
test('/router-guard', async () => {
- const { html } = await nuxt.renderRoute('/router-guard')
+ const { html } = await nuxt.server.renderRoute('/router-guard')
expect(html.includes(' Nuxt.js
')).toBe(true)
expect(html.includes('Router Guard')).toBe(false)
})
test('/jsx', async () => {
- const { html } = await nuxt.renderRoute('/jsx')
+ const { html } = await nuxt.server.renderRoute('/jsx')
expect(html.includes('JSX Page ')).toBe(true)
})
test('/jsx-link', async () => {
- const { html } = await nuxt.renderRoute('/jsx-link')
+ const { html } = await nuxt.server.renderRoute('/jsx-link')
expect(html.includes('JSX Link Page ')).toBe(true)
})
test('/js-link', async () => {
- const { html } = await nuxt.renderRoute('/js-link')
+ const { html } = await nuxt.server.renderRoute('/js-link')
expect(html.includes('vue file is first-class ')).toBe(true)
})
diff --git a/test/unit/children.test.js b/test/unit/children.test.js
index 166b4ef518..4da2dcc8f9 100644
--- a/test/unit/children.test.js
+++ b/test/unit/children.test.js
@@ -10,39 +10,39 @@ describe('children', () => {
const options = await loadFixture('children')
nuxt = new Nuxt(options)
port = await getPort()
- await nuxt.listen(port, 'localhost')
+ await nuxt.server.listen(port, 'localhost')
})
test('/parent', async () => {
- const { html } = await nuxt.renderRoute('/parent')
+ const { html } = await nuxt.server.renderRoute('/parent')
expect(html.includes('I am the parent ')).toBe(true)
})
test('/parent/child', async () => {
- const { html } = await nuxt.renderRoute('/parent/child')
+ const { html } = await nuxt.server.renderRoute('/parent/child')
expect(html.includes('I am the parent ')).toBe(true)
expect(html.includes('I am the child ')).toBe(true)
})
test('/parent should call _id.vue', async () => {
- const { html } = await nuxt.renderRoute('/parent')
+ const { html } = await nuxt.server.renderRoute('/parent')
expect(html.includes('I am the parent ')).toBe(true)
expect(html.includes('Id= ')).toBe(true)
})
test('/parent/1', async () => {
- const { html } = await nuxt.renderRoute('/parent/1')
+ const { html } = await nuxt.server.renderRoute('/parent/1')
expect(html.includes('I am the parent ')).toBe(true)
expect(html.includes('Id=1 ')).toBe(true)
})
test('/parent/validate-child should display 404', async () => {
- const { html } = await nuxt.renderRoute('/parent/validate-child')
+ const { html } = await nuxt.server.renderRoute('/parent/validate-child')
expect(html.includes('This page could not be found')).toBe(true)
})
test('/parent/validate-child?key=12345', async () => {
- const { html } = await nuxt.renderRoute('/parent/validate-child?key=12345')
+ const { html } = await nuxt.server.renderRoute('/parent/validate-child?key=12345')
expect(html.includes('I am the parent ')).toBe(true)
expect(html.includes('Child valid ')).toBe(true)
})
diff --git a/test/unit/custom-app-template.test.js b/test/unit/custom-app-template.test.js
index cd6dfe458d..22bbdb1174 100644
--- a/test/unit/custom-app-template.test.js
+++ b/test/unit/custom-app-template.test.js
@@ -8,10 +8,10 @@ describe('custom-app-template', () => {
const options = await loadFixture('custom-app-template')
nuxt = new Nuxt(options)
port = await getPort()
- await nuxt.listen(port, '0.0.0.0')
+ await nuxt.server.listen(port, '0.0.0.0')
})
test('/', async () => {
- const { html } = await nuxt.renderRoute('/')
+ const { html } = await nuxt.server.renderRoute('/')
expect(html.includes('My Template
')).toBe(true)
expect(html.includes('Custom! ')).toBe(true)
})
diff --git a/test/unit/custom-dirs.test.js b/test/unit/custom-dirs.test.js
index 8f351db726..d5a6c31e71 100644
--- a/test/unit/custom-dirs.test.js
+++ b/test/unit/custom-dirs.test.js
@@ -13,7 +13,7 @@ describe('custom-dirs', () => {
const config = await loadFixture('custom-dirs')
nuxt = new Nuxt(config)
port = await getPort()
- await nuxt.listen(port, 'localhost')
+ await nuxt.server.listen(port, 'localhost')
})
test('custom assets directory', async () => {
@@ -26,18 +26,18 @@ describe('custom-dirs', () => {
})
test('custom layouts directory', async () => {
- const { html } = await nuxt.renderRoute('/')
+ const { html } = await nuxt.server.renderRoute('/')
expect(html.includes('I have custom layouts directory
')).toBe(true)
})
test('custom middleware directory', async () => {
- const window = await nuxt.renderAndGetWindow(url('/user-agent'))
+ const window = await nuxt.server.renderAndGetWindow(url('/user-agent'))
const html = window.document.body.innerHTML
expect(html.includes('Mozilla')).toBe(true)
})
test('custom pages directory', async () => {
- const { html } = await nuxt.renderRoute('/')
+ const { html } = await nuxt.server.renderRoute('/')
expect(html.includes('I have custom pages directory ')).toBe(true)
})
diff --git a/test/unit/dist-options.test.js b/test/unit/dist-options.test.js
index 2c78c1bfcb..fc0700796b 100644
--- a/test/unit/dist-options.test.js
+++ b/test/unit/dist-options.test.js
@@ -10,7 +10,7 @@ describe('dist options', () => {
const options = await loadFixture('basic')
nuxt = new Nuxt(Object.assign(options, { dev: false }))
port = await getPort()
- await nuxt.listen(port, '0.0.0.0')
+ await nuxt.server.listen(port, '0.0.0.0')
})
test('Specify maxAge/index in render.dist options', async () => {
diff --git a/test/unit/error.test.js b/test/unit/error.test.js
index 97c2487cd5..474687d689 100644
--- a/test/unit/error.test.js
+++ b/test/unit/error.test.js
@@ -13,22 +13,22 @@ describe('error', () => {
const config = await loadFixture('error')
nuxt = new Nuxt(config)
port = await getPort()
- await nuxt.listen(port, 'localhost')
+ await nuxt.server.listen(port, 'localhost')
})
test('/ should display an error', async () => {
- await expect(nuxt.renderRoute('/')).rejects.toMatchObject({
+ await expect(nuxt.server.renderRoute('/')).rejects.toMatchObject({
message: expect.stringContaining('not_defined is not defined')
})
})
test('/404 should display an error too', async () => {
- const { error } = await nuxt.renderRoute('/404')
+ const { error } = await nuxt.server.renderRoute('/404')
expect(error.message.includes('This page could not be found')).toBe(true)
})
test('/ with renderAndGetWindow()', async () => {
- await expect(nuxt.renderAndGetWindow(url('/'))).rejects.toMatchObject({
+ await expect(nuxt.server.renderAndGetWindow(url('/'))).rejects.toMatchObject({
statusCode: 500
})
})
diff --git a/test/unit/extract-css.test.js b/test/unit/extract-css.test.js
index fd1b7c39a8..86bbd95ce2 100644
--- a/test/unit/extract-css.test.js
+++ b/test/unit/extract-css.test.js
@@ -11,7 +11,7 @@ describe('extract css', () => {
beforeAll(async () => {
const options = await loadFixture('extract-css')
nuxt = new Nuxt(options)
- await nuxt.listen(await getPort(), '0.0.0.0')
+ await nuxt.server.listen(await getPort(), '0.0.0.0')
})
test.skip('Verify global.css has been extracted and minified', async () => {
@@ -27,7 +27,7 @@ describe('extract css', () => {
})
test('/about should contain module style', async () => {
- const { html } = await nuxt.renderRoute('/about')
+ const { html } = await nuxt.server.renderRoute('/about')
expect(html).toMatch(/I'm BLUE<\/h1>/)
})
})
diff --git a/test/unit/fallback.generate.test.js b/test/unit/fallback.generate.test.js
index 1d52b306cf..2afec697e6 100644
--- a/test/unit/fallback.generate.test.js
+++ b/test/unit/fallback.generate.test.js
@@ -3,7 +3,7 @@ import { existsSync } from 'fs'
import { resolve } from 'path'
import serveStatic from 'serve-static'
import finalhandler from 'finalhandler'
-import { loadFixture, getPort, Nuxt, Generator, Options, rp } from '../utils'
+import { loadFixture, getPort, Nuxt, Generator, getNuxtConfig, rp } from '../utils'
let port
const url = route => 'http://localhost:' + port + route
@@ -76,7 +76,7 @@ describe('fallback generate', () => {
test('generate.fallback = true is transformed to /404.html', () => {
nuxt.options.generate.fallback = true
- const options = Options.from(nuxt.options)
+ const options = getNuxtConfig(nuxt.options)
expect(options.generate.fallback).toBe('404.html')
})
diff --git a/test/unit/https.test.js b/test/unit/https.test.js
index 1168a920d3..6539a0ad90 100644
--- a/test/unit/https.test.js
+++ b/test/unit/https.test.js
@@ -7,11 +7,11 @@ describe('basic https', () => {
const options = await loadFixture('https')
nuxt = new Nuxt(options)
const port = await getPort()
- await nuxt.listen(port, '0.0.0.0')
+ await nuxt.server.listen(port, '0.0.0.0')
})
test('/', async () => {
- const { html } = await nuxt.renderRoute('/')
+ const { html } = await nuxt.server.renderRoute('/')
expect(html.includes('Served over HTTPS! ')).toBe(true)
})
diff --git a/test/unit/module.test.js b/test/unit/module.test.js
index f53ff3859a..0fd337d84d 100644
--- a/test/unit/module.test.js
+++ b/test/unit/module.test.js
@@ -13,26 +13,26 @@ describe('module', () => {
const config = await loadFixture('module')
nuxt = new Nuxt(config)
port = await getPort()
- await nuxt.listen(port, 'localhost')
+ await nuxt.server.listen(port, 'localhost')
})
test('Plugin', async () => {
expect(normalize(nuxt.options.plugins[0].src).includes(
normalize('fixtures/module/.nuxt/basic.reverse.')
)).toBe(true)
- const { html } = await nuxt.renderRoute('/')
+ const { html } = await nuxt.server.renderRoute('/')
expect(html.includes('TXUN ')).toBe(true)
})
test('Layout', async () => {
expect(nuxt.options.layouts.layout.includes('layout')).toBe(true)
- const { html } = await nuxt.renderRoute('/layout')
+ const { html } = await nuxt.server.renderRoute('/layout')
expect(html.includes('Module Layouts ')).toBe(true)
})
test('/404 should display the module error layout', async () => {
- const { html } = await nuxt.renderRoute('/404')
+ const { html } = await nuxt.server.renderRoute('/404')
expect(html).toContain('You should see the error in a different Vue!')
})
@@ -60,7 +60,7 @@ describe('module', () => {
})
test('Hooks - render context', async () => {
- await nuxt.renderRoute('/render-context')
+ await nuxt.server.renderRoute('/render-context')
expect(nuxt.__render_context).toBeTruthy()
})
diff --git a/test/unit/nuxt.test.js b/test/unit/nuxt.test.js
index 0108e7c2e2..fb3396947b 100644
--- a/test/unit/nuxt.test.js
+++ b/test/unit/nuxt.test.js
@@ -36,9 +36,9 @@ describe('nuxt', () => {
const nuxt = new Nuxt()
new Builder(nuxt).build()
const port = await getPort()
- await nuxt.listen(port, 'localhost')
+ await nuxt.server.listen(port, 'localhost')
- const { html } = await nuxt.renderRoute('/')
+ const { html } = await nuxt.server.renderRoute('/')
expect(html.includes('Universal Vue.js Applications')).toBe(true)
expect(/Landscape__Page__Explanation/.test(html)).toBe(true)
diff --git a/test/unit/sockets.test.js b/test/unit/sockets.test.js
index a617b3af04..85be8752b0 100644
--- a/test/unit/sockets.test.js
+++ b/test/unit/sockets.test.js
@@ -6,11 +6,11 @@ describe.skip.win('basic sockets', () => {
beforeAll(async () => {
const options = await loadFixture('sockets')
nuxt = new Nuxt(options)
- await nuxt.listen()
+ await nuxt.server.listen()
})
test('/', async () => {
- const { html } = await nuxt.renderRoute('/')
+ const { html } = await nuxt.server.renderRoute('/')
expect(html.includes('Served over sockets! ')).toBe(true)
})
diff --git a/test/unit/spa.test.js b/test/unit/spa.test.js
index f631535657..01d60ad17d 100644
--- a/test/unit/spa.test.js
+++ b/test/unit/spa.test.js
@@ -5,7 +5,7 @@ let nuxt, port
const url = route => 'http://localhost:' + port + route
const renderRoute = async (_url) => {
- const window = await nuxt.renderAndGetWindow(url(_url))
+ const window = await nuxt.server.renderAndGetWindow(url(_url))
const head = window.document.head.innerHTML
const html = window.document.body.innerHTML
return { window, head, html }
@@ -16,7 +16,7 @@ describe('spa', () => {
const config = await loadFixture('spa')
nuxt = new Nuxt(config)
port = await getPort()
- await nuxt.listen(port, 'localhost')
+ await nuxt.server.listen(port, 'localhost')
})
test('/ (basic spa)', async () => {
diff --git a/test/unit/ssr.test.js b/test/unit/ssr.test.js
index 5656e86f6f..5e09eb6a8e 100644
--- a/test/unit/ssr.test.js
+++ b/test/unit/ssr.test.js
@@ -23,7 +23,7 @@ const uniqueTest = async (url) => {
const results = []
await parallel(range(5), async () => {
- const { html } = await nuxt.renderRoute(url)
+ const { html } = await nuxt.server.renderRoute(url)
const foobar = match(FOOBAR_REGEX, html)
results.push(parseInt(foobar))
})
@@ -67,7 +67,7 @@ describe('ssr', () => {
const config = await loadFixture('ssr')
nuxt = new Nuxt(config)
port = await getPort()
- await nuxt.listen(port, 'localhost')
+ await nuxt.server.listen(port, 'localhost')
})
test('unique responses with data()', async () => {
@@ -99,7 +99,7 @@ describe('ssr', () => {
})
test('store undefined variable response', async () => {
- const window = await nuxt.renderAndGetWindow(url('/store'))
+ const window = await nuxt.server.renderAndGetWindow(url('/store'))
expect('idUndefined' in window.__NUXT__.state).toBe(true)
expect(window.__NUXT__.state.idUndefined).toEqual(undefined)
})
diff --git a/test/unit/with-config.test.js b/test/unit/with-config.test.js
index 09bea055fc..453281c03e 100644
--- a/test/unit/with-config.test.js
+++ b/test/unit/with-config.test.js
@@ -11,53 +11,53 @@ describe('with-config', () => {
const config = await loadFixture('with-config')
nuxt = new Nuxt(config)
port = await getPort()
- await nuxt.listen(port, 'localhost')
+ await nuxt.server.listen(port, 'localhost')
})
test('/', async () => {
- const { html } = await nuxt.renderRoute('/')
+ const { html } = await nuxt.server.renderRoute('/')
expect(html.includes('I have custom configurations ')).toBe(true)
})
test('/ (asset name for analyze mode)', async () => {
- const { html } = await nuxt.renderRoute('/')
+ const { html } = await nuxt.server.renderRoute('/')
expect(html).toContain('
diff --git a/test/unit/modern.test.js b/test/unit/modern.test.js
new file mode 100644
index 0000000000..f57a014516
--- /dev/null
+++ b/test/unit/modern.test.js
@@ -0,0 +1,39 @@
+import { loadFixture, getPort, Nuxt, rp } from '../utils'
+
+let nuxt, port
+const url = route => 'http://localhost:' + port + route
+
+describe('modern build', () => {
+ beforeAll(async () => {
+ const options = await loadFixture('modern')
+ nuxt = new Nuxt(options)
+ port = await getPort()
+ await nuxt.server.listen(port, 'localhost')
+ })
+
+ test('should use legacy resources by default', async () => {
+ const response = await rp(url('/'))
+ expect(response).toContain('/_nuxt/app.js')
+ expect(response).toContain('/_nuxt/commons.app.js')
+ })
+
+ test('should use modern resources for modern resources', async () => {
+ const response = await rp(url('/'), {
+ headers: {
+ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36'
+ }
+ })
+ expect(response).toContain('/_nuxt/modern-app.js')
+ expect(response).toContain('/_nuxt/modern-commons.app.js')
+ })
+
+ test('should include es6 syntax in modern resources', async () => {
+ const response = await rp(url('/_nuxt/modern-app.js'))
+ expect(response).toContain('arrow:()=>"build test"')
+ })
+
+ test('should not include es6 syntax in normal resources', async () => {
+ const response = await rp(url('/_nuxt/app.js'))
+ expect(response).not.toContain('arrow:()=>"build test"')
+ })
+})
diff --git a/test/utils/build.js b/test/utils/build.js
index 7a022edec3..897b445ca6 100644
--- a/test/utils/build.js
+++ b/test/utils/build.js
@@ -1,4 +1,4 @@
-import { loadFixture, Nuxt, Builder, listPaths, equalOrStartsWith } from './index'
+import { loadFixture, Nuxt, Builder, BundleBuilder, listPaths, equalOrStartsWith } from './index'
export const buildFixture = function (fixture, callback, hooks = []) {
const pathsBefore = {}
@@ -16,7 +16,7 @@ export const buildFixture = function (fixture, callback, hooks = []) {
const buildDone = jest.fn()
hooks.forEach(([hook, fn]) => nuxt.hook(hook, fn))
nuxt.hook('build:done', buildDone)
- const builder = await new Builder(nuxt).build()
+ const builder = await new Builder(nuxt, BundleBuilder).build()
// 2: BUILD_DONE
expect(builder._buildStatus).toBe(2)
expect(buildDone).toHaveBeenCalledTimes(1)
diff --git a/yarn.lock b/yarn.lock
index 357bd22cab..aa6cd707c2 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2419,6 +2419,15 @@ browserify-zlib@^0.2.0:
dependencies:
pako "~1.0.5"
+browserslist-useragent@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.npmjs.org/browserslist-useragent/-/browserslist-useragent-2.0.1.tgz#ea5f706bc426c5fb2b5adf97cde7c1aed0864d0f"
+ integrity sha1-6l9wa8QmxfsrWt+XzefBrtCGTQ8=
+ dependencies:
+ browserslist "^4.0.1"
+ semver "^5.4.1"
+ useragent "^2.2.1"
+
browserslist@^4.0.0, browserslist@^4.1.0:
version "4.2.1"
resolved "https://registry.npmjs.org/browserslist/-/browserslist-4.2.1.tgz#257a24c879d1cd4016348eee5c25de683260b21d"
@@ -2428,7 +2437,7 @@ browserslist@^4.0.0, browserslist@^4.1.0:
electron-to-chromium "^1.3.79"
node-releases "^1.0.0-alpha.14"
-browserslist@^4.3.3, browserslist@^4.3.4:
+browserslist@^4.0.1, browserslist@^4.3.3, browserslist@^4.3.4:
version "4.3.4"
resolved "https://registry.npmjs.org/browserslist/-/browserslist-4.3.4.tgz#4477b737db6a1b07077275b24791e680d4300425"
integrity sha512-u5iz+ijIMUlmV8blX82VGFrB9ecnUg5qEt55CMZ/YJEhha+d8qpBfOFuutJ6F/VKRXjZoD33b6uvarpPxcl3RA==
@@ -6768,7 +6777,7 @@ lower-case@^1.1.1:
resolved "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz#9a2cabd1b9e8e0ae993a4bf7d5875c39c42e8eac"
integrity sha1-miyr0bno4K6ZOkv31YdcOcQujqw=
-lru-cache@^4.0.1, lru-cache@^4.1.1, lru-cache@^4.1.2, lru-cache@^4.1.3:
+lru-cache@4.1.x, lru-cache@^4.0.1, lru-cache@^4.1.1, lru-cache@^4.1.2, lru-cache@^4.1.3:
version "4.1.3"
resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.3.tgz#a1175cf3496dfc8436c156c334b4955992bce69c"
integrity sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA==
@@ -10468,7 +10477,7 @@ timsort@^0.3.0:
resolved "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4"
integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=
-tmp@^0.0.33:
+tmp@0.0.x, tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==
@@ -10806,6 +10815,14 @@ use@^3.1.0:
resolved "https://registry.npmjs.org/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"
integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==
+useragent@^2.2.1:
+ version "2.3.0"
+ resolved "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz#217f943ad540cb2128658ab23fc960f6a88c9972"
+ integrity sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw==
+ dependencies:
+ lru-cache "4.1.x"
+ tmp "0.0.x"
+
util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
From 8ff281e46de48f4d9dbcfe58037be49fc018207a Mon Sep 17 00:00:00 2001
From: Clark Du
Date: Wed, 31 Oct 2018 16:33:22 +0000
Subject: [PATCH 077/149] chore: add lerna changelog config (#4238)
---
lerna.json | 9 +++++++++
package.json | 4 ++++
2 files changed, 13 insertions(+)
diff --git a/lerna.json b/lerna.json
index 4aff17bfab..05cd08fc9f 100644
--- a/lerna.json
+++ b/lerna.json
@@ -14,5 +14,14 @@
"publish": {
"npmClient": "npm"
}
+ },
+ "changelog": {
+ "labels": {
+ "feat": "New Feature",
+ "fix": "Bug Fix",
+ "docs": "Documentation",
+ "perf": "Performance",
+ "refactor": "Code Refactoring"
+ }
}
}
diff --git a/package.json b/package.json
index 6b8bac1477..d61d8f7cbb 100644
--- a/package.json
+++ b/package.json
@@ -70,5 +70,9 @@
"rollup-plugin-replace": "^2.1.0",
"sort-package-json": "^1.16.0",
"vue-jest": "^3.0.0"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/nuxt/nuxt.js.git"
}
}
From 7c89a4a78554f5be75626dd5d0eb6f77e9341643 Mon Sep 17 00:00:00 2001
From: Clark Du
Date: Wed, 31 Oct 2018 17:08:55 +0000
Subject: [PATCH 078/149] chore: add lock and stale config (#4240)
## Types of changes
- [ ] Bug fix (a non-breaking change which fixes an issue)
- [ ] New feature (a non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
## Description
## Checklist:
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly. (PR: #)
- [ ] I have added tests to cover my changes (if not applicable, please state why)
- [ ] All new and existing tests are passing.
---
.github/lock.yml | 8 ++++++++
.github/stale.yml | 7 +++++++
2 files changed, 15 insertions(+)
create mode 100644 .github/lock.yml
create mode 100644 .github/stale.yml
diff --git a/.github/lock.yml b/.github/lock.yml
new file mode 100644
index 0000000000..6580ca74ab
--- /dev/null
+++ b/.github/lock.yml
@@ -0,0 +1,8 @@
+# Configuration for lock-threads - https://github.com/dessant/lock-threads
+daysUntilLock: 30
+exemptLabels: []
+lockLabel: false
+lockComment: >
+ This thread has been automatically locked since there has not been
+ any recent activity after it was closed. Please open a new issue for
+ related bugs.
diff --git a/.github/stale.yml b/.github/stale.yml
new file mode 100644
index 0000000000..bcdd71c075
--- /dev/null
+++ b/.github/stale.yml
@@ -0,0 +1,7 @@
+# Configuration for probot-stale - https://github.com/probot/stale
+daysUntilStale: 21
+daysUntilClose: 7
+staleLabel: stale
+markComment: >
+ This issue has been automatically marked as stale because it has not had
+ recent activity. It will be closed if no further activity occurs.
From 3ec2579d09ad3790630d77f9cd519d6bad238363 Mon Sep 17 00:00:00 2001
From: Kayla Ngan
Date: Wed, 31 Oct 2018 14:39:50 -0400
Subject: [PATCH 079/149] chore(ci, azure): report test results on azure
pipelines (#4242)
---
azure-pipelines.yml | 10 ++++++++--
jest.config.js | 5 +++++
package.json | 1 +
yarn.lock | 18 +++++++++++++++++-
4 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 4fa4d6940d..3c166a785a 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -20,9 +20,15 @@ steps:
displayName: 'Install dependencies'
- script: |
- yarn test:fixtures -w=2
+ set JEST_JUNIT_OUTPUT=test-fixtures-junit.xml && yarn test:fixtures -w=2
displayName: 'Test: Build Fixtures'
- script: |
- yarn test:unit -w=2
+ set JEST_JUNIT_OUTPUT=test-unit-junit.xml && yarn test:unit -w=2
displayName: 'Test: Run unit tests'
+
+- task: PublishTestResults@2
+ inputs:
+ testResultsFormat: 'JUnit'
+ testResultsFiles: 'test-*.xml'
+ displayName: 'Publish test results to Azure Pipelines'
diff --git a/jest.config.js b/jest.config.js
index c2546d018f..90431ce159 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -40,5 +40,10 @@ module.exports = {
moduleFileExtensions: [
'js',
'json'
+ ],
+
+ reporters: [
+ 'default',
+ 'jest-junit'
]
}
diff --git a/package.json b/package.json
index d61d8f7cbb..9741594392 100644
--- a/package.json
+++ b/package.json
@@ -50,6 +50,7 @@
"get-port": "^4.0.0",
"glob": "^7.1.3",
"jest": "^23.6.0",
+ "jest-junit": "^5.2.0",
"jsdom": "^13.0.0",
"klaw-sync": "^6.0.0",
"lerna": "^3.4.3",
diff --git a/yarn.lock b/yarn.lock
index aa6cd707c2..7dd858b23d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -6127,6 +6127,17 @@ jest-jasmine2@^23.6.0:
jest-util "^23.4.0"
pretty-format "^23.6.0"
+jest-junit@^5.2.0:
+ version "5.2.0"
+ resolved "https://registry.npmjs.org/jest-junit/-/jest-junit-5.2.0.tgz#980401db7aa69999cf117c6d740a8135c22ae379"
+ integrity sha512-Mdg0Qpdh1Xm/FA1B/mcLlmEmlr3XzH5pZg7MvcAwZhjHijPRd1z/UwYwkwNHmCV7o4ZOWCf77nLu7ZkhHHrtJg==
+ dependencies:
+ jest-config "^23.6.0"
+ jest-validate "^23.0.1"
+ mkdirp "^0.5.1"
+ strip-ansi "^4.0.0"
+ xml "^1.0.1"
+
jest-leak-detector@^23.6.0:
version "23.6.0"
resolved "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-23.6.0.tgz#e4230fd42cf381a1a1971237ad56897de7e171de"
@@ -6262,7 +6273,7 @@ jest-util@^23.4.0:
slash "^1.0.0"
source-map "^0.6.0"
-jest-validate@^23.6.0:
+jest-validate@^23.0.1, jest-validate@^23.6.0:
version "23.6.0"
resolved "https://registry.npmjs.org/jest-validate/-/jest-validate-23.6.0.tgz#36761f99d1ed33fcd425b4e4c5595d62b6597474"
integrity sha512-OFKapYxe72yz7agrDAWi8v2WL8GIfVqcbKRCLbRG9PAxtzF9b1SEDdTpytNDN12z2fJynoBwpMpvj2R39plI2A==
@@ -11345,6 +11356,11 @@ xml-name-validator@^3.0.0:
resolved "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==
+xml@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
+ integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=
+
xmlchars@^1.3.1:
version "1.3.1"
resolved "https://registry.npmjs.org/xmlchars/-/xmlchars-1.3.1.tgz#1dda035f833dbb4f86a0c28eaa6ca769214793cf"
From d6e6ded74ef29561031742f5c52540234fc826e5 Mon Sep 17 00:00:00 2001
From: Clark Du
Date: Wed, 31 Oct 2018 19:08:45 +0000
Subject: [PATCH 080/149] chore: exlcude feature-request in stale
---
.github/stale.yml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.github/stale.yml b/.github/stale.yml
index bcdd71c075..d2963a6b8a 100644
--- a/.github/stale.yml
+++ b/.github/stale.yml
@@ -2,6 +2,8 @@
daysUntilStale: 21
daysUntilClose: 7
staleLabel: stale
+exemptLabels:
+ - "cmty:feature-request"
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.
From e502d95090d04c20d51eeb35b800107ec65a38a5 Mon Sep 17 00:00:00 2001
From: Kayla Ngan
Date: Wed, 31 Oct 2018 16:18:25 -0400
Subject: [PATCH 081/149] chore(ci, azure): remove trailing spaces in SET
---
azure-pipelines.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 3c166a785a..168b259462 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -20,11 +20,11 @@ steps:
displayName: 'Install dependencies'
- script: |
- set JEST_JUNIT_OUTPUT=test-fixtures-junit.xml && yarn test:fixtures -w=2
+ set JEST_JUNIT_OUTPUT=test-fixtures-junit.xml&& yarn test:fixtures -w=2
displayName: 'Test: Build Fixtures'
- script: |
- set JEST_JUNIT_OUTPUT=test-unit-junit.xml && yarn test:unit -w=2
+ set JEST_JUNIT_OUTPUT=test-unit-junit.xml&& yarn test:unit -w=2
displayName: 'Test: Run unit tests'
- task: PublishTestResults@2
From 1dd32d0d21632302de3c5db4e6cabc8711902fe4 Mon Sep 17 00:00:00 2001
From: Pooya Parsa
Date: Thu, 1 Nov 2018 07:20:07 +0330
Subject: [PATCH 082/149] feat: update to consola 2 (#4247)
* add ~> addReporter
* remove badge
* withScope ~> withTag
* update to consola 2
* update build tests
---
distributions/nuxt-legacy/package.json | 2 +-
distributions/nuxt-start/package.json | 2 +-
distributions/nuxt/package.json | 2 +-
package.json | 2 +-
packages/builder/package.json | 2 +-
packages/builder/src/builder.js | 21 ++++---------------
packages/cli/package.json | 2 +-
packages/cli/src/setup.js | 2 +-
packages/cli/test/utils/index.js | 2 +-
packages/common/package.json | 2 +-
packages/config/package.json | 2 +-
packages/core/package.json | 2 +-
packages/generator/package.json | 2 +-
packages/generator/src/generator.js | 6 +-----
packages/server/package.json | 2 +-
packages/server/src/server.js | 6 +-----
packages/vue-renderer/package.json | 2 +-
packages/webpack/package.json | 2 +-
scripts/package.js | 2 +-
test/fixtures/cli/cli.build.test.js | 2 +-
.../missing-pages-dir.test.js | 9 +-------
test/fixtures/with-config/with-config.test.js | 10 ++++-----
yarn.lock | 18 +++++++++++++++-
23 files changed, 45 insertions(+), 59 deletions(-)
diff --git a/distributions/nuxt-legacy/package.json b/distributions/nuxt-legacy/package.json
index b697b31e69..fd11e1f8df 100644
--- a/distributions/nuxt-legacy/package.json
+++ b/distributions/nuxt-legacy/package.json
@@ -56,7 +56,7 @@
"@nuxt/core": "^2.2.0",
"@nuxt/generator": "^2.2.0",
"@nuxt/webpack": "^2.2.0",
- "consola": "^1.4.4"
+ "consola": "^2.0.0-1"
},
"engines": {
"node": ">=6.0.0",
diff --git a/distributions/nuxt-start/package.json b/distributions/nuxt-start/package.json
index 2531e2ca1a..00e802d73c 100644
--- a/distributions/nuxt-start/package.json
+++ b/distributions/nuxt-start/package.json
@@ -47,7 +47,7 @@
"@nuxt/cli": "^2.2.0",
"@nuxt/common": "^2.2.0",
"@nuxt/core": "^2.2.0",
- "consola": "^1.4.4"
+ "consola": "^2.0.0-1"
},
"engines": {
"node": ">=8.0.0",
diff --git a/distributions/nuxt/package.json b/distributions/nuxt/package.json
index f5ef413fb5..8a11c69ab3 100644
--- a/distributions/nuxt/package.json
+++ b/distributions/nuxt/package.json
@@ -52,7 +52,7 @@
"@nuxt/core": "^2.2.0",
"@nuxt/generator": "^2.2.0",
"@nuxt/webpack": "^2.2.0",
- "consola": "^1.4.4"
+ "consola": "^2.0.0-1"
},
"engines": {
"node": ">=8.0.0",
diff --git a/package.json b/package.json
index 9741594392..dbf7bd2033 100644
--- a/package.json
+++ b/package.json
@@ -31,7 +31,7 @@
"babel-jest": "^23.6.0",
"babel-plugin-dynamic-import-node": "^2.2.0",
"codecov": "^3.1.0",
- "consola": "^1.4.4",
+ "consola": "^2.0.0-1",
"cross-env": "^5.2.0",
"cross-spawn": "^6.0.5",
"eslint": "^5.8.0",
diff --git a/packages/builder/package.json b/packages/builder/package.json
index 6b2fb0e120..edaa9008dc 100644
--- a/packages/builder/package.json
+++ b/packages/builder/package.json
@@ -12,7 +12,7 @@
"@nuxt/vue-app": "^2.2.0",
"@nuxtjs/devalue": "^1.0.1",
"chokidar": "^2.0.4",
- "consola": "^1.4.4",
+ "consola": "^2.0.0-1",
"fs-extra": "^7.0.0",
"glob": "^7.1.3",
"hash-sum": "^1.0.2",
diff --git a/packages/builder/src/builder.js b/packages/builder/src/builder.js
index 224cea73d6..e93f2aa559 100644
--- a/packages/builder/src/builder.js
+++ b/packages/builder/src/builder.js
@@ -61,10 +61,7 @@ export default class Builder {
if (this.options.build.analyze) {
this.nuxt.hook('build:done', () => {
- consola.warn({
- message: 'Notice: Please do not deploy bundles built with analyze mode, it\'s only for analyzing purpose.',
- badge: true
- })
+ consola.warn('Notice: Please do not deploy bundles built with analyze mode, it\'s only for analyzing purpose.')
})
}
@@ -125,8 +122,7 @@ export default class Builder {
} else if (pluginFiles.length > 1) {
consola.warn({
message: `Found ${pluginFiles.length} plugins that match the configuration, suggest to specify extension:`,
- additional: ` ${pluginFiles.join('\n ')}`,
- badge: true
+ additional: pluginFiles.join('\n')
})
}
@@ -152,11 +148,7 @@ export default class Builder {
}
this._buildStatus = STATUS.BUILDING
- consola.info({
- message: 'Building project',
- badge: true,
- clear: !this.options.dev
- })
+ consola.info('Building project')
// Wait for nuxt ready
await this.nuxt.ready()
@@ -175,12 +167,7 @@ export default class Builder {
)
} else {
this._defaultPage = true
- consola.warn({
- message: `No \`${this.options.dir.pages}\` directory found in ${dir}.`,
- additional: 'Using the default built-in page.\n',
- additionalStyle: 'yellowBright',
- badge: true
- })
+ consola.warn(`No \`${this.options.dir.pages}\` directory found in ${dir}. Using the default built-in page.`)
}
}
}
diff --git a/packages/cli/package.json b/packages/cli/package.json
index f08b3843f8..460ef97c55 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -13,7 +13,7 @@
},
"dependencies": {
"@nuxt/config": "^2.2.0",
- "consola": "^1.4.4",
+ "consola": "^2.0.0-1",
"esm": "^3.0.84",
"minimist": "^1.2.0",
"wrap-ansi": "^4.0.0"
diff --git a/packages/cli/src/setup.js b/packages/cli/src/setup.js
index 802e7fb168..445a26e2db 100644
--- a/packages/cli/src/setup.js
+++ b/packages/cli/src/setup.js
@@ -21,7 +21,7 @@ export default function setup({ dev }) {
// Exit process on fatal errors
/* istanbul ignore next */
- consola.add({
+ consola.addReporter({
log(logObj) {
if (logObj.type === 'fatal') {
process.stderr.write('Nuxt Fatal Error :(\n')
diff --git a/packages/cli/test/utils/index.js b/packages/cli/test/utils/index.js
index ba9acd8c08..c5bbc52c4d 100644
--- a/packages/cli/test/utils/index.js
+++ b/packages/cli/test/utils/index.js
@@ -4,7 +4,7 @@ export { NuxtCommand } from '../../src'
jest.mock('consola')
-consola.add = jest.fn()
+consola.addReporter = jest.fn()
export {
consola
diff --git a/packages/common/package.json b/packages/common/package.json
index 2918e1cf54..3e9759e2b6 100644
--- a/packages/common/package.json
+++ b/packages/common/package.json
@@ -9,7 +9,7 @@
"main": "dist/common.js",
"dependencies": {
"@nuxt/config": "^2.2.0",
- "consola": "^1.4.4",
+ "consola": "^2.0.0-1",
"lodash": "^4.17.11"
},
"publishConfig": {
diff --git a/packages/config/package.json b/packages/config/package.json
index 7cefff1e78..39fdba871c 100644
--- a/packages/config/package.json
+++ b/packages/config/package.json
@@ -9,7 +9,7 @@
"main": "dist/config.js",
"dependencies": {
"@nuxt/common": "^2.2.0",
- "consola": "^1.4.4",
+ "consola": "^2.0.0-1",
"lodash": "^4.17.11",
"std-env": "^2.0.2"
},
diff --git a/packages/core/package.json b/packages/core/package.json
index fee32c3f1d..68e85491d0 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -14,7 +14,7 @@
"@nuxt/vue-renderer": "^2.2.0",
"@nuxtjs/devalue": "^1.0.1",
"@nuxtjs/opencollective": "^0.1.0",
- "consola": "^1.4.4",
+ "consola": "^2.0.0-1",
"debug": "^4.1.0",
"esm": "^3.0.84",
"fs-extra": "^7.0.0",
diff --git a/packages/generator/package.json b/packages/generator/package.json
index ac2952220e..6cbb9a7b23 100644
--- a/packages/generator/package.json
+++ b/packages/generator/package.json
@@ -10,7 +10,7 @@
"dependencies": {
"@nuxt/common": "^2.2.0",
"chalk": "^2.4.1",
- "consola": "^1.4.4",
+ "consola": "^2.0.0-1",
"fs-extra": "^7.0.0",
"html-minifier": "^3.5.21"
},
diff --git a/packages/generator/src/generator.js b/packages/generator/src/generator.js
index 39ba8a2180..ad2ab0fd67 100644
--- a/packages/generator/src/generator.js
+++ b/packages/generator/src/generator.js
@@ -31,11 +31,7 @@ export default class Generator {
const routes = await this.initRoutes()
- consola.info({
- message: 'Generating pages',
- badge: true,
- clear: true
- })
+ consola.info('Generating pages')
const errors = await this.generateRoutes(routes)
diff --git a/packages/server/package.json b/packages/server/package.json
index 6c58be7c18..f50d873a15 100644
--- a/packages/server/package.json
+++ b/packages/server/package.json
@@ -14,7 +14,7 @@
"chalk": "^2.4.1",
"compression": "^1.7.3",
"connect": "^3.6.6",
- "consola": "^1.4.4",
+ "consola": "^2.0.0-1",
"etag": "^1.8.1",
"fresh": "^0.5.2",
"fs-extra": "^7.0.0",
diff --git a/packages/server/src/server.js b/packages/server/src/server.js
index 986234439d..60bc005295 100644
--- a/packages/server/src/server.js
+++ b/packages/server/src/server.js
@@ -179,11 +179,7 @@ export default class Server {
showReady(clear = true) {
if (this.readyMessage) {
- consola.ready({
- message: this.readyMessage,
- badge: true,
- clear
- })
+ consola.success(this.readyMessage)
}
}
diff --git a/packages/vue-renderer/package.json b/packages/vue-renderer/package.json
index 5da4433d24..651f133c8e 100644
--- a/packages/vue-renderer/package.json
+++ b/packages/vue-renderer/package.json
@@ -11,7 +11,7 @@
"@nuxt/common": "^2.2.0",
"@nuxtjs/devalue": "^1.0.1",
"browserslist-useragent": "^2.0.1",
- "consola": "^1.4.4",
+ "consola": "^2.0.0-1",
"fs-extra": "^7.0.0",
"lru-cache": "^4.1.3",
"vue": "^2.5.17",
diff --git a/packages/webpack/package.json b/packages/webpack/package.json
index 56c116f56d..606147df47 100644
--- a/packages/webpack/package.json
+++ b/packages/webpack/package.json
@@ -17,7 +17,7 @@
"cache-loader": "^1.2.2",
"caniuse-lite": "^1.0.30000900",
"chalk": "^2.4.1",
- "consola": "^1.4.4",
+ "consola": "^2.0.0-1",
"css-loader": "^1.0.1",
"cssnano": "^4.1.7",
"file-loader": "^2.0.0",
diff --git a/scripts/package.js b/scripts/package.js
index 098ad50985..39cd8bcb1d 100644
--- a/scripts/package.js
+++ b/scripts/package.js
@@ -37,7 +37,7 @@ export default class Package extends EventEmitter {
this.readPkg()
// Init logger
- this.logger = consola.withScope(this.pkg.name)
+ this.logger = consola.withTag(this.pkg.name)
// Try to load config
this.loadConfig()
diff --git a/test/fixtures/cli/cli.build.test.js b/test/fixtures/cli/cli.build.test.js
index 109891c06d..8c957af316 100644
--- a/test/fixtures/cli/cli.build.test.js
+++ b/test/fixtures/cli/cli.build.test.js
@@ -15,7 +15,7 @@ describe('cli build', () => {
test('nuxt build -> error config', async () => {
await expect(execify(`node -r esm ${nuxtBin} build ${rootDir} -c config.js`)).rejects.toMatchObject({
- stdout: expect.stringContaining('Could not load config file: config.js')
+ stderr: expect.stringContaining('Could not load config file: config.js')
})
})
})
diff --git a/test/fixtures/missing-pages-dir/missing-pages-dir.test.js b/test/fixtures/missing-pages-dir/missing-pages-dir.test.js
index 8a1fe1b5f5..fa3cb36125 100644
--- a/test/fixtures/missing-pages-dir/missing-pages-dir.test.js
+++ b/test/fixtures/missing-pages-dir/missing-pages-dir.test.js
@@ -5,13 +5,6 @@ describe('missing-pages-dir', () => {
buildFixture('missing-pages-dir', (builder) => {
const options = builder.nuxt.options
expect(consola.warn).toHaveBeenCalledTimes(1)
- expect(consola.warn.mock.calls).toMatchObject([
- [{
- message: `No \`${options.dir.pages}\` directory found in ${options.srcDir}.`,
- additional: 'Using the default built-in page.\n',
- additionalStyle: 'yellowBright',
- badge: true
- }]
- ])
+ expect(consola.warn).toHaveBeenCalledWith(`No \`${options.dir.pages}\` directory found in ${options.srcDir}. Using the default built-in page.`)
})
})
diff --git a/test/fixtures/with-config/with-config.test.js b/test/fixtures/with-config/with-config.test.js
index d16e0f0a1e..5cb8aadaef 100644
--- a/test/fixtures/with-config/with-config.test.js
+++ b/test/fixtures/with-config/with-config.test.js
@@ -19,13 +19,11 @@ describe('with-config', () => {
expect(consola.warn.mock.calls).toMatchObject([
[{
message: 'Found 2 plugins that match the configuration, suggest to specify extension:',
- additional: expect.stringContaining('plugins/test.json'),
- badge: true
+ additional: expect.stringContaining('plugins/test.json')
}],
- [{
- message: 'Notice: Please do not deploy bundles built with analyze mode, it\'s only for analyzing purpose.',
- badge: true
- }]
+ [
+ 'Notice: Please do not deploy bundles built with analyze mode, it\'s only for analyzing purpose.'
+ ]
])
expect(customCompressionMiddlewareFunctionName).toBe('damn')
}, hooks)
diff --git a/yarn.lock b/yarn.lock
index 7dd858b23d..aff8d8c21a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3010,7 +3010,7 @@ connect@^3.6.6:
parseurl "~1.3.2"
utils-merge "1.0.1"
-consola@^1.4.3, consola@^1.4.4:
+consola@^1.4.3:
version "1.4.4"
resolved "https://registry.npmjs.org/consola/-/consola-1.4.4.tgz#cf5eda375c0e99df8970cc8f5e98be023da24ce0"
integrity sha512-6ZCi6LpbwGml3g8C8iXIuSf9yZAWoRAXodcHxBWRVvy42uKe4z7AG4JB4v46LEmgtPXv2rIqR6wVD+sxixDD/A==
@@ -3020,6 +3020,17 @@ consola@^1.4.3, consola@^1.4.4:
lodash "^4.17.5"
std-env "^1.1.0"
+consola@^2.0.0-1:
+ version "2.0.0-1"
+ resolved "https://registry.npmjs.org/consola/-/consola-2.0.0-1.tgz#4883f5c19ae07b63226f27311c4e54a42e18714a"
+ integrity sha512-X4sDWc37AbZFXVHT55I0SWKilv1qClu3fPDzakcnEKUENJZXrHaJwpSUDDXOrp0KBsdUBx6ji6DpuSZm6/QUVQ==
+ dependencies:
+ chalk "^2.4.1"
+ dayjs "^1.7.7"
+ figures "^2.0.0"
+ std-env "^2.0.2"
+ string-width "^2.1.1"
+
console-browserify@^1.1.0:
version "1.1.0"
resolved "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10"
@@ -3595,6 +3606,11 @@ dateformat@^3.0.0:
resolved "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae"
integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==
+dayjs@^1.7.7:
+ version "1.7.7"
+ resolved "https://registry.npmjs.org/dayjs/-/dayjs-1.7.7.tgz#8df20f78ac2476e3f5348ef49f8f22ebc3016370"
+ integrity sha512-Qlkiu0NNDpYwhk0syK4ImvAl/5YnsEMkvC2O123INviGeOA3Q8s5VyVkZzmN5SC7Wv9bb1+rfwO+uSqtHB4UWw==
+
de-indent@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"
From 6dadadfa25487e848a4f03a3bed3a4d0a85bfa5f Mon Sep 17 00:00:00 2001
From: Jonas Galvez
Date: Thu, 1 Nov 2018 00:53:06 -0300
Subject: [PATCH 083/149] feat(cli): list commands (#4245)
* add listCommands to cli/run
* add listCommands to cli/run (2)
* lint
* lint
* lint
* fix
* fixes
* fix
* lint
* maxCharsPerLine = process.stdout.columns * 80 / 100
* fix test
* fix imports
* refactor foldLines()
* default process.stdout.columns to 80
* default to 80
* fix
* fix test
* lint
* fix test
* add help flags to main usage
* fix
* fix
* fix
---
packages/cli/src/command.js | 14 +++-----
packages/cli/src/formatting.js | 29 +++++++++++++++++
packages/cli/src/run.js | 32 +++++++++++++++++++
packages/cli/src/utils.js | 23 -------------
.../unit/__snapshots__/command.test.js.snap | 6 ++--
packages/cli/test/unit/command.test.js | 8 ++---
packages/cli/test/unit/utils.test.js | 5 +--
7 files changed, 75 insertions(+), 42 deletions(-)
create mode 100644 packages/cli/src/formatting.js
diff --git a/packages/cli/src/command.js b/packages/cli/src/command.js
index d1908f46ac..5c85a87964 100644
--- a/packages/cli/src/command.js
+++ b/packages/cli/src/command.js
@@ -1,12 +1,9 @@
import parseArgs from 'minimist'
import { name, version } from '../package.json'
-import { loadNuxtConfig, indent, foldLines } from './utils'
+import { loadNuxtConfig } from './utils'
+import { indent, foldLines, startSpaces, optionSpaces } from './formatting'
import * as imports from './imports'
-const startSpaces = 2
-const optionSpaces = 2
-const maxCharsPerLine = 80
-
export default class NuxtCommand {
constructor({ name, description, usage, options, run } = {}) {
this.name = name || ''
@@ -117,15 +114,14 @@ export default class NuxtCommand {
const i = indent(maxOptionLength + optionSpaces - option.length)
return foldLines(
option + i + description,
- maxCharsPerLine,
startSpaces + maxOptionLength + optionSpaces * 2,
startSpaces + optionSpaces
)
}).join('\n')
- const usage = foldLines(`Usage: nuxt ${this.usage} [options]`, maxCharsPerLine, startSpaces)
- const description = foldLines(this.description, maxCharsPerLine, startSpaces)
- const opts = foldLines(`Options:`, maxCharsPerLine, startSpaces) + '\n\n' + _opts
+ const usage = foldLines(`Usage: nuxt ${this.usage} [options]`, startSpaces)
+ const description = foldLines(this.description, startSpaces)
+ const opts = foldLines(`Options:`, startSpaces) + '\n\n' + _opts
return `${usage}\n\n${description}\n\n${opts}\n\n`
}
diff --git a/packages/cli/src/formatting.js b/packages/cli/src/formatting.js
new file mode 100644
index 0000000000..c0085ffc54
--- /dev/null
+++ b/packages/cli/src/formatting.js
@@ -0,0 +1,29 @@
+import wrapAnsi from 'wrap-ansi'
+
+export const startSpaces = 2
+export const optionSpaces = 2
+
+// 80% of terminal column width
+export const maxCharsPerLine = (process.stdout.columns || 100) * 80 / 100
+
+export function indent(count, chr = ' ') {
+ return chr.repeat(count)
+}
+
+export function indentLines(string, spaces, firstLineSpaces) {
+ const lines = Array.isArray(string) ? string : string.split('\n')
+ let s = ''
+ if (lines.length) {
+ const i0 = indent(firstLineSpaces === undefined ? spaces : firstLineSpaces)
+ s = i0 + lines.shift()
+ }
+ if (lines.length) {
+ const i = indent(spaces)
+ s += '\n' + lines.map(l => i + l).join('\n')
+ }
+ return s
+}
+
+export function foldLines(string, spaces, firstLineSpaces, maxCharsPerLine) {
+ return indentLines(wrapAnsi(string, maxCharsPerLine, { trim: false }), spaces, firstLineSpaces)
+}
diff --git a/packages/cli/src/run.js b/packages/cli/src/run.js
index 97976d71b6..54ae0bcb32 100644
--- a/packages/cli/src/run.js
+++ b/packages/cli/src/run.js
@@ -2,6 +2,34 @@ import consola from 'consola'
import NuxtCommand from './command'
import * as commands from './commands'
import setup from './setup'
+import { indent, foldLines, startSpaces, optionSpaces } from './formatting'
+
+async function listCommands(_commands) {
+ _commands = await Promise.all(
+ Object.keys(_commands).map((cmd) => {
+ return _commands[cmd]().then(m => m.default)
+ })
+ )
+ let maxLength = 0
+ const commandsHelp = []
+ for (const name in _commands) {
+ commandsHelp.push([_commands[name].usage, _commands[name].description])
+ maxLength = Math.max(maxLength, _commands[name].usage.length)
+ }
+
+ const _cmmds = commandsHelp.map(([cmd, description]) => {
+ const i = indent(maxLength + optionSpaces - cmd.length)
+ return foldLines(
+ cmd + i + description,
+ startSpaces + maxLength + optionSpaces * 2,
+ startSpaces + optionSpaces
+ )
+ }).join('\n')
+
+ const usage = foldLines(`Usage: nuxt [--help|-h]`, startSpaces)
+ const cmmds = foldLines(`Commands:`, startSpaces) + '\n\n' + _cmmds
+ process.stdout.write(`${usage}\n\n${cmmds}\n\n`)
+}
export default function run() {
const defaultCommand = 'dev'
@@ -18,6 +46,10 @@ export default function run() {
if (cmds.has(cmd)) {
process.argv.splice(2, 1)
} else {
+ if (process.argv.includes('--help') || process.argv.includes('-h')) {
+ listCommands({ ...commands }).then(() => process.exit(0))
+ return
+ }
cmd = defaultCommand
}
diff --git a/packages/cli/src/utils.js b/packages/cli/src/utils.js
index fd9e138230..ac15beb8b7 100644
--- a/packages/cli/src/utils.js
+++ b/packages/cli/src/utils.js
@@ -2,7 +2,6 @@ import path from 'path'
import { existsSync } from 'fs'
import consola from 'consola'
import esm from 'esm'
-import wrapAnsi from 'wrap-ansi'
import defaultsDeep from 'lodash/defaultsDeep'
import { getDefaultNuxtConfig } from '@nuxt/config'
@@ -62,25 +61,3 @@ export async function loadNuxtConfig(argv) {
return options
}
-
-export function indent(count, chr = ' ') {
- return chr.repeat(count)
-}
-
-export function indentLines(string, spaces, firstLineSpaces) {
- const lines = Array.isArray(string) ? string : string.split('\n')
- let s = ''
- if (lines.length) {
- const i0 = indent(firstLineSpaces === undefined ? spaces : firstLineSpaces)
- s = i0 + lines.shift().trim()
- }
- if (lines.length) {
- const i = indent(spaces)
- s += '\n' + lines.map(l => i + l.trim()).join('\n')
- }
- return s
-}
-
-export function foldLines(string, maxCharsPerLine, spaces, firstLineSpaces) {
- return indentLines(wrapAnsi(string, maxCharsPerLine, { trim: false }), spaces, firstLineSpaces)
-}
diff --git a/packages/cli/test/unit/__snapshots__/command.test.js.snap b/packages/cli/test/unit/__snapshots__/command.test.js.snap
index be77274aa6..017fc5e908 100644
--- a/packages/cli/test/unit/__snapshots__/command.test.js.snap
+++ b/packages/cli/test/unit/__snapshots__/command.test.js.snap
@@ -3,8 +3,7 @@
exports[`cli/command builds help text 1`] = `
" Usage: nuxt this is how you do it [options]
- a very long description that is longer than 80 chars and should wrap to the next
- line while keeping indentation
+ a very long description that should not wrap to the next line because is not longer than the terminal width
Options:
@@ -16,8 +15,7 @@ exports[`cli/command builds help text 1`] = `
--port, -p Port number on which to start the application
--hostname, -H Hostname on which to start the application
--unix-socket, -n Path to a UNIX socket
- --foo very long option that is longer than 80 chars and should wrap
- to the next line while keeping indentation
+ --foo very long option that is not longer than the terminal width and should not wrap to the next line
"
`;
diff --git a/packages/cli/test/unit/command.test.js b/packages/cli/test/unit/command.test.js
index 07cbec1058..d3501fdf3b 100644
--- a/packages/cli/test/unit/command.test.js
+++ b/packages/cli/test/unit/command.test.js
@@ -101,15 +101,15 @@ describe('cli/command', () => {
test('builds help text', () => {
const cmd = new Command({
- description: 'a very long description that is longer than 80 chars and ' +
- 'should wrap to the next line while keeping indentation',
+ description: 'a very long description that should not wrap to the next line because is not longer ' +
+ 'than the terminal width',
usage: 'this is how you do it',
options: {
...allOptions,
foo: {
type: 'boolean',
- description: 'very long option that is longer than 80 chars and ' +
- 'should wrap to the next line while keeping indentation'
+ description: 'very long option that is not longer than the terminal width and ' +
+ 'should not wrap to the next line'
}
}
})
diff --git a/packages/cli/test/unit/utils.test.js b/packages/cli/test/unit/utils.test.js
index 5eb385101b..5c84900818 100644
--- a/packages/cli/test/unit/utils.test.js
+++ b/packages/cli/test/unit/utils.test.js
@@ -1,6 +1,7 @@
import { getDefaultNuxtConfig } from '@nuxt/config'
import { consola } from '../utils'
import * as utils from '../../src/utils'
+import * as fmt from '../../src/formatting'
describe('cli/utils', () => {
afterEach(() => jest.resetAllMocks())
@@ -96,10 +97,10 @@ describe('cli/utils', () => {
})
test('indent', () => {
- expect(utils.indent(4)).toBe(' ')
+ expect(fmt.indent(4)).toBe(' ')
})
test('indent custom char', () => {
- expect(utils.indent(4, '-')).toBe('----')
+ expect(fmt.indent(4, '-')).toBe('----')
})
})
From 78e3563687518ce62efca0e6842c0246e9b5d15e Mon Sep 17 00:00:00 2001
From: Clark Du
Date: Thu, 1 Nov 2018 03:59:17 +0000
Subject: [PATCH 084/149] feat: terser compress es6 forms in modern build
(#4241)
---
packages/webpack/src/config/client.js | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/packages/webpack/src/config/client.js b/packages/webpack/src/config/client.js
index 3010ad6266..eac9638982 100644
--- a/packages/webpack/src/config/client.js
+++ b/packages/webpack/src/config/client.js
@@ -19,7 +19,7 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
if (this.options.build.analyze) {
const key = args[0]
if (['app', 'chunk'].includes(key)) {
- return `${this.name === 'modern' ? 'modern-' : ''}[name].js`
+ return `${this.isModern ? 'modern-' : ''}[name].js`
}
}
return super.getFileName(...args)
@@ -106,7 +106,7 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
if (this.options.build.modern) {
plugins.push(new ModernModePlugin({
targetDir: path.resolve(this.options.buildDir, 'dist', 'client'),
- isModernBuild: this.name === 'modern'
+ isModernBuild: this.isModern
}))
}
@@ -131,6 +131,9 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
filename: 'LICENSES'
},
terserOptions: {
+ compress: {
+ ecma: this.isModern ? 6 : undefined
+ },
output: {
comments: /^\**!|@preserve|@license|@cc_on/
}
From 90325c35ae4d1a805d5d8bc7cf5f6fc7cbaf77d4 Mon Sep 17 00:00:00 2001
From: Pim
Date: Thu, 1 Nov 2018 05:00:28 +0100
Subject: [PATCH 085/149] feat(cli): use cjs dist stub in package (#4243)
* feat: use cjs dist stub for cli package
* fix: spawn nuxtBin directly
* keep node -r esm for optimal windows compatibility
---
scripts/dev | 22 +++++++++++++++++++++-
test/unit/cli.test.js | 2 +-
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/scripts/dev b/scripts/dev
index 890acce2fe..23a7898816 100755
--- a/scripts/dev
+++ b/scripts/dev
@@ -5,6 +5,26 @@ import consola from 'consola'
import Package from './package.js'
+const useCjs = new Set([
+ '@nuxt/cli'
+])
+
+const stub = {
+ es: `export * from '../src/index'`,
+ cjs: `const esm = require('esm')
+
+const _require = esm(module, {
+ cache: false,
+ cjs: {
+ cache: true,
+ vars: true,
+ namedExports: true
+ }
+})
+
+module.exports = _require('../src/index')
+`}
+
async function main() {
// Read package at current directory
const rootPackage = new Package()
@@ -18,7 +38,7 @@ async function main() {
consola.info(pkg.pkg.main)
const distMain = pkg.resolvePath(pkg.pkg.main)
await fs.mkdirp(path.dirname(distMain))
- await fs.writeFile(distMain, `export * from '../src/index'`)
+ await fs.writeFile(distMain, useCjs.has(pkg.pkg.name) ? stub.cjs : stub.es)
}
}
diff --git a/test/unit/cli.test.js b/test/unit/cli.test.js
index cceb70170a..ea8b5119b9 100644
--- a/test/unit/cli.test.js
+++ b/test/unit/cli.test.js
@@ -9,7 +9,7 @@ const rootDir = resolve(__dirname, '..', 'fixtures/cli')
const url = route => 'http://localhost:' + port + route
const nuxtBin = resolve(__dirname, '../../packages/cli/bin/nuxt.js')
-const spawnNuxt = (command, opts) => spawn('node', ['-r', 'esm', nuxtBin, command, rootDir], opts)
+const spawnNuxt = (command, opts) => spawn(nuxtBin, [command, rootDir], opts)
const close = async (nuxtInt) => {
nuxtInt.kill('SIGKILL')
From e9b63deba4c5d3753b2de13f060845f997ef9fd9 Mon Sep 17 00:00:00 2001
From: "renovate[bot]"
Date: Thu, 1 Nov 2018 05:13:12 +0100
Subject: [PATCH 086/149] fix(deps): update all non-major dependencies (#4229)
---
packages/webpack/package.json | 4 ++--
yarn.lock | 15 ++++++++++-----
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/packages/webpack/package.json b/packages/webpack/package.json
index 606147df47..0416c3f6dd 100644
--- a/packages/webpack/package.json
+++ b/packages/webpack/package.json
@@ -14,8 +14,8 @@
"@nuxt/common": "^2.2.0",
"@nuxtjs/friendly-errors-webpack-plugin": "^2.1.0",
"babel-loader": "^8.0.4",
- "cache-loader": "^1.2.2",
- "caniuse-lite": "^1.0.30000900",
+ "cache-loader": "^1.2.5",
+ "caniuse-lite": "^1.0.30000903",
"chalk": "^2.4.1",
"consola": "^2.0.0-1",
"css-loader": "^1.0.1",
diff --git a/yarn.lock b/yarn.lock
index aff8d8c21a..3a751c7549 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2561,10 +2561,10 @@ cache-base@^1.0.1:
union-value "^1.0.0"
unset-value "^1.0.0"
-cache-loader@^1.2.2:
- version "1.2.2"
- resolved "https://registry.npmjs.org/cache-loader/-/cache-loader-1.2.2.tgz#6d5c38ded959a09cc5d58190ab5af6f73bd353f5"
- integrity sha512-rsGh4SIYyB9glU+d0OcHwiXHXBoUgDhHZaQ1KAbiXqfz1CDPxtTboh1gPbJ0q2qdO8a9lfcjgC5CJ2Ms32y5bw==
+cache-loader@^1.2.5:
+ version "1.2.5"
+ resolved "https://registry.npmjs.org/cache-loader/-/cache-loader-1.2.5.tgz#9ab15b0ae5f546f376083a695fc1a75f546cb266"
+ integrity sha512-enWKEQ4kO3YreDFd7AtVRjtJBmNiqh/X9hVDReu0C4qm8gsGmySkwuWtdc+N5O+vq5FzxL1mIZc30NyXCB7o/Q==
dependencies:
loader-utils "^1.1.0"
mkdirp "^0.5.1"
@@ -2648,7 +2648,7 @@ caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000890:
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000893.tgz#284b20932bd41b93e21626975f2050cb01561986"
integrity sha512-kOddHcTEef+NgN/fs0zmX2brHTNATVOWMEIhlZHCuwQRtXobjSw9pAECc44Op4bTBcavRjkLaPrGomknH7+Jvg==
-caniuse-lite@^1.0.30000898, caniuse-lite@^1.0.30000900:
+caniuse-lite@^1.0.30000898:
version "1.0.30000900"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000900.tgz#015cfe37897a3386a3075a914498800c29afe77e"
integrity sha512-xDVs8pBFr6bzq9pXUkLKpGQQnzsF/l6/yX38UnCkTcUcwC0rDl1NGZGildcJVTU+uGBxfsyniK/ZWagPNn1Oqw==
@@ -2658,6 +2658,11 @@ caniuse-lite@^1.0.30000899:
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000899.tgz#6febdbbc388a7982f620ee0e3d09aab0c061389e"
integrity sha512-enC3zKfUCJxxwvUIsBkbHd54CtJw1KtIWvrK0JZxWD/fEN2knHaai45lndJ4xXAkyRAPyk60J3yagkKDWhfeMA==
+caniuse-lite@^1.0.30000903:
+ version "1.0.30000903"
+ resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000903.tgz#86d46227759279b3db345ddbe778335dbba9e858"
+ integrity sha512-T1XVJEpGCoaq7MDw7/6hCdYUukmSaS+1l/OQJkLtw7Cr2+/+d67tNGKEbyiqf7Ck8x6EhNFUxjYFXXka0N/w5g==
+
capture-exit@^1.2.0:
version "1.2.0"
resolved "https://registry.npmjs.org/capture-exit/-/capture-exit-1.2.0.tgz#1c5fcc489fd0ab00d4f1ac7ae1072e3173fbab6f"
From 19287cce96a3e3c44f28fd85d1774e821168ff54 Mon Sep 17 00:00:00 2001
From: Jonas Galvez
Date: Fri, 2 Nov 2018 01:35:32 -0300
Subject: [PATCH 087/149] feat(cli): add help command (#4248)
* add commands/help
* simply cmds in run()
* refinement
* simply cmds in run() (2)
* simply cmds in run() (3)
* lint
* cmd.showHelp()
* check for cmd / uknown cmd
* final fix
* fixes
* remove Set
* Add NuxtCommand.load()
* updated tests
* lint
---
packages/cli/src/command.js | 12 +++++++++++
packages/cli/src/commands/help.js | 20 ++++++++++++++++++
packages/cli/src/commands/index.js | 1 +
packages/cli/src/run.js | 21 +++++--------------
.../unit/__snapshots__/command.test.js.snap | 19 +++++++++++++++++
packages/cli/test/unit/command.test.js | 5 +++++
6 files changed, 62 insertions(+), 16 deletions(-)
create mode 100644 packages/cli/src/commands/help.js
diff --git a/packages/cli/src/command.js b/packages/cli/src/command.js
index 5c85a87964..acab1c442b 100644
--- a/packages/cli/src/command.js
+++ b/packages/cli/src/command.js
@@ -2,6 +2,7 @@ import parseArgs from 'minimist'
import { name, version } from '../package.json'
import { loadNuxtConfig } from './utils'
import { indent, foldLines, startSpaces, optionSpaces } from './formatting'
+import * as commands from './commands'
import * as imports from './imports'
export default class NuxtCommand {
@@ -13,6 +14,17 @@ export default class NuxtCommand {
this._run = run
}
+ static async load(name) {
+ // So eslint doesn't complain about lookups
+ const _commands = { ...commands }
+ if (name in _commands) {
+ const cmd = await _commands[name]().then(m => m.default)
+ return NuxtCommand.from(cmd)
+ } else {
+ // TODO dynamic module loading
+ }
+ }
+
static from(options) {
if (options instanceof NuxtCommand) {
return options
diff --git a/packages/cli/src/commands/help.js b/packages/cli/src/commands/help.js
new file mode 100644
index 0000000000..9c32681f48
--- /dev/null
+++ b/packages/cli/src/commands/help.js
@@ -0,0 +1,20 @@
+import consola from 'consola'
+import NuxtCommand from '../command'
+
+export default {
+ name: 'help',
+ description: 'Shows help for ',
+ usage: 'help ',
+ async run(cmd) {
+ const argv = cmd.getArgv()._
+ const name = argv[0] || null
+ const command = await NuxtCommand.load(name)
+ if (command) {
+ command.showHelp()
+ } else if (name === null) {
+ consola.info(`Please specify a command`)
+ } else {
+ consola.info(`Unknown command: ${name}`)
+ }
+ }
+}
diff --git a/packages/cli/src/commands/index.js b/packages/cli/src/commands/index.js
index d92eb03998..70ad510a39 100644
--- a/packages/cli/src/commands/index.js
+++ b/packages/cli/src/commands/index.js
@@ -2,3 +2,4 @@ export const start = () => import('./start')
export const dev = () => import('./dev')
export const build = () => import('./build')
export const generate = () => import('./generate')
+export const help = () => import('./help')
diff --git a/packages/cli/src/run.js b/packages/cli/src/run.js
index 54ae0bcb32..1b931cecff 100644
--- a/packages/cli/src/run.js
+++ b/packages/cli/src/run.js
@@ -6,9 +6,7 @@ import { indent, foldLines, startSpaces, optionSpaces } from './formatting'
async function listCommands(_commands) {
_commands = await Promise.all(
- Object.keys(_commands).map((cmd) => {
- return _commands[cmd]().then(m => m.default)
- })
+ Object.keys(_commands).map(cmd => NuxtCommand.load(cmd))
)
let maxLength = 0
const commandsHelp = []
@@ -33,21 +31,14 @@ async function listCommands(_commands) {
export default function run() {
const defaultCommand = 'dev'
-
- const cmds = new Set([
- defaultCommand,
- 'build',
- 'start',
- 'generate'
- ])
-
let cmd = process.argv[2]
- if (cmds.has(cmd)) {
+ const _commands = { ...commands }
+ if (_commands[cmd]) {
process.argv.splice(2, 1)
} else {
if (process.argv.includes('--help') || process.argv.includes('-h')) {
- listCommands({ ...commands }).then(() => process.exit(0))
+ listCommands(_commands).then(() => process.exit(0))
return
}
cmd = defaultCommand
@@ -58,9 +49,7 @@ export default function run() {
dev: cmd === 'dev'
})
- return commands[cmd]() // eslint-disable-line import/namespace
- .then(m => m.default)
- .then(options => NuxtCommand.from(options))
+ return NuxtCommand.load(cmd)
.then(command => command.run())
.catch((error) => {
consola.fatal(error)
diff --git a/packages/cli/test/unit/__snapshots__/command.test.js.snap b/packages/cli/test/unit/__snapshots__/command.test.js.snap
index 017fc5e908..5793b42ed8 100644
--- a/packages/cli/test/unit/__snapshots__/command.test.js.snap
+++ b/packages/cli/test/unit/__snapshots__/command.test.js.snap
@@ -19,3 +19,22 @@ exports[`cli/command builds help text 1`] = `
"
`;
+
+exports[`cli/command loads command from name 1`] = `
+" Usage: nuxt dev [options]
+
+ Start the application in development mode (e.g. hot-code reloading, error reporting)
+
+ Options:
+
+ --spa, -s Launch in SPA mode
+ --universal, -u Launch in Universal mode (default)
+ --config-file, -c Path to Nuxt.js config file (default: nuxt.config.js)
+ --version Display the Nuxt version
+ --help, -h Display this message
+ --port, -p Port number on which to start the application
+ --hostname, -H Hostname on which to start the application
+ --unix-socket, -n Path to a UNIX socket
+
+"
+`;
diff --git a/packages/cli/test/unit/command.test.js b/packages/cli/test/unit/command.test.js
index d3501fdf3b..b337371764 100644
--- a/packages/cli/test/unit/command.test.js
+++ b/packages/cli/test/unit/command.test.js
@@ -117,6 +117,11 @@ describe('cli/command', () => {
expect(cmd._getHelp()).toMatchSnapshot()
})
+ test('loads command from name', async () => {
+ const cmd = await Command.load('dev')
+ expect(cmd._getHelp()).toMatchSnapshot()
+ })
+
test('show version prints to stdout and exits', () => {
jest.spyOn(process.stdout, 'write').mockImplementation(() => {})
jest.spyOn(process, 'exit').mockImplementationOnce(code => code)
From 12151d81d650d3043826a8e0706c3720f3625d7b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Chopin?=
Date: Fri, 2 Nov 2018 18:07:39 +0900
Subject: [PATCH 088/149] feat: add --modern to nuxt start (#4254)
---
packages/babel-preset-app/src/index.js | 2 +-
packages/cli/src/commands/start.js | 13 ++++++++++++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/packages/babel-preset-app/src/index.js b/packages/babel-preset-app/src/index.js
index db9673d723..f687cf60d0 100644
--- a/packages/babel-preset-app/src/index.js
+++ b/packages/babel-preset-app/src/index.js
@@ -39,7 +39,7 @@ module.exports = (context, options = {}) => {
const {
buildTarget,
loose = false,
- useBuiltIns = 'usage',
+ useBuiltIns = (modern ? false : 'usage'),
modules = false,
polyfills: userPolyfills,
ignoreBrowserslistConfig = modern,
diff --git a/packages/cli/src/commands/start.js b/packages/cli/src/commands/start.js
index 506f0fe47f..2423bf5bb1 100644
--- a/packages/cli/src/commands/start.js
+++ b/packages/cli/src/commands/start.js
@@ -9,7 +9,18 @@ export default {
usage: 'start ',
options: {
...common,
- ...server
+ ...server,
+ modern: {
+ alias: 'm',
+ type: 'boolean',
+ description: 'Build app for modern browsers',
+ prepare(cmd, options, argv) {
+ options.build = options.build || {}
+ if (argv.modern) {
+ options.build.modern = !!argv.modern
+ }
+ }
+ }
},
async run(cmd) {
const argv = cmd.getArgv()
From 17e0890c9070b46eb8e16e9fbca472b8aa04dd3c Mon Sep 17 00:00:00 2001
From: Clark Du
Date: Fri, 2 Nov 2018 13:54:58 +0000
Subject: [PATCH 089/149] fix(cli): remove duplicate error message in start and
build (#4258)
---
packages/cli/src/commands/build.js | 3 ---
packages/cli/src/commands/start.js | 3 ---
packages/common/src/hookable.js | 4 ++--
test/unit/error.test.js | 6 +++---
4 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/packages/cli/src/commands/build.js b/packages/cli/src/commands/build.js
index 085309ea7b..d199e2f4d1 100644
--- a/packages/cli/src/commands/build.js
+++ b/packages/cli/src/commands/build.js
@@ -56,9 +56,6 @@ export default {
await cmd.getNuxtConfig(argv, { dev: false })
)
- // Setup hooks
- nuxt.hook('error', err => consola.fatal(err))
-
let builderOrGenerator
if (nuxt.options.mode !== 'spa' || argv.generate === false) {
// Build only
diff --git a/packages/cli/src/commands/start.js b/packages/cli/src/commands/start.js
index 2423bf5bb1..44fec39bf7 100644
--- a/packages/cli/src/commands/start.js
+++ b/packages/cli/src/commands/start.js
@@ -30,9 +30,6 @@ export default {
await cmd.getNuxtConfig(argv, { dev: false })
)
- // Setup hooks
- nuxt.hook('error', err => consola.fatal(err))
-
// Check if project is built for production
const distDir = path.resolve(
nuxt.options.rootDir,
diff --git a/packages/common/src/hookable.js b/packages/common/src/hookable.js
index 658f25791b..a29f33b65d 100644
--- a/packages/common/src/hookable.js
+++ b/packages/common/src/hookable.js
@@ -34,8 +34,8 @@ export default class Hookable {
try {
await sequence(this._hooks[name], fn => fn(...args))
} catch (err) {
- consola.error(err)
- this.callHook('error', err)
+ name !== 'error' && this.callHook('error', err)
+ consola.fatal(err)
}
}
diff --git a/test/unit/error.test.js b/test/unit/error.test.js
index 474687d689..c019a5199b 100644
--- a/test/unit/error.test.js
+++ b/test/unit/error.test.js
@@ -39,7 +39,7 @@ describe('error', () => {
})
test('Error: callHook()', async () => {
- consola.error.mockClear()
+ consola.fatal.mockClear()
const errorHook = jest.fn()
const error = new Error('test hook error')
@@ -50,8 +50,8 @@ describe('error', () => {
expect(errorHook).toHaveBeenCalledTimes(1)
expect(errorHook).toHaveBeenCalledWith(error)
- expect(consola.error).toHaveBeenCalledTimes(1)
- expect(consola.error).toHaveBeenCalledWith(error)
+ expect(consola.fatal).toHaveBeenCalledTimes(1)
+ expect(consola.fatal).toHaveBeenCalledWith(error)
})
// Close server and ask nuxt to stop listening to file changes
From 2f78f87c06db66f8f88fd94addbfcc7a670a7abb Mon Sep 17 00:00:00 2001
From: xxRockOnxx
Date: Sat, 3 Nov 2018 20:25:41 +0800
Subject: [PATCH 090/149] [skip ci] move misleading comment (#4265)
---
packages/builder/src/builder.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/packages/builder/src/builder.js b/packages/builder/src/builder.js
index e93f2aa559..733063da34 100644
--- a/packages/builder/src/builder.js
+++ b/packages/builder/src/builder.js
@@ -293,7 +293,7 @@ export default class Builder {
['index.vue'],
this.template.templatesDir + '/pages'
)
- } else if (this._nuxtPages) { // If user defined a custom method to create routes
+ } else if (this._nuxtPages) {
// Use nuxt.js createRoutes bases on pages/
const files = {}
; (await glob(`${this.options.dir.pages}/**/*.{vue,js}`, {
@@ -310,7 +310,7 @@ export default class Builder {
this.options.srcDir,
this.options.dir.pages
)
- } else {
+ } else { // If user defined a custom method to create routes
templateVars.router.routes = this.options.build.createRoutes(
this.options.srcDir
)
From f10f86029253faf7602230f1d133ceec66a6e527 Mon Sep 17 00:00:00 2001
From: "renovate[bot]"
Date: Sat, 3 Nov 2018 22:16:58 +0330
Subject: [PATCH 091/149] fix(deps): update all non-major dependencies (#4253)
---
distributions/nuxt-legacy/package.json | 2 +-
distributions/nuxt-start/package.json | 2 +-
distributions/nuxt/package.json | 2 +-
package.json | 6 +-
packages/builder/package.json | 4 +-
packages/cli/package.json | 2 +-
packages/common/package.json | 2 +-
packages/config/package.json | 4 +-
packages/core/package.json | 6 +-
packages/generator/package.json | 2 +-
packages/server/package.json | 2 +-
packages/vue-renderer/package.json | 4 +-
packages/webpack/package.json | 6 +-
yarn.lock | 288 ++++++++++++-------------
14 files changed, 166 insertions(+), 166 deletions(-)
diff --git a/distributions/nuxt-legacy/package.json b/distributions/nuxt-legacy/package.json
index fd11e1f8df..b8cef610b0 100644
--- a/distributions/nuxt-legacy/package.json
+++ b/distributions/nuxt-legacy/package.json
@@ -56,7 +56,7 @@
"@nuxt/core": "^2.2.0",
"@nuxt/generator": "^2.2.0",
"@nuxt/webpack": "^2.2.0",
- "consola": "^2.0.0-1"
+ "consola": "^2.1.1"
},
"engines": {
"node": ">=6.0.0",
diff --git a/distributions/nuxt-start/package.json b/distributions/nuxt-start/package.json
index 00e802d73c..0cda2ec302 100644
--- a/distributions/nuxt-start/package.json
+++ b/distributions/nuxt-start/package.json
@@ -47,7 +47,7 @@
"@nuxt/cli": "^2.2.0",
"@nuxt/common": "^2.2.0",
"@nuxt/core": "^2.2.0",
- "consola": "^2.0.0-1"
+ "consola": "^2.1.1"
},
"engines": {
"node": ">=8.0.0",
diff --git a/distributions/nuxt/package.json b/distributions/nuxt/package.json
index 8a11c69ab3..d646845d2c 100644
--- a/distributions/nuxt/package.json
+++ b/distributions/nuxt/package.json
@@ -52,7 +52,7 @@
"@nuxt/core": "^2.2.0",
"@nuxt/generator": "^2.2.0",
"@nuxt/webpack": "^2.2.0",
- "consola": "^2.0.0-1"
+ "consola": "^2.1.1"
},
"engines": {
"node": ">=8.0.0",
diff --git a/package.json b/package.json
index dbf7bd2033..80bf86b44e 100644
--- a/package.json
+++ b/package.json
@@ -31,14 +31,14 @@
"babel-jest": "^23.6.0",
"babel-plugin-dynamic-import-node": "^2.2.0",
"codecov": "^3.1.0",
- "consola": "^2.0.0-1",
+ "consola": "^2.1.1",
"cross-env": "^5.2.0",
"cross-spawn": "^6.0.5",
"eslint": "^5.8.0",
"eslint-config-standard": "^12.0.0",
"eslint-multiplexer": "^1.0.2",
"eslint-plugin-import": "^2.14.0",
- "eslint-plugin-jest": "^21.26.2",
+ "eslint-plugin-jest": "^21.27.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
@@ -57,7 +57,7 @@
"lodash": "^4.17.11",
"pug": "^2.0.3",
"pug-plain-loader": "^1.0.0",
- "puppeteer": "^1.9.0",
+ "puppeteer": "^1.10.0",
"request": "^2.88.0",
"request-promise-native": "^1.0.5",
"rimraf": "^2.6.2",
diff --git a/packages/builder/package.json b/packages/builder/package.json
index edaa9008dc..eba668aadc 100644
--- a/packages/builder/package.json
+++ b/packages/builder/package.json
@@ -10,9 +10,9 @@
"dependencies": {
"@nuxt/common": "^2.2.0",
"@nuxt/vue-app": "^2.2.0",
- "@nuxtjs/devalue": "^1.0.1",
+ "@nuxtjs/devalue": "^1.1.0",
"chokidar": "^2.0.4",
- "consola": "^2.0.0-1",
+ "consola": "^2.1.1",
"fs-extra": "^7.0.0",
"glob": "^7.1.3",
"hash-sum": "^1.0.2",
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 460ef97c55..4f1b5f6d17 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -13,7 +13,7 @@
},
"dependencies": {
"@nuxt/config": "^2.2.0",
- "consola": "^2.0.0-1",
+ "consola": "^2.1.1",
"esm": "^3.0.84",
"minimist": "^1.2.0",
"wrap-ansi": "^4.0.0"
diff --git a/packages/common/package.json b/packages/common/package.json
index 3e9759e2b6..d5a2b2915d 100644
--- a/packages/common/package.json
+++ b/packages/common/package.json
@@ -9,7 +9,7 @@
"main": "dist/common.js",
"dependencies": {
"@nuxt/config": "^2.2.0",
- "consola": "^2.0.0-1",
+ "consola": "^2.1.1",
"lodash": "^4.17.11"
},
"publishConfig": {
diff --git a/packages/config/package.json b/packages/config/package.json
index 39fdba871c..1b0968100c 100644
--- a/packages/config/package.json
+++ b/packages/config/package.json
@@ -9,9 +9,9 @@
"main": "dist/config.js",
"dependencies": {
"@nuxt/common": "^2.2.0",
- "consola": "^2.0.0-1",
+ "consola": "^2.1.1",
"lodash": "^4.17.11",
- "std-env": "^2.0.2"
+ "std-env": "^2.1.0"
},
"publishConfig": {
"access": "public"
diff --git a/packages/core/package.json b/packages/core/package.json
index 68e85491d0..71cb0cfc93 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -12,15 +12,15 @@
"@nuxt/config": "^2.2.0",
"@nuxt/server": "^2.2.0",
"@nuxt/vue-renderer": "^2.2.0",
- "@nuxtjs/devalue": "^1.0.1",
+ "@nuxtjs/devalue": "^1.1.0",
"@nuxtjs/opencollective": "^0.1.0",
- "consola": "^2.0.0-1",
+ "consola": "^2.1.1",
"debug": "^4.1.0",
"esm": "^3.0.84",
"fs-extra": "^7.0.0",
"hash-sum": "^1.0.2",
"lodash": "^4.17.11",
- "std-env": "^2.0.2"
+ "std-env": "^2.1.0"
},
"publishConfig": {
"access": "public"
diff --git a/packages/generator/package.json b/packages/generator/package.json
index 6cbb9a7b23..06c0bf04d9 100644
--- a/packages/generator/package.json
+++ b/packages/generator/package.json
@@ -10,7 +10,7 @@
"dependencies": {
"@nuxt/common": "^2.2.0",
"chalk": "^2.4.1",
- "consola": "^2.0.0-1",
+ "consola": "^2.1.1",
"fs-extra": "^7.0.0",
"html-minifier": "^3.5.21"
},
diff --git a/packages/server/package.json b/packages/server/package.json
index f50d873a15..a71d3cf0ad 100644
--- a/packages/server/package.json
+++ b/packages/server/package.json
@@ -14,7 +14,7 @@
"chalk": "^2.4.1",
"compression": "^1.7.3",
"connect": "^3.6.6",
- "consola": "^2.0.0-1",
+ "consola": "^2.1.1",
"etag": "^1.8.1",
"fresh": "^0.5.2",
"fs-extra": "^7.0.0",
diff --git a/packages/vue-renderer/package.json b/packages/vue-renderer/package.json
index 651f133c8e..771b3f6973 100644
--- a/packages/vue-renderer/package.json
+++ b/packages/vue-renderer/package.json
@@ -9,9 +9,9 @@
"main": "dist/vue-renderer.js",
"dependencies": {
"@nuxt/common": "^2.2.0",
- "@nuxtjs/devalue": "^1.0.1",
+ "@nuxtjs/devalue": "^1.1.0",
"browserslist-useragent": "^2.0.1",
- "consola": "^2.0.0-1",
+ "consola": "^2.1.1",
"fs-extra": "^7.0.0",
"lru-cache": "^4.1.3",
"vue": "^2.5.17",
diff --git a/packages/webpack/package.json b/packages/webpack/package.json
index 0416c3f6dd..7e4dd12991 100644
--- a/packages/webpack/package.json
+++ b/packages/webpack/package.json
@@ -15,9 +15,9 @@
"@nuxtjs/friendly-errors-webpack-plugin": "^2.1.0",
"babel-loader": "^8.0.4",
"cache-loader": "^1.2.5",
- "caniuse-lite": "^1.0.30000903",
+ "caniuse-lite": "^1.0.30000904",
"chalk": "^2.4.1",
- "consola": "^2.0.0-1",
+ "consola": "^2.1.1",
"css-loader": "^1.0.1",
"cssnano": "^4.1.7",
"file-loader": "^2.0.0",
@@ -42,7 +42,7 @@
"time-fix-plugin": "^2.0.5",
"url-loader": "^1.1.2",
"vue-loader": "^15.4.2",
- "webpack": "^4.23.1",
+ "webpack": "^4.24.0",
"webpack-bundle-analyzer": "^3.0.3",
"webpack-dev-middleware": "^3.4.0",
"webpack-hot-middleware": "^2.24.3",
diff --git a/yarn.lock b/yarn.lock
index 3a751c7549..f9ac9a2133 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1333,12 +1333,12 @@
resolved "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-1.1.2.tgz#54c5a964462be3d4d78af631363c18d6fa91ac26"
integrity sha512-yprFYuno9FtNsSHVlSWd+nRlmGoAbqbeCwOryP6sC/zoCjhpArcRMYp19EvpSUSizJAlsXEwJv+wcWS9XaXdMw==
-"@nuxtjs/devalue@^1.0.1":
- version "1.0.1"
- resolved "https://registry.npmjs.org/@nuxtjs/devalue/-/devalue-1.0.1.tgz#661f16ed4c5d4bf64ab8b6e66fa1aa16bc57d504"
- integrity sha512-kL4x8JyK8fvOKWhFENDzwTH+AR4HUYOCVEGkoe0XUyniqsesIXcZiPCV+sGXBwTwwopQDVpaz97y+RyBH535gw==
+"@nuxtjs/devalue@^1.1.0":
+ version "1.1.0"
+ resolved "https://registry.npmjs.org/@nuxtjs/devalue/-/devalue-1.1.0.tgz#4dcdf33d914f6ea71b09da365452dd1016390d64"
+ integrity sha512-q0c6OY+NgIs0whENpQtGOdnxy95e357aBtX8ix4koMtqijjUuWO+SjFE/s3Apg7F+YfBWMuDJ0wj9ZWktzDnhg==
dependencies:
- consola "^1.4.3"
+ consola "^2.0.7"
"@nuxtjs/eslint-config@^0.0.1":
version "0.0.1"
@@ -1426,147 +1426,147 @@
source-map "^0.5.6"
vue-template-es2015-compiler "^1.6.0"
-"@webassemblyjs/ast@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.7.10.tgz#0cfc61d61286240b72fc522cb755613699eea40a"
- integrity sha512-wTUeaByYN2EA6qVqhbgavtGc7fLTOx0glG2IBsFlrFG51uXIGlYBTyIZMf4SPLo3v1bgV/7lBN3l7Z0R6Hswew==
+"@webassemblyjs/ast@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.7.11.tgz#b988582cafbb2b095e8b556526f30c90d057cace"
+ integrity sha512-ZEzy4vjvTzScC+SH8RBssQUawpaInUdMTYwYYLh54/s8TuT0gBLuyUnppKsVyZEi876VmmStKsUs28UxPgdvrA==
dependencies:
- "@webassemblyjs/helper-module-context" "1.7.10"
- "@webassemblyjs/helper-wasm-bytecode" "1.7.10"
- "@webassemblyjs/wast-parser" "1.7.10"
+ "@webassemblyjs/helper-module-context" "1.7.11"
+ "@webassemblyjs/helper-wasm-bytecode" "1.7.11"
+ "@webassemblyjs/wast-parser" "1.7.11"
-"@webassemblyjs/floating-point-hex-parser@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.7.10.tgz#ee63d729c6311a85863e369a473f9983f984e4d9"
- integrity sha512-gMsGbI6I3p/P1xL2UxqhNh1ga2HCsx5VBB2i5VvJFAaqAjd2PBTRULc3BpTydabUQEGlaZCzEUQhLoLG7TvEYQ==
+"@webassemblyjs/floating-point-hex-parser@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.7.11.tgz#a69f0af6502eb9a3c045555b1a6129d3d3f2e313"
+ integrity sha512-zY8dSNyYcgzNRNT666/zOoAyImshm3ycKdoLsyDw/Bwo6+/uktb7p4xyApuef1dwEBo/U/SYQzbGBvV+nru2Xg==
-"@webassemblyjs/helper-api-error@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.7.10.tgz#bfcb3bbe59775357475790a2ad7b289f09b2f198"
- integrity sha512-DoYRlPWtuw3yd5BOr9XhtrmB6X1enYF0/54yNvQWGXZEPDF5PJVNI7zQ7gkcKfTESzp8bIBWailaFXEK/jjCsw==
+"@webassemblyjs/helper-api-error@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.7.11.tgz#c7b6bb8105f84039511a2b39ce494f193818a32a"
+ integrity sha512-7r1qXLmiglC+wPNkGuXCvkmalyEstKVwcueZRP2GNC2PAvxbLYwLLPr14rcdJaE4UtHxQKfFkuDFuv91ipqvXg==
-"@webassemblyjs/helper-buffer@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.7.10.tgz#0a8c624c67ad0b214d2e003859921a1988cb151b"
- integrity sha512-+RMU3dt/dPh4EpVX4u5jxsOlw22tp3zjqE0m3ftU2tsYxnPULb4cyHlgaNd2KoWuwasCQqn8Mhr+TTdbtj3LlA==
+"@webassemblyjs/helper-buffer@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.7.11.tgz#3122d48dcc6c9456ed982debe16c8f37101df39b"
+ integrity sha512-MynuervdylPPh3ix+mKZloTcL06P8tenNH3sx6s0qE8SLR6DdwnfgA7Hc9NSYeob2jrW5Vql6GVlsQzKQCa13w==
-"@webassemblyjs/helper-code-frame@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.7.10.tgz#0ab7e22fad0241a173178c73976fc0edf50832ce"
- integrity sha512-UiytbpKAULOEab2hUZK2ywXen4gWJVrgxtwY3Kn+eZaaSWaRM8z/7dAXRSoamhKFiBh1uaqxzE/XD9BLlug3gw==
+"@webassemblyjs/helper-code-frame@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.7.11.tgz#cf8f106e746662a0da29bdef635fcd3d1248364b"
+ integrity sha512-T8ESC9KMXFTXA5urJcyor5cn6qWeZ4/zLPyWeEXZ03hj/x9weSokGNkVCdnhSabKGYWxElSdgJ+sFa9G/RdHNw==
dependencies:
- "@webassemblyjs/wast-printer" "1.7.10"
+ "@webassemblyjs/wast-printer" "1.7.11"
-"@webassemblyjs/helper-fsm@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/helper-fsm/-/helper-fsm-1.7.10.tgz#0915e7713fbbb735620a9d3e4fa3d7951f97ac64"
- integrity sha512-w2vDtUK9xeSRtt5+RnnlRCI7wHEvLjF0XdnxJpgx+LJOvklTZPqWkuy/NhwHSLP19sm9H8dWxKeReMR7sCkGZA==
+"@webassemblyjs/helper-fsm@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/helper-fsm/-/helper-fsm-1.7.11.tgz#df38882a624080d03f7503f93e3f17ac5ac01181"
+ integrity sha512-nsAQWNP1+8Z6tkzdYlXT0kxfa2Z1tRTARd8wYnc/e3Zv3VydVVnaeePgqUzFrpkGUyhUUxOl5ML7f1NuT+gC0A==
-"@webassemblyjs/helper-module-context@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/helper-module-context/-/helper-module-context-1.7.10.tgz#9beb83f72740f5ac8075313b5cac5e796510f755"
- integrity sha512-yE5x/LzZ3XdPdREmJijxzfrf+BDRewvO0zl8kvORgSWmxpRrkqY39KZSq6TSgIWBxkK4SrzlS3BsMCv2s1FpsQ==
+"@webassemblyjs/helper-module-context@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/helper-module-context/-/helper-module-context-1.7.11.tgz#d874d722e51e62ac202476935d649c802fa0e209"
+ integrity sha512-JxfD5DX8Ygq4PvXDucq0M+sbUFA7BJAv/GGl9ITovqE+idGX+J3QSzJYz+LwQmL7fC3Rs+utvWoJxDb6pmC0qg==
-"@webassemblyjs/helper-wasm-bytecode@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.7.10.tgz#797b1e734bbcfdea8399669cdc58308ef1c7ffc0"
- integrity sha512-u5qy4SJ/OrxKxZqJ9N3qH4ZQgHaAzsopsYwLvoWJY6Q33r8PhT3VPyNMaJ7ZFoqzBnZlCcS/0f4Sp8WBxylXfg==
+"@webassemblyjs/helper-wasm-bytecode@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.7.11.tgz#dd9a1e817f1c2eb105b4cf1013093cb9f3c9cb06"
+ integrity sha512-cMXeVS9rhoXsI9LLL4tJxBgVD/KMOKXuFqYb5oCJ/opScWpkCMEz9EJtkonaNcnLv2R3K5jIeS4TRj/drde1JQ==
-"@webassemblyjs/helper-wasm-section@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.7.10.tgz#c0ea3703c615d7bc3e3507c3b7991c8767b2f20e"
- integrity sha512-Ecvww6sCkcjatcyctUrn22neSJHLN/TTzolMGG/N7S9rpbsTZ8c6Bl98GpSpV77EvzNijiNRHBG0+JO99qKz6g==
+"@webassemblyjs/helper-wasm-section@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.7.11.tgz#9c9ac41ecf9fbcfffc96f6d2675e2de33811e68a"
+ integrity sha512-8ZRY5iZbZdtNFE5UFunB8mmBEAbSI3guwbrsCl4fWdfRiAcvqQpeqd5KHhSWLL5wuxo53zcaGZDBU64qgn4I4Q==
dependencies:
- "@webassemblyjs/ast" "1.7.10"
- "@webassemblyjs/helper-buffer" "1.7.10"
- "@webassemblyjs/helper-wasm-bytecode" "1.7.10"
- "@webassemblyjs/wasm-gen" "1.7.10"
+ "@webassemblyjs/ast" "1.7.11"
+ "@webassemblyjs/helper-buffer" "1.7.11"
+ "@webassemblyjs/helper-wasm-bytecode" "1.7.11"
+ "@webassemblyjs/wasm-gen" "1.7.11"
-"@webassemblyjs/ieee754@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.7.10.tgz#62c1728b7ef0f66ef8221e2966a0afd75db430df"
- integrity sha512-HRcWcY+YWt4+s/CvQn+vnSPfRaD4KkuzQFt5MNaELXXHSjelHlSEA8ZcqT69q0GTIuLWZ6JaoKar4yWHVpZHsQ==
+"@webassemblyjs/ieee754@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.7.11.tgz#c95839eb63757a31880aaec7b6512d4191ac640b"
+ integrity sha512-Mmqx/cS68K1tSrvRLtaV/Lp3NZWzXtOHUW2IvDvl2sihAwJh4ACE0eL6A8FvMyDG9abes3saB6dMimLOs+HMoQ==
dependencies:
"@xtuc/ieee754" "^1.2.0"
-"@webassemblyjs/leb128@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.7.10.tgz#167e0bb4b06d7701585772a73fba9f4df85439f6"
- integrity sha512-og8MciYlA8hvzCLR71hCuZKPbVBfLQeHv7ImKZ4nlyxrYbG7uJHYtHiHu6OV9SqrGuD03H/HtXC4Bgdjfm9FHw==
+"@webassemblyjs/leb128@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.7.11.tgz#d7267a1ee9c4594fd3f7e37298818ec65687db63"
+ integrity sha512-vuGmgZjjp3zjcerQg+JA+tGOncOnJLWVkt8Aze5eWQLwTQGNgVLcyOTqgSCxWTR4J42ijHbBxnuRaL1Rv7XMdw==
dependencies:
"@xtuc/long" "4.2.1"
-"@webassemblyjs/utf8@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.7.10.tgz#b6728f5b6f50364abc155be029f9670e6685605a"
- integrity sha512-Ng6Pxv6siyZp635xCSnH3mKmIFgqWPCcGdoo0GBYgyGdxu7cUj4agV7Uu1a8REP66UYUFXJLudeGgd4RvuJAnQ==
+"@webassemblyjs/utf8@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.7.11.tgz#06d7218ea9fdc94a6793aa92208160db3d26ee82"
+ integrity sha512-C6GFkc7aErQIAH+BMrIdVSmW+6HSe20wg57HEC1uqJP8E/xpMjXqQUxkQw07MhNDSDcGpxI9G5JSNOQCqJk4sA==
-"@webassemblyjs/wasm-edit@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.7.10.tgz#83fe3140f5a58f5a30b914702be9f0e59a399092"
- integrity sha512-e9RZFQlb+ZuYcKRcW9yl+mqX/Ycj9+3/+ppDI8nEE/NCY6FoK8f3dKBcfubYV/HZn44b+ND4hjh+4BYBt+sDnA==
+"@webassemblyjs/wasm-edit@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.7.11.tgz#8c74ca474d4f951d01dbae9bd70814ee22a82005"
+ integrity sha512-FUd97guNGsCZQgeTPKdgxJhBXkUbMTY6hFPf2Y4OedXd48H97J+sOY2Ltaq6WGVpIH8o/TGOVNiVz/SbpEMJGg==
dependencies:
- "@webassemblyjs/ast" "1.7.10"
- "@webassemblyjs/helper-buffer" "1.7.10"
- "@webassemblyjs/helper-wasm-bytecode" "1.7.10"
- "@webassemblyjs/helper-wasm-section" "1.7.10"
- "@webassemblyjs/wasm-gen" "1.7.10"
- "@webassemblyjs/wasm-opt" "1.7.10"
- "@webassemblyjs/wasm-parser" "1.7.10"
- "@webassemblyjs/wast-printer" "1.7.10"
+ "@webassemblyjs/ast" "1.7.11"
+ "@webassemblyjs/helper-buffer" "1.7.11"
+ "@webassemblyjs/helper-wasm-bytecode" "1.7.11"
+ "@webassemblyjs/helper-wasm-section" "1.7.11"
+ "@webassemblyjs/wasm-gen" "1.7.11"
+ "@webassemblyjs/wasm-opt" "1.7.11"
+ "@webassemblyjs/wasm-parser" "1.7.11"
+ "@webassemblyjs/wast-printer" "1.7.11"
-"@webassemblyjs/wasm-gen@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.7.10.tgz#4de003806ae29c97ab3707782469b53299570174"
- integrity sha512-M0lb6cO2Y0PzDye/L39PqwV+jvO+2YxEG5ax+7dgq7EwXdAlpOMx1jxyXJTScQoeTpzOPIb+fLgX/IkLF8h2yw==
+"@webassemblyjs/wasm-gen@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.7.11.tgz#9bbba942f22375686a6fb759afcd7ac9c45da1a8"
+ integrity sha512-U/KDYp7fgAZX5KPfq4NOupK/BmhDc5Kjy2GIqstMhvvdJRcER/kUsMThpWeRP8BMn4LXaKhSTggIJPOeYHwISA==
dependencies:
- "@webassemblyjs/ast" "1.7.10"
- "@webassemblyjs/helper-wasm-bytecode" "1.7.10"
- "@webassemblyjs/ieee754" "1.7.10"
- "@webassemblyjs/leb128" "1.7.10"
- "@webassemblyjs/utf8" "1.7.10"
+ "@webassemblyjs/ast" "1.7.11"
+ "@webassemblyjs/helper-wasm-bytecode" "1.7.11"
+ "@webassemblyjs/ieee754" "1.7.11"
+ "@webassemblyjs/leb128" "1.7.11"
+ "@webassemblyjs/utf8" "1.7.11"
-"@webassemblyjs/wasm-opt@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.7.10.tgz#d151e31611934a556c82789fdeec41a814993c2a"
- integrity sha512-R66IHGCdicgF5ZliN10yn5HaC7vwYAqrSVJGjtJJQp5+QNPBye6heWdVH/at40uh0uoaDN/UVUfXK0gvuUqtVg==
+"@webassemblyjs/wasm-opt@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.7.11.tgz#b331e8e7cef8f8e2f007d42c3a36a0580a7d6ca7"
+ integrity sha512-XynkOwQyiRidh0GLua7SkeHvAPXQV/RxsUeERILmAInZegApOUAIJfRuPYe2F7RcjOC9tW3Cb9juPvAC/sCqvg==
dependencies:
- "@webassemblyjs/ast" "1.7.10"
- "@webassemblyjs/helper-buffer" "1.7.10"
- "@webassemblyjs/wasm-gen" "1.7.10"
- "@webassemblyjs/wasm-parser" "1.7.10"
+ "@webassemblyjs/ast" "1.7.11"
+ "@webassemblyjs/helper-buffer" "1.7.11"
+ "@webassemblyjs/wasm-gen" "1.7.11"
+ "@webassemblyjs/wasm-parser" "1.7.11"
-"@webassemblyjs/wasm-parser@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.7.10.tgz#0367be7bf8f09e3e6abc95f8e483b9206487ec65"
- integrity sha512-AEv8mkXVK63n/iDR3T693EzoGPnNAwKwT3iHmKJNBrrALAhhEjuPzo/lTE4U7LquEwyvg5nneSNdTdgrBaGJcA==
+"@webassemblyjs/wasm-parser@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.7.11.tgz#6e3d20fa6a3519f6b084ef9391ad58211efb0a1a"
+ integrity sha512-6lmXRTrrZjYD8Ng8xRyvyXQJYUQKYSXhJqXOBLw24rdiXsHAOlvw5PhesjdcaMadU/pyPQOJ5dHreMjBxwnQKg==
dependencies:
- "@webassemblyjs/ast" "1.7.10"
- "@webassemblyjs/helper-api-error" "1.7.10"
- "@webassemblyjs/helper-wasm-bytecode" "1.7.10"
- "@webassemblyjs/ieee754" "1.7.10"
- "@webassemblyjs/leb128" "1.7.10"
- "@webassemblyjs/utf8" "1.7.10"
+ "@webassemblyjs/ast" "1.7.11"
+ "@webassemblyjs/helper-api-error" "1.7.11"
+ "@webassemblyjs/helper-wasm-bytecode" "1.7.11"
+ "@webassemblyjs/ieee754" "1.7.11"
+ "@webassemblyjs/leb128" "1.7.11"
+ "@webassemblyjs/utf8" "1.7.11"
-"@webassemblyjs/wast-parser@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/wast-parser/-/wast-parser-1.7.10.tgz#058f598b52f730b23fc874d4775b6286b6247264"
- integrity sha512-YTPEtOBljkCL0VjDp4sHe22dAYSm3ZwdJ9+2NTGdtC7ayNvuip1wAhaAS8Zt9Q6SW9E5Jf5PX7YE3XWlrzR9cw==
+"@webassemblyjs/wast-parser@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/wast-parser/-/wast-parser-1.7.11.tgz#25bd117562ca8c002720ff8116ef9072d9ca869c"
+ integrity sha512-lEyVCg2np15tS+dm7+JJTNhNWq9yTZvi3qEhAIIOaofcYlUp0UR5/tVqOwa/gXYr3gjwSZqw+/lS9dscyLelbQ==
dependencies:
- "@webassemblyjs/ast" "1.7.10"
- "@webassemblyjs/floating-point-hex-parser" "1.7.10"
- "@webassemblyjs/helper-api-error" "1.7.10"
- "@webassemblyjs/helper-code-frame" "1.7.10"
- "@webassemblyjs/helper-fsm" "1.7.10"
+ "@webassemblyjs/ast" "1.7.11"
+ "@webassemblyjs/floating-point-hex-parser" "1.7.11"
+ "@webassemblyjs/helper-api-error" "1.7.11"
+ "@webassemblyjs/helper-code-frame" "1.7.11"
+ "@webassemblyjs/helper-fsm" "1.7.11"
"@xtuc/long" "4.2.1"
-"@webassemblyjs/wast-printer@1.7.10":
- version "1.7.10"
- resolved "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.7.10.tgz#d817909d2450ae96c66b7607624d98a33b84223b"
- integrity sha512-mJ3QKWtCchL1vhU/kZlJnLPuQZnlDOdZsyP0bbLWPGdYsQDnSBvyTLhzwBA3QAMlzEL9V4JHygEmK6/OTEyytA==
+"@webassemblyjs/wast-printer@1.7.11":
+ version "1.7.11"
+ resolved "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.7.11.tgz#c4245b6de242cb50a2cc950174fdbf65c78d7813"
+ integrity sha512-m5vkAsuJ32QpkdkDOUPGSltrg8Cuk3KBx4YrmAGQwCZPRdUHXxG4phIOuuycLemHFr74sWL9Wthqss4fzdzSwg==
dependencies:
- "@webassemblyjs/ast" "1.7.10"
- "@webassemblyjs/wast-parser" "1.7.10"
+ "@webassemblyjs/ast" "1.7.11"
+ "@webassemblyjs/wast-parser" "1.7.11"
"@xtuc/long" "4.2.1"
"@xtuc/ieee754@^1.2.0":
@@ -2658,10 +2658,10 @@ caniuse-lite@^1.0.30000899:
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000899.tgz#6febdbbc388a7982f620ee0e3d09aab0c061389e"
integrity sha512-enC3zKfUCJxxwvUIsBkbHd54CtJw1KtIWvrK0JZxWD/fEN2knHaai45lndJ4xXAkyRAPyk60J3yagkKDWhfeMA==
-caniuse-lite@^1.0.30000903:
- version "1.0.30000903"
- resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000903.tgz#86d46227759279b3db345ddbe778335dbba9e858"
- integrity sha512-T1XVJEpGCoaq7MDw7/6hCdYUukmSaS+1l/OQJkLtw7Cr2+/+d67tNGKEbyiqf7Ck8x6EhNFUxjYFXXka0N/w5g==
+caniuse-lite@^1.0.30000904:
+ version "1.0.30000904"
+ resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000904.tgz#4445d00da859a0e0ae6dbb2876c545f3324f6c74"
+ integrity sha512-M4sXvogCoY5Fp6fuXIaQG/MIexlEFQ3Lgwban+KlqiQUbUIkSmjAB8ZJIP79aj2cdqz2F1Lb+Z+5GwHvCrbLtg==
capture-exit@^1.2.0:
version "1.2.0"
@@ -3025,15 +3025,15 @@ consola@^1.4.3:
lodash "^4.17.5"
std-env "^1.1.0"
-consola@^2.0.0-1:
- version "2.0.0-1"
- resolved "https://registry.npmjs.org/consola/-/consola-2.0.0-1.tgz#4883f5c19ae07b63226f27311c4e54a42e18714a"
- integrity sha512-X4sDWc37AbZFXVHT55I0SWKilv1qClu3fPDzakcnEKUENJZXrHaJwpSUDDXOrp0KBsdUBx6ji6DpuSZm6/QUVQ==
+consola@^2.0.7, consola@^2.1.1:
+ version "2.1.1"
+ resolved "https://registry.npmjs.org/consola/-/consola-2.1.1.tgz#2be8bf537145d5adc47726024c84cf38e85b48e4"
+ integrity sha512-6CFUwEF1Scd7xPjdaN20VF8BV0RF2Fkc5nehvusfh/3ymDnn96K+sj+AM8wmWgCdMjglyo3vd+zszaS5MlhuCQ==
dependencies:
chalk "^2.4.1"
dayjs "^1.7.7"
figures "^2.0.0"
- std-env "^2.0.2"
+ std-env "^2.1.0"
string-width "^2.1.1"
console-browserify@^1.1.0:
@@ -4186,10 +4186,10 @@ eslint-plugin-import@^2.14.0:
read-pkg-up "^2.0.0"
resolve "^1.6.0"
-eslint-plugin-jest@^21.26.2:
- version "21.26.2"
- resolved "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-21.26.2.tgz#5b24413970e83e2c5b87c5c047a08a4881783605"
- integrity sha512-SCTBC6q182D4qQlQAN81D351jdte/YwTMo4f+l19Gvh1VemaNZP7ak3MLLvw6xkL9dO2FxVjCLk5DCdl1KfdLw==
+eslint-plugin-jest@^21.27.0:
+ version "21.27.0"
+ resolved "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-21.27.0.tgz#35ab98d41066efbac481b7a50b7c2877dfede70e"
+ integrity sha512-ePtyE/zUE+aCfB3fE9wfJWej2UFVDPxEUmKo62xbERRj026MrLUhrMuQHICosFI8/oTzbzi4ypk9qnfYnoIDaA==
eslint-plugin-node@^8.0.0:
version "8.0.0"
@@ -9032,10 +9032,10 @@ punycode@^2.1.0:
resolved "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
-puppeteer@^1.9.0:
- version "1.9.0"
- resolved "https://registry.npmjs.org/puppeteer/-/puppeteer-1.9.0.tgz#56dba79e7ea4faac807877bee3b23d63291fc59e"
- integrity sha512-GH4PmhJf9wBRAPvtJkEJLAvdNNOofZortmBZSj8cGWYni98GUFqsf66blOEfJbo5B8l0KG5HR2d/W2MejnUrzg==
+puppeteer@^1.10.0:
+ version "1.10.0"
+ resolved "https://registry.npmjs.org/puppeteer/-/puppeteer-1.10.0.tgz#e3005f1251c2feae0e10c0f7a35afbcd56589ceb"
+ integrity sha512-3i28X/ucX8t3eL4TZA60FLMOQNKqudFSOGDHr0cT7T4dE027CrcS885aAqjdxNybhMPliM5yImNsKJ6SQrPzhw==
dependencies:
debug "^3.1.0"
extract-zip "^1.6.6"
@@ -10147,10 +10147,10 @@ std-env@^1.1.0, std-env@^1.3.1:
dependencies:
is-ci "^1.1.0"
-std-env@^2.0.2:
- version "2.0.2"
- resolved "https://registry.npmjs.org/std-env/-/std-env-2.0.2.tgz#290baa5c905cd4d54f970596923d3f3077adaf06"
- integrity sha512-c5ighQ15FdLEXYfeed0Zf2qA+YIIW3NcqsoohqaZvBLRhgSiqq+650JDGLAxu3NmdNU/VlWNTnb9sSZg5Xthgw==
+std-env@^2.1.0:
+ version "2.1.0"
+ resolved "https://registry.npmjs.org/std-env/-/std-env-2.1.0.tgz#0eab8ddabf6a27c055cc23120d131b4ae90c9b8f"
+ integrity sha512-Jb0FHRwR0Ca1IZVPjHI8nRBQngzuza8GYp/Gv02PKBrJ3M+Yrj5exDzVIb8Xwf3x/6P/69XNQAMaed65OyiBzw==
dependencies:
ci-info "^1.6.0"
@@ -11162,15 +11162,15 @@ webpack-sources@^1.1.0, webpack-sources@^1.3.0:
source-list-map "^2.0.0"
source-map "~0.6.1"
-webpack@^4.23.1:
- version "4.23.1"
- resolved "https://registry.npmjs.org/webpack/-/webpack-4.23.1.tgz#db7467b116771ae020c58bdfe2a0822785bb8239"
- integrity sha512-iE5Cu4rGEDk7ONRjisTOjVHv3dDtcFfwitSxT7evtYj/rANJpt1OuC/Kozh1pBa99AUBr1L/LsaNB+D9Xz3CEg==
+webpack@^4.24.0:
+ version "4.24.0"
+ resolved "https://registry.npmjs.org/webpack/-/webpack-4.24.0.tgz#d9822c91eeb595f7351aa5dd785a1952f9c4340a"
+ integrity sha512-Xur0l8nBETnW+DjpFqSGME1jNXxEPVETl30k1lWAsbnukVJdq330/i3PDOLPUtVl/E/cciiOp5uW098hFfQLQA==
dependencies:
- "@webassemblyjs/ast" "1.7.10"
- "@webassemblyjs/helper-module-context" "1.7.10"
- "@webassemblyjs/wasm-edit" "1.7.10"
- "@webassemblyjs/wasm-parser" "1.7.10"
+ "@webassemblyjs/ast" "1.7.11"
+ "@webassemblyjs/helper-module-context" "1.7.11"
+ "@webassemblyjs/wasm-edit" "1.7.11"
+ "@webassemblyjs/wasm-parser" "1.7.11"
acorn "^5.6.2"
acorn-dynamic-import "^3.0.0"
ajv "^6.1.0"
From 7d34f2ef26b1423c89ed041094d97130da0f1987 Mon Sep 17 00:00:00 2001
From: Clark Du
Date: Sun, 4 Nov 2018 14:47:56 +0000
Subject: [PATCH 092/149] refactor: persist isModernBrowser on http connection
(#4268)
---
packages/vue-renderer/src/renderer.js | 16 +++++++++-------
scripts/dev | 2 +-
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/packages/vue-renderer/src/renderer.js b/packages/vue-renderer/src/renderer.js
index 8a07029919..10a3bf93af 100644
--- a/packages/vue-renderer/src/renderer.js
+++ b/packages/vue-renderer/src/renderer.js
@@ -224,16 +224,18 @@ export default class VueRenderer {
return { html, getPreloadFiles }
}
- const { req } = context
- const ua = req && req.headers && req.headers['user-agent']
- const isModernBrowser = this.renderer.modern && ua && matchesUA(ua, {
- allowHigherVersions: true,
- browsers: this.modernBrowsers
- })
+ const { req: { socket = {}, headers } = {} } = context
+ if (socket.isModernBrowser === undefined) {
+ const ua = headers && headers['user-agent']
+ socket.isModernBrowser = this.renderer.modern && ua && matchesUA(ua, {
+ allowHigherVersions: true,
+ browsers: this.modernBrowsers
+ })
+ }
let APP
// Call renderToString from the bundleRenderer and generate the HTML (will update the context as well)
- if (isModernBrowser) {
+ if (socket.isModernBrowser) {
APP = await this.renderer.modern.renderToString(context)
} else {
APP = await this.renderer.ssr.renderToString(context)
diff --git a/scripts/dev b/scripts/dev
index 23a7898816..ff8d204b4f 100755
--- a/scripts/dev
+++ b/scripts/dev
@@ -23,7 +23,7 @@ const _require = esm(module, {
})
module.exports = _require('../src/index')
-`}
+` }
async function main() {
// Read package at current directory
From 4935017f94be553c3f36f8f607bed05c096cff8e Mon Sep 17 00:00:00 2001
From: "renovate[bot]"
Date: Sun, 4 Nov 2018 17:52:41 +0000
Subject: [PATCH 093/149] chore(deps): update all non-major dependencies
(#4267)
This PR contains the following updates:
| Package | Type | Update | Change | References |
|---|---|---|---|---|
| eslint-plugin-jest | devDependencies | patch | `^21.27.0` -> `^21.27.1` | [source](https://renovatebot.com/gh/jest-community/eslint-plugin-jest) |
| rollup | devDependencies | minor | `^0.66.6` -> `^0.67.0` | [source](https://renovatebot.com/gh/rollup/rollup) |
---
### Release Notes
jest-community/eslint-plugin-jest
### [`v21.27.1`](https://renovatebot.com/gh/jest-community/eslint-plugin-jest/releases/v21.27.1)
[Compare Source](https://renovatebot.com/gh/jest-community/eslint-plugin-jest/compare/v21.27.0...v21.27.1)
##### Bug Fixes
- **prefer-spy-on:** fix Cannot read property 'type' of undefined ([#199](https://renovatebot.com/gh/jest-community/eslint-plugin-jes/issues/199)) ([02cd21a](https://renovatebot.com/gh/jest-community/eslint-plugin-jes/commit/02cd21a)), closes [#198](https://renovatebot.com/gh/jest-community/eslint-plugin-jes/issues/198)
rollup/rollup
### [`v0.67.0`](https://renovatebot.com/gh/rollup/rollup/blob/master/CHANGELOG.md#0670)
[Compare Source](https://renovatebot.com/gh/rollup/rollup/compare/v0.66.6...v0.67.0)
_2018-11-04_
- add `sourcemapExcludeSources` option to exclude the source content from sourcemaps ([#2531](https://renovatebot.com/gh/rollup/rollup/pull/2531))
- Create chunks for virtual modules when preserving modules ([#2511](https://renovatebot.com/gh/rollup/rollup/pull/2511))
- Improve execution order of chunks and externals ([#2508](https://renovatebot.com/gh/rollup/rollup/pull/2508))
- Do not resolve external dynamic imports via plugins ([#2505](https://renovatebot.com/gh/rollup/rollup/pull/2505))
- Do not tree-shake children of unknown nodes to e.g. properly handle do-expressions via acorn plugin ([#2510](https://renovatebot.com/gh/rollup/rollup/pull/2510))
- Fix mis-placed semicolons for certain SystemJS exports ([#2529](https://renovatebot.com/gh/rollup/rollup/pull/2529))
- Prevent memory leak when using the bundle as cache ([#2522](https://renovatebot.com/gh/rollup/rollup/pull/2522))
- Fix public sourcemap type ([#2507](https://renovatebot.com/gh/rollup/rollup/pull/2507))
---
### Renovate configuration
:date: **Schedule**: At any time (no schedule defined).
:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
:recycle: **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with "`rebase!`".
:ghost: **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://renovatebot.com/gh/renovatebot/config-help/issues) if that's undesired.
---
This PR has been generated by [Renovate Bot](https://renovatebot.com/gh/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#nuxt/nuxt.js).
---
package.json | 4 ++--
yarn.lock | 16 ++++++++--------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/package.json b/package.json
index 80bf86b44e..95fde29b04 100644
--- a/package.json
+++ b/package.json
@@ -38,7 +38,7 @@
"eslint-config-standard": "^12.0.0",
"eslint-multiplexer": "^1.0.2",
"eslint-plugin-import": "^2.14.0",
- "eslint-plugin-jest": "^21.27.0",
+ "eslint-plugin-jest": "^21.27.1",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
@@ -61,7 +61,7 @@
"request": "^2.88.0",
"request-promise-native": "^1.0.5",
"rimraf": "^2.6.2",
- "rollup": "^0.66.6",
+ "rollup": "^0.67.0",
"rollup-plugin-alias": "^1.4.0",
"rollup-plugin-babel": "^4.0.3",
"rollup-plugin-commonjs": "^9.2.0",
diff --git a/yarn.lock b/yarn.lock
index f9ac9a2133..990656fd5b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4186,10 +4186,10 @@ eslint-plugin-import@^2.14.0:
read-pkg-up "^2.0.0"
resolve "^1.6.0"
-eslint-plugin-jest@^21.27.0:
- version "21.27.0"
- resolved "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-21.27.0.tgz#35ab98d41066efbac481b7a50b7c2877dfede70e"
- integrity sha512-ePtyE/zUE+aCfB3fE9wfJWej2UFVDPxEUmKo62xbERRj026MrLUhrMuQHICosFI8/oTzbzi4ypk9qnfYnoIDaA==
+eslint-plugin-jest@^21.27.1:
+ version "21.27.1"
+ resolved "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-21.27.1.tgz#b64c2d6a7f0751cecc14580d7f4d9a5520424448"
+ integrity sha512-K+S4Wa20MoRRXICfnQBqjl2g9+ipJBeDUVrB3Csg4wOrxXMGcNxYuPRaiyA0pqmb/vO2cgaLEzurORfsLrztxg==
eslint-plugin-node@^8.0.0:
version "8.0.0"
@@ -9635,10 +9635,10 @@ rollup-pluginutils@^2.0.1, rollup-pluginutils@^2.3.0, rollup-pluginutils@^2.3.1,
estree-walker "^0.5.2"
micromatch "^2.3.11"
-rollup@^0.66.6:
- version "0.66.6"
- resolved "https://registry.npmjs.org/rollup/-/rollup-0.66.6.tgz#ce7d6185beb7acea644ce220c25e71ae03275482"
- integrity sha512-J7/SWanrcb83vfIHqa8+aVVGzy457GcjA6GVZEnD0x2u4OnOd0Q1pCrEoNe8yLwM6z6LZP02zBT2uW0yh5TqOw==
+rollup@^0.67.0:
+ version "0.67.0"
+ resolved "https://registry.npmjs.org/rollup/-/rollup-0.67.0.tgz#16d4f259c55224dded6408e7666b7731500797a3"
+ integrity sha512-p34buXxArhwv9ieTdHvdhdo65Cbig68s/Z8llbZuiX5e+3zCqnBF02Ck9IH0tECrmvvrJVMws32Ry84hTnS1Tw==
dependencies:
"@types/estree" "0.0.39"
"@types/node" "*"
From 47f67cc26a5835e87386303d805b802cdf1f692b Mon Sep 17 00:00:00 2001
From: "renovate[bot]"
Date: Sun, 4 Nov 2018 22:18:39 +0330
Subject: [PATCH 094/149] fix(deps): update dependency consola to ^2.2.0
(#4269)
---
distributions/nuxt-legacy/package.json | 2 +-
distributions/nuxt-start/package.json | 2 +-
distributions/nuxt/package.json | 2 +-
package.json | 2 +-
packages/builder/package.json | 2 +-
packages/cli/package.json | 2 +-
packages/common/package.json | 2 +-
packages/config/package.json | 2 +-
packages/core/package.json | 2 +-
packages/generator/package.json | 2 +-
packages/server/package.json | 2 +-
packages/vue-renderer/package.json | 2 +-
packages/webpack/package.json | 2 +-
yarn.lock | 13 ++++++++++++-
14 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/distributions/nuxt-legacy/package.json b/distributions/nuxt-legacy/package.json
index b8cef610b0..9e2a76d172 100644
--- a/distributions/nuxt-legacy/package.json
+++ b/distributions/nuxt-legacy/package.json
@@ -56,7 +56,7 @@
"@nuxt/core": "^2.2.0",
"@nuxt/generator": "^2.2.0",
"@nuxt/webpack": "^2.2.0",
- "consola": "^2.1.1"
+ "consola": "^2.2.0"
},
"engines": {
"node": ">=6.0.0",
diff --git a/distributions/nuxt-start/package.json b/distributions/nuxt-start/package.json
index 0cda2ec302..0f6e9a4ed8 100644
--- a/distributions/nuxt-start/package.json
+++ b/distributions/nuxt-start/package.json
@@ -47,7 +47,7 @@
"@nuxt/cli": "^2.2.0",
"@nuxt/common": "^2.2.0",
"@nuxt/core": "^2.2.0",
- "consola": "^2.1.1"
+ "consola": "^2.2.0"
},
"engines": {
"node": ">=8.0.0",
diff --git a/distributions/nuxt/package.json b/distributions/nuxt/package.json
index d646845d2c..b0a1eff3c3 100644
--- a/distributions/nuxt/package.json
+++ b/distributions/nuxt/package.json
@@ -52,7 +52,7 @@
"@nuxt/core": "^2.2.0",
"@nuxt/generator": "^2.2.0",
"@nuxt/webpack": "^2.2.0",
- "consola": "^2.1.1"
+ "consola": "^2.2.0"
},
"engines": {
"node": ">=8.0.0",
diff --git a/package.json b/package.json
index 95fde29b04..7d6a8727e2 100644
--- a/package.json
+++ b/package.json
@@ -31,7 +31,7 @@
"babel-jest": "^23.6.0",
"babel-plugin-dynamic-import-node": "^2.2.0",
"codecov": "^3.1.0",
- "consola": "^2.1.1",
+ "consola": "^2.2.0",
"cross-env": "^5.2.0",
"cross-spawn": "^6.0.5",
"eslint": "^5.8.0",
diff --git a/packages/builder/package.json b/packages/builder/package.json
index eba668aadc..c336ecd456 100644
--- a/packages/builder/package.json
+++ b/packages/builder/package.json
@@ -12,7 +12,7 @@
"@nuxt/vue-app": "^2.2.0",
"@nuxtjs/devalue": "^1.1.0",
"chokidar": "^2.0.4",
- "consola": "^2.1.1",
+ "consola": "^2.2.0",
"fs-extra": "^7.0.0",
"glob": "^7.1.3",
"hash-sum": "^1.0.2",
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 4f1b5f6d17..27967bf86b 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -13,7 +13,7 @@
},
"dependencies": {
"@nuxt/config": "^2.2.0",
- "consola": "^2.1.1",
+ "consola": "^2.2.0",
"esm": "^3.0.84",
"minimist": "^1.2.0",
"wrap-ansi": "^4.0.0"
diff --git a/packages/common/package.json b/packages/common/package.json
index d5a2b2915d..de089eaa03 100644
--- a/packages/common/package.json
+++ b/packages/common/package.json
@@ -9,7 +9,7 @@
"main": "dist/common.js",
"dependencies": {
"@nuxt/config": "^2.2.0",
- "consola": "^2.1.1",
+ "consola": "^2.2.0",
"lodash": "^4.17.11"
},
"publishConfig": {
diff --git a/packages/config/package.json b/packages/config/package.json
index 1b0968100c..b048af7a59 100644
--- a/packages/config/package.json
+++ b/packages/config/package.json
@@ -9,7 +9,7 @@
"main": "dist/config.js",
"dependencies": {
"@nuxt/common": "^2.2.0",
- "consola": "^2.1.1",
+ "consola": "^2.2.0",
"lodash": "^4.17.11",
"std-env": "^2.1.0"
},
diff --git a/packages/core/package.json b/packages/core/package.json
index 71cb0cfc93..c6df37b9ac 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -14,7 +14,7 @@
"@nuxt/vue-renderer": "^2.2.0",
"@nuxtjs/devalue": "^1.1.0",
"@nuxtjs/opencollective": "^0.1.0",
- "consola": "^2.1.1",
+ "consola": "^2.2.0",
"debug": "^4.1.0",
"esm": "^3.0.84",
"fs-extra": "^7.0.0",
diff --git a/packages/generator/package.json b/packages/generator/package.json
index 06c0bf04d9..9ff6a8716c 100644
--- a/packages/generator/package.json
+++ b/packages/generator/package.json
@@ -10,7 +10,7 @@
"dependencies": {
"@nuxt/common": "^2.2.0",
"chalk": "^2.4.1",
- "consola": "^2.1.1",
+ "consola": "^2.2.0",
"fs-extra": "^7.0.0",
"html-minifier": "^3.5.21"
},
diff --git a/packages/server/package.json b/packages/server/package.json
index a71d3cf0ad..2a4405fdbf 100644
--- a/packages/server/package.json
+++ b/packages/server/package.json
@@ -14,7 +14,7 @@
"chalk": "^2.4.1",
"compression": "^1.7.3",
"connect": "^3.6.6",
- "consola": "^2.1.1",
+ "consola": "^2.2.0",
"etag": "^1.8.1",
"fresh": "^0.5.2",
"fs-extra": "^7.0.0",
diff --git a/packages/vue-renderer/package.json b/packages/vue-renderer/package.json
index 771b3f6973..bd6f21e9c9 100644
--- a/packages/vue-renderer/package.json
+++ b/packages/vue-renderer/package.json
@@ -11,7 +11,7 @@
"@nuxt/common": "^2.2.0",
"@nuxtjs/devalue": "^1.1.0",
"browserslist-useragent": "^2.0.1",
- "consola": "^2.1.1",
+ "consola": "^2.2.0",
"fs-extra": "^7.0.0",
"lru-cache": "^4.1.3",
"vue": "^2.5.17",
diff --git a/packages/webpack/package.json b/packages/webpack/package.json
index 7e4dd12991..50d233f4a2 100644
--- a/packages/webpack/package.json
+++ b/packages/webpack/package.json
@@ -17,7 +17,7 @@
"cache-loader": "^1.2.5",
"caniuse-lite": "^1.0.30000904",
"chalk": "^2.4.1",
- "consola": "^2.1.1",
+ "consola": "^2.2.0",
"css-loader": "^1.0.1",
"cssnano": "^4.1.7",
"file-loader": "^2.0.0",
diff --git a/yarn.lock b/yarn.lock
index 990656fd5b..60d6c057dd 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3025,7 +3025,7 @@ consola@^1.4.3:
lodash "^4.17.5"
std-env "^1.1.0"
-consola@^2.0.7, consola@^2.1.1:
+consola@^2.0.7:
version "2.1.1"
resolved "https://registry.npmjs.org/consola/-/consola-2.1.1.tgz#2be8bf537145d5adc47726024c84cf38e85b48e4"
integrity sha512-6CFUwEF1Scd7xPjdaN20VF8BV0RF2Fkc5nehvusfh/3ymDnn96K+sj+AM8wmWgCdMjglyo3vd+zszaS5MlhuCQ==
@@ -3036,6 +3036,17 @@ consola@^2.0.7, consola@^2.1.1:
std-env "^2.1.0"
string-width "^2.1.1"
+consola@^2.2.0:
+ version "2.2.0"
+ resolved "https://registry.npmjs.org/consola/-/consola-2.2.0.tgz#88d947de0a4b49987e08c5fbd0f290663f1af6f6"
+ integrity sha512-gRFiX/IBKriTBg2LNVozgwCOnBOWwlid6wEWshyjP1erBRPgzS7Fz+0Yvu4kd7jksAWGDvMr4ZnxztOd7NJeCg==
+ dependencies:
+ chalk "^2.4.1"
+ dayjs "^1.7.7"
+ figures "^2.0.0"
+ std-env "^2.1.0"
+ string-width "^2.1.1"
+
console-browserify@^1.1.0:
version "1.1.0"
resolved "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10"
From 1a154e81881646117b02bb37a5bc3d491f9867e4 Mon Sep 17 00:00:00 2001
From: "renovate[bot]"
Date: Mon, 5 Nov 2018 02:29:06 +0330
Subject: [PATCH 095/149] fix(deps): update all non-major dependencies (#4270)
---
distributions/nuxt-legacy/package.json | 2 +-
distributions/nuxt-start/package.json | 2 +-
distributions/nuxt/package.json | 2 +-
package.json | 2 +-
packages/builder/package.json | 2 +-
packages/cli/package.json | 2 +-
packages/common/package.json | 2 +-
packages/config/package.json | 4 ++--
packages/core/package.json | 4 ++--
packages/generator/package.json | 2 +-
packages/server/package.json | 2 +-
packages/vue-renderer/package.json | 2 +-
packages/webpack/package.json | 2 +-
yarn.lock | 17 ++++++++++++-----
14 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/distributions/nuxt-legacy/package.json b/distributions/nuxt-legacy/package.json
index 9e2a76d172..f0c7ac6e2a 100644
--- a/distributions/nuxt-legacy/package.json
+++ b/distributions/nuxt-legacy/package.json
@@ -56,7 +56,7 @@
"@nuxt/core": "^2.2.0",
"@nuxt/generator": "^2.2.0",
"@nuxt/webpack": "^2.2.0",
- "consola": "^2.2.0"
+ "consola": "^2.2.2"
},
"engines": {
"node": ">=6.0.0",
diff --git a/distributions/nuxt-start/package.json b/distributions/nuxt-start/package.json
index 0f6e9a4ed8..0ca8e5af86 100644
--- a/distributions/nuxt-start/package.json
+++ b/distributions/nuxt-start/package.json
@@ -47,7 +47,7 @@
"@nuxt/cli": "^2.2.0",
"@nuxt/common": "^2.2.0",
"@nuxt/core": "^2.2.0",
- "consola": "^2.2.0"
+ "consola": "^2.2.2"
},
"engines": {
"node": ">=8.0.0",
diff --git a/distributions/nuxt/package.json b/distributions/nuxt/package.json
index b0a1eff3c3..5ff8d1408b 100644
--- a/distributions/nuxt/package.json
+++ b/distributions/nuxt/package.json
@@ -52,7 +52,7 @@
"@nuxt/core": "^2.2.0",
"@nuxt/generator": "^2.2.0",
"@nuxt/webpack": "^2.2.0",
- "consola": "^2.2.0"
+ "consola": "^2.2.2"
},
"engines": {
"node": ">=8.0.0",
diff --git a/package.json b/package.json
index 7d6a8727e2..7bcc762163 100644
--- a/package.json
+++ b/package.json
@@ -31,7 +31,7 @@
"babel-jest": "^23.6.0",
"babel-plugin-dynamic-import-node": "^2.2.0",
"codecov": "^3.1.0",
- "consola": "^2.2.0",
+ "consola": "^2.2.2",
"cross-env": "^5.2.0",
"cross-spawn": "^6.0.5",
"eslint": "^5.8.0",
diff --git a/packages/builder/package.json b/packages/builder/package.json
index c336ecd456..4718eaecb2 100644
--- a/packages/builder/package.json
+++ b/packages/builder/package.json
@@ -12,7 +12,7 @@
"@nuxt/vue-app": "^2.2.0",
"@nuxtjs/devalue": "^1.1.0",
"chokidar": "^2.0.4",
- "consola": "^2.2.0",
+ "consola": "^2.2.2",
"fs-extra": "^7.0.0",
"glob": "^7.1.3",
"hash-sum": "^1.0.2",
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 27967bf86b..b319c7f75a 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -13,7 +13,7 @@
},
"dependencies": {
"@nuxt/config": "^2.2.0",
- "consola": "^2.2.0",
+ "consola": "^2.2.2",
"esm": "^3.0.84",
"minimist": "^1.2.0",
"wrap-ansi": "^4.0.0"
diff --git a/packages/common/package.json b/packages/common/package.json
index de089eaa03..b75b81fa28 100644
--- a/packages/common/package.json
+++ b/packages/common/package.json
@@ -9,7 +9,7 @@
"main": "dist/common.js",
"dependencies": {
"@nuxt/config": "^2.2.0",
- "consola": "^2.2.0",
+ "consola": "^2.2.2",
"lodash": "^4.17.11"
},
"publishConfig": {
diff --git a/packages/config/package.json b/packages/config/package.json
index b048af7a59..6cb134d02e 100644
--- a/packages/config/package.json
+++ b/packages/config/package.json
@@ -9,9 +9,9 @@
"main": "dist/config.js",
"dependencies": {
"@nuxt/common": "^2.2.0",
- "consola": "^2.2.0",
+ "consola": "^2.2.2",
"lodash": "^4.17.11",
- "std-env": "^2.1.0"
+ "std-env": "^2.1.1"
},
"publishConfig": {
"access": "public"
diff --git a/packages/core/package.json b/packages/core/package.json
index c6df37b9ac..d1f434dd98 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -14,13 +14,13 @@
"@nuxt/vue-renderer": "^2.2.0",
"@nuxtjs/devalue": "^1.1.0",
"@nuxtjs/opencollective": "^0.1.0",
- "consola": "^2.2.0",
+ "consola": "^2.2.2",
"debug": "^4.1.0",
"esm": "^3.0.84",
"fs-extra": "^7.0.0",
"hash-sum": "^1.0.2",
"lodash": "^4.17.11",
- "std-env": "^2.1.0"
+ "std-env": "^2.1.1"
},
"publishConfig": {
"access": "public"
diff --git a/packages/generator/package.json b/packages/generator/package.json
index 9ff6a8716c..122ff76ae5 100644
--- a/packages/generator/package.json
+++ b/packages/generator/package.json
@@ -10,7 +10,7 @@
"dependencies": {
"@nuxt/common": "^2.2.0",
"chalk": "^2.4.1",
- "consola": "^2.2.0",
+ "consola": "^2.2.2",
"fs-extra": "^7.0.0",
"html-minifier": "^3.5.21"
},
diff --git a/packages/server/package.json b/packages/server/package.json
index 2a4405fdbf..4dace24242 100644
--- a/packages/server/package.json
+++ b/packages/server/package.json
@@ -14,7 +14,7 @@
"chalk": "^2.4.1",
"compression": "^1.7.3",
"connect": "^3.6.6",
- "consola": "^2.2.0",
+ "consola": "^2.2.2",
"etag": "^1.8.1",
"fresh": "^0.5.2",
"fs-extra": "^7.0.0",
diff --git a/packages/vue-renderer/package.json b/packages/vue-renderer/package.json
index bd6f21e9c9..6121835e80 100644
--- a/packages/vue-renderer/package.json
+++ b/packages/vue-renderer/package.json
@@ -11,7 +11,7 @@
"@nuxt/common": "^2.2.0",
"@nuxtjs/devalue": "^1.1.0",
"browserslist-useragent": "^2.0.1",
- "consola": "^2.2.0",
+ "consola": "^2.2.2",
"fs-extra": "^7.0.0",
"lru-cache": "^4.1.3",
"vue": "^2.5.17",
diff --git a/packages/webpack/package.json b/packages/webpack/package.json
index 50d233f4a2..03e9416107 100644
--- a/packages/webpack/package.json
+++ b/packages/webpack/package.json
@@ -17,7 +17,7 @@
"cache-loader": "^1.2.5",
"caniuse-lite": "^1.0.30000904",
"chalk": "^2.4.1",
- "consola": "^2.2.0",
+ "consola": "^2.2.2",
"css-loader": "^1.0.1",
"cssnano": "^4.1.7",
"file-loader": "^2.0.0",
diff --git a/yarn.lock b/yarn.lock
index 60d6c057dd..39fd786c8f 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3036,15 +3036,15 @@ consola@^2.0.7:
std-env "^2.1.0"
string-width "^2.1.1"
-consola@^2.2.0:
- version "2.2.0"
- resolved "https://registry.npmjs.org/consola/-/consola-2.2.0.tgz#88d947de0a4b49987e08c5fbd0f290663f1af6f6"
- integrity sha512-gRFiX/IBKriTBg2LNVozgwCOnBOWwlid6wEWshyjP1erBRPgzS7Fz+0Yvu4kd7jksAWGDvMr4ZnxztOd7NJeCg==
+consola@^2.2.2:
+ version "2.2.2"
+ resolved "https://registry.npmjs.org/consola/-/consola-2.2.2.tgz#02a1df59b63746211d5cff1df436a1b2321cc716"
+ integrity sha512-lrJmVXiQ3LD2unImvgfhcjXRqg81sKjfzPVoQNrl/17BNc5Z1RGFYpexlBavXUMdFfBZlVJgjhosQa6aCHNOVg==
dependencies:
chalk "^2.4.1"
dayjs "^1.7.7"
figures "^2.0.0"
- std-env "^2.1.0"
+ std-env "^2.1.1"
string-width "^2.1.1"
console-browserify@^1.1.0:
@@ -10165,6 +10165,13 @@ std-env@^2.1.0:
dependencies:
ci-info "^1.6.0"
+std-env@^2.1.1:
+ version "2.1.1"
+ resolved "https://registry.npmjs.org/std-env/-/std-env-2.1.1.tgz#b7429cee321390faf39a07f10f0747eec736a78b"
+ integrity sha512-EPOQ97Zg5xlQj322LohFaGoUXFSr9VY30mjL5hKXWMcRUf5o6bOF1S1dkbFH1vOXTD3PcUePr3v4oj1RTeXgHw==
+ dependencies:
+ ci-info "^1.6.0"
+
stealthy-require@^1.1.0:
version "1.1.1"
resolved "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b"
From 3f2b10ea0c707732ccc1b81dad094d969a7de2f9 Mon Sep 17 00:00:00 2001
From: Clark Du
Date: Tue, 6 Nov 2018 10:50:38 +0000
Subject: [PATCH 096/149] fix: Duplicate declaration plugin when add/remove
file in dev mode (#4278)
---
packages/builder/src/builder.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/packages/builder/src/builder.js b/packages/builder/src/builder.js
index 733063da34..140790d5a5 100644
--- a/packages/builder/src/builder.js
+++ b/packages/builder/src/builder.js
@@ -207,6 +207,7 @@ export default class Builder {
async generateRoutesAndFiles() {
consola.debug(`Generating nuxt files`)
+ this.plugins.length = 0
this.plugins.push.apply(this.plugins, this.normalizePlugins())
// -- Templates --
From 3953eef2719c9f14b0d1edf9a9f0352b9f242469 Mon Sep 17 00:00:00 2001
From: Clark Du
Date: Tue, 6 Nov 2018 12:53:15 +0000
Subject: [PATCH 097/149] refactor(builder): make plugins in BuildContext
update dynamically (#4280)
---
packages/builder/src/builder.js | 4 ++--
packages/builder/src/context.js | 6 +++++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/packages/builder/src/builder.js b/packages/builder/src/builder.js
index 140790d5a5..b4e0d9442e 100644
--- a/packages/builder/src/builder.js
+++ b/packages/builder/src/builder.js
@@ -207,8 +207,8 @@ export default class Builder {
async generateRoutesAndFiles() {
consola.debug(`Generating nuxt files`)
- this.plugins.length = 0
- this.plugins.push.apply(this.plugins, this.normalizePlugins())
+ // Plugins
+ this.plugins = Array.from(this.normalizePlugins())
// -- Templates --
let templatesFiles = Array.from(this.template.templatesFiles)
diff --git a/packages/builder/src/context.js b/packages/builder/src/context.js
index 25178c150b..3b60d116e4 100644
--- a/packages/builder/src/context.js
+++ b/packages/builder/src/context.js
@@ -1,8 +1,12 @@
export default class BuildContext {
constructor(builder) {
+ this._builder = builder
this.nuxt = builder.nuxt
this.options = builder.nuxt.options
this.isStatic = false
- this.plugins = builder.plugins
+ }
+
+ get plugins() {
+ return this._builder.plugins
}
}
From 10c608a649ddddfb7725b583b1a811cd00295731 Mon Sep 17 00:00:00 2001
From: Alexander Lichter
Date: Tue, 6 Nov 2018 13:02:07 +0000
Subject: [PATCH 098/149] chore(vue-app): deprecate callback-based asyncData,
fetch and middleware (#4256)
---
packages/vue-app/template/utils.js | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/packages/vue-app/template/utils.js b/packages/vue-app/template/utils.js
index 968c503f42..a73fecbbe7 100644
--- a/packages/vue-app/template/utils.js
+++ b/packages/vue-app/template/utils.js
@@ -226,6 +226,11 @@ export function middlewareSeries(promises, appContext) {
export function promisify(fn, context) {
let promise
if (fn.length === 2) {
+ <% if (isDev) { %>
+ console.warn('Callback-based asyncData, fetch or middleware calls are deprecated. ' +
+ 'Please switch to promises or async/await syntax')
+ <% } %>
+
// fn(context, callback)
promise = new Promise((resolve) => {
fn(context, function (err, data) {
From 1abbeb0e10dedca2a99d7dfc715f3c9abe579324 Mon Sep 17 00:00:00 2001
From: Alexander Lichter
Date: Wed, 7 Nov 2018 10:19:50 +0000
Subject: [PATCH 099/149] chore: fix parenthesis in package.json (#4288)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Small finding while investigating another issue π
---
distributions/nuxt-legacy/package.json | 2 +-
distributions/nuxt-start/package.json | 2 +-
distributions/nuxt/package.json | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/distributions/nuxt-legacy/package.json b/distributions/nuxt-legacy/package.json
index f0c7ac6e2a..103b1a1ee3 100644
--- a/distributions/nuxt-legacy/package.json
+++ b/distributions/nuxt-legacy/package.json
@@ -36,7 +36,7 @@
"name": "Jonas Galvez (@galvez)"
},
{
- "name": "Alexander Lichter (@manniL}"
+ "name": "Alexander Lichter (@manniL)"
}
],
"files": [
diff --git a/distributions/nuxt-start/package.json b/distributions/nuxt-start/package.json
index 0ca8e5af86..9814cf2155 100644
--- a/distributions/nuxt-start/package.json
+++ b/distributions/nuxt-start/package.json
@@ -36,7 +36,7 @@
"name": "Jonas Galvez (@galvez)"
},
{
- "name": "Alexander Lichter (@manniL}"
+ "name": "Alexander Lichter (@manniL)"
}
],
"files": [
diff --git a/distributions/nuxt/package.json b/distributions/nuxt/package.json
index 5ff8d1408b..c7b43ea017 100644
--- a/distributions/nuxt/package.json
+++ b/distributions/nuxt/package.json
@@ -35,7 +35,7 @@
"name": "Jonas Galvez (@galvez)"
},
{
- "name": "Alexander Lichter (@manniL}"
+ "name": "Alexander Lichter (@manniL)"
}
],
"files": [
From b3eb4278a55c4d157c78c0d5dfdade531f0db2f5 Mon Sep 17 00:00:00 2001
From: Alexander Lichter
Date: Wed, 7 Nov 2018 22:33:09 +0000
Subject: [PATCH 100/149] fix: serialize config head fn shorthand correctly
(#4283)
[skip ci]
---
packages/vue-app/template/App.js | 2 +-
test/fixtures/basic/nuxt.config.js | 8 +++++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/packages/vue-app/template/App.js b/packages/vue-app/template/App.js
index 1b5c33767b..fdc81a3c6f 100644
--- a/packages/vue-app/template/App.js
+++ b/packages/vue-app/template/App.js
@@ -18,7 +18,7 @@ const layouts = { <%= Object.keys(layouts).map(key => `"_${key}": _${hash(key)}`
export default {
<%= isTest ? '/* eslint-disable quotes, semi, indent, comma-spacing, key-spacing, object-curly-spacing, object-property-newline, arrow-parens */' : '' %>
- head: <%= serialize(head).replace(/:\w+\(/gm, ':function(') %>,
+ head: <%= serialize(head).replace(/:\w+\(/gm, ':function(').replace('head(', 'function(') %>,
<%= isTest ? '/* eslint-enable quotes, semi, indent, comma-spacing, key-spacing, object-curly-spacing, object-property-newline, arrow-parens */' : '' %>
render(h, props) {
<% if (loading) { %>const loadingEl = h('nuxt-loading', { ref: 'loading' })<% } %>
diff --git a/test/fixtures/basic/nuxt.config.js b/test/fixtures/basic/nuxt.config.js
index b5c802eb60..0c716e5be0 100644
--- a/test/fixtures/basic/nuxt.config.js
+++ b/test/fixtures/basic/nuxt.config.js
@@ -36,9 +36,11 @@ export default {
interval: 200,
subFolders: true
},
- head: {
- titleTemplate: (titleChunk) => {
- return titleChunk ? `${titleChunk} - Nuxt.js` : 'Nuxt.js'
+ head() {
+ return {
+ titleTemplate: (titleChunk) => {
+ return titleChunk ? `${titleChunk} - Nuxt.js` : 'Nuxt.js'
+ }
}
},
modulesDir: path.join(__dirname, '..', '..', '..', 'node_modules'),
From ead994bbb5ac276b1c7d99d37e6f565b22a42ecf Mon Sep 17 00:00:00 2001
From: Alexander Lichter
Date: Wed, 7 Nov 2018 22:34:14 +0000
Subject: [PATCH 101/149] test: add a size limit test (#4272)
[skip ci]
---
package.json | 2 +
test/unit/async-config.size-limit.test.js | 39 +++++++++++++
yarn.lock | 71 ++++++++++++++++++++---
3 files changed, 105 insertions(+), 7 deletions(-)
create mode 100644 test/unit/async-config.size-limit.test.js
diff --git a/package.json b/package.json
index 7bcc762163..2189a523ff 100644
--- a/package.json
+++ b/package.json
@@ -30,6 +30,7 @@
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"babel-plugin-dynamic-import-node": "^2.2.0",
+ "cheerio": "^1.0.0-rc.2",
"codecov": "^3.1.0",
"consola": "^2.2.2",
"cross-env": "^5.2.0",
@@ -55,6 +56,7 @@
"klaw-sync": "^6.0.0",
"lerna": "^3.4.3",
"lodash": "^4.17.11",
+ "node-fetch": "^2.2.1",
"pug": "^2.0.3",
"pug-plain-loader": "^1.0.0",
"puppeteer": "^1.10.0",
diff --git a/test/unit/async-config.size-limit.test.js b/test/unit/async-config.size-limit.test.js
new file mode 100644
index 0000000000..b3ab624447
--- /dev/null
+++ b/test/unit/async-config.size-limit.test.js
@@ -0,0 +1,39 @@
+import cheerio from 'cheerio'
+import fetch from 'node-fetch'
+import { getPort, loadFixture, Nuxt } from '../utils'
+
+let port
+let nuxt = null
+const url = route => 'http://localhost:' + port + route
+let responseSizes
+
+describe('size-limit test', () => {
+ beforeAll(async () => {
+ const options = await loadFixture('async-config')
+ nuxt = new Nuxt(options)
+ port = await getPort()
+ await nuxt.server.listen(port, '0.0.0.0')
+
+ const { html } = await nuxt.server.renderRoute('/')
+ // Get all script URLs from the HTML
+ const $ = cheerio.load(html)
+ const scriptsUrls = $('script[src]')
+ .map((_, el) => $(el).attr('src'))
+ .get()
+ .map(url)
+ const resourceUrls = [url('/'), ...scriptsUrls]
+
+ // Fetch all resources and get their size (bytes)
+ responseSizes = await Promise.all(resourceUrls.map(async (url) => {
+ const response = await fetch(url).then(res => res.text())
+ return response.length
+ }))
+ })
+
+ it('should stay within the size boundaries', () => {
+ const responseSizeBytes = responseSizes.reduce((bytes, responseLength) => bytes + responseLength, 0)
+ const responseSizeKilobytes = Math.ceil(responseSizeBytes / 1024)
+ // Without gzip!
+ expect(responseSizeKilobytes).toBeLessThanOrEqual(170)
+ })
+})
diff --git a/yarn.lock b/yarn.lock
index 39fd786c8f..34ffba657b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2720,6 +2720,18 @@ check-types@^7.3.0:
resolved "https://registry.npmjs.org/check-types/-/check-types-7.4.0.tgz#0378ec1b9616ec71f774931a3c6516fad8c152f4"
integrity sha512-YbulWHdfP99UfZ73NcUDlNJhEIDgm9Doq9GhpyXbF+7Aegi3CVV7qqMCKTTqJxlvEvnQBp9IA+dxsGN6xK/nSg==
+cheerio@^1.0.0-rc.2:
+ version "1.0.0-rc.2"
+ resolved "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.2.tgz#4b9f53a81b27e4d5dac31c0ffd0cfa03cc6830db"
+ integrity sha1-S59TqBsn5NXawxwP/Qz6A8xoMNs=
+ dependencies:
+ css-select "~1.2.0"
+ dom-serializer "~0.1.0"
+ entities "~1.1.1"
+ htmlparser2 "^3.9.1"
+ lodash "^4.15.0"
+ parse5 "^3.0.1"
+
chokidar@^2.0.2, chokidar@^2.0.4:
version "2.0.4"
resolved "https://registry.npmjs.org/chokidar/-/chokidar-2.0.4.tgz#356ff4e2b0e8e43e322d18a372460bbcf3accd26"
@@ -3354,7 +3366,7 @@ css-select-base-adapter@~0.1.0:
resolved "https://registry.npmjs.org/css-select-base-adapter/-/css-select-base-adapter-0.1.0.tgz#0102b3d14630df86c3eb9fa9f5456270106cf990"
integrity sha1-AQKz0UYw34bD65+p9UVicBBs+ZA=
-css-select@^1.1.0:
+css-select@^1.1.0, css-select@~1.2.0:
version "1.2.0"
resolved "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz#2b3a110539c5355f1cd8d314623e870b121ec858"
integrity sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg=
@@ -3873,7 +3885,7 @@ dom-converter@~0.2:
dependencies:
utila "~0.4"
-dom-serializer@0:
+dom-serializer@0, dom-serializer@~0.1.0:
version "0.1.0"
resolved "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz#073c697546ce0780ce23be4a28e293e40bc30c82"
integrity sha1-BzxpdUbOB4DOI75KKOKT5AvDDII=
@@ -3886,7 +3898,7 @@ domain-browser@^1.1.1:
resolved "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz#3d31f50191a6749dd1375a7f522e823d42e54eda"
integrity sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==
-domelementtype@1:
+domelementtype@1, domelementtype@^1.3.0:
version "1.3.0"
resolved "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz#b17aed82e8ab59e52dd9c19b1756e0fc187204c2"
integrity sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=
@@ -3910,6 +3922,13 @@ domhandler@2.1:
dependencies:
domelementtype "1"
+domhandler@^2.3.0:
+ version "2.4.2"
+ resolved "https://registry.npmjs.org/domhandler/-/domhandler-2.4.2.tgz#8805097e933d65e85546f726d60f5eb88b44f803"
+ integrity sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA==
+ dependencies:
+ domelementtype "1"
+
domutils@1.1:
version "1.1.6"
resolved "https://registry.npmjs.org/domutils/-/domutils-1.1.6.tgz#bddc3de099b9a2efacc51c623f28f416ecc57485"
@@ -3925,7 +3944,7 @@ domutils@1.5.1:
dom-serializer "0"
domelementtype "1"
-domutils@^1.7.0:
+domutils@^1.5.1, domutils@^1.7.0:
version "1.7.0"
resolved "https://registry.npmjs.org/domutils/-/domutils-1.7.0.tgz#56ea341e834e06e6748af7a1cb25da67ea9f8c2a"
integrity sha512-Lgd2XcJ/NjEw+7tFvfKxOzCYKZsdct5lczQ2ZaQY8Djz7pfAD3Gbp8ySJWtreII/vDlMVmxwa6pHmdxIYgttDg==
@@ -4058,6 +4077,11 @@ enhanced-resolve@^4.1.0:
memory-fs "^0.4.0"
tapable "^1.0.0"
+entities@^1.1.1:
+ version "1.1.2"
+ resolved "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz#bdfa735299664dfafd34529ed4f8522a275fea56"
+ integrity sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==
+
entities@~1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0"
@@ -5323,6 +5347,18 @@ html-webpack-plugin@^3.2.0:
toposort "^1.0.0"
util.promisify "1.0.0"
+htmlparser2@^3.9.1:
+ version "3.10.0"
+ resolved "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.0.tgz#5f5e422dcf6119c0d983ed36260ce9ded0bee464"
+ integrity sha512-J1nEUGv+MkXS0weHNWVKJJ+UrLfePxRWpN3C9bEi9fLxL2+ggW94DQvgYVXsaT30PGwYRIZKNZXuyMhp3Di4bQ==
+ dependencies:
+ domelementtype "^1.3.0"
+ domhandler "^2.3.0"
+ domutils "^1.5.1"
+ entities "^1.1.1"
+ inherits "^2.0.1"
+ readable-stream "^3.0.6"
+
htmlparser2@~3.3.0:
version "3.3.0"
resolved "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.3.0.tgz#cc70d05a59f6542e43f0e685c982e14c924a9efe"
@@ -6781,7 +6817,7 @@ lodash@4.17.9:
resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.9.tgz#9c056579af0bdbb4322e23c836df13ef2b271cb7"
integrity sha512-vuRLquvot5sKUldMBumG0YqLvX6m/RGBBOmqb3CWR/MC/QvvD1cTH1fOqxz2FJAQeoExeUdX5Gu9vP2EP6ik+Q==
-lodash@4.x, lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1:
+lodash@4.x, lodash@^4.13.1, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1:
version "4.17.11"
resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==
@@ -7331,6 +7367,11 @@ node-fetch@^2.2.0:
resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.2.0.tgz#4ee79bde909262f9775f731e3656d0db55ced5b5"
integrity sha512-OayFWziIxiHY8bCUyLX6sTpDH8Jsbp4FfYd1j1f7vZyfgkcOnAyM4oQR16f8a0s7Gl/viMGRey8eScYk4V4EZA==
+node-fetch@^2.2.1:
+ version "2.2.1"
+ resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.2.1.tgz#1fe551e0ded6c45b3b3b937d0fb46f76df718d1e"
+ integrity sha512-ObXBpNCD3A/vYQiQtEWl7DuqjAXjfptYFuGHLdPl5U19/6kJuZV+8uMHLrkj3wJrJoyfg4nhgyFixZdaZoAiEQ==
+
node-gyp@^3.8.0:
version "3.8.0"
resolved "https://registry.npmjs.org/node-gyp/-/node-gyp-3.8.0.tgz#540304261c330e80d0d5edce253a68cb3964218c"
@@ -7927,6 +7968,13 @@ parse5@5.1.0:
resolved "https://registry.npmjs.org/parse5/-/parse5-5.1.0.tgz#c59341c9723f414c452975564c7c00a68d58acd2"
integrity sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==
+parse5@^3.0.1:
+ version "3.0.3"
+ resolved "https://registry.npmjs.org/parse5/-/parse5-3.0.3.tgz#042f792ffdd36851551cf4e9e066b3874ab45b5c"
+ integrity sha512-rgO9Zg5LLLkfJF9E6CCmXlSE4UVceloys8JrFqCcHloC3usd/kJCyPDwH2SOlzix2j3xaP9sUX3e8+kvkuleAA==
+ dependencies:
+ "@types/node" "*"
+
parseurl@~1.3.2:
version "1.3.2"
resolved "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3"
@@ -9249,6 +9297,15 @@ readable-stream@1.0:
isarray "0.0.1"
string_decoder "~0.10.x"
+readable-stream@^3.0.6:
+ version "3.0.6"
+ resolved "https://registry.npmjs.org/readable-stream/-/readable-stream-3.0.6.tgz#351302e4c68b5abd6a2ed55376a7f9a25be3057a"
+ integrity sha512-9E1oLoOWfhSXHGv6QlwXJim7uNzd9EVlWK+21tCU9Ju/kR0/p2AZYPz4qSchgO8PlLIH4FpZYfzwS+rEksZjIg==
+ dependencies:
+ inherits "^2.0.3"
+ string_decoder "^1.1.1"
+ util-deprecate "^1.0.1"
+
readdir-scoped-modules@^1.0.0:
version "1.0.2"
resolved "https://registry.npmjs.org/readdir-scoped-modules/-/readdir-scoped-modules-1.0.2.tgz#9fafa37d286be5d92cbaebdee030dc9b5f406747"
@@ -10234,7 +10291,7 @@ string-width@^1.0.1:
is-fullwidth-code-point "^2.0.0"
strip-ansi "^4.0.0"
-string_decoder@^1.0.0, string_decoder@~1.1.1:
+string_decoder@^1.0.0, string_decoder@^1.1.1, string_decoder@~1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8"
integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==
@@ -10873,7 +10930,7 @@ useragent@^2.2.1:
lru-cache "4.1.x"
tmp "0.0.x"
-util-deprecate@~1.0.1:
+util-deprecate@^1.0.1, util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=
From dd114ff74fecafe3cb16190279c431acf94397d3 Mon Sep 17 00:00:00 2001
From: "renovate[bot]"
Date: Thu, 8 Nov 2018 02:09:37 +0330
Subject: [PATCH 102/149] fix(deps): update all non-major dependencies (#4271)
---
distributions/nuxt-legacy/package.json | 4 +-
package.json | 8 +-
packages/babel-preset-app/package.json | 6 +-
packages/builder/package.json | 2 +-
packages/core/package.json | 2 +-
packages/generator/package.json | 2 +-
packages/server/package.json | 2 +-
packages/vue-renderer/package.json | 2 +-
packages/webpack/package.json | 10 +-
yarn.lock | 169 +++++++++++++++++--------
10 files changed, 132 insertions(+), 75 deletions(-)
diff --git a/distributions/nuxt-legacy/package.json b/distributions/nuxt-legacy/package.json
index 103b1a1ee3..828eac9d6f 100644
--- a/distributions/nuxt-legacy/package.json
+++ b/distributions/nuxt-legacy/package.json
@@ -46,9 +46,9 @@
"nuxt-legacy": "bin/nuxt-legacy.js"
},
"dependencies": {
- "@babel/core": "^7.1.2",
+ "@babel/core": "^7.1.5",
"@babel/polyfill": "^7.0.0",
- "@babel/preset-env": "^7.1.0",
+ "@babel/preset-env": "^7.1.5",
"@babel/register": "^7.0.0",
"@nuxt/builder": "^2.2.0",
"@nuxt/cli": "^2.2.0",
diff --git a/package.json b/package.json
index 2189a523ff..648ed0ee80 100644
--- a/package.json
+++ b/package.json
@@ -23,8 +23,8 @@
"postinstall": "lerna link && yarn dev"
},
"devDependencies": {
- "@babel/core": "^7.1.2",
- "@babel/preset-env": "^7.1.0",
+ "@babel/core": "^7.1.5",
+ "@babel/preset-env": "^7.1.5",
"@nuxtjs/eslint-config": "^0.0.1",
"babel-core": "^7.0.0-bridge",
"babel-eslint": "^10.0.1",
@@ -39,7 +39,7 @@
"eslint-config-standard": "^12.0.0",
"eslint-multiplexer": "^1.0.2",
"eslint-plugin-import": "^2.14.0",
- "eslint-plugin-jest": "^21.27.1",
+ "eslint-plugin-jest": "^21.27.2",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
@@ -47,7 +47,7 @@
"esm": "^3.0.84",
"express": "^4.16.4",
"finalhandler": "^1.1.1",
- "fs-extra": "^7.0.0",
+ "fs-extra": "^7.0.1",
"get-port": "^4.0.0",
"glob": "^7.1.3",
"jest": "^23.6.0",
diff --git a/packages/babel-preset-app/package.json b/packages/babel-preset-app/package.json
index fbda384793..db5eafaa99 100644
--- a/packages/babel-preset-app/package.json
+++ b/packages/babel-preset-app/package.json
@@ -10,14 +10,14 @@
],
"main": "src/index.js",
"dependencies": {
- "@babel/core": "^7.1.2",
+ "@babel/core": "^7.1.5",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-decorators": "^7.1.2",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-jsx": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.1.0",
- "@babel/preset-env": "^7.1.0",
- "@babel/runtime": "^7.1.2",
+ "@babel/preset-env": "^7.1.5",
+ "@babel/runtime": "^7.1.5",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-plugin-transform-vue-jsx": "^4.0.1"
},
diff --git a/packages/builder/package.json b/packages/builder/package.json
index 4718eaecb2..a294868091 100644
--- a/packages/builder/package.json
+++ b/packages/builder/package.json
@@ -13,7 +13,7 @@
"@nuxtjs/devalue": "^1.1.0",
"chokidar": "^2.0.4",
"consola": "^2.2.2",
- "fs-extra": "^7.0.0",
+ "fs-extra": "^7.0.1",
"glob": "^7.1.3",
"hash-sum": "^1.0.2",
"lodash": "^4.17.11",
diff --git a/packages/core/package.json b/packages/core/package.json
index d1f434dd98..b00868d608 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -17,7 +17,7 @@
"consola": "^2.2.2",
"debug": "^4.1.0",
"esm": "^3.0.84",
- "fs-extra": "^7.0.0",
+ "fs-extra": "^7.0.1",
"hash-sum": "^1.0.2",
"lodash": "^4.17.11",
"std-env": "^2.1.1"
diff --git a/packages/generator/package.json b/packages/generator/package.json
index 122ff76ae5..87ac033a72 100644
--- a/packages/generator/package.json
+++ b/packages/generator/package.json
@@ -11,7 +11,7 @@
"@nuxt/common": "^2.2.0",
"chalk": "^2.4.1",
"consola": "^2.2.2",
- "fs-extra": "^7.0.0",
+ "fs-extra": "^7.0.1",
"html-minifier": "^3.5.21"
},
"publishConfig": {
diff --git a/packages/server/package.json b/packages/server/package.json
index 4dace24242..da43b803f2 100644
--- a/packages/server/package.json
+++ b/packages/server/package.json
@@ -17,7 +17,7 @@
"consola": "^2.2.2",
"etag": "^1.8.1",
"fresh": "^0.5.2",
- "fs-extra": "^7.0.0",
+ "fs-extra": "^7.0.1",
"ip": "^1.1.5",
"launch-editor-middleware": "^2.2.1",
"serve-static": "^1.13.2",
diff --git a/packages/vue-renderer/package.json b/packages/vue-renderer/package.json
index 6121835e80..c35db010dc 100644
--- a/packages/vue-renderer/package.json
+++ b/packages/vue-renderer/package.json
@@ -12,7 +12,7 @@
"@nuxtjs/devalue": "^1.1.0",
"browserslist-useragent": "^2.0.1",
"consola": "^2.2.2",
- "fs-extra": "^7.0.0",
+ "fs-extra": "^7.0.1",
"lru-cache": "^4.1.3",
"vue": "^2.5.17",
"vue-meta": "^1.5.5",
diff --git a/packages/webpack/package.json b/packages/webpack/package.json
index 03e9416107..029db24988 100644
--- a/packages/webpack/package.json
+++ b/packages/webpack/package.json
@@ -8,20 +8,20 @@
],
"main": "dist/webpack.js",
"dependencies": {
- "@babel/core": "^7.1.2",
+ "@babel/core": "^7.1.5",
"@babel/polyfill": "^7.0.0",
"@nuxt/babel-preset-app": "^2.2.0",
"@nuxt/common": "^2.2.0",
"@nuxtjs/friendly-errors-webpack-plugin": "^2.1.0",
"babel-loader": "^8.0.4",
"cache-loader": "^1.2.5",
- "caniuse-lite": "^1.0.30000904",
+ "caniuse-lite": "^1.0.30000906",
"chalk": "^2.4.1",
"consola": "^2.2.2",
"css-loader": "^1.0.1",
"cssnano": "^4.1.7",
"file-loader": "^2.0.0",
- "fs-extra": "^7.0.0",
+ "fs-extra": "^7.0.1",
"glob": "^7.1.3",
"hash-sum": "^1.0.2",
"html-webpack-plugin": "^3.2.0",
@@ -34,7 +34,7 @@
"postcss-import": "^12.0.1",
"postcss-import-resolver": "^1.1.0",
"postcss-loader": "^3.0.0",
- "postcss-preset-env": "^6.3.0",
+ "postcss-preset-env": "^6.4.0",
"postcss-url": "^8.0.0",
"style-resources-loader": "^1.2.1",
"terser-webpack-plugin": "^1.1.0",
@@ -42,7 +42,7 @@
"time-fix-plugin": "^2.0.5",
"url-loader": "^1.1.2",
"vue-loader": "^15.4.2",
- "webpack": "^4.24.0",
+ "webpack": "^4.25.1",
"webpack-bundle-analyzer": "^3.0.3",
"webpack-dev-middleware": "^3.4.0",
"webpack-hot-middleware": "^2.24.3",
diff --git a/yarn.lock b/yarn.lock
index 34ffba657b..ebc52e2f36 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -16,18 +16,18 @@
dependencies:
"@babel/highlight" "^7.0.0"
-"@babel/core@^7.1.2":
- version "7.1.2"
- resolved "https://registry.npmjs.org/@babel/core/-/core-7.1.2.tgz#f8d2a9ceb6832887329a7b60f9d035791400ba4e"
- integrity sha512-IFeSSnjXdhDaoysIlev//UzHZbdEmm7D0EIH2qtse9xK7mXEZQpYjs2P00XlP1qYsYvid79p+Zgg6tz1mp6iVw==
+"@babel/core@^7.1.5":
+ version "7.1.5"
+ resolved "https://registry.npmjs.org/@babel/core/-/core-7.1.5.tgz#abb32d7aa247a91756469e788998db6a72b93090"
+ integrity sha512-vOyH020C56tQvte++i+rX2yokZcRfbv/kKcw+/BCRw/cK6dvsr47aCzm8oC1XHwMSEWbqrZKzZRLzLnq6SFMsg==
dependencies:
"@babel/code-frame" "^7.0.0"
- "@babel/generator" "^7.1.2"
- "@babel/helpers" "^7.1.2"
- "@babel/parser" "^7.1.2"
+ "@babel/generator" "^7.1.5"
+ "@babel/helpers" "^7.1.5"
+ "@babel/parser" "^7.1.5"
"@babel/template" "^7.1.2"
- "@babel/traverse" "^7.1.0"
- "@babel/types" "^7.1.2"
+ "@babel/traverse" "^7.1.5"
+ "@babel/types" "^7.1.5"
convert-source-map "^1.1.0"
debug "^3.1.0"
json5 "^0.5.0"
@@ -47,7 +47,7 @@
source-map "^0.5.0"
trim-right "^1.0.1"
-"@babel/generator@^7.1.2", "@babel/generator@^7.1.3":
+"@babel/generator@^7.1.3":
version "7.1.3"
resolved "https://registry.npmjs.org/@babel/generator/-/generator-7.1.3.tgz#2103ec9c42d9bdad9190a6ad5ff2d456fd7b8673"
integrity sha512-ZoCZGcfIJFJuZBqxcY9OjC1KW2lWK64qrX1o4UYL3yshVhwKFYgzpWZ0vvtGMNJdTlvkw0W+HR1VnYN8q3QPFQ==
@@ -58,6 +58,17 @@
source-map "^0.5.0"
trim-right "^1.0.1"
+"@babel/generator@^7.1.5":
+ version "7.1.5"
+ resolved "https://registry.npmjs.org/@babel/generator/-/generator-7.1.5.tgz#615f064d13d95f8f9157c7261f68eddf32ec15b3"
+ integrity sha512-IO31r62xfMI+wBJVmgx0JR9ZOHty8HkoYpQAjRWUGG9vykBTlGHdArZ8zoFtpUu2gs17K7qTl/TtPpiSi6t+MA==
+ dependencies:
+ "@babel/types" "^7.1.5"
+ jsesc "^2.5.1"
+ lodash "^4.17.10"
+ source-map "^0.5.0"
+ trim-right "^1.0.1"
+
"@babel/helper-annotate-as-pure@^7.0.0":
version "7.0.0"
resolved "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.0.0.tgz#323d39dd0b50e10c7c06ca7d7638e6864d8c5c32"
@@ -236,14 +247,14 @@
"@babel/traverse" "^7.1.0"
"@babel/types" "^7.0.0"
-"@babel/helpers@^7.1.2":
- version "7.1.2"
- resolved "https://registry.npmjs.org/@babel/helpers/-/helpers-7.1.2.tgz#ab752e8c35ef7d39987df4e8586c63b8846234b5"
- integrity sha512-Myc3pUE8eswD73aWcartxB16K6CGmHDv9KxOmD2CeOs/FaEAQodr3VYGmlvOmog60vNQ2w8QbatuahepZwrHiA==
+"@babel/helpers@^7.1.5":
+ version "7.1.5"
+ resolved "https://registry.npmjs.org/@babel/helpers/-/helpers-7.1.5.tgz#68bfc1895d685f2b8f1995e788dbfe1f6ccb1996"
+ integrity sha512-2jkcdL02ywNBry1YNFAH/fViq4fXG0vdckHqeJk+75fpQ2OH+Az6076tX/M0835zA45E0Cqa6pV5Kiv9YOqjEg==
dependencies:
"@babel/template" "^7.1.2"
- "@babel/traverse" "^7.1.0"
- "@babel/types" "^7.1.2"
+ "@babel/traverse" "^7.1.5"
+ "@babel/types" "^7.1.5"
"@babel/highlight@7.0.0-beta.44":
version "7.0.0-beta.44"
@@ -268,6 +279,11 @@
resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.1.3.tgz#2c92469bac2b7fbff810b67fca07bd138b48af77"
integrity sha512-gqmspPZOMW3MIRb9HlrnbZHXI1/KHTOroBwN1NcLL6pWxzqzEKGvRTq0W/PxS45OtQGbaFikSQpkS5zbnsQm2w==
+"@babel/parser@^7.1.5":
+ version "7.1.5"
+ resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.1.5.tgz#20b7d5e7e1811ba996f8a868962ea7dd2bfcd2fc"
+ integrity sha512-WXKf5K5HT6X0kKiCOezJZFljsfxKV1FpU8Tf1A7ZpGvyd/Q4hlrJm2EwoH2onaUq3O4tLDp+4gk0hHPsMyxmOg==
+
"@babel/plugin-proposal-async-generator-functions@^7.1.0":
version "7.1.0"
resolved "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.1.0.tgz#41c1a702e10081456e23a7b74d891922dd1bb6ce"
@@ -411,10 +427,10 @@
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
-"@babel/plugin-transform-block-scoping@^7.0.0":
- version "7.0.0"
- resolved "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.0.0.tgz#1745075edffd7cdaf69fab2fb6f9694424b7e9bc"
- integrity sha512-GWEMCrmHQcYWISilUrk9GDqH4enf3UmhOEbNbNrlNAX1ssH3MsS1xLOS6rdjRVPgA7XXVPn87tRkdTEoA/dxEg==
+"@babel/plugin-transform-block-scoping@^7.1.5":
+ version "7.1.5"
+ resolved "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.1.5.tgz#3e8e0bc9a5104519923302a24f748f72f2f61f37"
+ integrity sha512-jlYcDrz+5ayWC7mxgpn1Wj8zj0mmjCT2w0mPIMSwO926eXBRxpEgoN/uQVRBfjtr8ayjcmS+xk2G1jaP8JjMJQ==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
lodash "^4.17.10"
@@ -621,10 +637,10 @@
core-js "^2.5.7"
regenerator-runtime "^0.11.1"
-"@babel/preset-env@^7.1.0":
- version "7.1.0"
- resolved "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.1.0.tgz#e67ea5b0441cfeab1d6f41e9b5c79798800e8d11"
- integrity sha512-ZLVSynfAoDHB/34A17/JCZbyrzbQj59QC1Anyueb4Bwjh373nVPq5/HMph0z+tCmcDjXDe+DlKQq9ywQuvWrQg==
+"@babel/preset-env@^7.1.5":
+ version "7.1.5"
+ resolved "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.1.5.tgz#a28b5482ca8bc2f2d0712234d6c690240b92495d"
+ integrity sha512-pQ+2o0YyCp98XG0ODOHJd9z4GsSoV5jicSedRwCrU8uiqcJahwQiOq0asSZEb/m/lwyu6X5INvH/DSiwnQKncw==
dependencies:
"@babel/helper-module-imports" "^7.0.0"
"@babel/helper-plugin-utils" "^7.0.0"
@@ -639,7 +655,7 @@
"@babel/plugin-transform-arrow-functions" "^7.0.0"
"@babel/plugin-transform-async-to-generator" "^7.1.0"
"@babel/plugin-transform-block-scoped-functions" "^7.0.0"
- "@babel/plugin-transform-block-scoping" "^7.0.0"
+ "@babel/plugin-transform-block-scoping" "^7.1.5"
"@babel/plugin-transform-classes" "^7.1.0"
"@babel/plugin-transform-computed-properties" "^7.0.0"
"@babel/plugin-transform-destructuring" "^7.0.0"
@@ -681,10 +697,10 @@
pirates "^4.0.0"
source-map-support "^0.5.9"
-"@babel/runtime@^7.1.2":
- version "7.1.2"
- resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.1.2.tgz#81c89935f4647706fc54541145e6b4ecfef4b8e3"
- integrity sha512-Y3SCjmhSupzFB6wcv1KmmFucH6gDVnI30WjOcicV10ju0cZjak3Jcs67YLIXBrmZYw1xCrVeJPbycFwrqNyxpg==
+"@babel/runtime@^7.1.5":
+ version "7.1.5"
+ resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.1.5.tgz#4170907641cf1f61508f563ece3725150cc6fe39"
+ integrity sha512-xKnPpXG/pvK1B90JkwwxSGii90rQGKtzcMt2gI5G6+M0REXaq6rOHsGC2ay6/d0Uje7zzvSzjEzfR3ENhFlrfA==
dependencies:
regenerator-runtime "^0.12.0"
@@ -738,6 +754,21 @@
globals "^11.1.0"
lodash "^4.17.10"
+"@babel/traverse@^7.1.5":
+ version "7.1.5"
+ resolved "https://registry.npmjs.org/@babel/traverse/-/traverse-7.1.5.tgz#5aafca2039aa058c104cf2bfeb9fc4a857ccbca9"
+ integrity sha512-eU6XokWypl0MVJo+MTSPUtlfPePkrqsF26O+l1qFGlCKWwmiYAYy2Sy44Qw8m2u/LbPCsxYt90rghmqhYMGpPA==
+ dependencies:
+ "@babel/code-frame" "^7.0.0"
+ "@babel/generator" "^7.1.5"
+ "@babel/helper-function-name" "^7.1.0"
+ "@babel/helper-split-export-declaration" "^7.0.0"
+ "@babel/parser" "^7.1.5"
+ "@babel/types" "^7.1.5"
+ debug "^3.1.0"
+ globals "^11.1.0"
+ lodash "^4.17.10"
+
"@babel/types@7.0.0-beta.44":
version "7.0.0-beta.44"
resolved "http://registry.npmjs.org/@babel/types/-/types-7.0.0-beta.44.tgz#6b1b164591f77dec0a0342aca995f2d046b3a757"
@@ -756,6 +787,15 @@
lodash "^4.17.10"
to-fast-properties "^2.0.0"
+"@babel/types@^7.1.5":
+ version "7.1.5"
+ resolved "https://registry.npmjs.org/@babel/types/-/types-7.1.5.tgz#12fe64e91a431234b7017b4227a78cc0eec4e081"
+ integrity sha512-sJeqa/d9eM/bax8Ivg+fXF7FpN3E/ZmTrWbkk6r+g7biVYfALMnLin4dKijsaqEhpd2xvOGfQTkQkD31YCVV4A==
+ dependencies:
+ esutils "^2.0.2"
+ lodash "^4.17.10"
+ to-fast-properties "^2.0.0"
+
"@csstools/convert-colors@^1.4.0":
version "1.4.0"
resolved "https://registry.npmjs.org/@csstools/convert-colors/-/convert-colors-1.4.0.tgz#ad495dc41b12e75d588c6db8b9834f08fa131eb7"
@@ -2658,10 +2698,10 @@ caniuse-lite@^1.0.30000899:
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000899.tgz#6febdbbc388a7982f620ee0e3d09aab0c061389e"
integrity sha512-enC3zKfUCJxxwvUIsBkbHd54CtJw1KtIWvrK0JZxWD/fEN2knHaai45lndJ4xXAkyRAPyk60J3yagkKDWhfeMA==
-caniuse-lite@^1.0.30000904:
- version "1.0.30000904"
- resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000904.tgz#4445d00da859a0e0ae6dbb2876c545f3324f6c74"
- integrity sha512-M4sXvogCoY5Fp6fuXIaQG/MIexlEFQ3Lgwban+KlqiQUbUIkSmjAB8ZJIP79aj2cdqz2F1Lb+Z+5GwHvCrbLtg==
+caniuse-lite@^1.0.30000905, caniuse-lite@^1.0.30000906:
+ version "1.0.30000906"
+ resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000906.tgz#7c44e498a2504f7a5db3b4f91285bbc821157a77"
+ integrity sha512-ME7JFX6h0402om/nC/8Lw+q23QvPe2ust9U0ntLmkX9F2zaGwq47fZkjlyHKirFBuq1EM+T/LXBcDdW4bvkCTA==
capture-exit@^1.2.0:
version "1.2.0"
@@ -3361,6 +3401,13 @@ css-loader@^1.0.1:
postcss-value-parser "^3.3.0"
source-list-map "^2.0.0"
+css-prefers-color-scheme@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.npmjs.org/css-prefers-color-scheme/-/css-prefers-color-scheme-3.0.0.tgz#690f1eef52bff570791940e57d61b68ba9ed6d2a"
+ integrity sha512-1+K66s3763YVIoXf7n9Qj+hZLy8+j5N3sDOW9NBkcvg++EhhfP3bSOhyFFytICaQBvPSgi6xBOXfMQJKq+a1LA==
+ dependencies:
+ postcss "^7.0.5"
+
css-select-base-adapter@~0.1.0:
version "0.1.0"
resolved "https://registry.npmjs.org/css-select-base-adapter/-/css-select-base-adapter-0.1.0.tgz#0102b3d14630df86c3eb9fa9f5456270106cf990"
@@ -3436,10 +3483,10 @@ css@^2.1.0:
source-map-resolve "^0.5.2"
urix "^0.1.0"
-cssdb@^4.1.0:
- version "4.1.0"
- resolved "https://registry.npmjs.org/cssdb/-/cssdb-4.1.0.tgz#5eff01703b3380256a6d2fd0dfa42de383b5f0e7"
- integrity sha512-qaEHVEtScIHoBgdTEHNUMKQw7GXfVYHiaFcL8jerXWJ47lNBy2PgApHdHbR4yovVJsZK6Zq+YkBw8MuhAOvixg==
+cssdb@^4.2.0:
+ version "4.2.0"
+ resolved "https://registry.npmjs.org/cssdb/-/cssdb-4.2.0.tgz#89623ec696121d0688080ccdcd4627c7e6c6ee0d"
+ integrity sha512-27CuM+rp1/HIH4hkiOvrRUjgv31WamWk7+XSGz7OP/uWR8EOMeXOh4Ncpa/Eq1eO/1eRhQx7HWj8KEbt4nKQBA==
cssesc@^0.1.0:
version "0.1.0"
@@ -4221,10 +4268,10 @@ eslint-plugin-import@^2.14.0:
read-pkg-up "^2.0.0"
resolve "^1.6.0"
-eslint-plugin-jest@^21.27.1:
- version "21.27.1"
- resolved "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-21.27.1.tgz#b64c2d6a7f0751cecc14580d7f4d9a5520424448"
- integrity sha512-K+S4Wa20MoRRXICfnQBqjl2g9+ipJBeDUVrB3Csg4wOrxXMGcNxYuPRaiyA0pqmb/vO2cgaLEzurORfsLrztxg==
+eslint-plugin-jest@^21.27.2:
+ version "21.27.2"
+ resolved "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-21.27.2.tgz#2a795b7c3b5e707df48a953d651042bd01d7b0a8"
+ integrity sha512-0E4OIgBJVlAmf1KfYFtZ3gYxgUzC5Eb3Jzmrc9ikI1OY+/cM8Kh72Ti7KfpeHNeD3HJNf9SmEfmvQLIz44Hrhw==
eslint-plugin-node@^8.0.0:
version "8.0.0"
@@ -4873,6 +4920,15 @@ fs-extra@^7.0.0:
jsonfile "^4.0.0"
universalify "^0.1.0"
+fs-extra@^7.0.1:
+ version "7.0.1"
+ resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
+ integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==
+ dependencies:
+ graceful-fs "^4.1.2"
+ jsonfile "^4.0.0"
+ universalify "^0.1.0"
+
fs-minipass@^1.2.5:
version "1.2.5"
resolved "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d"
@@ -8232,10 +8288,10 @@ postcss-custom-media@^7.0.7:
dependencies:
postcss "^7.0.5"
-postcss-custom-properties@^8.0.8:
- version "8.0.8"
- resolved "https://registry.npmjs.org/postcss-custom-properties/-/postcss-custom-properties-8.0.8.tgz#1812e2553805e1affce93164dd1709ef6b69c53e"
- integrity sha512-G3U8uSxj0B4jPJ1QBF5WYeW716n5HV/wcH2lOTV1V+EI+F0T0/ZOhl32MLLTMD79bN2mE77IOoclbCoLl4QtPA==
+postcss-custom-properties@^8.0.9:
+ version "8.0.9"
+ resolved "https://registry.npmjs.org/postcss-custom-properties/-/postcss-custom-properties-8.0.9.tgz#8943870528a6eae4c8e8d285b6ccc9fd1f97e69c"
+ integrity sha512-/Lbn5GP2JkKhgUO2elMs4NnbUJcvHX4AaF5nuJDaNkd2chYW1KA5qtOGGgdkBEWcXtKSQfHXzT7C6grEVyb13w==
dependencies:
postcss "^7.0.5"
postcss-values-parser "^2.0.0"
@@ -8624,15 +8680,16 @@ postcss-place@^4.0.1:
postcss "^7.0.2"
postcss-values-parser "^2.0.0"
-postcss-preset-env@^6.3.0:
- version "6.3.0"
- resolved "https://registry.npmjs.org/postcss-preset-env/-/postcss-preset-env-6.3.0.tgz#726f033fb81607cabd2e35deb26a56bb976ab1e7"
- integrity sha512-3iTlt9tuD7QsQ9wdJwr7E7hjVlNKrN6Fk/nChxJAtHHTLbtVdD25W6ogM7bgkv1xCjClU5w33Hb28dBG435FLQ==
+postcss-preset-env@^6.4.0:
+ version "6.4.0"
+ resolved "https://registry.npmjs.org/postcss-preset-env/-/postcss-preset-env-6.4.0.tgz#f5466550b177454fc98ca5054b4478e8e5caa714"
+ integrity sha512-0jCyY/T9kWv1i2abt5DOOoh0uHJia0HUTWMV72Tw75tGx3pH628oSS8WBMCE5L1Ou3LvoAl9pe07u8g/afvc3A==
dependencies:
autoprefixer "^9.3.1"
browserslist "^4.3.4"
- caniuse-lite "^1.0.30000899"
- cssdb "^4.1.0"
+ caniuse-lite "^1.0.30000905"
+ css-prefers-color-scheme "^3.0.0"
+ cssdb "^4.2.0"
postcss "^7.0.5"
postcss-attribute-case-insensitive "^4.0.0"
postcss-color-functional-notation "^2.0.1"
@@ -8641,7 +8698,7 @@ postcss-preset-env@^6.3.0:
postcss-color-mod-function "^3.0.3"
postcss-color-rebeccapurple "^4.0.1"
postcss-custom-media "^7.0.7"
- postcss-custom-properties "^8.0.8"
+ postcss-custom-properties "^8.0.9"
postcss-custom-selectors "^5.1.2"
postcss-dir-pseudo-class "^5.0.0"
postcss-double-position-gradients "^1.0.0"
@@ -11237,10 +11294,10 @@ webpack-sources@^1.1.0, webpack-sources@^1.3.0:
source-list-map "^2.0.0"
source-map "~0.6.1"
-webpack@^4.24.0:
- version "4.24.0"
- resolved "https://registry.npmjs.org/webpack/-/webpack-4.24.0.tgz#d9822c91eeb595f7351aa5dd785a1952f9c4340a"
- integrity sha512-Xur0l8nBETnW+DjpFqSGME1jNXxEPVETl30k1lWAsbnukVJdq330/i3PDOLPUtVl/E/cciiOp5uW098hFfQLQA==
+webpack@^4.25.1:
+ version "4.25.1"
+ resolved "https://registry.npmjs.org/webpack/-/webpack-4.25.1.tgz#4f459fbaea0f93440dc86c89f771bb3a837cfb6d"
+ integrity sha512-T0GU/3NRtO4tMfNzsvpdhUr8HnzA4LTdP2zd+e5zd6CdOH5vNKHnAlO+DvzccfhPdzqRrALOFcjYxx7K5DWmvA==
dependencies:
"@webassemblyjs/ast" "1.7.11"
"@webassemblyjs/helper-module-context" "1.7.11"
From 2c26730b93bfa58fac34975d13f0ba08acfc0f56 Mon Sep 17 00:00:00 2001
From: "renovate[bot]"
Date: Thu, 8 Nov 2018 02:10:33 +0330
Subject: [PATCH 103/149] chore(deps): update dependency eslint-plugin-jest to
v22 (#4289)
[skip ci]
---
package.json | 2 +-
yarn.lock | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/package.json b/package.json
index 648ed0ee80..57902859e6 100644
--- a/package.json
+++ b/package.json
@@ -39,7 +39,7 @@
"eslint-config-standard": "^12.0.0",
"eslint-multiplexer": "^1.0.2",
"eslint-plugin-import": "^2.14.0",
- "eslint-plugin-jest": "^21.27.2",
+ "eslint-plugin-jest": "^22.0.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
diff --git a/yarn.lock b/yarn.lock
index ebc52e2f36..2b22a03d6d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4268,10 +4268,10 @@ eslint-plugin-import@^2.14.0:
read-pkg-up "^2.0.0"
resolve "^1.6.0"
-eslint-plugin-jest@^21.27.2:
- version "21.27.2"
- resolved "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-21.27.2.tgz#2a795b7c3b5e707df48a953d651042bd01d7b0a8"
- integrity sha512-0E4OIgBJVlAmf1KfYFtZ3gYxgUzC5Eb3Jzmrc9ikI1OY+/cM8Kh72Ti7KfpeHNeD3HJNf9SmEfmvQLIz44Hrhw==
+eslint-plugin-jest@^22.0.0:
+ version "22.0.0"
+ resolved "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-22.0.0.tgz#87dc52bbdd47f37f23bf2b10bb8469458bb3ed68"
+ integrity sha512-YOj8cYI5ZXEZUrX2kUBLachR1ffjQiicIMBoivN7bXXHnxi8RcwNvmVzwlu3nTmjlvk5AP3kIpC5i8HcinmhPA==
eslint-plugin-node@^8.0.0:
version "8.0.0"
From 83f8b1183c9fc2d01f4d30c8cd36ebc1b5b1d4e1 Mon Sep 17 00:00:00 2001
From: Dmitry Molotkov
Date: Thu, 8 Nov 2018 01:43:02 +0300
Subject: [PATCH 104/149] examples: update vuetify to use vuetify loader
(#4263)
[skip ci]
---
examples/with-vuetify/nuxt.config.js | 6 +++++-
examples/with-vuetify/package.json | 3 ++-
examples/with-vuetify/plugins/vuetify.js | 2 +-
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/examples/with-vuetify/nuxt.config.js b/examples/with-vuetify/nuxt.config.js
index 90677abf77..f13447cd02 100644
--- a/examples/with-vuetify/nuxt.config.js
+++ b/examples/with-vuetify/nuxt.config.js
@@ -1,3 +1,5 @@
+import VuetifyLoaderPlugin from 'vuetify-loader/lib/plugin'
+
export default {
/*
** Head elements
@@ -14,7 +16,9 @@ export default {
},
build: {
- extractCSS: true
+ plugins: [new VuetifyLoaderPlugin()],
+ extractCSS: true,
+ transpile: ['vuetify/lib']
},
/*
** Load Vuetify into the app
diff --git a/examples/with-vuetify/package.json b/examples/with-vuetify/package.json
index 69198428e2..0bd05cb0fd 100644
--- a/examples/with-vuetify/package.json
+++ b/examples/with-vuetify/package.json
@@ -2,7 +2,8 @@
"name": "example-with-vuetify",
"dependencies": {
"nuxt-edge": "latest",
- "vuetify": "latest"
+ "vuetify": "latest",
+ "vuetify-loader": "latest"
},
"scripts": {
"dev": "nuxt",
diff --git a/examples/with-vuetify/plugins/vuetify.js b/examples/with-vuetify/plugins/vuetify.js
index 351cf071b1..12bb590ca4 100644
--- a/examples/with-vuetify/plugins/vuetify.js
+++ b/examples/with-vuetify/plugins/vuetify.js
@@ -1,5 +1,5 @@
import Vue from 'vue'
-import Vuetify from 'vuetify'
+import Vuetify from 'vuetify/lib'
import colors from 'vuetify/es5/util/colors'
// You can also specify those components you are going to use for "a la carte" build:
From 2a36dbad22961ee68a4bd68420e0243d1f910294 Mon Sep 17 00:00:00 2001
From: Clark Du
Date: Wed, 7 Nov 2018 23:37:06 +0000
Subject: [PATCH 105/149] feat: client mode modern and support dev/generate
(#4264)
---
packages/cli/src/commands/build.js | 11 ---
packages/cli/src/commands/generate.js | 9 +++
packages/cli/src/commands/start.js | 13 +---
packages/cli/src/options/common.js | 10 +++
.../unit/__snapshots__/command.test.js.snap | 2 +
packages/cli/test/unit/command.test.js | 2 +-
.../data/modern-browsers.json | 0
packages/common/src/index.js | 1 +
packages/config/src/config/_common.js | 1 +
packages/config/src/config/build.js | 1 -
packages/config/src/options.js | 4 ++
packages/server/package.json | 1 +
packages/server/src/middleware/modern.js | 22 ++++++
packages/server/src/server.js | 18 +++--
packages/vue-renderer/package.json | 1 -
packages/vue-renderer/src/renderer.js | 72 ++++++++++++++-----
packages/webpack/src/builder.js | 28 ++++----
packages/webpack/src/config/client.js | 6 +-
.../webpack/src/config/plugins/vue/client.js | 10 ++-
.../webpack/src/config/plugins/vue/modern.js | 52 +++++++++-----
test/fixtures/modern/nuxt.config.js | 2 +-
test/unit/modern.client.test.js | 36 ++++++++++
.../{modern.test.js => modern.server.test.js} | 9 ++-
23 files changed, 223 insertions(+), 88 deletions(-)
rename packages/{vue-renderer => common}/data/modern-browsers.json (100%)
create mode 100644 packages/server/src/middleware/modern.js
create mode 100644 test/unit/modern.client.test.js
rename test/unit/{modern.test.js => modern.server.test.js} (84%)
diff --git a/packages/cli/src/commands/build.js b/packages/cli/src/commands/build.js
index d199e2f4d1..9870bed3e8 100644
--- a/packages/cli/src/commands/build.js
+++ b/packages/cli/src/commands/build.js
@@ -24,17 +24,6 @@ export default {
default: true,
description: 'Don\'t generate static version for SPA mode (useful for nuxt start)'
},
- modern: {
- alias: 'm',
- type: 'boolean',
- description: 'Build app for modern browsers',
- prepare(cmd, options, argv) {
- options.build = options.build || {}
- if (argv.modern) {
- options.build.modern = !!argv.modern
- }
- }
- },
quiet: {
alias: 'q',
type: 'boolean',
diff --git a/packages/cli/src/commands/generate.js b/packages/cli/src/commands/generate.js
index c2e406f96c..818bf9d3ab 100644
--- a/packages/cli/src/commands/generate.js
+++ b/packages/cli/src/commands/generate.js
@@ -11,6 +11,15 @@ export default {
type: 'boolean',
default: true,
description: 'Only generate pages for dynamic routes. Nuxt has to be built once before using this option'
+ },
+ modern: {
+ ...common.modern,
+ description: 'Generate app in modern build (modern mode can be only client)',
+ prepare(cmd, options, argv) {
+ if (argv.modern) {
+ options.modern = 'client'
+ }
+ }
}
},
async run(cmd) {
diff --git a/packages/cli/src/commands/start.js b/packages/cli/src/commands/start.js
index 44fec39bf7..eee4c26b2d 100644
--- a/packages/cli/src/commands/start.js
+++ b/packages/cli/src/commands/start.js
@@ -9,18 +9,7 @@ export default {
usage: 'start ',
options: {
...common,
- ...server,
- modern: {
- alias: 'm',
- type: 'boolean',
- description: 'Build app for modern browsers',
- prepare(cmd, options, argv) {
- options.build = options.build || {}
- if (argv.modern) {
- options.build.modern = !!argv.modern
- }
- }
- }
+ ...server
},
async run(cmd) {
const argv = cmd.getArgv()
diff --git a/packages/cli/src/options/common.js b/packages/cli/src/options/common.js
index a1565a0950..3bf9fd0f60 100644
--- a/packages/cli/src/options/common.js
+++ b/packages/cli/src/options/common.js
@@ -15,6 +15,16 @@ export default {
default: 'nuxt.config.js',
description: 'Path to Nuxt.js config file (default: nuxt.config.js)'
},
+ modern: {
+ alias: 'm',
+ type: 'string',
+ description: 'Build/Start app for modern browsers, e.g. server, client and false',
+ prepare(cmd, options, argv) {
+ if (argv.modern) {
+ options.modern = argv.modern
+ }
+ }
+ },
version: {
type: 'boolean',
description: 'Display the Nuxt version'
diff --git a/packages/cli/test/unit/__snapshots__/command.test.js.snap b/packages/cli/test/unit/__snapshots__/command.test.js.snap
index 5793b42ed8..0e2f57d57a 100644
--- a/packages/cli/test/unit/__snapshots__/command.test.js.snap
+++ b/packages/cli/test/unit/__snapshots__/command.test.js.snap
@@ -10,6 +10,7 @@ exports[`cli/command builds help text 1`] = `
--spa, -s Launch in SPA mode
--universal, -u Launch in Universal mode (default)
--config-file, -c Path to Nuxt.js config file (default: nuxt.config.js)
+ --modern, -m Build/Start app for modern browsers, e.g. server, client and false
--version Display the Nuxt version
--help, -h Display this message
--port, -p Port number on which to start the application
@@ -30,6 +31,7 @@ exports[`cli/command loads command from name 1`] = `
--spa, -s Launch in SPA mode
--universal, -u Launch in Universal mode (default)
--config-file, -c Path to Nuxt.js config file (default: nuxt.config.js)
+ --modern, -m Build/Start app for modern browsers, e.g. server, client and false
--version Display the Nuxt version
--help, -h Display this message
--port, -p Port number on which to start the application
diff --git a/packages/cli/test/unit/command.test.js b/packages/cli/test/unit/command.test.js
index b337371764..237162167a 100644
--- a/packages/cli/test/unit/command.test.js
+++ b/packages/cli/test/unit/command.test.js
@@ -18,7 +18,7 @@ describe('cli/command', () => {
const cmd = new Command({ options: allOptions })
const minimistOptions = cmd._getMinimistOptions()
- expect(minimistOptions.string.length).toBe(4)
+ expect(minimistOptions.string.length).toBe(5)
expect(minimistOptions.boolean.length).toBe(4)
expect(minimistOptions.alias.c).toBe('config-file')
expect(minimistOptions.default.c).toBe(common['config-file'].default)
diff --git a/packages/vue-renderer/data/modern-browsers.json b/packages/common/data/modern-browsers.json
similarity index 100%
rename from packages/vue-renderer/data/modern-browsers.json
rename to packages/common/data/modern-browsers.json
diff --git a/packages/common/src/index.js b/packages/common/src/index.js
index 6d33677a6a..41440566ca 100644
--- a/packages/common/src/index.js
+++ b/packages/common/src/index.js
@@ -1,2 +1,3 @@
export { default as Hookable } from './hookable'
+export { default as ModernBrowsers } from '../data/modern-browsers.json'
export * from './utils'
diff --git a/packages/config/src/config/_common.js b/packages/config/src/config/_common.js
index 9b8dec7742..a5283f10f8 100644
--- a/packages/config/src/config/_common.js
+++ b/packages/config/src/config/_common.js
@@ -12,6 +12,7 @@ export default () => ({
// Mode
mode: 'universal',
+ modern: false,
// Globals
globalName: `nuxt`,
diff --git a/packages/config/src/config/build.js b/packages/config/src/config/build.js
index 8dd2fcdb23..2da4cc21e1 100644
--- a/packages/config/src/config/build.js
+++ b/packages/config/src/config/build.js
@@ -7,7 +7,6 @@ export default () => ({
extractCSS: false,
cssSourceMap: undefined,
ssr: undefined,
- modern: undefined,
parallel: false,
cache: false,
publicPath: '/_nuxt/',
diff --git a/packages/config/src/options.js b/packages/config/src/options.js
index 491eecebe7..6e13e079f7 100644
--- a/packages/config/src/options.js
+++ b/packages/config/src/options.js
@@ -216,6 +216,10 @@ export function getNuxtConfig(_options) {
const modePreset = options.modes[options.mode || 'universal']
defaultsDeep(options, modePreset)
+ if (options.modern === true) {
+ options.modern = 'server'
+ }
+
// If no server-side rendering, add appear true transition
/* istanbul ignore if */
if (options.render.ssr === false && options.transition) {
diff --git a/packages/server/package.json b/packages/server/package.json
index da43b803f2..272ef30004 100644
--- a/packages/server/package.json
+++ b/packages/server/package.json
@@ -11,6 +11,7 @@
"@nuxt/common": "^2.2.0",
"@nuxt/config": "^2.2.0",
"@nuxtjs/youch": "^4.2.3",
+ "browserslist-useragent": "^2.0.1",
"chalk": "^2.4.1",
"compression": "^1.7.3",
"connect": "^3.6.6",
diff --git a/packages/server/src/middleware/modern.js b/packages/server/src/middleware/modern.js
new file mode 100644
index 0000000000..ff7f7148b1
--- /dev/null
+++ b/packages/server/src/middleware/modern.js
@@ -0,0 +1,22 @@
+import { ModernBrowsers } from '@nuxt/common'
+import { matchesUA } from 'browserslist-useragent'
+
+const modernBrowsers = Object.keys(ModernBrowsers)
+ .map(browser => `${browser} >= ${ModernBrowsers[browser]}`)
+
+const isModernBrowser = (ua) => {
+ return Boolean(ua) && matchesUA(ua, {
+ allowHigherVersions: true,
+ browsers: modernBrowsers
+ })
+}
+
+export default function (req, res, next) {
+ const { socket = {}, headers } = req
+ if (socket.isModernBrowser === undefined) {
+ const ua = headers && headers['user-agent']
+ socket.isModernBrowser = isModernBrowser(ua)
+ }
+ req.isModernBrowser = socket.isModernBrowser
+ next()
+}
diff --git a/packages/server/src/server.js b/packages/server/src/server.js
index 60bc005295..38a59ece07 100644
--- a/packages/server/src/server.js
+++ b/packages/server/src/server.js
@@ -13,6 +13,7 @@ import ServerContext from './context'
import renderAndGetWindow from './jsdom'
import nuxtMiddleware from './middleware/nuxt'
import errorMiddleware from './middleware/error'
+import modernMiddleware from './middleware/modern'
export default class Server {
constructor(nuxt) {
@@ -29,8 +30,8 @@ export default class Server {
this.resources = {}
// Will be available on dev
- this.webpackDevMiddleware = null
- this.webpackHotMiddleware = null
+ this.devMiddleware = null
+ this.hotMiddleware = null
// Create new connect instance
this.app = connect()
@@ -70,14 +71,19 @@ export default class Server {
}
}
+ if (this.options.modern === 'server') {
+ this.useMiddleware(modernMiddleware)
+ }
+
// Add webpack middleware support only for development
if (this.options.dev) {
this.useMiddleware(async (req, res, next) => {
- if (this.webpackDevMiddleware) {
- await this.webpackDevMiddleware(req, res)
+ const name = req.isModernBrowser ? 'modern' : 'client'
+ if (this.devMiddleware[name]) {
+ await this.devMiddleware[name](req, res)
}
- if (this.webpackHotMiddleware) {
- await this.webpackHotMiddleware(req, res)
+ if (this.hotMiddleware[name]) {
+ await this.hotMiddleware[name](req, res)
}
next()
})
diff --git a/packages/vue-renderer/package.json b/packages/vue-renderer/package.json
index c35db010dc..386d7fa0d2 100644
--- a/packages/vue-renderer/package.json
+++ b/packages/vue-renderer/package.json
@@ -10,7 +10,6 @@
"dependencies": {
"@nuxt/common": "^2.2.0",
"@nuxtjs/devalue": "^1.1.0",
- "browserslist-useragent": "^2.0.1",
"consola": "^2.2.2",
"fs-extra": "^7.0.1",
"lru-cache": "^4.1.3",
diff --git a/packages/vue-renderer/src/renderer.js b/packages/vue-renderer/src/renderer.js
index 10a3bf93af..22d6be48ed 100644
--- a/packages/vue-renderer/src/renderer.js
+++ b/packages/vue-renderer/src/renderer.js
@@ -3,12 +3,11 @@ import crypto from 'crypto'
import fs from 'fs-extra'
import consola from 'consola'
import devalue from '@nuxtjs/devalue'
+import invert from 'lodash/invert'
import template from 'lodash/template'
import { waitFor } from '@nuxt/common'
-import { matchesUA } from 'browserslist-useragent'
import { createBundleRenderer } from 'vue-server-renderer'
-import ModernBrowsers from '../data/modern-browsers.json'
import SPAMetaRenderer from './spa-meta'
export default class VueRenderer {
@@ -22,9 +21,6 @@ export default class VueRenderer {
spa: null
}
- this.modernBrowsers = Object.keys(ModernBrowsers)
- .map(browser => `${browser} >= ${ModernBrowsers[browser]}`)
-
// Renderer runtime resources
Object.assign(this.context.resources, {
clientManifest: null,
@@ -36,6 +32,52 @@ export default class VueRenderer {
})
}
+ get assetsMapping() {
+ if (this._assetsMapping) return this._assetsMapping
+
+ const legacyAssets = this.context.resources.clientManifest.assetsMapping
+ const modernAssets = invert(this.context.resources.modernManifest.assetsMapping)
+ const mapping = {}
+ for (const legacyJsFile in legacyAssets) {
+ const chunkNamesHash = legacyAssets[legacyJsFile]
+ mapping[legacyJsFile] = modernAssets[chunkNamesHash]
+ }
+ delete this.context.resources.clientManifest.assetsMapping
+ delete this.context.resources.modernManifest.assetsMapping
+ this._assetsMapping = mapping
+ return mapping
+ }
+
+ renderScripts(context) {
+ if (this.context.options.modern === 'client') {
+ const publicPath = this.context.options.build.publicPath
+ const scriptPattern = /`
- APP += context.renderScripts()
+ APP += this.renderScripts(context)
APP += m.script.text({ body: true })
APP += m.noscript.text({ body: true })
diff --git a/packages/webpack/src/builder.js b/packages/webpack/src/builder.js
index 11ac813de1..7f0e1be643 100644
--- a/packages/webpack/src/builder.js
+++ b/packages/webpack/src/builder.js
@@ -24,8 +24,8 @@ export class WebpackBuilder {
// Fields that set on build
this.compilers = []
this.compilersWatching = []
- this.webpackDevMiddleware = null
- this.webpackHotMiddleware = null
+ this.devMiddleware = {}
+ this.hotMiddleware = {}
this.perfLoader = null
// Initialize shared FS and Cache
@@ -47,7 +47,7 @@ export class WebpackBuilder {
// Modern
let modernConfig
- if (options.build.modern) {
+ if (options.modern) {
modernConfig = new ModernConfig(this).config()
compilersOptions.push(modernConfig)
}
@@ -141,7 +141,7 @@ export class WebpackBuilder {
if (options.dev) {
// --- Dev Build ---
// Client Build, watch is started by dev-middleware
- if (compiler.options.name === 'client') {
+ if (['client', 'modern'].includes(name)) {
return this.webpackDev(compiler)
}
// Server, build and watch for changes
@@ -178,10 +178,11 @@ export class WebpackBuilder {
webpackDev(compiler) {
consola.debug('Adding webpack middleware...')
+ const name = [compiler.options.name]
const { nuxt: { server }, options } = this.context
// Create webpack dev middleware
- this.webpackDevMiddleware = pify(
+ this.devMiddleware[name] = pify(
webpackDevMiddleware(
compiler,
Object.assign(
@@ -196,9 +197,9 @@ export class WebpackBuilder {
)
)
- this.webpackDevMiddleware.close = pify(this.webpackDevMiddleware.close)
+ this.devMiddleware[name].close = pify(this.devMiddleware[name].close)
- this.webpackHotMiddleware = pify(
+ this.hotMiddleware[name] = pify(
webpackHotMiddleware(
compiler,
Object.assign(
@@ -206,15 +207,18 @@ export class WebpackBuilder {
log: false,
heartbeat: 10000
},
- options.build.hotMiddleware
+ options.build.hotMiddleware,
+ {
+ path: `/__webpack_hmr/${name}`
+ }
)
)
)
// Inject to renderer instance
if (server) {
- server.webpackDevMiddleware = this.webpackDevMiddleware
- server.webpackHotMiddleware = this.webpackHotMiddleware
+ server.devMiddleware = this.devMiddleware
+ server.hotMiddleware = this.hotMiddleware
}
}
@@ -223,8 +227,8 @@ export class WebpackBuilder {
watching.close()
}
// Stop webpack middleware
- if (this.webpackDevMiddleware) {
- await this.webpackDevMiddleware.close()
+ for (const devMiddleware of Object.values(this.devMiddleware)) {
+ await devMiddleware.close()
}
}
diff --git a/packages/webpack/src/config/client.js b/packages/webpack/src/config/client.js
index eac9638982..763ee917ef 100644
--- a/packages/webpack/src/config/client.js
+++ b/packages/webpack/src/config/client.js
@@ -103,7 +103,7 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
}, this.options.build.analyze)))
}
- if (this.options.build.modern) {
+ if (this.options.modern) {
plugins.push(new ModernModePlugin({
targetDir: path.resolve(this.options.buildDir, 'dist', 'client'),
isModernBuild: this.isModern
@@ -167,9 +167,9 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
if (this.options.dev) {
config.entry.app.unshift(
// https://github.com/glenjamin/webpack-hot-middleware#config
- `webpack-hot-middleware/client?name=client&reload=true&timeout=30000&path=${
+ `webpack-hot-middleware/client?name=${this.name}&reload=true&timeout=30000&path=${
this.options.router.base
- }/__webpack_hmr`.replace(/\/\//g, '/')
+ }/__webpack_hmr/${this.name}`.replace(/\/\//g, '/')
)
}
diff --git a/packages/webpack/src/config/plugins/vue/client.js b/packages/webpack/src/config/plugins/vue/client.js
index df96a35081..52ad2576b3 100644
--- a/packages/webpack/src/config/plugins/vue/client.js
+++ b/packages/webpack/src/config/plugins/vue/client.js
@@ -26,12 +26,20 @@ export default class VueSSRClientPlugin {
.filter(file => isJS(file) || isCSS(file))
.filter(file => !initialFiles.includes(file))
+ const assetsMapping = {}
+ stats.assets
+ .filter(({ name }) => isJS(name))
+ .forEach(({ name, chunkNames }) => {
+ assetsMapping[name] = hash(chunkNames.join('|'))
+ })
+
const manifest = {
publicPath: stats.publicPath,
all: allFiles,
initial: initialFiles,
async: asyncFiles,
- modules: { /* [identifier: string]: Array */ }
+ modules: { /* [identifier: string]: Array */ },
+ assetsMapping
}
const assetModules = stats.modules.filter(m => m.assets.length)
diff --git a/packages/webpack/src/config/plugins/vue/modern.js b/packages/webpack/src/config/plugins/vue/modern.js
index 069e0db5f8..f6b05f5e4f 100644
--- a/packages/webpack/src/config/plugins/vue/modern.js
+++ b/packages/webpack/src/config/plugins/vue/modern.js
@@ -2,12 +2,14 @@
** This plugin is inspired by @vue/cli-service ModernModePlugin
** https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/webpack/ModernModePlugin.js
*/
-import path from 'path'
-import fs from 'fs-extra'
+import EventEmitter from 'events'
// https://gist.github.com/samthor/64b114e4a4f539915a95b91ffd340acc
const safariFix = `!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();`
+const assetsMap = {}
+const watcher = new EventEmitter()
+
class ModernModePlugin {
constructor({ targetDir, isModernBuild }) {
this.targetDir = targetDir
@@ -22,20 +24,33 @@ class ModernModePlugin {
}
}
+ set assets({ name, content }) {
+ assetsMap[name] = content
+ watcher.emit(name)
+ }
+
+ getAssets(name) {
+ return assetsMap[name] ||
+ new Promise((resolve) => {
+ watcher.once(name, () => {
+ return assetsMap[name] && resolve(assetsMap[name])
+ })
+ return assetsMap[name] && resolve(assetsMap[name])
+ })
+ }
+
applyLegacy(compiler) {
const ID = `nuxt-legacy-bundle`
compiler.hooks.compilation.tap(ID, (compilation) => {
// For html-webpack-plugin 4.0
// HtmlWebpackPlugin.getHooks(compilation).alterAssetTags.tapAsync(ID, async (data, cb) => {
- compilation.hooks.htmlWebpackPluginAlterAssetTags.tapAsync(ID, async (data, cb) => {
+ compilation.hooks.htmlWebpackPluginAlterAssetTags.tapAsync(ID, (data, cb) => {
// get stats, write to disk
- await fs.ensureDir(this.targetDir)
- const htmlName = path.basename(data.plugin.options.filename)
- // Watch out for output files in sub directories
- const htmlPath = path.dirname(data.plugin.options.filename)
- const tempFilename = path.join(this.targetDir, htmlPath, `legacy-assets-${htmlName}.json`)
- await fs.mkdirp(path.dirname(tempFilename))
- await fs.writeFile(tempFilename, JSON.stringify(data.body))
+ this.assets = {
+ name: data.plugin.options.filename,
+ content: data.body
+ }
+
cb()
})
})
@@ -72,15 +87,16 @@ class ModernModePlugin {
})
// inject links for legacy assets as
diff --git a/examples/tailwindcss-purgecss/postcss.config.js b/examples/tailwindcss-purgecss/postcss.config.js
new file mode 100644
index 0000000000..3ffd4aacb2
--- /dev/null
+++ b/examples/tailwindcss-purgecss/postcss.config.js
@@ -0,0 +1,31 @@
+const path = require('path')
+const purgecss = require('@fullhuman/postcss-purgecss')
+
+const tailwindConfig = path.join(__dirname, 'tailwind.js')
+
+class TailwindExtractor {
+ static extract(content) {
+ return content.match(/[A-Za-z0-9-_:\/]+/g) || [] // eslint-disable-line no-useless-escape
+ }
+}
+
+module.exports = {
+ plugins: [
+ require('tailwindcss')(tailwindConfig),
+ require('autoprefixer'),
+ purgecss({
+ content: [
+ path.join(__dirname, './pages/**/*.vue'),
+ path.join(__dirname, './layouts/**/*.vue'),
+ path.join(__dirname, './components/**/*.vue')
+ ],
+ extractors: [
+ {
+ extractor: TailwindExtractor,
+ extensions: ['vue', 'js', 'html']
+ }
+ ],
+ whitelist: ['html', 'body', 'nuxt-progress']
+ })
+ ]
+}
diff --git a/examples/tailwindcss-purgecss/tailwind.js b/examples/tailwindcss-purgecss/tailwind.js
new file mode 100644
index 0000000000..f672c69ee1
--- /dev/null
+++ b/examples/tailwindcss-purgecss/tailwind.js
@@ -0,0 +1,921 @@
+/*
+
+Tailwind - The Utility-First CSS Framework
+
+A project by Adam Wathan (@adamwathan), Jonathan Reinink (@reinink),
+David Hemphill (@davidhemphill) and Steve Schoger (@steveschoger).
+
+Welcome to the Tailwind config file. This is where you can customize
+Tailwind specifically for your project. Don't be intimidated by the
+length of this file. It's really just a big JavaScript object and
+we've done our very best to explain each section.
+
+View the full documentation at https://tailwindcss.com.
+
+|-------------------------------------------------------------------------------
+| The default config
+|-------------------------------------------------------------------------------
+|
+| This variable contains the default Tailwind config. You don't have
+| to use it, but it can sometimes be helpful to have available. For
+| example, you may choose to merge your custom configuration
+| values with some of the Tailwind defaults.
+|
+*/
+
+// let defaultConfig = require('tailwindcss/defaultConfig')()
+
+/*
+|-------------------------------------------------------------------------------
+| Colors https://tailwindcss.com/docs/colors
+|-------------------------------------------------------------------------------
+|
+| Here you can specify the colors used in your project. To get you started,
+| we've provided a generous palette of great looking colors that are perfect
+| for prototyping, but don't hesitate to change them for your project. You
+| own these colors, nothing will break if you change everything about them.
+|
+| We've used literal color names ("red", "blue", etc.) for the default
+| palette, but if you'd rather use functional names like "primary" and
+| "secondary", or even a numeric scale like "100" and "200", go for it.
+|
+*/
+
+const colors = {
+ 'transparent': 'transparent',
+
+ 'black': '#22292f',
+ 'grey-darkest': '#3d4852',
+ 'grey-darker': '#606f7b',
+ 'grey-dark': '#8795a1',
+ 'grey': '#b8c2cc',
+ 'grey-light': '#dae1e7',
+ 'grey-lighter': '#f1f5f8',
+ 'grey-lightest': '#f8fafc',
+ 'white': '#ffffff',
+
+ 'red-darkest': '#3b0d0c',
+ 'red-darker': '#621b18',
+ 'red-dark': '#cc1f1a',
+ 'red': '#e3342f',
+ 'red-light': '#ef5753',
+ 'red-lighter': '#f9acaa',
+ 'red-lightest': '#fcebea',
+
+ 'orange-darkest': '#462a16',
+ 'orange-darker': '#613b1f',
+ 'orange-dark': '#de751f',
+ 'orange': '#f6993f',
+ 'orange-light': '#faad63',
+ 'orange-lighter': '#fcd9b6',
+ 'orange-lightest': '#fff5eb',
+
+ 'yellow-darkest': '#453411',
+ 'yellow-darker': '#684f1d',
+ 'yellow-dark': '#f2d024',
+ 'yellow': '#ffed4a',
+ 'yellow-light': '#fff382',
+ 'yellow-lighter': '#fff9c2',
+ 'yellow-lightest': '#fcfbeb',
+
+ 'green-darkest': '#0f2f21',
+ 'green-darker': '#1a4731',
+ 'green-dark': '#1f9d55',
+ 'green': '#38c172',
+ 'green-light': '#51d88a',
+ 'green-lighter': '#a2f5bf',
+ 'green-lightest': '#e3fcec',
+
+ 'teal-darkest': '#0d3331',
+ 'teal-darker': '#20504f',
+ 'teal-dark': '#38a89d',
+ 'teal': '#4dc0b5',
+ 'teal-light': '#64d5ca',
+ 'teal-lighter': '#a0f0ed',
+ 'teal-lightest': '#e8fffe',
+
+ 'blue-darkest': '#12283a',
+ 'blue-darker': '#1c3d5a',
+ 'blue-dark': '#2779bd',
+ 'blue': '#3490dc',
+ 'blue-light': '#6cb2eb',
+ 'blue-lighter': '#bcdefa',
+ 'blue-lightest': '#eff8ff',
+
+ 'indigo-darkest': '#191e38',
+ 'indigo-darker': '#2f365f',
+ 'indigo-dark': '#5661b3',
+ 'indigo': '#6574cd',
+ 'indigo-light': '#7886d7',
+ 'indigo-lighter': '#b2b7ff',
+ 'indigo-lightest': '#e6e8ff',
+
+ 'purple-darkest': '#21183c',
+ 'purple-darker': '#382b5f',
+ 'purple-dark': '#794acf',
+ 'purple': '#9561e2',
+ 'purple-light': '#a779e9',
+ 'purple-lighter': '#d6bbfc',
+ 'purple-lightest': '#f3ebff',
+
+ 'pink-darkest': '#451225',
+ 'pink-darker': '#6f213f',
+ 'pink-dark': '#eb5286',
+ 'pink': '#f66d9b',
+ 'pink-light': '#fa7ea8',
+ 'pink-lighter': '#ffbbca',
+ 'pink-lightest': '#ffebef'
+}
+
+module.exports = {
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Colors https://tailwindcss.com/docs/colors
+ |-----------------------------------------------------------------------------
+ |
+ | The color palette defined above is also assigned to the "colors" key of
+ | your Tailwind config. This makes it easy to access them in your CSS
+ | using Tailwind's config helper. For example:
+ |
+ | .error { color: config('colors.red') }
+ |
+ */
+
+ colors: colors,
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Screens https://tailwindcss.com/docs/responsive-design
+ |-----------------------------------------------------------------------------
+ |
+ | Screens in Tailwind are translated to CSS media queries. They define the
+ | responsive breakpoints for your project. By default Tailwind takes a
+ | "mobile first" approach, where each screen size represents a minimum
+ | viewport width. Feel free to have as few or as many screens as you
+ | want, naming them in whatever way you'd prefer for your project.
+ |
+ | Tailwind also allows for more complex screen definitions, which can be
+ | useful in certain situations. Be sure to see the full responsive
+ | documentation for a complete list of options.
+ |
+ | Class name: .{screen}:{utility}
+ |
+ */
+
+ screens: {
+ 'sm': '576px',
+ 'md': '768px',
+ 'lg': '992px',
+ 'xl': '1200px'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Fonts https://tailwindcss.com/docs/fonts
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your project's font stack, or font families.
+ | Keep in mind that Tailwind doesn't actually load any fonts for you.
+ | If you're using custom fonts you'll need to import them prior to
+ | defining them here.
+ |
+ | By default we provide a native font stack that works remarkably well on
+ | any device or OS you're using, since it just uses the default fonts
+ | provided by the platform.
+ |
+ | Class name: .font-{name}
+ |
+ */
+
+ fonts: {
+ 'sans': [
+ 'system-ui',
+ 'BlinkMacSystemFont',
+ '-apple-system',
+ 'Segoe UI',
+ 'Roboto',
+ 'Oxygen',
+ 'Ubuntu',
+ 'Cantarell',
+ 'Fira Sans',
+ 'Droid Sans',
+ 'Helvetica Neue',
+ 'sans-serif'
+ ],
+ 'serif': [
+ 'Constantia',
+ 'Lucida Bright',
+ 'Lucidabright',
+ 'Lucida Serif',
+ 'Lucida',
+ 'DejaVu Serif',
+ 'Bitstream Vera Serif',
+ 'Liberation Serif',
+ 'Georgia',
+ 'serif'
+ ],
+ 'mono': [
+ 'Menlo',
+ 'Monaco',
+ 'Consolas',
+ 'Liberation Mono',
+ 'Courier New',
+ 'monospace'
+ ]
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Text sizes https://tailwindcss.com/docs/text-sizing
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your text sizes. Name these in whatever way
+ | makes the most sense to you. We use size names by default, but
+ | you're welcome to use a numeric scale or even something else
+ | entirely.
+ |
+ | By default Tailwind uses the "rem" unit type for most measurements.
+ | This allows you to set a root font size which all other sizes are
+ | then based on. That said, you are free to use whatever units you
+ | prefer, be it rems, ems, pixels or other.
+ |
+ | Class name: .text-{size}
+ |
+ */
+
+ textSizes: {
+ 'xs': '.75rem', // 12px
+ 'sm': '.875rem', // 14px
+ 'base': '1rem', // 16px
+ 'lg': '1.125rem', // 18px
+ 'xl': '1.25rem', // 20px
+ '2xl': '1.5rem', // 24px
+ '3xl': '1.875rem', // 30px
+ '4xl': '2.25rem', // 36px
+ '5xl': '3rem' // 48px
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Font weights https://tailwindcss.com/docs/font-weight
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your font weights. We've provided a list of
+ | common font weight names with their respective numeric scale values
+ | to get you started. It's unlikely that your project will require
+ | all of these, so we recommend removing those you don't need.
+ |
+ | Class name: .font-{weight}
+ |
+ */
+
+ fontWeights: {
+ 'hairline': 100,
+ 'thin': 200,
+ 'light': 300,
+ 'normal': 400,
+ 'medium': 500,
+ 'semibold': 600,
+ 'bold': 700,
+ 'extrabold': 800,
+ 'black': 900
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Leading (line height) https://tailwindcss.com/docs/line-height
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your line height values, or as we call
+ | them in Tailwind, leadings.
+ |
+ | Class name: .leading-{size}
+ |
+ */
+
+ leading: {
+ 'none': 1,
+ 'tight': 1.25,
+ 'normal': 1.5,
+ 'loose': 2
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Tracking (letter spacing) https://tailwindcss.com/docs/letter-spacing
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your letter spacing values, or as we call
+ | them in Tailwind, tracking.
+ |
+ | Class name: .tracking-{size}
+ |
+ */
+
+ tracking: {
+ 'tight': '-0.05em',
+ 'normal': '0',
+ 'wide': '0.05em'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Text colors https://tailwindcss.com/docs/text-color
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your text colors. By default these use the
+ | color palette we defined above, however you're welcome to set these
+ | independently if that makes sense for your project.
+ |
+ | Class name: .text-{color}
+ |
+ */
+
+ textColors: colors,
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Background colors https://tailwindcss.com/docs/background-color
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your background colors. By default these use
+ | the color palette we defined above, however you're welcome to set
+ | these independently if that makes sense for your project.
+ |
+ | Class name: .bg-{color}
+ |
+ */
+
+ backgroundColors: colors,
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Background sizes https://tailwindcss.com/docs/background-size
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your background sizes. We provide some common
+ | values that are useful in most projects, but feel free to add other sizes
+ | that are specific to your project here as well.
+ |
+ | Class name: .bg-{size}
+ |
+ */
+
+ backgroundSize: {
+ 'auto': 'auto',
+ 'cover': 'cover',
+ 'contain': 'contain'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Border widths https://tailwindcss.com/docs/border-width
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your border widths. Take note that border
+ | widths require a special "default" value set as well. This is the
+ | width that will be used when you do not specify a border width.
+ |
+ | Class name: .border{-side?}{-width?}
+ |
+ */
+
+ borderWidths: {
+ default: '1px',
+ '0': '0',
+ '2': '2px',
+ '4': '4px',
+ '8': '8px'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Border colors https://tailwindcss.com/docs/border-color
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your border colors. By default these use the
+ | color palette we defined above, however you're welcome to set these
+ | independently if that makes sense for your project.
+ |
+ | Take note that border colors require a special "default" value set
+ | as well. This is the color that will be used when you do not
+ | specify a border color.
+ |
+ | Class name: .border-{color}
+ |
+ */
+
+ borderColors: global.Object.assign({ default: colors['grey-light'] }, colors),
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Border radius https://tailwindcss.com/docs/border-radius
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your border radius values. If a `default` radius
+ | is provided, it will be made available as the non-suffixed `.rounded`
+ | utility.
+ |
+ | If your scale includes a `0` value to reset already rounded corners, it's
+ | a good idea to put it first so other values are able to override it.
+ |
+ | Class name: .rounded{-side?}{-size?}
+ |
+ */
+
+ borderRadius: {
+ 'none': '0',
+ 'sm': '.125rem',
+ default: '.25rem',
+ 'lg': '.5rem',
+ 'full': '9999px'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Width https://tailwindcss.com/docs/width
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your width utility sizes. These can be
+ | percentage based, pixels, rems, or any other units. By default
+ | we provide a sensible rem based numeric scale, a percentage
+ | based fraction scale, plus some other common use-cases. You
+ | can, of course, modify these values as needed.
+ |
+ |
+ | It's also worth mentioning that Tailwind automatically escapes
+ | invalid CSS class name characters, which allows you to have
+ | awesome classes like .w-2/3.
+ |
+ | Class name: .w-{size}
+ |
+ */
+
+ width: {
+ 'auto': 'auto',
+ 'px': '1px',
+ '1': '0.25rem',
+ '2': '0.5rem',
+ '3': '0.75rem',
+ '4': '1rem',
+ '5': '1.25rem',
+ '6': '1.5rem',
+ '8': '2rem',
+ '10': '2.5rem',
+ '12': '3rem',
+ '16': '4rem',
+ '24': '6rem',
+ '32': '8rem',
+ '48': '12rem',
+ '64': '16rem',
+ '1/2': '50%',
+ '1/3': '33.33333%',
+ '2/3': '66.66667%',
+ '1/4': '25%',
+ '3/4': '75%',
+ '1/5': '20%',
+ '2/5': '40%',
+ '3/5': '60%',
+ '4/5': '80%',
+ '1/6': '16.66667%',
+ '5/6': '83.33333%',
+ 'full': '100%',
+ 'screen': '100vw'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Height https://tailwindcss.com/docs/height
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your height utility sizes. These can be
+ | percentage based, pixels, rems, or any other units. By default
+ | we provide a sensible rem based numeric scale plus some other
+ | common use-cases. You can, of course, modify these values as
+ | needed.
+ |
+ | Class name: .h-{size}
+ |
+ */
+
+ height: {
+ 'auto': 'auto',
+ 'px': '1px',
+ '1': '0.25rem',
+ '2': '0.5rem',
+ '3': '0.75rem',
+ '4': '1rem',
+ '5': '1.25rem',
+ '6': '1.5rem',
+ '8': '2rem',
+ '10': '2.5rem',
+ '12': '3rem',
+ '16': '4rem',
+ '24': '6rem',
+ '32': '8rem',
+ '48': '12rem',
+ '64': '16rem',
+ 'full': '100%',
+ 'screen': '100vh'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Minimum width https://tailwindcss.com/docs/min-width
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your minimum width utility sizes. These can
+ | be percentage based, pixels, rems, or any other units. We provide a
+ | couple common use-cases by default. You can, of course, modify
+ | these values as needed.
+ |
+ | Class name: .min-w-{size}
+ |
+ */
+
+ minWidth: {
+ '0': '0',
+ 'full': '100%'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Minimum height https://tailwindcss.com/docs/min-height
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your minimum height utility sizes. These can
+ | be percentage based, pixels, rems, or any other units. We provide a
+ | few common use-cases by default. You can, of course, modify these
+ | values as needed.
+ |
+ | Class name: .min-h-{size}
+ |
+ */
+
+ minHeight: {
+ '0': '0',
+ 'full': '100%',
+ 'screen': '100vh'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Maximum width https://tailwindcss.com/docs/max-width
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your maximum width utility sizes. These can
+ | be percentage based, pixels, rems, or any other units. By default
+ | we provide a sensible rem based scale and a "full width" size,
+ | which is basically a reset utility. You can, of course,
+ | modify these values as needed.
+ |
+ | Class name: .max-w-{size}
+ |
+ */
+
+ maxWidth: {
+ 'xs': '20rem',
+ 'sm': '30rem',
+ 'md': '40rem',
+ 'lg': '50rem',
+ 'xl': '60rem',
+ '2xl': '70rem',
+ '3xl': '80rem',
+ '4xl': '90rem',
+ '5xl': '100rem',
+ 'full': '100%'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Maximum height https://tailwindcss.com/docs/max-height
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your maximum height utility sizes. These can
+ | be percentage based, pixels, rems, or any other units. We provide a
+ | couple common use-cases by default. You can, of course, modify
+ | these values as needed.
+ |
+ | Class name: .max-h-{size}
+ |
+ */
+
+ maxHeight: {
+ 'full': '100%',
+ 'screen': '100vh'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Padding https://tailwindcss.com/docs/padding
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your padding utility sizes. These can be
+ | percentage based, pixels, rems, or any other units. By default we
+ | provide a sensible rem based numeric scale plus a couple other
+ | common use-cases like "1px". You can, of course, modify these
+ | values as needed.
+ |
+ | Class name: .p{side?}-{size}
+ |
+ */
+
+ padding: {
+ 'px': '1px',
+ '0': '0',
+ '1': '0.25rem',
+ '2': '0.5rem',
+ '3': '0.75rem',
+ '4': '1rem',
+ '5': '1.25rem',
+ '6': '1.5rem',
+ '8': '2rem',
+ '10': '2.5rem',
+ '12': '3rem',
+ '16': '4rem',
+ '20': '5rem',
+ '24': '6rem',
+ '32': '8rem'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Margin https://tailwindcss.com/docs/margin
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your margin utility sizes. These can be
+ | percentage based, pixels, rems, or any other units. By default we
+ | provide a sensible rem based numeric scale plus a couple other
+ | common use-cases like "1px". You can, of course, modify these
+ | values as needed.
+ |
+ | Class name: .m{side?}-{size}
+ |
+ */
+
+ margin: {
+ 'auto': 'auto',
+ 'px': '1px',
+ '0': '0',
+ '1': '0.25rem',
+ '2': '0.5rem',
+ '3': '0.75rem',
+ '4': '1rem',
+ '5': '1.25rem',
+ '6': '1.5rem',
+ '8': '2rem',
+ '10': '2.5rem',
+ '12': '3rem',
+ '16': '4rem',
+ '20': '5rem',
+ '24': '6rem',
+ '32': '8rem'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Negative margin https://tailwindcss.com/docs/negative-margin
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your negative margin utility sizes. These can
+ | be percentage based, pixels, rems, or any other units. By default we
+ | provide matching values to the padding scale since these utilities
+ | generally get used together. You can, of course, modify these
+ | values as needed.
+ |
+ | Class name: .-m{side?}-{size}
+ |
+ */
+
+ negativeMargin: {
+ 'px': '1px',
+ '0': '0',
+ '1': '0.25rem',
+ '2': '0.5rem',
+ '3': '0.75rem',
+ '4': '1rem',
+ '5': '1.25rem',
+ '6': '1.5rem',
+ '8': '2rem',
+ '10': '2.5rem',
+ '12': '3rem',
+ '16': '4rem',
+ '20': '5rem',
+ '24': '6rem',
+ '32': '8rem'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Shadows https://tailwindcss.com/docs/shadows
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your shadow utilities. As you can see from
+ | the defaults we provide, it's possible to apply multiple shadows
+ | per utility using comma separation.
+ |
+ | If a `default` shadow is provided, it will be made available as the non-
+ | suffixed `.shadow` utility.
+ |
+ | Class name: .shadow-{size?}
+ |
+ */
+
+ shadows: {
+ default: '0 2px 4px 0 rgba(0,0,0,0.10)',
+ 'md': '0 4px 8px 0 rgba(0,0,0,0.12), 0 2px 4px 0 rgba(0,0,0,0.08)',
+ 'lg': '0 15px 30px 0 rgba(0,0,0,0.11), 0 5px 15px 0 rgba(0,0,0,0.08)',
+ 'inner': 'inset 0 2px 4px 0 rgba(0,0,0,0.06)',
+ 'outline': '0 0 0 3px rgba(52,144,220,0.5)',
+ 'none': 'none'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Z-index https://tailwindcss.com/docs/z-index
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your z-index utility values. By default we
+ | provide a sensible numeric scale. You can, of course, modify these
+ | values as needed.
+ |
+ | Class name: .z-{index}
+ |
+ */
+
+ zIndex: {
+ 'auto': 'auto',
+ '0': 0,
+ '10': 10,
+ '20': 20,
+ '30': 30,
+ '40': 40,
+ '50': 50
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Opacity https://tailwindcss.com/docs/opacity
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your opacity utility values. By default we
+ | provide a sensible numeric scale. You can, of course, modify these
+ | values as needed.
+ |
+ | Class name: .opacity-{name}
+ |
+ */
+
+ opacity: {
+ '0': '0',
+ '25': '.25',
+ '50': '.5',
+ '75': '.75',
+ '100': '1'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | SVG fill https://tailwindcss.com/docs/svg
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your SVG fill colors. By default we just provide
+ | `fill-current` which sets the fill to the current text color. This lets you
+ | specify a fill color using existing text color utilities and helps keep the
+ | generated CSS file size down.
+ |
+ | Class name: .fill-{name}
+ |
+ */
+
+ svgFill: {
+ 'current': 'currentColor'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | SVG stroke https://tailwindcss.com/docs/svg
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you define your SVG stroke colors. By default we just provide
+ | `stroke-current` which sets the stroke to the current text color. This lets
+ | you specify a stroke color using existing text color utilities and helps
+ | keep the generated CSS file size down.
+ |
+ | Class name: .stroke-{name}
+ |
+ */
+
+ svgStroke: {
+ 'current': 'currentColor'
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Modules https://tailwindcss.com/docs/configuration#modules
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you control which modules are generated and what variants are
+ | generated for each of those modules.
+ |
+ | Currently supported variants:
+ | - responsive
+ | - hover
+ | - focus
+ | - active
+ | - group-hover
+ |
+ | To disable a module completely, use `false` instead of an array.
+ |
+ */
+
+ modules: {
+ appearance: ['responsive'],
+ backgroundAttachment: ['responsive'],
+ backgroundColors: ['responsive', 'hover', 'focus'],
+ backgroundPosition: ['responsive'],
+ backgroundRepeat: ['responsive'],
+ backgroundSize: ['responsive'],
+ borderCollapse: [],
+ borderColors: ['responsive', 'hover', 'focus'],
+ borderRadius: ['responsive'],
+ borderStyle: ['responsive'],
+ borderWidths: ['responsive'],
+ cursor: ['responsive'],
+ display: ['responsive'],
+ flexbox: ['responsive'],
+ float: ['responsive'],
+ fonts: ['responsive'],
+ fontWeights: ['responsive', 'hover', 'focus'],
+ height: ['responsive'],
+ leading: ['responsive'],
+ lists: ['responsive'],
+ margin: ['responsive'],
+ maxHeight: ['responsive'],
+ maxWidth: ['responsive'],
+ minHeight: ['responsive'],
+ minWidth: ['responsive'],
+ negativeMargin: ['responsive'],
+ opacity: ['responsive'],
+ outline: ['focus'],
+ overflow: ['responsive'],
+ padding: ['responsive'],
+ pointerEvents: ['responsive'],
+ position: ['responsive'],
+ resize: ['responsive'],
+ shadows: ['responsive', 'hover', 'focus'],
+ svgFill: [],
+ svgStroke: [],
+ tableLayout: ['responsive'],
+ textAlign: ['responsive'],
+ textColors: ['responsive', 'hover', 'focus'],
+ textSizes: ['responsive'],
+ textStyle: ['responsive', 'hover', 'focus'],
+ tracking: ['responsive'],
+ userSelect: ['responsive'],
+ verticalAlign: ['responsive'],
+ visibility: ['responsive'],
+ whitespace: ['responsive'],
+ width: ['responsive'],
+ zIndex: ['responsive']
+ },
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Plugins https://tailwindcss.com/docs/plugins
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you can register any plugins you'd like to use in your
+ | project. Tailwind's built-in `container` plugin is enabled by default to
+ | give you a Bootstrap-style responsive container component out of the box.
+ |
+ | Be sure to view the complete plugin documentation to learn more about how
+ | the plugin system works.
+ |
+ */
+
+ plugins: [
+ require('tailwindcss/plugins/container')({
+ // center: true,
+ // padding: '1rem',
+ })
+ ],
+
+ /*
+ |-----------------------------------------------------------------------------
+ | Advanced Options https://tailwindcss.com/docs/configuration#options
+ |-----------------------------------------------------------------------------
+ |
+ | Here is where you can tweak advanced configuration options. We recommend
+ | leaving these options alone unless you absolutely need to change them.
+ |
+ */
+
+ options: {
+ prefix: '',
+ important: false,
+ separator: ':'
+ }
+
+}
From cf1aa1abc8f0c9584881d5fc0e8b3dc09b854d3c Mon Sep 17 00:00:00 2001
From: Alexander Lichter
Date: Thu, 8 Nov 2018 09:41:24 +0000
Subject: [PATCH 111/149] test: improve tests (#4237)
---
test/unit/async-config.test.js | 2 +-
test/unit/basic.config.defaults.test.js | 2 +-
test/unit/basic.dev.test.js | 2 +-
test/unit/basic.generate.test.js | 34 ++++++------
test/unit/basic.ssr.csp.test.js | 16 +++---
test/unit/basic.ssr.test.js | 62 +++++++++++-----------
test/unit/children.test.js | 20 +++----
test/unit/cli.test.js | 2 +-
test/unit/custom-app-template.test.js | 4 +-
test/unit/custom-dirs.test.js | 6 +--
test/unit/dist-options.test.js | 2 +-
test/unit/error.test.js | 2 +-
test/unit/express.test.js | 2 +-
test/unit/https.test.js | 2 +-
test/unit/module.test.js | 6 +--
test/unit/nuxt.test.js | 10 ++--
test/unit/sockets.test.js | 2 +-
test/unit/with-config.test.js | 69 +++++++++++++------------
18 files changed, 123 insertions(+), 122 deletions(-)
diff --git a/test/unit/async-config.test.js b/test/unit/async-config.test.js
index 5e85754c3c..15c4111edb 100644
--- a/test/unit/async-config.test.js
+++ b/test/unit/async-config.test.js
@@ -14,6 +14,6 @@ describe('basic ssr', () => {
test('/', async () => {
expect(nuxt.options.head.title).toBe('Async Config!')
const { html } = await nuxt.server.renderRoute('/')
- expect(html.includes('I am ALIVE! ')).toBe(true)
+ expect(html).toContain('I am ALIVE! ')
})
})
diff --git a/test/unit/basic.config.defaults.test.js b/test/unit/basic.config.defaults.test.js
index f0de55e406..e533a5c101 100644
--- a/test/unit/basic.config.defaults.test.js
+++ b/test/unit/basic.config.defaults.test.js
@@ -11,7 +11,7 @@ describe('basic config defaults', () => {
test('modulesDir uses /node_modules as default if not set', () => {
const options = getNuxtConfig({})
const currentNodeModulesDir = resolve(__dirname, '..', '..', 'node_modules')
- expect(options.modulesDir.includes(currentNodeModulesDir)).toBe(true)
+ expect(options.modulesDir).toContain(currentNodeModulesDir)
})
test('vendor has been deprecated', () => {
diff --git a/test/unit/basic.dev.test.js b/test/unit/basic.dev.test.js
index 158edb964d..c6dd6cb6e3 100644
--- a/test/unit/basic.dev.test.js
+++ b/test/unit/basic.dev.test.js
@@ -85,7 +85,7 @@ describe('basic dev', () => {
test('/stateless', async () => {
const window = await nuxt.server.renderAndGetWindow(url('/stateless'))
const html = window.document.body.innerHTML
- expect(html.includes('My component! ')).toBe(true)
+ expect(html).toContain('My component! ')
})
test('Check render:routeDone hook called', () => {
diff --git a/test/unit/basic.generate.test.js b/test/unit/basic.generate.test.js
index 7bbae4464a..36d77ff537 100644
--- a/test/unit/basic.generate.test.js
+++ b/test/unit/basic.generate.test.js
@@ -86,20 +86,20 @@ describe('basic generate', () => {
test('/stateless', async () => {
const window = await generator.nuxt.server.renderAndGetWindow(url('/stateless'))
const html = window.document.body.innerHTML
- expect(html.includes('My component! ')).toBe(true)
+ expect(html).toContain('My component! ')
})
test('/store-module', async () => {
const window = await generator.nuxt.server.renderAndGetWindow(url('/store-module'))
const html = window.document.body.innerHTML
- expect(html.includes('mutated ')).toBe(true)
+ expect(html).toContain('mutated ')
})
test('/css', async () => {
const window = await generator.nuxt.server.renderAndGetWindow(url('/css'))
const headHtml = window.document.head.innerHTML
- expect(headHtml.includes('.red{color:red')).toBe(true)
+ expect(headHtml).toContain('.red{color:red')
const element = window.document.querySelector('.red')
expect(element).not.toBe(null)
@@ -111,7 +111,7 @@ describe('basic generate', () => {
test('/stateful', async () => {
const window = await generator.nuxt.server.renderAndGetWindow(url('/stateful'))
const html = window.document.body.innerHTML
- expect(html.includes('')).toBe(true)
+ expect(html).toContain('')
})
test('/head', async () => {
@@ -120,18 +120,18 @@ describe('basic generate', () => {
const metas = window.document.getElementsByTagName('meta')
expect(window.document.title).toBe('My title - Nuxt.js')
expect(metas[0].getAttribute('content')).toBe('my meta')
- expect(html.includes('
I can haz meta tags ')).toBe(true)
+ expect(html).toContain('
I can haz meta tags ')
})
test('/async-data', async () => {
const window = await generator.nuxt.server.renderAndGetWindow(url('/async-data'))
const html = window.document.body.innerHTML
- expect(html.includes('Nuxt.js
')).toBe(true)
+ expect(html).toContain('Nuxt.js
')
})
test('/users/1/index.html', async () => {
const html = await rp(url('/users/1/index.html'))
- expect(html.includes('User: 1 ')).toBe(true)
+ expect(html).toContain('User: 1 ')
expect(
existsSync(resolve(distDir, 'users/1/index.html'))
).toBe(true)
@@ -140,12 +140,12 @@ describe('basic generate', () => {
test('/users/2', async () => {
const html = await rp(url('/users/2'))
- expect(html.includes('User: 2 ')).toBe(true)
+ expect(html).toContain('User: 2 ')
})
test('/users/3 (payload given)', async () => {
const html = await rp(url('/users/3'))
- expect(html.includes('User: 3000 ')).toBe(true)
+ expect(html).toContain('User: 3000 ')
})
test('/users/4 -> Not found', async () => {
@@ -159,32 +159,32 @@ describe('basic generate', () => {
test('/validate should not be server-rendered', async () => {
const html = await rp(url('/validate'))
- expect(html.includes('
')).toBe(true)
- expect(html.includes('serverRendered:!1')).toBe(true)
+ expect(html).toContain('
')
+ expect(html).toContain('serverRendered:!1')
})
test('/validate -> should display a 404', async () => {
const window = await generator.nuxt.server.renderAndGetWindow(url('/validate'))
const html = window.document.body.innerHTML
- expect(html.includes('This page could not be found')).toBe(true)
+ expect(html).toContain('This page could not be found')
})
test('/validate?valid=true', async () => {
const window = await generator.nuxt.server.renderAndGetWindow(url('/validate?valid=true'))
const html = window.document.body.innerHTML
- expect(html.includes('I am valid ')).toBe(true)
+ expect(html).toContain('I am valid')
})
test('/redirect should not be server-rendered', async () => {
const html = await rp(url('/redirect'))
- expect(html.includes('
')).toBe(true)
- expect(html.includes('serverRendered:!1')).toBe(true)
+ expect(html).toContain('
')
+ expect(html).toContain('serverRendered:!1')
})
test('/redirect -> check redirected source', async () => {
const window = await generator.nuxt.server.renderAndGetWindow(url('/redirect'))
const html = window.document.body.innerHTML
- expect(html.includes('Index page ')).toBe(true)
+ expect(html).toContain('Index page ')
})
test('/users/1 not found', async () => {
@@ -204,7 +204,7 @@ describe('basic generate', () => {
test('/users/1.html', async () => {
const html = await rp(url('/users/1.html'))
- expect(html.includes('User: 1 ')).toBe(true)
+ expect(html).toContain('User: 1 ')
expect(existsSync(resolve(distDir, 'users/1.html'))).toBe(true)
expect(
existsSync(resolve(distDir, 'users/1/index.html'))
diff --git a/test/unit/basic.ssr.csp.test.js b/test/unit/basic.ssr.csp.test.js
index 4048a640de..f9cee79346 100644
--- a/test/unit/basic.ssr.csp.test.js
+++ b/test/unit/basic.ssr.csp.test.js
@@ -92,8 +92,8 @@ describe('basic ssr csp', () => {
})
expect(headers[cspHeader]).toMatch(/^script-src 'self' 'sha256-.*'/)
- expect(headers[cspHeader].includes('https://example.com')).toBe(true)
- expect(headers[cspHeader].includes('https://example.io')).toBe(true)
+ expect(headers[cspHeader]).toContain('https://example.com')
+ expect(headers[cspHeader]).toContain('https://example.io')
}
)
@@ -115,8 +115,8 @@ describe('basic ssr csp', () => {
expect(headers[cspHeader]).toMatch(/default-src 'none'/)
expect(headers[cspHeader]).toMatch(/script-src 'sha256-(.*)?' 'self'/)
- expect(headers[cspHeader].includes('https://example.com')).toBe(true)
- expect(headers[cspHeader].includes('https://example.io')).toBe(true)
+ expect(headers[cspHeader]).toContain('https://example.com')
+ expect(headers[cspHeader]).toContain('https://example.io')
}
)
@@ -235,8 +235,8 @@ describe('basic ssr csp', () => {
})
expect(headers[reportOnlyHeader]).toMatch(/^script-src 'self' 'sha256-.*'/)
- expect(headers[reportOnlyHeader].includes('https://example.com')).toBe(true)
- expect(headers[reportOnlyHeader].includes('https://example.io')).toBe(true)
+ expect(headers[reportOnlyHeader]).toContain('https://example.com')
+ expect(headers[reportOnlyHeader]).toContain('https://example.io')
}
)
@@ -258,8 +258,8 @@ describe('basic ssr csp', () => {
expect(headers[reportOnlyHeader]).toMatch(/default-src 'none'/)
expect(headers[reportOnlyHeader]).toMatch(/script-src 'sha256-(.*)?' 'self'/)
- expect(headers[reportOnlyHeader].includes('https://example.com')).toBe(true)
- expect(headers[reportOnlyHeader].includes('https://example.io')).toBe(true)
+ expect(headers[reportOnlyHeader]).toContain('https://example.com')
+ expect(headers[reportOnlyHeader]).toContain('https://example.io')
}
)
diff --git a/test/unit/basic.ssr.test.js b/test/unit/basic.ssr.test.js
index 78b550d7fb..8718601efa 100644
--- a/test/unit/basic.ssr.test.js
+++ b/test/unit/basic.ssr.test.js
@@ -16,12 +16,12 @@ describe('basic ssr', () => {
test('/stateless', async () => {
const { html } = await nuxt.server.renderRoute('/stateless')
- expect(html.includes('My component! ')).toBe(true)
+ expect(html).toContain('My component! ')
})
test('/store-module', async () => {
const { html } = await nuxt.server.renderRoute('/store-module')
- expect(html.includes('mutated ')).toBe(true)
+ expect(html).toContain('mutated ')
})
/*
@@ -31,7 +31,7 @@ describe('basic ssr', () => {
const window = await nuxt.server.renderAndGetWindow(url('/css'))
const headHtml = window.document.head.innerHTML
- expect(headHtml.includes('color:red')).toBe(true)
+ expect(headHtml).toContain('color:red')
const element = window.document.querySelector('.red')
expect(element).not.toBe(null)
@@ -44,7 +44,7 @@ describe('basic ssr', () => {
const window = await nuxt.server.renderAndGetWindow(url('/css'))
const headHtml = window.document.head.innerHTML
- expect(headHtml.includes('background-color:#00f')).toBe(true)
+ expect(headHtml).toContain('background-color:#00f')
// const element = window.document.querySelector('div.red')
// t.is(window.getComputedStyle(element)['background-color'], 'blue')
@@ -52,13 +52,13 @@ describe('basic ssr', () => {
test('/stateful', async () => {
const { html } = await nuxt.server.renderRoute('/stateful')
- expect(html.includes('')).toBe(true)
+ expect(html).toContain('')
})
test('/store', async () => {
const { html } = await nuxt.server.renderRoute('/store')
- expect(html.includes('Vuex Nested Modules ')).toBe(true)
- expect(html.includes('1
')).toBe(true)
+ expect(html).toContain('Vuex Nested Modules ')
+ expect(html).toContain('1
')
})
test('/head', async () => {
@@ -66,7 +66,7 @@ describe('basic ssr', () => {
expect(window.document.title).toBe('My title - Nuxt.js')
const html = window.document.body.innerHTML
- expect(html.includes('
I can haz meta tags ')).toBe(true)
+ expect(html).toContain('
I can haz meta tags ')
expect(
html.includes('
diff --git a/test/fixtures/basic/pages/error-string.vue b/test/fixtures/basic/pages/error-string.vue
new file mode 100644
index 0000000000..4b6c6d5256
--- /dev/null
+++ b/test/fixtures/basic/pages/error-string.vue
@@ -0,0 +1,8 @@
+
diff --git a/test/fixtures/basic/pages/error.vue b/test/fixtures/basic/pages/error.vue
index 2b2308b386..d6975dcc52 100644
--- a/test/fixtures/basic/pages/error.vue
+++ b/test/fixtures/basic/pages/error.vue
@@ -4,7 +4,7 @@
diff --git a/test/fixtures/spa/pages/error-handler-string.vue b/test/fixtures/spa/pages/error-handler-string.vue
new file mode 100644
index 0000000000..4b6c6d5256
--- /dev/null
+++ b/test/fixtures/spa/pages/error-handler-string.vue
@@ -0,0 +1,8 @@
+
diff --git a/test/fixtures/spa/plugins/error.js b/test/fixtures/spa/plugins/error.js
index 27bb917894..5c6de6b278 100644
--- a/test/fixtures/spa/plugins/error.js
+++ b/test/fixtures/spa/plugins/error.js
@@ -1,5 +1,5 @@
import Vue from 'vue'
Vue.config.errorHandler = function (err) {
- document.body.appendChild(document.createTextNode(`error handler triggered: ${err.message}`))
+ document.body.appendChild(document.createTextNode(`error handler triggered: ${err.message || err}`))
}
diff --git a/test/unit/basic.ssr.test.js b/test/unit/basic.ssr.test.js
index 8718601efa..665ef19fbc 100644
--- a/test/unit/basic.ssr.test.js
+++ b/test/unit/basic.ssr.test.js
@@ -174,6 +174,26 @@ describe('basic ssr', () => {
.rejects.toThrow('Error mouahahah')
})
+ test('/error-string', async () => {
+ let error
+ try {
+ await nuxt.server.renderRoute('/error-string', { req: {}, res: {} })
+ } catch (e) {
+ error = e
+ }
+ await expect(error).toEqual('fetch error!')
+ })
+
+ test('/error-object', async () => {
+ let error
+ try {
+ await nuxt.server.renderRoute('/error-object', { req: {}, res: {} })
+ } catch (e) {
+ error = e
+ }
+ await expect(error).toEqual({ error: 'fetch error!' })
+ })
+
test('/error status code', async () => {
await expect(rp(url('/error'))).rejects.toMatchObject({
statusCode: 500
@@ -201,7 +221,7 @@ describe('basic ssr', () => {
const { html, error } = await nuxt.server.renderRoute('/error2')
expect(html).toContain('Custom error')
expect(error.message).toContain('Custom error')
- expect(error.statusCode === undefined).toBe(true)
+ expect(error.statusCode).toBe(500)
})
test('/error2 status code', async () => {
diff --git a/test/unit/spa.test.js b/test/unit/spa.test.js
index 01d60ad17d..e882be4392 100644
--- a/test/unit/spa.test.js
+++ b/test/unit/spa.test.js
@@ -41,13 +41,21 @@ describe('spa', () => {
})
test('/error-handler', async () => {
- await renderRoute('/error-handler')
const { html } = await renderRoute('/error-handler')
expect(html).toMatch('error handler triggered: fetch error!')
})
+ test('/error-handler-object', async () => {
+ const { html } = await renderRoute('/error-handler')
+ expect(html).toMatch('error handler triggered: fetch error!')
+ })
+
+ test('/error-handler-string', async () => {
+ const { html } = await renderRoute('/error-handler-string')
+ expect(html).toMatch('error handler triggered: fetch error!')
+ })
+
test('/error-handler-async', async () => {
- await renderRoute('/error-handler-async')
const { html } = await renderRoute('/error-handler-async')
expect(html).toMatch('error handler triggered: asyncData error!')
})
From 68523b95bc1bc663c96f30b28425f2e4cee29c7c Mon Sep 17 00:00:00 2001
From: Pooya Parsa
Date: Wed, 14 Nov 2018 23:02:07 +0330
Subject: [PATCH 136/149] feat(server): fallback option (#4323)
---
packages/config/src/config/render.js | 13 ++++++++
packages/server/package.json | 1 +
packages/server/src/server.js | 22 +++++++++++++-
packages/vue-renderer/src/renderer.js | 13 --------
test/unit/fallback.test.js | 44 +++++++++++++++++++++++++++
test/unit/spa.test.js | 9 ------
yarn.lock | 23 +++++++++++++-
7 files changed, 101 insertions(+), 24 deletions(-)
create mode 100644 test/unit/fallback.test.js
diff --git a/packages/config/src/config/render.js b/packages/config/src/config/render.js
index 28d96ca802..505d9ad7c9 100644
--- a/packages/config/src/config/render.js
+++ b/packages/config/src/config/render.js
@@ -1,3 +1,5 @@
+// TODO: Refactor @nuxt/server related options into `server.js`
+
export default () => ({
bundleRenderer: {
shouldPrefetch: () => false
@@ -23,5 +25,16 @@ export default () => ({
index: false,
// 1 year in production
maxAge: '1y'
+ },
+ // https://github.com/nuxt/serve-placeholder
+ fallback: {
+ dist: {},
+ static: {
+ skipUnknown: true,
+ handlers: {
+ '.htm': false,
+ '.html': false
+ }
+ }
}
})
diff --git a/packages/server/package.json b/packages/server/package.json
index 533218cc89..9a3e74e7f7 100644
--- a/packages/server/package.json
+++ b/packages/server/package.json
@@ -22,6 +22,7 @@
"ip": "^1.1.5",
"launch-editor-middleware": "^2.2.1",
"pify": "^4.0.1",
+ "serve-placeholder": "^1.1.0",
"serve-static": "^1.13.2",
"server-destroy": "^1.0.1"
},
diff --git a/packages/server/src/server.js b/packages/server/src/server.js
index 5013a2db4c..bd5cfea2f1 100644
--- a/packages/server/src/server.js
+++ b/packages/server/src/server.js
@@ -1,6 +1,7 @@
import path from 'path'
import launchMiddleware from 'launch-editor-middleware'
import serveStatic from 'serve-static'
+import servePlaceholder from 'serve-placeholder'
import connect from 'connect'
import { determineGlobals, isUrl } from '@nuxt/common'
@@ -125,11 +126,30 @@ export default class Server {
})
}
- // Add User provided middleware
+ // Add user provided middleware
this.options.serverMiddleware.forEach((m) => {
this.useMiddleware(m)
})
+ const { fallback } = this.options.render
+ if (fallback) {
+ // Graceful 404 errors for dist files
+ if (fallback.dist) {
+ this.useMiddleware({
+ path: this.publicPath,
+ handler: servePlaceholder(fallback.dist)
+ })
+ }
+
+ // Graceful 404 errors for other paths
+ if (fallback.static) {
+ this.useMiddleware({
+ path: '/',
+ handler: servePlaceholder(fallback.static)
+ })
+ }
+ }
+
// Finally use nuxtMiddleware
this.useMiddleware(nuxtMiddleware({
options: this.options,
diff --git a/packages/vue-renderer/src/renderer.js b/packages/vue-renderer/src/renderer.js
index ef61338505..02b586c6dd 100644
--- a/packages/vue-renderer/src/renderer.js
+++ b/packages/vue-renderer/src/renderer.js
@@ -254,19 +254,6 @@ export default class VueRenderer {
const APP =
`${this.context.resources.loadingHTML}
` + BODY_SCRIPTS
- // Detect 404 errors
- if (
- url.includes(this.context.options.build.publicPath) ||
- url.includes('__webpack')
- ) {
- const err = {
- statusCode: 404,
- message: this.context.options.messages.error_404,
- name: 'ResourceNotFound'
- }
- throw err
- }
-
const html = this.renderTemplate(false, {
HTML_ATTRS,
BODY_ATTRS,
diff --git a/test/unit/fallback.test.js b/test/unit/fallback.test.js
new file mode 100644
index 0000000000..983eb6d353
--- /dev/null
+++ b/test/unit/fallback.test.js
@@ -0,0 +1,44 @@
+import { getPort, loadFixture, Nuxt, rp } from '../utils'
+
+let port
+const url = route => 'http://localhost:' + port + route
+
+let nuxt = null
+
+describe('fallback', () => {
+ beforeAll(async () => {
+ const config = await loadFixture('with-config')
+ nuxt = new Nuxt(config)
+ port = await getPort()
+ await nuxt.server.listen(port, 'localhost')
+ })
+
+ test('robots.txt handled', async () => {
+ await expect(rp(url('/test/robots.txt')))
+ .rejects.toMatchObject({
+ statusCode: 404,
+ response: { body: '' }
+ })
+ })
+
+ test('normal html routes should be rendered using SSR', async () => {
+ await expect(rp(url('/test/index.html')))
+ .rejects.toMatchObject({
+ statusCode: 404,
+ response: { body: expect.stringContaining('data-n-head-ssr') }
+ })
+ })
+
+ test('uknown assets handled in dist', async () => {
+ await expect(rp(url('/test/orion/foo.xyz')))
+ .rejects.toMatchObject({
+ statusCode: 404,
+ response: { body: '' }
+ })
+ })
+
+ // Close server and ask nuxt to stop listening to file changes
+ afterAll(async () => {
+ await nuxt.close()
+ })
+})
diff --git a/test/unit/spa.test.js b/test/unit/spa.test.js
index e882be4392..935169e80e 100644
--- a/test/unit/spa.test.js
+++ b/test/unit/spa.test.js
@@ -60,15 +60,6 @@ describe('spa', () => {
expect(html).toMatch('error handler triggered: asyncData error!')
})
- test('/_nuxt/ (access publicPath in spa mode)', async () => {
- await expect(renderRoute('/_nuxt/')).rejects.toMatchObject({
- response: {
- statusCode: 404,
- statusMessage: 'ResourceNotFound'
- }
- })
- })
-
// Close server and ask nuxt to stop listening to file changes
afterAll(async () => {
await nuxt.close()
diff --git a/yarn.lock b/yarn.lock
index 8411593e19..e7bf2e4351 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3597,6 +3597,15 @@ default-require-extensions@^1.0.0:
dependencies:
strip-bom "^2.0.0"
+defaults-deep@^0.2.4:
+ version "0.2.4"
+ resolved "https://registry.npmjs.org/defaults-deep/-/defaults-deep-0.2.4.tgz#a479cfeafce025810fb93aa8d2dde0ee2d677cc6"
+ integrity sha512-V6BtqzcMvn0EPOy7f+SfMhfmTawq+7UQdt9yZH0EBK89+IHo5f+Hse/qzTorAXOBrQpxpwb6cB/8OgtaMrT+Fg==
+ dependencies:
+ for-own "^0.1.3"
+ is-extendable "^0.1.1"
+ lazy-cache "^0.2.3"
+
defaults@^1.0.3:
version "1.0.3"
resolved "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d"
@@ -4676,7 +4685,7 @@ for-in@^1.0.1, for-in@^1.0.2:
resolved "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=
-for-own@^0.1.4:
+for-own@^0.1.3, for-own@^0.1.4:
version "0.1.5"
resolved "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce"
integrity sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=
@@ -6468,6 +6477,11 @@ launch-editor@^2.2.1:
chalk "^2.3.0"
shell-quote "^1.6.1"
+lazy-cache@^0.2.3:
+ version "0.2.7"
+ resolved "https://registry.npmjs.org/lazy-cache/-/lazy-cache-0.2.7.tgz#7feddf2dcb6edb77d11ef1d117ab5ffdf0ab1b65"
+ integrity sha1-f+3fLctu23fRHvHRF6tf/fCrG2U=
+
lazy-cache@^1.0.3:
version "1.0.4"
resolved "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e"
@@ -9650,6 +9664,13 @@ serialize-javascript@^1.3.0, serialize-javascript@^1.4.0, serialize-javascript@^
resolved "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.5.0.tgz#1aa336162c88a890ddad5384baebc93a655161fe"
integrity sha512-Ga8c8NjAAp46Br4+0oZ2WxJCwIzwP60Gq1YPgU+39PiTVxyed/iKE/zyZI6+UlVYH5Q4PaQdHhcegIFPZTUfoQ==
+serve-placeholder@^1.1.0:
+ version "1.1.0"
+ resolved "https://registry.npmjs.org/serve-placeholder/-/serve-placeholder-1.1.0.tgz#3c0930b311a9896c3d90903bb8ea60fff12101b2"
+ integrity sha512-kMYOLX8hwcyQ/8nLuyPcOhGhi4c29sJLsfz3i1vOFQnYMtZdPSsJLxxblTU+5wf6CPHh/g3EYo/V/SQ6eVEO5Q==
+ dependencies:
+ defaults-deep "^0.2.4"
+
serve-static@1.13.2, serve-static@^1.13.2:
version "1.13.2"
resolved "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz#095e8472fd5b46237db50ce486a43f4b86c6cec1"
From 660ab37bff1c3150203e745f605ed876012f8469 Mon Sep 17 00:00:00 2001
From: Clark Du
Date: Wed, 14 Nov 2018 19:35:00 +0000
Subject: [PATCH 137/149] fix(tests): make assets in test consistent with build
---
babel.config.js | 6 +++++-
test/fixtures/with-config/layouts/default.vue | 14 --------------
.../with-config/layouts/desktop/default.vue | 14 --------------
.../with-config/layouts/mobile/default.vue | 14 --------------
test/fixtures/with-config/pages/index.vue | 7 +++++++
test/unit/modern.server.test.js | 8 ++++----
6 files changed, 16 insertions(+), 47 deletions(-)
diff --git a/babel.config.js b/babel.config.js
index 00e49276e9..a6f2bd372a 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -1,5 +1,9 @@
+function isBabelLoader(caller) {
+ return caller && caller.name === 'babel-loader'
+}
+
module.exports = function (api) {
- if (api.env('test')) {
+ if (api.env('test') && !api.caller(isBabelLoader)) {
return {
presets: [
['@babel/env', {
diff --git a/test/fixtures/with-config/layouts/default.vue b/test/fixtures/with-config/layouts/default.vue
index f89869bff1..f1670a7a2d 100644
--- a/test/fixtures/with-config/layouts/default.vue
+++ b/test/fixtures/with-config/layouts/default.vue
@@ -4,17 +4,3 @@
-
-
diff --git a/test/fixtures/with-config/layouts/desktop/default.vue b/test/fixtures/with-config/layouts/desktop/default.vue
index e516aa2469..649ec36e41 100644
--- a/test/fixtures/with-config/layouts/desktop/default.vue
+++ b/test/fixtures/with-config/layouts/desktop/default.vue
@@ -4,17 +4,3 @@
-
-
diff --git a/test/fixtures/with-config/layouts/mobile/default.vue b/test/fixtures/with-config/layouts/mobile/default.vue
index 406ee00dc9..7219975d14 100644
--- a/test/fixtures/with-config/layouts/mobile/default.vue
+++ b/test/fixtures/with-config/layouts/mobile/default.vue
@@ -4,17 +4,3 @@