This commit is contained in:
Pooya Parsa 2019-04-04 21:37:53 +04:30 committed by GitHub
commit f00a675f03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
117 changed files with 2309 additions and 1401 deletions

View File

@ -3,6 +3,45 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.6.0](https://github.com/nuxt/nuxt.js/compare/v2.5.1...v2.6.0) (2019-04-04)
### Bug Fixes
* revert node-externals disabling in dev mode ([#5452](https://github.com/nuxt/nuxt.js/issues/5452)) ([6ce99d2](https://github.com/nuxt/nuxt.js/commit/6ce99d2))
* **webpack:** prefer `main` over `module` field for server config ([#5446](https://github.com/nuxt/nuxt.js/issues/5446)) ([e155ea4](https://github.com/nuxt/nuxt.js/commit/e155ea4))
* disable `node-externals` for dev mode ([#5414](https://github.com/nuxt/nuxt.js/issues/5414)) ([a5a1657](https://github.com/nuxt/nuxt.js/commit/a5a1657))
* not override externals set by build.extend ([#5444](https://github.com/nuxt/nuxt.js/issues/5444)) ([1ae4333](https://github.com/nuxt/nuxt.js/commit/1ae4333))
* **build:** disable loading `babel.config.js` by default ([#5365](https://github.com/nuxt/nuxt.js/issues/5365)) ([64fa424](https://github.com/nuxt/nuxt.js/commit/64fa424))
* **builder:** await for renderer to load resources ([#5341](https://github.com/nuxt/nuxt.js/issues/5341)) ([caf5198](https://github.com/nuxt/nuxt.js/commit/caf5198))
* **cli:** catch all possible errors thrown from proper-filelock ([#5347](https://github.com/nuxt/nuxt.js/issues/5347)) ([39bbe46](https://github.com/nuxt/nuxt.js/commit/39bbe46))
* **renderer:** retry render if renderer is in loading or created state ([#5417](https://github.com/nuxt/nuxt.js/issues/5417)) ([8b99695](https://github.com/nuxt/nuxt.js/commit/8b99695))
* **vue-app:** prevent mounting page twice on redirect ([#5361](https://github.com/nuxt/nuxt.js/issues/5361)) ([2d73e8a](https://github.com/nuxt/nuxt.js/commit/2d73e8a))
* **vue-renderer:** add the csp hash if `unsafe-inline` hasn't been specified ([#5387](https://github.com/nuxt/nuxt.js/issues/5387)) ([97db6a4](https://github.com/nuxt/nuxt.js/commit/97db6a4))
* add type definition for configuring forkTsChecker ([2c1444d](https://github.com/nuxt/nuxt.js/commit/2c1444d))
* fail in case of missing core-js dependency ([#5342](https://github.com/nuxt/nuxt.js/issues/5342)) ([439b914](https://github.com/nuxt/nuxt.js/commit/439b914))
* memory leak in dev mode ([#5399](https://github.com/nuxt/nuxt.js/issues/5399)) ([04ddcac](https://github.com/nuxt/nuxt.js/commit/04ddcac))
* SyntaxError Unexpected token export in importing babel runtime helper ([#5401](https://github.com/nuxt/nuxt.js/issues/5401)) ([3b85dd9](https://github.com/nuxt/nuxt.js/commit/3b85dd9))
* **vue-app:** decode uri in `getlocation` ([#5337](https://github.com/nuxt/nuxt.js/issues/5337)) ([77dcfe6](https://github.com/nuxt/nuxt.js/commit/77dcfe6))
### Features
* **babel-preset-app:** support specifying core-js version ([#5411](https://github.com/nuxt/nuxt.js/issues/5411)) ([159123f](https://github.com/nuxt/nuxt.js/commit/159123f))
* **cli:** add `--quiet` option to nuxt generate command ([#5357](https://github.com/nuxt/nuxt.js/issues/5357)) ([91f4eb0](https://github.com/nuxt/nuxt.js/commit/91f4eb0))
* **cli:** add internal _generate and _build options ([#5434](https://github.com/nuxt/nuxt.js/issues/5434)) ([516aea3](https://github.com/nuxt/nuxt.js/commit/516aea3))
* **typescript:** detect typescript based on `tsconfig.json` ([#5412](https://github.com/nuxt/nuxt.js/issues/5412)) ([6ffc5c5](https://github.com/nuxt/nuxt.js/commit/6ffc5c5))
* **vue-renderer:** add csp meta tags ([#5354](https://github.com/nuxt/nuxt.js/issues/5354)) ([b978a37](https://github.com/nuxt/nuxt.js/commit/b978a37))
### Reverts
* **core:** call ready to prevent breaking changes ([#5413](https://github.com/nuxt/nuxt.js/issues/5413)) ([001ba77](https://github.com/nuxt/nuxt.js/commit/001ba77))
## [2.5.1](https://github.com/nuxt/nuxt.js/compare/v2.5.0...v2.5.1) (2019-03-21)

View File

@ -100,10 +100,10 @@ Or you can start by using one of our starter templates:
const { Nuxt, Builder } = require('nuxt')
// Import and set nuxt.js options
let config = require('./nuxt.config.js')
const config = require('./nuxt.config.js')
config.dev = (process.env.NODE_ENV !== 'production')
let nuxt = new Nuxt(config)
const nuxt = new Nuxt(config)
// Start build process (only in development)
if (config.dev) {
@ -117,7 +117,7 @@ Learn more: https://nuxtjs.org/api/nuxt
## Using nuxt.js as a middleware
You might want to use your own server with your configurations, your API and everything awesome your created with. That's why you can use nuxt.js as a middleware. It's recommended to use it at the end of your middleware since it will handle the rendering of your web application and won't call next().
You might want to use your own server with your configurations, your API and everything awesome you have created with. That's why you can use nuxt.js as a middleware. It's recommended to use it at the end of your middleware since it will handle the rendering of your web application and won't call next().
```js
app.use(nuxt.render)

View File

@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.6.0](https://github.com/nuxt/nuxt.js/compare/v2.5.1...v2.6.0) (2019-04-04)
**Note:** Version bump only for package nuxt-start
## [2.5.1](https://github.com/nuxt/nuxt.js/compare/v2.5.0...v2.5.1) (2019-03-21)
**Note:** Version bump only for package nuxt-start

View File

@ -1,6 +1,6 @@
{
"name": "nuxt-start",
"version": "2.5.1",
"version": "2.6.0",
"description": "Starts Nuxt.js Application in production mode",
"keywords": [
"nuxt",
@ -52,11 +52,11 @@
"main": "dist/nuxt-start.js",
"bin": "bin/nuxt-start.js",
"dependencies": {
"@nuxt/cli": "2.5.1",
"@nuxt/core": "2.5.1",
"@nuxt/cli": "2.6.0",
"@nuxt/core": "2.6.0",
"node-fetch": "^2.3.0",
"vue": "^2.6.10",
"vue-meta": "^1.5.8",
"vue-meta": "^1.6.0",
"vue-no-ssr": "^1.1.1",
"vue-router": "^3.0.2",
"vuex": "^3.1.0"

View File

@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.6.0](https://github.com/nuxt/nuxt.js/compare/v2.5.1...v2.6.0) (2019-04-04)
**Note:** Version bump only for package nuxt-ts
## [2.5.1](https://github.com/nuxt/nuxt.js/compare/v2.5.0...v2.5.1) (2019-03-21)
**Note:** Version bump only for package nuxt-ts

View File

@ -1,6 +1,6 @@
{
"name": "nuxt-ts",
"version": "2.5.1",
"version": "2.6.0",
"description": "Nuxt With Runtime Typescript Support",
"keywords": [
"nuxt",
@ -56,14 +56,14 @@
"nuxts": "bin/nuxt-ts.js"
},
"dependencies": {
"@nuxt/builder": "2.5.1",
"@nuxt/cli": "2.5.1",
"@nuxt/core": "2.5.1",
"@nuxt/generator": "2.5.1",
"@nuxt/loading-screen": "^0.1.2",
"@nuxt/opencollective": "^0.2.1",
"@nuxt/typescript": "2.5.1",
"@nuxt/webpack": "2.5.1"
"@nuxt/builder": "2.6.0",
"@nuxt/cli": "2.6.0",
"@nuxt/core": "2.6.0",
"@nuxt/generator": "2.6.0",
"@nuxt/loading-screen": "^0.2.0",
"@nuxt/opencollective": "^0.2.2",
"@nuxt/typescript": "2.6.0",
"@nuxt/webpack": "2.6.0"
},
"engines": {
"node": ">=6.0.0",

View File

@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.6.0](https://github.com/nuxt/nuxt.js/compare/v2.5.1...v2.6.0) (2019-04-04)
**Note:** Version bump only for package nuxt
## [2.5.1](https://github.com/nuxt/nuxt.js/compare/v2.5.0...v2.5.1) (2019-03-21)
**Note:** Version bump only for package nuxt

View File

@ -1,6 +1,6 @@
{
"name": "nuxt",
"version": "2.5.1",
"version": "2.6.0",
"description": "A minimalistic framework for server-rendered Vue.js applications (inspired by Next.js)",
"keywords": [
"nuxt",
@ -54,13 +54,13 @@
"postinstall": "opencollective || exit 0"
},
"dependencies": {
"@nuxt/builder": "2.5.1",
"@nuxt/cli": "2.5.1",
"@nuxt/core": "2.5.1",
"@nuxt/generator": "2.5.1",
"@nuxt/loading-screen": "^0.1.2",
"@nuxt/opencollective": "^0.2.1",
"@nuxt/webpack": "2.5.1"
"@nuxt/builder": "2.6.0",
"@nuxt/cli": "2.6.0",
"@nuxt/core": "2.6.0",
"@nuxt/generator": "2.6.0",
"@nuxt/loading-screen": "^0.2.0",
"@nuxt/opencollective": "^0.2.2",
"@nuxt/webpack": "2.6.0"
},
"engines": {
"node": ">=8.0.0",

View File

@ -0,0 +1,84 @@
# Created by .ignore support plugin (hsz.mobi)
### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# Nuxt generate
dist
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless
# IDE
.idea
# Service worker
sw.*

View File

@ -0,0 +1,5 @@
*.yaml
*.md
*.lock
LICENSE
CHANGELOG

View File

@ -0,0 +1,12 @@
# docker-build
## Build Setup
```bash
# Build a nuxt-docker image
$ docker build -t nuxt-docker .
# Run the container for the nuxt-docker image with a exposed port 3000
$ docker run --rm -it -p 3000:3000 nuxt-docker
```

View File

@ -0,0 +1 @@
# ASSETS

View File

@ -0,0 +1 @@
# COMPONENTS

View File

@ -0,0 +1,31 @@
FROM node:latest as builder
WORKDIR /src
COPY . .
RUN yarn install \
--prefer-offline \
--frozen-lockfile \
--non-interactive \
--production=false
RUN yarn build
RUN rm -rf node_modules && \
NODE_ENV=production yarn install \
--prefer-offline \
--pure-lockfile \
--non-interactive \
--production=true
FROM node:alpine
WORKDIR /src
COPY --from=builder /src .
ENV HOST 0.0.0.0
EXPOSE 3000
CMD [ "yarn", "start" ]

View File

@ -0,0 +1 @@
# LAYOUTS

View File

@ -0,0 +1,8 @@
<template>
<div>
<nuxt />
</div>
</template>
<style>
</style>

View File

@ -0,0 +1 @@
# MIDDLEWARE

View File

@ -0,0 +1,54 @@
import pkg from './package'
export default {
mode: 'universal',
/*
** Headers of the page
*/
head: {
title: pkg.name,
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: pkg.description }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },
/*
** Global CSS
*/
css: [
],
/*
** Plugins to load before mounting the App
*/
plugins: [
],
/*
** Nuxt.js modules
*/
modules: [
],
/*
** Build configuration
*/
build: {
/*
** You can extend webpack config here
*/
extend(config, ctx) {
}
}
}

View File

@ -0,0 +1,16 @@
{
"name": "docker-build",
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt-start",
"generate": "nuxt generate"
},
"dependencies": {
"cross-env": "latest",
"nuxt-start": "latest"
},
"devDependencies": {
"nuxt": "latest"
}
}

View File

@ -0,0 +1 @@
# PAGES

View File

@ -0,0 +1,12 @@
<template>
<div>
<h1>It works!</h1>
</div>
</template>
<script>
export default {}
</script>
<style>
</style>

View File

@ -0,0 +1 @@
# PLUGINS

View File

@ -0,0 +1 @@
# STATIC

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1 @@
# STORE

View File

@ -6,8 +6,6 @@
Data model is: {{ model }}
<NuxtLink to="/about">Goto About</NuxtLink>
<NuxtLink to="/pug">Goto Pug</NuxtLink>
</template>
<script>

View File

@ -1 +1,32 @@
{}
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"lib": [
"esnext",
"esnext.asynciterable",
"dom"
],
"esModuleInterop": true,
"experimentalDecorators": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noImplicitAny": false,
"noEmit": true,
"baseUrl": ".",
"paths": {
"~/*": [
"./*"
],
"@/*": [
"./*"
]
},
"types": [
"@types/node",
"@nuxt/vue-app"
]
}
}

View File

@ -1 +1,32 @@
{}
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"lib": [
"esnext",
"esnext.asynciterable",
"dom"
],
"esModuleInterop": true,
"experimentalDecorators": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noImplicitAny": false,
"noEmit": true,
"baseUrl": ".",
"paths": {
"~/*": [
"./*"
],
"@/*": [
"./*"
]
},
"types": [
"@types/node",
"@nuxt/vue-app"
]
}
}

View File

@ -1,6 +1,34 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"lib": [
"esnext",
"esnext.asynciterable",
"dom"
],
"esModuleInterop": true,
"experimentalDecorators": true,
"allowJs": true,
"jsx": "preserve",
"noImplicitThis": true
"sourceMap": true,
"strict": true,
"noImplicitAny": false,
"noImplicitThis": true,
"noEmit": true,
"baseUrl": ".",
"paths": {
"~/*": [
"./*"
],
"@/*": [
"./*"
]
},
"types": [
"@types/node",
"@nuxt/vue-app"
]
}
}

View File

@ -1 +1,32 @@
{}
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"lib": [
"esnext",
"esnext.asynciterable",
"dom"
],
"esModuleInterop": true,
"experimentalDecorators": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noImplicitAny": false,
"noEmit": true,
"baseUrl": ".",
"paths": {
"~/*": [
"./*"
],
"@/*": [
"./*"
]
},
"types": [
"@types/node",
"@nuxt/vue-app"
]
}
}

View File

@ -1 +1,32 @@
{}
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"lib": [
"esnext",
"esnext.asynciterable",
"dom"
],
"esModuleInterop": true,
"experimentalDecorators": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noImplicitAny": false,
"noEmit": true,
"baseUrl": ".",
"paths": {
"~/*": [
"./*"
],
"@/*": [
"./*"
]
},
"types": [
"@types/node",
"@nuxt/vue-app"
]
}
}

View File

@ -1,5 +0,0 @@
import { createNetworkInterface } from 'apollo-client'
export default (ctx) => {
return createNetworkInterface({ uri: 'https://api.graph.cool/simple/v1/cj1dqiyvqqnmj0113yuqamkuu' })
}

View File

@ -1,8 +1,10 @@
export default {
modules: ['@nuxtjs/apollo'],
apollo: {
networkInterfaces: {
default: '~/apollo/network-interfaces/default.js'
clientConfigs: {
default: {
httpEndpoint: 'https://api.graph.cool/simple/v1/cj1dqiyvqqnmj0113yuqamkuu'
}
}
}
}

View File

@ -1,7 +1,9 @@
{
"name": "example-vue-apollo",
"dependencies": {
"@nuxtjs/apollo": "^2.1.1",
"@nuxtjs/apollo": "^4.0.0-rc.4",
"core-js": "^2.6.5",
"node-fetch": "^2.3.0",
"nuxt": "latest"
},
"scripts": {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -0,0 +1,42 @@
<template>
<div class="column">
<div class="card">
<header class="card-header">
<p class="card-header-title has-text-grey">
{{ title }}
</p>
</header>
<div class="card-content">
<div class="content has-text-centered">
<b-icon
:icon="icon"
size="is-large"
type="is-primary"
/>
</div>
</div>
<footer class="card-footer">
<div class="card-footer-item">
<span>
<slot />
</span>
</div>
</footer>
</div>
</div>
</template>
<script>
export default {
props: {
title: {
type: String,
required: true
},
icon: {
type: String,
required: true
}
}
}
</script>

View File

@ -3,8 +3,9 @@ export default {
** Customize the progress bar color
*/
loading: { color: '#3B8070' },
mode: 'spa',
plugins: ['~plugins/buefy'],
modules: [
'nuxt-buefy'
],
router: {
linkActiveClass: 'is-active'
}

View File

@ -10,12 +10,7 @@
"post-update": "yarn upgrade --latest"
},
"dependencies": {
"buefy": "^0.5.4",
"nuxt": "latest",
"vue": "~2.4.4"
},
"devDependencies": {
"node-sass": "^4.6.0",
"sass-loader": "^6.0.6"
"nuxt-buefy": "latest"
}
}

View File

@ -1,3 +0,0 @@
<template>
<h1>About</h1>
</template>

View File

@ -1,28 +1,43 @@
<template>
<nav class="navbar has-shadow is-light">
<div class="container">
<div class="navbar-brand">
<NuxtLink to="/" class="navbar-item">
<img src="~/assets/logo.png">
</NuxtLink>
<section class="section">
<div class="columns is-mobile">
<card
title="Free"
icon="github-circle"
>
Open source on <a href="https://github.com/buefy/buefy"> GitHub</a>
</card>
<card
title="Responsive"
icon="cellphone-link"
>
<b class="has-text-grey">Every</b> component is responsive
</card>
<card
title="Modern"
icon="alert-decagram"
>
Built with <a href="https://vuejs.org/">Vue.js</a> and <a href="http://bulma.io/">Bulma</a>
</card>
<card
title="Lightweight"
icon="arrange-bring-to-front"
>
No other internal dependency
</card>
</div>
<div class="navbar-menu">
<div class="navbar-start">
<NuxtLink to="/" class="navbar-item is-tab" exact>
Home
</NuxtLink>
<NuxtLink to="/about" class="navbar-item is-tab" exact>
About
</NuxtLink>
</div>
</div>
</div>
</nav>
</section>
</template>
<style lang="scss">
$primary: blue;
$navbar-tab-active-border-bottom-color: red;
@import "~bulma";
@import "~buefy/src/scss/buefy";
</style>
<script>
import Card from '~/components/Card'
export default {
name: 'HomePage',
components: {
Card
}
}
</script>

View File

@ -1,4 +0,0 @@
import Vue from 'vue'
import Buefy from 'buefy'
Vue.use(Buefy)

View File

@ -3,14 +3,14 @@
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"element-ui": "^2",
"nuxt": "latest",
"post-update": "yarn upgrade --latest"
"element-ui": "^2.6.3",
"nuxt": "latest"
},
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start"
"start": "nuxt start",
"post-update": "yarn upgrade --latest"
},
"devDependencies": {
"node-sass": "^4.6.0",

View File

@ -1,5 +1,5 @@
{
"version": "2.5.1",
"version": "2.6.0",
"npmClient": "yarn",
"useWorkspaces": true,
"conventionalCommits": true,

View File

@ -1,92 +1,91 @@
{
"name": "nuxt.js",
"private": true,
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt/nuxt.js.git"
},
"workspaces": [
"packages/*",
"distributions/*"
],
"scripts": {
"build": "yarn clean && yarn pkg",
"pkg": "node -r esm ./scripts/package",
"clean": "yarn clean:build && yarn clean:examples && yarn clean:test",
"clean:build": "rimraf distributions/*/dist packages/*/dist",
"clean:examples": "rimraf examples/*/dist examples/*/.nuxt",
"clean:test": "rimraf test/fixtures/*/dist test/fixtures/*/.nuxt*/",
"dev": "node -r esm ./scripts/dev.js",
"coverage": "codecov",
"dev": "node -r esm ./scripts/dev.js",
"postinstall": "lerna link && yarn dev",
"lint": "eslint --ext .js,.mjs,.vue .",
"lint:app": "eslint-multiplexer eslint --ignore-path packages/vue-app/template/.eslintignore 'test/fixtures/!(missing-plugin)/.nuxt!(-dev)/**' | eslint-multiplexer -b",
"nuxt": "node -r esm ./packages/cli/bin/nuxt-cli.js",
"pkg": "node -r esm ./scripts/package",
"release": "./scripts/release",
"test": "yarn test:fixtures && yarn test:unit && yarn test:types",
"test:fixtures": "jest test/fixtures --forceExit",
"test:e2e": "jest -i test/e2e --forceExit",
"test:fixtures": "jest test/fixtures --forceExit",
"test:lint": "yarn lint",
"test:unit": "jest test/unit packages --forceExit",
"test:types": "tsc -p test/types",
"postinstall": "lerna link && yarn dev",
"release": "./scripts/release"
"test:unit": "jest test/unit packages --forceExit"
},
"devDependencies": {
"@babel/core": "^7.4.0",
"@babel/preset-env": "^7.4.2",
"@babel/core": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"@nuxtjs/eslint-config": "^0.0.1",
"@vue/server-test-utils": "^1.0.0-beta.29",
"@vue/test-utils": "^1.0.0-beta.29",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.5.0",
"babel-jest": "^24.7.1",
"babel-plugin-dynamic-import-node": "^2.2.0",
"cheerio": "^1.0.0-rc.2",
"codecov": "^3.2.0",
"consola": "^2.5.7",
"codecov": "^3.3.0",
"consola": "^2.5.8",
"cross-env": "^5.2.0",
"cross-spawn": "^6.0.5",
"eslint": "^5.15.3",
"eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0",
"eslint-multiplexer": "^1.0.4",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jest": "^22.4.1",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^5.2.2",
"esm": "^3.2.20",
"esm": "^3.2.22",
"express": "^4.16.4",
"finalhandler": "^1.1.1",
"fork-ts-checker-webpack-plugin": "^1.0.0",
"fork-ts-checker-webpack-plugin": "^1.0.1",
"fs-extra": "^7.0.1",
"get-port": "^4.2.0",
"glob": "^7.1.3",
"is-wsl": "^1.1.0",
"jest": "^24.5.0",
"jest": "^24.7.1",
"jsdom": "^14.0.0",
"klaw-sync": "^6.0.0",
"lerna": "^3.13.1",
"lodash": "^4.17.11",
"node-fetch": "^2.3.0",
"pug": "^2.0.3",
"pug-plain-loader": "^1.0.0",
"puppeteer-core": "^1.13.0",
"puppeteer-core": "^1.14.0",
"request": "^2.88.0",
"request-promise-native": "^1.0.7",
"rimraf": "^2.6.3",
"rollup": "^1.7.0",
"rollup": "^1.8.0",
"rollup-plugin-alias": "^1.5.1",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.2.1",
"rollup-plugin-commonjs": "^9.3.3",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-license": "^0.8.1",
"rollup-plugin-node-resolve": "^4.0.1",
"rollup-plugin-replace": "^2.1.1",
"sort-package-json": "^1.21.0",
"ts-jest": "^24.0.0",
"sort-package-json": "^1.22.1",
"ts-jest": "^24.0.1",
"ts-loader": "^5.3.3",
"tslint": "^5.14.0",
"typescript": "^3.3.4000",
"ts-node": "^8.0.3",
"tslint": "^5.15.0",
"typescript": "^3.4.1",
"vue-jest": "^4.0.0-beta.2",
"vue-property-decorator": "^8.1.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt/nuxt.js.git"
},
"name": "nuxt.js"
}
}

View File

@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.6.0](https://github.com/nuxt/nuxt.js/compare/v2.5.1...v2.6.0) (2019-04-04)
### Bug Fixes
* SyntaxError Unexpected token export in importing babel runtime helper ([#5401](https://github.com/nuxt/nuxt.js/issues/5401)) ([3b85dd9](https://github.com/nuxt/nuxt.js/commit/3b85dd9))
### Features
* **babel-preset-app:** support specifying core-js version ([#5411](https://github.com/nuxt/nuxt.js/issues/5411)) ([159123f](https://github.com/nuxt/nuxt.js/commit/159123f))
## [2.5.1](https://github.com/nuxt/nuxt.js/compare/v2.5.0...v2.5.1) (2019-03-21)
**Note:** Version bump only for package @nuxt/babel-preset-app

View File

@ -15,6 +15,18 @@ babel: {
}
}
```
**Note**: Since `core-js@2` and `core-js@3` are both supported from Babel 7.4.0, we recommend directly adding `core-js` and setting the version via the [`corejs`](#corejs) option.
```sh
yarn add --dev core-js@3 @babel/runtime-corejs3
# or
yarn add --dev core-js@2 @babel/runtime-corejs2
```
...where `options` is an object with parameters, for example:
```
const options = {
@ -37,7 +49,7 @@ Below is a list of all available parameters:
* **loose**, default `false` - '[@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env#loose)' parameter and also sets `loose=true` for `@babel/plugin-proposal-class-properties`
* **modern** passed by builder, either `true` or `false`
* **modules**, default `false` - '[@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env#modules)' parameter
* **polyfills**, default `['es6.array.iterator','es6.promise','es6.object.assign','es7.promise.finally']`, more [in the corresponding repository](https://github.com/zloirock/core-js)
* **polyfills**, default `core-js@2: ['es6.array.iterator','es6.promise','es6.object.assign','es7.promise.finally']`, `core-js@3: ['es.array.iterator','es.promise','es.object.assign','es.promise.finally']`, more [in the corresponding repository](https://github.com/zloirock/core-js)
* **shippedProposals** - '[@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env#shippedproposals)' parameter
* **spec** - '[@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env#spec)' parameter
* **targets** - '[@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env#targets)' parameter

View File

@ -1,6 +1,6 @@
{
"name": "@nuxt/babel-preset-app",
"version": "2.5.1",
"version": "2.6.0",
"description": "babel-preset-app for nuxt.js",
"repository": "nuxt/nuxt.js",
"license": "MIT",
@ -10,14 +10,14 @@
],
"main": "src/index.js",
"dependencies": {
"@babel/core": "^7.4.0",
"@babel/core": "^7.4.3",
"@babel/plugin-proposal-class-properties": "^7.4.0",
"@babel/plugin-proposal-decorators": "^7.4.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.4.0",
"@babel/preset-env": "^7.4.2",
"@babel/runtime": "^7.4.2",
"@vue/babel-preset-jsx": "^1.0.0-beta.2",
"@babel/plugin-transform-runtime": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"@babel/runtime": "^7.4.3",
"@vue/babel-preset-jsx": "^1.0.0-beta.3",
"core-js": "^2.6.5"
},
"publishConfig": {

View File

@ -1,19 +1,39 @@
const defaultPolyfills = [
const coreJsMeta = {
2: {
prefixes: {
es6: 'es6',
es7: 'es7'
},
builtIns: '@babel/preset-env/data/built-ins.json.js'
},
3: {
prefixes: {
es6: 'es',
es7: 'es'
},
builtIns: 'core-js-compat/data'
}
}
function getDefaultPolyfills(corejs) {
const { prefixes: { es6, es7 } } = coreJsMeta[corejs.version]
return [
// Promise polyfill alone doesn't work in IE,
// Needs this as well. see: #1642
'es6.array.iterator',
`${es6}.array.iterator`,
// This is required for webpack code splitting, vuex etc.
'es6.promise',
`${es6}.promise`,
// this is needed for object rest spread support in templates
// as vue-template-es2015-compiler 1.8+ compiles it to Object.assign() calls.
'es6.object.assign',
`${es6}.object.assign`,
// #2012 es7.promise replaces native Promise in FF and causes missing finally
'es7.promise.finally'
`${es7}.promise.finally`
]
}
function getPolyfills(targets, includes, { ignoreBrowserslistConfig, configPath }) {
function getPolyfills(targets, includes, { ignoreBrowserslistConfig, configPath, corejs }) {
const { isPluginRequired } = require('@babel/preset-env')
const builtInsList = require('@babel/preset-env/data/built-ins.json.js')
const builtInsList = require(coreJsMeta[corejs.version].builtIns)
const getTargets = require('@babel/preset-env/lib/targets-parser').default
const builtInTargets = getTargets(targets, {
ignoreBrowserslistConfig,
@ -48,6 +68,12 @@ module.exports = (context, options = {}) => {
absoluteRuntime
} = options
let { corejs = { version: 2 } } = options
if (typeof corejs !== 'object') {
corejs = { version: Number(corejs) }
}
let { targets } = options
if (modern === true) {
targets = { esmodules: true }
@ -57,17 +83,16 @@ module.exports = (context, options = {}) => {
let polyfills
if (modern === false && useBuiltIns === 'usage' && buildTarget === 'client') {
polyfills = getPolyfills(targets, userPolyfills || defaultPolyfills, {
polyfills = getPolyfills(targets, userPolyfills || getDefaultPolyfills(corejs), {
ignoreBrowserslistConfig,
configPath
configPath,
corejs
})
plugins.push([require('./polyfills-plugin'), { polyfills }])
} else {
polyfills = []
}
const corejs = { version: 2 }
// Pass options along to babel-preset-env
presets.push([
require('@babel/preset-env'), {
@ -106,7 +131,7 @@ module.exports = (context, options = {}) => {
regenerator: useBuiltIns !== 'usage',
corejs: useBuiltIns !== false ? false : corejs,
helpers: useBuiltIns === 'usage',
useESModules: true,
useESModules: buildTarget !== 'server',
absoluteRuntime
}])

View File

@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.6.0](https://github.com/nuxt/nuxt.js/compare/v2.5.1...v2.6.0) (2019-04-04)
### Bug Fixes
* fail in case of missing core-js dependency ([#5342](https://github.com/nuxt/nuxt.js/issues/5342)) ([439b914](https://github.com/nuxt/nuxt.js/commit/439b914))
## [2.5.1](https://github.com/nuxt/nuxt.js/compare/v2.5.0...v2.5.1) (2019-03-21)
**Note:** Version bump only for package @nuxt/builder

View File

@ -1,6 +1,6 @@
{
"name": "@nuxt/builder",
"version": "2.5.1",
"version": "2.6.0",
"repository": "nuxt/nuxt.js",
"license": "MIT",
"files": [
@ -9,17 +9,17 @@
"main": "dist/builder.js",
"dependencies": {
"@nuxt/devalue": "^1.2.2",
"@nuxt/utils": "2.5.1",
"@nuxt/vue-app": "2.5.1",
"chokidar": "^2.1.2",
"consola": "^2.5.7",
"@nuxt/utils": "2.6.0",
"@nuxt/vue-app": "2.6.0",
"chokidar": "^2.1.5",
"consola": "^2.5.8",
"fs-extra": "^7.0.1",
"glob": "^7.1.3",
"hash-sum": "^1.0.2",
"ignore": "^5.0.6",
"lodash": "^4.17.11",
"pify": "^4.0.1",
"semver": "^5.6.0",
"semver": "^6.0.0",
"serialize-javascript": "^1.6.1",
"upath": "^1.1.2"
},

View File

@ -222,7 +222,7 @@ export default class Builder {
'Using npm:\n',
`npm i ${dependencyFixes.join(' ')}\n`
)
throw new Error('Missing Template Dependencies')
throw new Error('Missing App Dependencies')
}
}

View File

@ -263,7 +263,7 @@ describe('builder: builder build', () => {
.mockReturnValueOnce({ version: 'alpha' })
.mockReturnValueOnce(undefined)
expect(() => builder.validateTemplate()).toThrow('Missing Template Dependencies')
expect(() => builder.validateTemplate()).toThrow('Missing App Dependencies')
expect(nuxt.resolver.requireModule).toBeCalledTimes(2)
expect(nuxt.resolver.requireModule).nthCalledWith(1, 'join(vue, package.json)')

View File

@ -3,6 +3,19 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.6.0](https://github.com/nuxt/nuxt.js/compare/v2.5.1...v2.6.0) (2019-04-04)
### Features
* **cli:** add `--quiet` option to nuxt generate command ([#5357](https://github.com/nuxt/nuxt.js/issues/5357)) ([91f4eb0](https://github.com/nuxt/nuxt.js/commit/91f4eb0))
* **cli:** add internal _generate and _build options ([#5434](https://github.com/nuxt/nuxt.js/issues/5434)) ([516aea3](https://github.com/nuxt/nuxt.js/commit/516aea3))
* **typescript:** detect typescript based on `tsconfig.json` ([#5412](https://github.com/nuxt/nuxt.js/issues/5412)) ([6ffc5c5](https://github.com/nuxt/nuxt.js/commit/6ffc5c5))
## [2.5.1](https://github.com/nuxt/nuxt.js/compare/v2.5.0...v2.5.1) (2019-03-21)
**Note:** Version bump only for package @nuxt/cli

View File

@ -1,6 +1,6 @@
{
"name": "@nuxt/cli",
"version": "2.5.1",
"version": "2.6.0",
"repository": "nuxt/nuxt.js",
"license": "MIT",
"files": [
@ -12,19 +12,20 @@
"nuxt-cli": "bin/nuxt-cli.js"
},
"dependencies": {
"@nuxt/config": "2.5.1",
"@nuxt/utils": "2.5.1",
"@nuxt/config": "2.6.0",
"@nuxt/utils": "2.6.0",
"boxen": "^3.0.0",
"chalk": "^2.4.2",
"consola": "^2.5.7",
"esm": "^3.2.20",
"consola": "^2.5.8",
"esm": "^3.2.22",
"execa": "^1.0.0",
"exit": "^0.1.2",
"fs-extra": "^7.0.1",
"minimist": "^1.2.0",
"opener": "1.5.1",
"pretty-bytes": "^5.1.0",
"std-env": "^2.2.1",
"wrap-ansi": "^5.0.0"
"wrap-ansi": "^5.1.0"
},
"publishConfig": {
"access": "public"

View File

@ -6,7 +6,7 @@ import { name, version } from '../package.json'
import { loadNuxtConfig, forceExit } from './utils'
import { indent, foldLines, colorize } from './utils/formatting'
import { startSpaces, optionSpaces, forceExitTimeout } from './utils/constants'
import { detectAndSetupTypeScriptSupport } from './utils/typescript'
import { detectTypeScript } from './utils/typescript'
import * as imports from './imports'
export default class NuxtCommand {
@ -92,7 +92,11 @@ export default class NuxtCommand {
async getNuxtConfig(extraOptions = {}) {
const rootDir = path.resolve(this.argv._[0] || '.')
extraOptions._typescript = await detectAndSetupTypeScriptSupport(rootDir, { transpileOnly: this.cmd.name === 'start' })
// Typescript support
extraOptions._typescript = await detectTypeScript(rootDir, {
transpileOnly: this.cmd.name === 'start'
})
const config = await loadNuxtConfig(this.argv)
const options = Object.assign(config, extraOptions)

View File

@ -61,7 +61,7 @@ export default {
}
},
async run(cmd) {
const config = await cmd.getNuxtConfig({ dev: false })
const config = await cmd.getNuxtConfig({ dev: false, _build: true })
const nuxt = await cmd.getNuxt(config)
if (cmd.argv.lock) {

View File

@ -35,7 +35,7 @@ export default {
},
async _startDev(cmd, argv) {
const config = await cmd.getNuxtConfig({ dev: true })
const config = await cmd.getNuxtConfig({ dev: true, _build: true })
const nuxt = await cmd.getNuxt(config)
// Setup hooks

View File

@ -25,6 +25,18 @@ export default {
}
}
},
quiet: {
alias: 'q',
type: 'boolean',
description: 'Disable output except for errors',
prepare(cmd, options, argv) {
// Silence output when using --quiet
options.build = options.build || {}
if (argv.quiet) {
options.build.quiet = true
}
}
},
modern: {
...common.modern,
description: 'Generate app in modern build (modern mode can be only client)',
@ -41,7 +53,7 @@ export default {
}
},
async run(cmd) {
const config = await cmd.getNuxtConfig({ dev: false })
const config = await cmd.getNuxtConfig({ dev: false, _generate: true, _build: cmd.argv.build })
// Disable analyze if set by the nuxt config
if (!config.build) {

View File

@ -29,4 +29,8 @@ export const builder = () => _import('@nuxt/builder')
export const webpack = () => _import('@nuxt/webpack')
export const generator = () => _import('@nuxt/generator')
export const core = () => _import('@nuxt/core')
export const tsNode = () => _import('ts-node')
export const nuxtTypescript = () => _import('@nuxt/typescript')
export const importModule = _import

View File

@ -101,6 +101,10 @@ export function showBanner(nuxt) {
// Running mode
titleLines.push(`Running in ${nuxt.options.dev ? chalk.bold.blue('development') : chalk.bold.green('production')} mode (${chalk.bold(nuxt.options.mode)})`)
if (nuxt.options._typescript && nuxt.options._typescript.runtime) {
titleLines.push(`TypeScript support is ${chalk.green.bold('enabled')}`)
}
// https://nodejs.org/api/process.html#process_process_memoryusage
const { heapUsed, rss } = process.memoryUsage()
titleLines.push(`Memory usage: ${chalk.bold(prettyBytes(heapUsed))} (RSS: ${prettyBytes(rss)})`)

View File

@ -1,38 +1,59 @@
import path from 'path'
import { existsSync } from 'fs'
import chalk from 'chalk'
import consola from 'consola'
import { warningBox } from './formatting'
import fs from 'fs-extra'
import * as imports from '../imports'
const dependencyNotFoundMessage =
`Please install @nuxt/typescript and rerun the command
async function registerTSNode({ tsConfigPath, options }) {
const { register } = await imports.tsNode()
${chalk.bold('Using yarn')}
yarn add -D @nuxt/typescript
${chalk.bold('Using npm')}
npm install -D @nuxt/typescript`
export async function detectAndSetupTypeScriptSupport(rootDir, options = {}) {
const tsConfigPath = path.resolve(rootDir, 'tsconfig.json')
if (!existsSync(tsConfigPath)) {
return false
// https://github.com/TypeStrong/ts-node
register({
project: tsConfigPath,
compilerOptions: {
module: 'commonjs'
},
...options
})
}
consola.info(`${chalk.bold.blue('tsconfig.json')} found, enabling TypeScript runtime support`)
async function getNuxtTypeScript() {
try {
const { setup } = require('@nuxt/typescript')
await setup(tsConfigPath, options)
} catch (e) {
if (e.code === 'MODULE_NOT_FOUND') {
process.stdout.write(warningBox(dependencyNotFoundMessage, chalk.yellow('An external official dependency is needed to enable TS support')))
process.exit(1)
} else {
throw (e)
return await imports.nuxtTypescript()
} catch (error) {
if (error.code !== 'MODULE_NOT_FOUND') {
throw (error)
}
}
}
return true
export async function detectTypeScript(rootDir, options = {}) {
const typescript = {
tsConfigPath: path.resolve(rootDir, 'tsconfig.json'),
tsConfigExists: false,
runtime: false,
build: false,
options
}
// Check if tsconfig.json exists
typescript.tsConfigExists = await fs.exists(typescript.tsConfigPath)
// Skip if tsconfig.json not exists
if (!typescript.tsConfigExists) {
return typescript
}
// Register runtime support
typescript.runtime = true
await registerTSNode(typescript)
// Try to load @nuxt/typescript
const nuxtTypeScript = await getNuxtTypeScript()
// If exists do additional setup
if (nuxtTypeScript) {
typescript.build = true
await nuxtTypeScript.setupDefaults(typescript.tsConfigPath)
}
return typescript
}

View File

@ -0,0 +1,41 @@
import { resolve } from 'path'
import { mkdirp, writeFile, remove } from 'fs-extra'
import { register } from 'ts-node'
import { detectTypeScript } from '../../src/utils/typescript'
jest.mock('ts-node')
describe('Typescript Support', () => {
const rootDir = 'tmp'
const rootDir2 = 'tmp2'
const tsConfigPath = resolve(rootDir, 'tsconfig.json')
beforeAll(async () => {
await mkdirp(rootDir)
await mkdirp(rootDir2)
await writeFile(tsConfigPath, '{}', 'utf-8')
})
test('detectTypeScript detects and registers runtime', async () => {
register.mockReset()
await detectTypeScript(rootDir)
expect(register).toHaveBeenCalledTimes(1)
expect(register).toHaveBeenCalledWith({
project: tsConfigPath,
compilerOptions: {
module: 'commonjs'
}
})
})
test('detectTypeScript skips rootDir without tsconfig.json', async () => {
register.mockReset()
await detectTypeScript(rootDir2)
expect(register).toHaveBeenCalledTimes(0)
})
afterAll(async () => {
await remove(rootDir)
await remove(rootDir2)
})
})

View File

@ -3,6 +3,23 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.6.0](https://github.com/nuxt/nuxt.js/compare/v2.5.1...v2.6.0) (2019-04-04)
### Bug Fixes
* **build:** disable loading `babel.config.js` by default ([#5365](https://github.com/nuxt/nuxt.js/issues/5365)) ([64fa424](https://github.com/nuxt/nuxt.js/commit/64fa424))
* add type definition for configuring forkTsChecker ([2c1444d](https://github.com/nuxt/nuxt.js/commit/2c1444d))
### Features
* **vue-renderer:** add csp meta tags ([#5354](https://github.com/nuxt/nuxt.js/issues/5354)) ([b978a37](https://github.com/nuxt/nuxt.js/commit/b978a37))
## [2.5.1](https://github.com/nuxt/nuxt.js/compare/v2.5.0...v2.5.1) (2019-03-21)

View File

@ -1,6 +1,6 @@
{
"name": "@nuxt/config",
"version": "2.5.1",
"version": "2.6.0",
"repository": "nuxt/nuxt.js",
"license": "MIT",
"files": [
@ -10,8 +10,8 @@
"main": "dist/config.js",
"typings": "types/index.d.ts",
"dependencies": {
"@nuxt/utils": "2.5.1",
"consola": "^2.5.7",
"@nuxt/utils": "2.6.0",
"consola": "^2.5.8",
"std-env": "^2.2.1"
},
"publishConfig": {

View File

@ -79,6 +79,7 @@ export default () => ({
commons: true
},
babel: {
configFile: false,
babelrc: false,
cacheDirectory: undefined
},

View File

@ -3,7 +3,6 @@ import fs from 'fs'
import defaultsDeep from 'lodash/defaultsDeep'
import defaults from 'lodash/defaults'
import pick from 'lodash/pick'
import isObject from 'lodash/isObject'
import uniq from 'lodash/uniq'
import consola from 'consola'
import { guardDir, isNonEmptyString, isPureObject, isUrl, getMainModule } from '@nuxt/utils'
@ -179,16 +178,14 @@ export function getNuxtConfig(_options) {
}
// Apply default hash to CSP option
const { csp } = options.render
const cspDefaults = {
if (options.render.csp) {
options.render.csp = defaults({}, options.render.csp, {
hashAlgorithm: 'sha256',
allowedSources: undefined,
policies: undefined,
addMeta: Boolean(options._generate),
reportOnly: options.debug
}
if (csp) {
options.render.csp = defaults(isObject(csp) ? csp : {}, cspDefaults)
})
}
// cssSourceMap

View File

@ -12,6 +12,7 @@ Object {
"babel": Object {
"babelrc": false,
"cacheDirectory": false,
"configFile": false,
},
"cache": false,
"crossorigin": undefined,

View File

@ -9,6 +9,7 @@ Object {
"babel": Object {
"babelrc": false,
"cacheDirectory": undefined,
"configFile": false,
},
"cache": false,
"crossorigin": undefined,
@ -340,6 +341,7 @@ Object {
"babel": Object {
"babelrc": false,
"cacheDirectory": undefined,
"configFile": false,
},
"cache": false,
"crossorigin": undefined,

View File

@ -81,6 +81,7 @@ describe('config: options', () => {
const { render: { csp } } = getNuxtConfig({ render: { csp: { allowedSources: true, test: true } } })
expect(csp).toEqual({
hashAlgorithm: 'sha256',
addMeta: false,
allowedSources: true,
policies: undefined,
reportOnly: false,
@ -189,9 +190,10 @@ describe('config: options', () => {
})
expect(consola.warn).toHaveBeenCalledWith('@nuxtjs/babel-preset-app has been deprecated, please use @nuxt/babel-preset-app.')
expect(babel).toEqual({
'babelrc': false,
'cacheDirectory': false,
'presets': ['@nuxt/babel-preset-app']
configFile: false,
babelrc: false,
cacheDirectory: false,
presets: ['@nuxt/babel-preset-app']
})
})
@ -200,9 +202,10 @@ describe('config: options', () => {
build: { babel: { presets: [['@nuxt/babel-preset-app', { test: true }]] } }
})
expect(babel).toEqual({
'babelrc': false,
'cacheDirectory': false,
'presets': [['@nuxt/babel-preset-app', { test: true }]]
configFile: false,
babelrc: false,
cacheDirectory: false,
presets: [['@nuxt/babel-preset-app', { test: true }]]
})
})
})

View File

@ -58,6 +58,8 @@ export interface NuxtConfigurationBuild {
templates?: any
terser?: TerserPluginOptions | boolean
transpile?: (string | RegExp)[]
useForkTsChecker?: { [key: string]: string } | boolean // TBD - Couldn't find typedefs for the forkTsCheckerWebpackPlugin options
typescript?: {
typeCheck?: { [key: string]: any } | boolean // TBD - Couldn't find typedefs for the forkTsCheckerWebpackPlugin options
}
watch?: string[]
}

View File

@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.6.0](https://github.com/nuxt/nuxt.js/compare/v2.5.1...v2.6.0) (2019-04-04)
### Reverts
* **core:** call ready to prevent breaking changes ([#5413](https://github.com/nuxt/nuxt.js/issues/5413)) ([001ba77](https://github.com/nuxt/nuxt.js/commit/001ba77))
## [2.5.1](https://github.com/nuxt/nuxt.js/compare/v2.5.0...v2.5.1) (2019-03-21)

View File

@ -1,6 +1,6 @@
{
"name": "@nuxt/core",
"version": "2.5.1",
"version": "2.6.0",
"repository": "nuxt/nuxt.js",
"license": "MIT",
"files": [
@ -8,14 +8,14 @@
],
"main": "dist/core.js",
"dependencies": {
"@nuxt/config": "2.5.1",
"@nuxt/config": "2.6.0",
"@nuxt/devalue": "^1.2.2",
"@nuxt/server": "2.5.1",
"@nuxt/utils": "2.5.1",
"@nuxt/vue-renderer": "2.5.1",
"consola": "^2.5.7",
"@nuxt/server": "2.6.0",
"@nuxt/utils": "2.6.0",
"@nuxt/vue-renderer": "2.6.0",
"consola": "^2.5.8",
"debug": "^4.1.1",
"esm": "^3.2.20",
"esm": "^3.2.22",
"fs-extra": "^7.0.1",
"hash-sum": "^1.0.2",
"std-env": "^2.2.1"

View File

@ -38,6 +38,13 @@ export default class Nuxt extends Hookable {
if (this.options.server !== false) {
this._initServer()
}
// Call ready
if (this.options._ready !== false) {
this.ready().catch((err) => {
consola.fatal(err)
})
}
}
static get version() {
@ -46,9 +53,7 @@ export default class Nuxt extends Hookable {
ready() {
if (!this._ready) {
this._ready = this._init().catch((err) => {
consola.fatal(err)
})
this._ready = this._init()
}
return this._ready
}

View File

@ -1,4 +1,3 @@
import consola from 'consola'
import { defineAlias } from '@nuxt/utils'
import { getNuxtConfig } from '@nuxt/config'
import { Server } from '@nuxt/server'
@ -14,7 +13,9 @@ jest.mock('@nuxt/utils')
jest.mock('@nuxt/server')
jest.mock('@nuxt/config', () => ({
getNuxtConfig: jest.fn(() => ({}))
getNuxtConfig: jest.fn(() => ({
_ready: false
}))
}))
describe('core: nuxt', () => {
@ -67,10 +68,7 @@ describe('core: nuxt', () => {
const err = new Error('nuxt ready failed')
const nuxt = new Nuxt()
nuxt._init = () => Promise.reject(err)
await nuxt.ready()
expect(consola.fatal).toBeCalledTimes(1)
expect(consola.fatal).toBeCalledWith(err)
await expect(nuxt.ready()).rejects.toThrow(err)
})
test('should return nuxt version from package.json', () => {
@ -113,7 +111,7 @@ describe('core: nuxt', () => {
test('should add object hooks', async () => {
const hooks = {}
getNuxtConfig.mockReturnValueOnce({ hooks })
getNuxtConfig.mockReturnValueOnce({ hooks, _ready: false })
const nuxt = new Nuxt()
nuxt.addHooks = jest.fn()

View File

@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.6.0](https://github.com/nuxt/nuxt.js/compare/v2.5.1...v2.6.0) (2019-04-04)
**Note:** Version bump only for package @nuxt/generator
## [2.5.1](https://github.com/nuxt/nuxt.js/compare/v2.5.0...v2.5.1) (2019-03-21)
**Note:** Version bump only for package @nuxt/generator

View File

@ -1,6 +1,6 @@
{
"name": "@nuxt/generator",
"version": "2.5.1",
"version": "2.6.0",
"repository": "nuxt/nuxt.js",
"license": "MIT",
"files": [
@ -8,11 +8,11 @@
],
"main": "dist/generator.js",
"dependencies": {
"@nuxt/utils": "2.5.1",
"@nuxt/utils": "2.6.0",
"chalk": "^2.4.2",
"consola": "^2.5.7",
"consola": "^2.5.8",
"fs-extra": "^7.0.1",
"html-minifier": "^3.5.21"
"html-minifier": "^4.0.0"
},
"publishConfig": {
"access": "public"

View File

@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.6.0](https://github.com/nuxt/nuxt.js/compare/v2.5.1...v2.6.0) (2019-04-04)
**Note:** Version bump only for package @nuxt/server
## [2.5.1](https://github.com/nuxt/nuxt.js/compare/v2.5.0...v2.5.1) (2019-03-21)
**Note:** Version bump only for package @nuxt/server

View File

@ -1,6 +1,6 @@
{
"name": "@nuxt/server",
"version": "2.5.1",
"version": "2.6.0",
"repository": "nuxt/nuxt.js",
"license": "MIT",
"files": [
@ -8,13 +8,13 @@
],
"main": "dist/server.js",
"dependencies": {
"@nuxt/config": "2.5.1",
"@nuxt/utils": "2.5.1",
"@nuxt/config": "2.6.0",
"@nuxt/utils": "2.6.0",
"@nuxtjs/youch": "^4.2.3",
"chalk": "^2.4.2",
"compression": "^1.7.4",
"connect": "^3.6.6",
"consola": "^2.5.7",
"consola": "^2.5.8",
"etag": "^1.8.1",
"fresh": "^0.5.2",
"fs-extra": "^7.0.1",
@ -22,7 +22,7 @@
"launch-editor-middleware": "^2.2.1",
"on-headers": "^1.0.2",
"pify": "^4.0.1",
"semver": "^5.6.0",
"semver": "^6.0.0",
"serve-placeholder": "^1.2.1",
"serve-static": "^1.13.2",
"server-destroy": "^1.0.1",

View File

@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.6.0](https://github.com/nuxt/nuxt.js/compare/v2.5.1...v2.6.0) (2019-04-04)
### Features
* **typescript:** detect typescript based on `tsconfig.json` ([#5412](https://github.com/nuxt/nuxt.js/issues/5412)) ([6ffc5c5](https://github.com/nuxt/nuxt.js/commit/6ffc5c5))
## [2.5.1](https://github.com/nuxt/nuxt.js/compare/v2.5.0...v2.5.1) (2019-03-21)
**Note:** Version bump only for package @nuxt/typescript

View File

@ -1,6 +1,6 @@
{
"name": "@nuxt/typescript",
"version": "2.5.1",
"version": "2.6.0",
"repository": "nuxt/nuxt.js",
"license": "MIT",
"files": [
@ -13,20 +13,19 @@
"@types/etag": "^1.8.0",
"@types/express": "^4.16.1",
"@types/html-minifier": "^3.5.3",
"@types/node": "^11.11.4",
"@types/node": "^11.13.0",
"@types/optimize-css-assets-webpack-plugin": "^1.3.4",
"@types/serve-static": "^1.13.2",
"@types/terser-webpack-plugin": "^1.2.1",
"@types/webpack": "^4.4.26",
"@types/webpack": "^4.4.27",
"@types/webpack-bundle-analyzer": "^2.13.1",
"@types/webpack-dev-middleware": "^2.0.2",
"@types/webpack-hot-middleware": "^2.16.5",
"fork-ts-checker-webpack-plugin": "^1.0.0",
"consola": "^2.5.8",
"fork-ts-checker-webpack-plugin": "^1.0.1",
"fs-extra": "^7.0.1",
"lodash": "^4.17.11",
"ts-loader": "^5.3.3",
"ts-node": "^8.0.3",
"typescript": "^3.3.4000"
"typescript": "^3.4.1"
},
"publishConfig": {
"access": "public"

View File

@ -1,6 +1,5 @@
import { readJSON, writeJSON } from 'fs-extra'
import { register } from 'ts-node'
import defaultsDeep from 'lodash/defaultsDeep'
import { exists, readFile, writeJSON } from 'fs-extra'
import consola from 'consola'
export const defaultTsJsonConfig = {
compilerOptions: {
@ -35,23 +34,15 @@ export const defaultTsJsonConfig = {
}
}
let _setup = false
export async function setupDefaults(tsConfigPath) {
let contents = ''
export async function setup(tsConfigPath, options = {}) {
if (_setup) {
return
if (await exists(tsConfigPath)) {
contents = await readFile(tsConfigPath, 'utf-8')
}
_setup = true
const config = await readJSON(tsConfigPath)
await writeJSON(tsConfigPath, defaultsDeep(config, defaultTsJsonConfig), { spaces: 2 })
// https://github.com/TypeStrong/ts-node
register({
project: tsConfigPath,
compilerOptions: {
module: 'commonjs'
},
...options
})
if (!contents || contents === '{}') {
consola.info(`Generating ${tsConfigPath.replace(process.cwd(), '')}`)
await writeJSON(tsConfigPath, defaultTsJsonConfig, { spaces: 2 })
}
}

View File

@ -1,40 +1,31 @@
import { resolve } from 'path'
import { mkdirp, readJSON, remove, writeJSON } from 'fs-extra'
import { register } from 'ts-node'
import { defaultTsJsonConfig, setup as setupTypeScript } from '@nuxt/typescript'
jest.mock('ts-node')
import { mkdirp, readJSON, writeFile, remove, readFile } from 'fs-extra'
import { defaultTsJsonConfig, setupDefaults } from '@nuxt/typescript'
describe('typescript setup', () => {
const rootDir = 'tmp'
const tsConfigPath = resolve(rootDir, 'tsconfig.json')
beforeAll(async () => {
// We're assuming that rootDir provided to setupTypeScript is existing so we create the tested one
await mkdirp(rootDir)
await writeJSON(tsConfigPath, {})
await setupTypeScript(tsConfigPath)
await writeFile(tsConfigPath, '{}', 'utf-8')
})
test('tsconfig.json has been updated with defaults', async () => {
test('Create tsconfig.json with defaults', async () => {
await setupDefaults(tsConfigPath)
expect(await readJSON(tsConfigPath)).toEqual(defaultTsJsonConfig)
})
test('ts-node has been registered once', async () => {
// Call setupTypeScript a second time to test guard
await setupTypeScript(tsConfigPath)
test('Do not override tsconfig.json', async () => {
const fooJSON = '{ "foo": 123 }'
await writeFile(tsConfigPath, fooJSON, 'utf-8')
expect(register).toHaveBeenCalledTimes(1)
expect(register).toHaveBeenCalledWith({
project: tsConfigPath,
compilerOptions: {
module: 'commonjs'
}
})
await setupDefaults(tsConfigPath)
expect(await readFile(tsConfigPath, 'utf-8')).toEqual(fooJSON)
})
afterAll(async () => {
// Clean workspace by removing the temporary folder (and the generated tsconfig.json at the same time)
await remove(rootDir)
})
})

View File

@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.6.0](https://github.com/nuxt/nuxt.js/compare/v2.5.1...v2.6.0) (2019-04-04)
### Bug Fixes
* **cli:** catch all possible errors thrown from proper-filelock ([#5347](https://github.com/nuxt/nuxt.js/issues/5347)) ([39bbe46](https://github.com/nuxt/nuxt.js/commit/39bbe46))
## [2.5.1](https://github.com/nuxt/nuxt.js/compare/v2.5.0...v2.5.1) (2019-03-21)

View File

@ -1,6 +1,6 @@
{
"name": "@nuxt/utils",
"version": "2.5.1",
"version": "2.6.0",
"repository": "nuxt/nuxt.js",
"license": "MIT",
"files": [
@ -8,10 +8,10 @@
],
"main": "dist/utils.js",
"dependencies": {
"consola": "^2.5.7",
"consola": "^2.5.8",
"fs-extra": "^7.0.1",
"hash-sum": "^1.0.2",
"proper-lockfile": "^4.1.0",
"proper-lockfile": "^4.1.1",
"serialize-javascript": "^1.6.1",
"signal-exit": "^3.0.2"
},

View File

@ -35,16 +35,33 @@ export async function getLockPath(config) {
export async function lock({ id, dir, root, options }) {
const lockPath = await getLockPath({ id, dir, root })
try {
const locked = await properlock.check(lockPath)
if (locked) {
consola.fatal(`A lock with id '${id}' already exists on ${dir}`)
}
} catch (e) {
consola.debug(`Check for an existing lock with id '${id}' on ${dir} failed`, e)
}
let lockWasCompromised = false
let release
try {
options = getLockOptions(options)
const release = await properlock.lock(lockPath, options)
const onCompromised = options.onCompromised
options.onCompromised = (err) => {
onCompromised(err)
lockWasCompromised = true
}
release = await properlock.lock(lockPath, options)
} catch (e) {}
if (!release) {
consola.warn(`Unable to get a lock with id '${id}' on ${dir} (but will continue)`)
return false
}
if (!lockPaths.size) {
@ -59,8 +76,27 @@ export async function lock({ id, dir, root, options }) {
lockPaths.add(lockPath)
return async function lockRelease() {
await release()
try {
await fs.remove(lockPath)
lockPaths.delete(lockPath)
// release as last so the lockPath is still removed
// when it fails on a compromised lock
await release()
} catch (e) {
if (!lockWasCompromised || !e.message.includes('already released')) {
consola.debug(e)
return
}
// proper-lockfile doesnt remove lockDir when lock is compromised
// removing it here could cause the 'other' process to throw an error
// as well, but in our case its much more likely the lock was
// compromised due to mtime update timeouts
const lockDir = `${lockPath}.lock`
if (await fs.exists(lockDir)) {
await fs.remove(lockDir)
}
}
}
}

View File

@ -61,7 +61,7 @@ describe('util: locking', () => {
})
test('lock creates a lock and returns a release fn', async () => {
properlock.lock.mockImplementationOnce(() => true)
properlock.lock.mockReturnValue(true)
const fn = await lock(lockConfig)
@ -75,7 +75,7 @@ describe('util: locking', () => {
})
test('lock throws error when lock already exists', async () => {
properlock.check.mockImplementationOnce(() => true)
properlock.check.mockReturnValue(true)
await lock(lockConfig)
expect(properlock.check).toHaveBeenCalledTimes(1)
@ -84,7 +84,19 @@ describe('util: locking', () => {
})
test('lock logs warning when it couldnt get a lock', async () => {
properlock.lock.mockImplementationOnce(() => false)
properlock.lock.mockReturnValue(false)
const fn = await lock(lockConfig)
expect(fn).toBe(false)
expect(properlock.lock).toHaveBeenCalledTimes(1)
expect(consola.warn).toHaveBeenCalledTimes(1)
expect(consola.warn).toHaveBeenCalledWith(`Unable to get a lock with id '${lockConfig.id}' on ${lockConfig.dir} (but will continue)`)
})
test('lock logs warning when proper.lock threw error', async () => {
properlock.lock.mockImplementation(() => {
throw new Error('test error')
})
await lock(lockConfig)
expect(properlock.lock).toHaveBeenCalledTimes(1)
@ -94,7 +106,7 @@ describe('util: locking', () => {
test('lock returns a release method for unlocking both lockfile as lockPath', async () => {
const release = jest.fn()
properlock.lock.mockImplementationOnce(() => release)
properlock.lock.mockImplementation(() => release)
const fn = await lock(lockConfig)
await fn()
@ -105,7 +117,7 @@ describe('util: locking', () => {
test('lock release also cleansup onExit set', async () => {
const release = jest.fn()
properlock.lock.mockImplementationOnce(() => release)
properlock.lock.mockImplementation(() => release)
const fn = await lock(lockConfig)
expect(lockPaths.size).toBe(1)
@ -114,8 +126,58 @@ describe('util: locking', () => {
expect(lockPaths.size).toBe(0)
})
test('lock release only logs error when error thrown', async () => {
const release = jest.fn(() => {
throw new Error('test error')
})
properlock.lock.mockImplementation(() => release)
const fn = await lock(lockConfig)
await expect(fn()).resolves.not.toThrow()
expect(consola.debug).toHaveBeenCalledTimes(1)
})
test('lock check only logs error when error thrown', async () => {
const testError = new Error('check error')
properlock.lock.mockImplementation(() => () => {})
properlock.check.mockImplementation(() => {
throw testError
})
const fn = await lock(lockConfig)
expect(fn).toEqual(expect.any(Function))
expect(consola.debug).toHaveBeenCalledTimes(1)
expect(consola.debug).toHaveBeenCalledWith(`Check for an existing lock with id '${lockConfig.id}' on ${lockConfig.dir} failed`, testError)
})
test('lock release doesnt log error when error thrown because lock compromised', async () => {
fs.exists.mockReturnValue(true)
const testError = new Error('Lock is already released')
const release = jest.fn(() => {
throw testError
})
properlock.lock.mockImplementation((path, options) => {
options.onCompromised()
return release
})
const fn = await lock({
...lockConfig,
options: {
// overwrite default compromised which calls consola.warn
onCompromised() {}
}
})
await expect(fn()).resolves.not.toThrow()
expect(consola.warn).not.toHaveBeenCalled()
})
test('lock sets exit listener once to remove lockPaths', async () => {
properlock.lock.mockImplementationOnce(() => true)
properlock.lock.mockReturnValue(true)
await lock(lockConfig)
await lock(lockConfig)
@ -124,8 +186,10 @@ describe('util: locking', () => {
})
test('exit listener removes all lockPaths when called', async () => {
properlock.lock.mockReturnValue(true)
let callback
onExit.mockImplementationOnce(cb => (callback = cb))
onExit.mockImplementation(cb => (callback = cb))
const lockConfig2 = Object.assign({}, lockConfig, { id: 'id2' })
@ -145,7 +209,7 @@ describe('util: locking', () => {
})
test('lock uses setLockOptions to set defaults', async () => {
const spy = properlock.lock.mockImplementationOnce(() => true)
const spy = properlock.lock.mockReturnValue(true)
await lock(lockConfig)

View File

@ -3,6 +3,24 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.6.0](https://github.com/nuxt/nuxt.js/compare/v2.5.1...v2.6.0) (2019-04-04)
### Bug Fixes
* **vue-app:** decode uri in `getlocation` ([#5337](https://github.com/nuxt/nuxt.js/issues/5337)) ([77dcfe6](https://github.com/nuxt/nuxt.js/commit/77dcfe6))
* **vue-app:** prevent mounting page twice on redirect ([#5361](https://github.com/nuxt/nuxt.js/issues/5361)) ([2d73e8a](https://github.com/nuxt/nuxt.js/commit/2d73e8a))
* fail in case of missing core-js dependency ([#5342](https://github.com/nuxt/nuxt.js/issues/5342)) ([439b914](https://github.com/nuxt/nuxt.js/commit/439b914))
### Features
* **babel-preset-app:** support specifying core-js version ([#5411](https://github.com/nuxt/nuxt.js/issues/5411)) ([159123f](https://github.com/nuxt/nuxt.js/commit/159123f))
## [2.5.1](https://github.com/nuxt/nuxt.js/compare/v2.5.0...v2.5.1) (2019-03-21)
**Note:** Version bump only for package @nuxt/vue-app

View File

@ -1,6 +1,6 @@
{
"name": "@nuxt/vue-app",
"version": "2.5.1",
"version": "2.6.0",
"repository": "nuxt/nuxt.js",
"license": "MIT",
"files": [
@ -15,7 +15,7 @@
"node-fetch": "^2.3.0",
"unfetch": "^4.1.0",
"vue": "^2.6.10",
"vue-meta": "^1.5.8",
"vue-meta": "^1.6.0",
"vue-no-ssr": "^1.1.1",
"vue-router": "^3.0.2",
"vue-template-compiler": "^2.6.10",

View File

@ -649,6 +649,10 @@ async function mountApp(__app) {
const mount = () => {
_app.$mount('#<%= globals.id %>')
// Add afterEach router hooks
router.afterEach(normalizeComponents)
router.afterEach(fixPrepatch.bind(_app))
// Listen for first Vue update
Vue.nextTick(() => {
// Call window.{{globals.readyCallback}} callbacks
@ -671,11 +675,9 @@ async function mountApp(__app) {
_app.$loading = {} // To avoid error while _app.$nuxt does not exist
if (NUXT.error) _app.error(NUXT.error)
// Add router hooks
// Add beforeEach router hooks
router.beforeEach(loadAsyncComponents.bind(_app))
router.beforeEach(render.bind(_app))
router.afterEach(normalizeComponents)
router.afterEach(fixPrepatch.bind(_app))
// If page already is server rendered
if (NUXT.serverRendered) {
@ -684,20 +686,30 @@ async function mountApp(__app) {
}
// First render on client-side
render.call(_app, router.currentRoute, router.currentRoute, (path) => {
// If not redirected
if (!path) {
const clientFirstMount = () => {
normalizeComponents(router.currentRoute, router.currentRoute)
showNextPage.call(_app, router.currentRoute)
// Don't call fixPrepatch.call(_app, router.currentRoute, router.currentRoute) since it's first render
mount()
}
render.call(_app, router.currentRoute, router.currentRoute, (path) => {
// If not redirected
if (!path) {
clientFirstMount()
return
}
// Push the path and then mount app
router.push(path, () => mount(), (err) => {
if (!err) return mount()
errorHandler(err)
// Add a one-time afterEach hook to
// mount the app wait for redirect and route gets resolved
const unregisterHook = router.afterEach((to, from) => {
unregisterHook()
clientFirstMount()
})
// Push the path and let route to be resolved
router.push(path, undefined, (err) => {
if (err) errorHandler(err)
})
})
}

View File

@ -259,14 +259,14 @@ export function promisify(fn, context) {
// Imported from vue-router
export function getLocation(base, mode) {
let path = window.location.pathname
let path = decodeURI(window.location.pathname)
if (mode === 'hash') {
return window.location.hash.replace(/^#\//, '')
}
if (base && path.indexOf(base) === 0) {
path = path.slice(base.length)
}
return decodeURI(path || '/') + window.location.search + window.location.hash
return (path || '/') + window.location.search + window.location.hash
}
export function urlJoin() {

View File

@ -3,6 +3,24 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.6.0](https://github.com/nuxt/nuxt.js/compare/v2.5.1...v2.6.0) (2019-04-04)
### Bug Fixes
* **builder:** await for renderer to load resources ([#5341](https://github.com/nuxt/nuxt.js/issues/5341)) ([caf5198](https://github.com/nuxt/nuxt.js/commit/caf5198))
* **renderer:** retry render if renderer is in loading or created state ([#5417](https://github.com/nuxt/nuxt.js/issues/5417)) ([8b99695](https://github.com/nuxt/nuxt.js/commit/8b99695))
* **vue-renderer:** add the csp hash if `unsafe-inline` hasn't been specified ([#5387](https://github.com/nuxt/nuxt.js/issues/5387)) ([97db6a4](https://github.com/nuxt/nuxt.js/commit/97db6a4))
### Features
* **vue-renderer:** add csp meta tags ([#5354](https://github.com/nuxt/nuxt.js/issues/5354)) ([b978a37](https://github.com/nuxt/nuxt.js/commit/b978a37))
## [2.5.1](https://github.com/nuxt/nuxt.js/compare/v2.5.0...v2.5.1) (2019-03-21)
**Note:** Version bump only for package @nuxt/vue-renderer

View File

@ -1,6 +1,6 @@
{
"name": "@nuxt/vue-renderer",
"version": "2.5.1",
"version": "2.6.0",
"repository": "nuxt/nuxt.js",
"license": "MIT",
"files": [
@ -9,12 +9,12 @@
"main": "dist/vue-renderer.js",
"dependencies": {
"@nuxt/devalue": "^1.2.2",
"@nuxt/utils": "2.5.1",
"consola": "^2.5.7",
"@nuxt/utils": "2.6.0",
"consola": "^2.5.8",
"fs-extra": "^7.0.1",
"lru-cache": "^5.1.1",
"vue": "^2.6.10",
"vue-meta": "^1.5.8",
"vue-meta": "^1.6.0",
"vue-server-renderer": "^2.6.10"
},
"publishConfig": {

View File

@ -33,6 +33,10 @@ export default class VueRenderer {
spaTemplate: undefined,
errorTemplate: this.parseTemplate('Nuxt.js Internal Server Error')
})
// Default status
this._state = 'created'
this._error = null
}
get assetsMapping() {
@ -120,12 +124,25 @@ export default class VueRenderer {
return context.renderResourceHints()
}
async ready() {
if (this._readyCalled) {
ready() {
if (!this._readyPromise) {
this._state = 'loading'
this._readyPromise = this._ready()
.then(() => {
this._state = 'ready'
return this
})
.catch((error) => {
this._state = 'error'
this._error = error
throw error
})
}
this._readyCalled = true
return this._readyPromise
}
async _ready() {
// Resolve dist path
this.distPath = path.resolve(this.context.options.buildDir, 'dist', 'server')
@ -140,7 +157,7 @@ export default class VueRenderer {
// Try once to load SSR resources from fs
await this.loadResources(fs)
// Without using `nuxt start` (Programmatic, Tests and Generate)
// Without using `nuxt start` (programmatic, tests and generate)
if (!this.context.options._start) {
this.context.nuxt.hook('build:resources', () => this.loadResources(fs))
return
@ -156,8 +173,6 @@ export default class VueRenderer {
`No build files found in ${this.distPath}.\nUse either \`nuxt build\` or \`builder.build()\` or start nuxt in development mode.`
)
}
return this
}
async loadResources(_fs) {
@ -186,7 +201,6 @@ export default class VueRenderer {
// Skip unavailable resources
if (!resource) {
consola.debug('Resource not available:', resourceName)
continue
}
@ -212,9 +226,6 @@ export default class VueRenderer {
this.createRenderer()
}
// Call resourcesLoaded hook
consola.debug('Resources loaded:', updated.join(','))
return this.context.nuxt.callHook('render:resourcesLoaded', this.context.resources)
}
@ -396,17 +407,26 @@ export default class VueRenderer {
APP += `<script>${serializedSession}</script>`
// Calculate CSP hashes
const { csp } = this.context.options.render
const cspScriptSrcHashes = []
if (this.context.options.render.csp) {
const { hashAlgorithm } = this.context.options.render.csp
const hash = crypto.createHash(hashAlgorithm)
if (csp) {
// Only add the hash if 'unsafe-inline' rule isn't present to avoid conflicts (#5387)
const containsUnsafeInlineScriptSrc = csp.policies && csp.policies['script-src'] && csp.policies['script-src'].includes(`'unsafe-inline'`)
if (!containsUnsafeInlineScriptSrc) {
const hash = crypto.createHash(csp.hashAlgorithm)
hash.update(serializedSession)
cspScriptSrcHashes.push(`'${hashAlgorithm}-${hash.digest('base64')}'`)
cspScriptSrcHashes.push(`'${csp.hashAlgorithm}-${hash.digest('base64')}'`)
}
// Call ssr:csp hook
await this.context.nuxt.callHook('vue-renderer:ssr:csp', cspScriptSrcHashes)
// Add csp meta tags
if (csp.addMeta) {
HEAD += `<meta http-equiv="Content-Security-Policy" content="script-src ${cspScriptSrcHashes.join()}">`
}
}
// Prepend scripts
APP += this.renderScripts(context)
APP += m.script.text({ body: true })
@ -437,23 +457,27 @@ export default class VueRenderer {
}
}
_throwNotReadyError() {
const error = new Error()
error.statusCode = 500
if (!this._readyCalled) {
error.message = 'Nuxt is not initialized! `nuxt.ready()` should be called.'
} else {
error.message = `SSR renderer is not initialized! Please check ${this.distPath} existence.`
}
throw error
}
async renderRoute(url, context = {}) {
async renderRoute(url, context = {}, _retried) {
/* istanbul ignore if */
if (!this.isReady) {
// Production
if (!this.context.options.dev) {
return this._throwNotReadyError()
if (!_retried && ['loading', 'created'].includes(this._state)) {
await this.ready()
return this.renderRoute(url, context, true)
}
switch (this._state) {
case 'created':
throw new Error('Renderer ready() is not called! Please ensure `nuxt.ready()` is called and awaited.')
case 'loading':
throw new Error(`Renderer is loading.`)
case 'error':
throw this._error
case 'ready':
throw new Error(`Renderer is loaded but not all resources are unavailable! Please check ${this.distPath} existence.`)
default:
throw new Error('Renderer is in unknown state!')
}
}
// Tell nuxt middleware to render UI
return false

View File

@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.6.0](https://github.com/nuxt/nuxt.js/compare/v2.5.1...v2.6.0) (2019-04-04)
### Bug Fixes
* revert node-externals disabling in dev mode ([#5452](https://github.com/nuxt/nuxt.js/issues/5452)) ([6ce99d2](https://github.com/nuxt/nuxt.js/commit/6ce99d2))
* **webpack:** prefer `main` over `module` field for server config ([#5446](https://github.com/nuxt/nuxt.js/issues/5446)) ([e155ea4](https://github.com/nuxt/nuxt.js/commit/e155ea4))
* disable `node-externals` for dev mode ([#5414](https://github.com/nuxt/nuxt.js/issues/5414)) ([a5a1657](https://github.com/nuxt/nuxt.js/commit/a5a1657))
* memory leak in dev mode ([#5399](https://github.com/nuxt/nuxt.js/issues/5399)) ([04ddcac](https://github.com/nuxt/nuxt.js/commit/04ddcac))
* not override externals set by build.extend ([#5444](https://github.com/nuxt/nuxt.js/issues/5444)) ([1ae4333](https://github.com/nuxt/nuxt.js/commit/1ae4333))
* **builder:** await for renderer to load resources ([#5341](https://github.com/nuxt/nuxt.js/issues/5341)) ([caf5198](https://github.com/nuxt/nuxt.js/commit/caf5198))
## [2.5.1](https://github.com/nuxt/nuxt.js/compare/v2.5.0...v2.5.1) (2019-03-21)
**Note:** Version bump only for package @nuxt/webpack

View File

@ -1,6 +1,6 @@
{
"name": "@nuxt/webpack",
"version": "2.5.1",
"version": "2.6.0",
"repository": "nuxt/nuxt.js",
"license": "MIT",
"files": [
@ -8,19 +8,19 @@
],
"main": "dist/webpack.js",
"dependencies": {
"@babel/core": "^7.4.0",
"@nuxt/babel-preset-app": "2.5.1",
"@babel/core": "^7.4.3",
"@nuxt/babel-preset-app": "2.6.0",
"@nuxt/friendly-errors-webpack-plugin": "^2.4.0",
"@nuxt/utils": "2.5.1",
"@nuxt/utils": "2.6.0",
"babel-loader": "^8.0.5",
"cache-loader": "^2.0.1",
"caniuse-lite": "^1.0.30000951",
"caniuse-lite": "^1.0.30000957",
"chalk": "^2.4.2",
"consola": "^2.5.7",
"consola": "^2.5.8",
"css-loader": "^2.1.1",
"cssnano": "^4.1.10",
"eventsource-polyfill": "^0.9.6",
"extract-css-chunks-webpack-plugin": "^4.0.1",
"extract-css-chunks-webpack-plugin": "^4.3.0",
"file-loader": "^3.0.1",
"fs-extra": "^7.0.1",
"glob": "^7.1.3",
@ -32,7 +32,7 @@
"pify": "^4.0.1",
"postcss": "^7.0.14",
"postcss-import": "^12.0.1",
"postcss-import-resolver": "^1.1.0",
"postcss-import-resolver": "^1.2.2",
"postcss-loader": "^3.0.0",
"postcss-preset-env": "^6.6.0",
"postcss-url": "^8.0.0",
@ -45,7 +45,7 @@
"vue-loader": "^15.7.0",
"webpack": "^4.29.6",
"webpack-bundle-analyzer": "^3.1.0",
"webpack-dev-middleware": "^3.6.1",
"webpack-dev-middleware": "^3.6.2",
"webpack-hot-middleware": "^2.24.3",
"webpack-node-externals": "^1.7.2",
"webpackbar": "^3.1.5"

View File

@ -6,14 +6,10 @@ import webpackDevMiddleware from 'webpack-dev-middleware'
import webpackHotMiddleware from 'webpack-hot-middleware'
import consola from 'consola'
import {
parallel,
sequence,
wrapArray
} from '@nuxt/utils'
import { parallel, sequence, wrapArray } from '@nuxt/utils'
import AsyncMFS from './utils/async-mfs'
import { ClientConfig, ModernConfig, ServerConfig } from './config'
import * as WebpackConfigs from './config'
import PerfLoader from './utils/perf-loader'
const glob = pify(Glob)
@ -37,44 +33,28 @@ export class WebpackBundler {
}
}
getWebpackConfig(name) {
const Config = WebpackConfigs[name] // eslint-disable-line import/namespace
if (!Config) {
throw new Error(`Unsupported webpack config ${name}`)
}
const config = new Config(this)
return config.config()
}
async build() {
const { options } = this.buildContext
const compilersOptions = []
const webpackConfigs = [
this.getWebpackConfig('Client')
]
// Client
const clientConfig = new ClientConfig(this).config()
compilersOptions.push(clientConfig)
// Modern
let modernConfig
if (options.modern) {
modernConfig = new ModernConfig(this).config()
compilersOptions.push(modernConfig)
webpackConfigs.push(this.getWebpackConfig('Modern'))
}
// Server
let serverConfig = null
if (options.build.ssr) {
serverConfig = new ServerConfig(this).config()
compilersOptions.push(serverConfig)
}
for (const p of this.buildContext.plugins) {
// Client config
if (!clientConfig.resolve.alias[p.name]) {
clientConfig.resolve.alias[p.name] = p.mode === 'server' ? './empty.js' : p.src
}
// Modern config
if (modernConfig && !modernConfig.resolve.alias[p.name]) {
modernConfig.resolve.alias[p.name] = p.mode === 'server' ? './empty.js' : p.src
}
// Server config
if (serverConfig && !serverConfig.resolve.alias[p.name]) {
serverConfig.resolve.alias[p.name] = p.mode === 'client' ? './empty.js' : p.src
}
webpackConfigs.push(this.getWebpackConfig('Server'))
}
// Check styleResource existence
@ -96,8 +76,8 @@ export class WebpackBundler {
}
// Configure compilers
this.compilers = compilersOptions.map((compilerOptions) => {
const compiler = webpack(compilerOptions)
this.compilers = webpackConfigs.map((config) => {
const compiler = webpack(config)
// In dev, write files in memory FS
if (options.dev) {
@ -173,6 +153,9 @@ export class WebpackBundler {
// Actual error will be printed by webpack
throw new Error('Nuxt Build Error')
}
// Await for renderer to load resources (programmatic, tests and generate)
await nuxt.callHook('build:resources')
}
async webpackDev(compiler) {

View File

@ -147,6 +147,22 @@ export default class WebpackBaseConfig {
return optimization
}
resolve() {
// Prioritize nested node_modules in webpack search path (#2558)
const webpackModulesDir = ['node_modules'].concat(this.buildContext.options.modulesDir)
return {
resolve: {
extensions: ['.wasm', '.mjs', '.js', '.json', '.vue', '.jsx', '.ts', '.tsx'],
alias: this.alias(),
modules: webpackModulesDir
},
resolveLoader: {
modules: webpackModulesDir
}
}
}
minimizer() {
const minimizer = []
const { terser, cache } = this.buildContext.buildOptions
@ -414,9 +430,6 @@ export default class WebpackBaseConfig {
}
config() {
// Prioritize nested node_modules in webpack search path (#2558)
const webpackModulesDir = ['node_modules'].concat(this.buildContext.options.modulesDir)
const config = {
name: this.name,
mode: this.mode,
@ -427,18 +440,11 @@ export default class WebpackBaseConfig {
maxEntrypointSize: 1000 * 1024,
hints: this.dev ? false : 'warning'
},
resolve: {
extensions: ['.wasm', '.mjs', '.js', '.json', '.vue', '.jsx', '.ts', '.tsx'],
alias: this.alias(),
modules: webpackModulesDir
},
resolveLoader: {
modules: webpackModulesDir
},
module: {
rules: this.rules()
},
plugins: this.plugins()
plugins: this.plugins(),
...this.resolve()
}
// Clone deep avoid leaking config between Client and Server

View File

@ -74,9 +74,22 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
return minimizer
}
alias() {
const aliases = super.alias()
for (const p of this.buildContext.plugins) {
if (!aliases[p.name]) {
// Do not load server-side plugins on client-side
aliases[p.name] = p.mode === 'server' ? './empty.js' : p.src
}
}
return aliases
}
plugins() {
const plugins = super.plugins()
const { buildOptions, options: { appTemplatePath, buildDir, modern, rootDir, _typescript } } = this.buildContext
const { buildOptions, options: { appTemplatePath, buildDir, modern, rootDir, _typescript = {} } } = this.buildContext
// Generate output HTML for SSR
if (buildOptions.ssr) {
@ -139,8 +152,7 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
// TypeScript type checker
// Only performs once per client compilation and only if `ts-loader` checker is not used (transpileOnly: true)
if (_typescript && buildOptions.typescript && buildOptions.typescript.typeCheck && !this.isModern && this.loaders.ts.transpileOnly) {
// We assume that "_typescript" being truthy means @nuxt/typescript is installed <=> fork-ts-checker-webpack-plugin is installed
if (_typescript.build && buildOptions.typescript && buildOptions.typescript.typeCheck && !this.isModern && this.loaders.ts.transpileOnly) {
const ForkTsCheckerWebpackPlugin = require(this.buildContext.nuxt.resolver.resolveModule('fork-ts-checker-webpack-plugin'))
plugins.push(new ForkTsCheckerWebpackPlugin(Object.assign({
vue: true,

View File

@ -1,3 +1,3 @@
export { default as ClientConfig } from './client'
export { default as ModernConfig } from './modern'
export { default as ServerConfig } from './server'
export { default as Client } from './client'
export { default as Modern } from './modern'
export { default as Server } from './server'

View File

@ -28,6 +28,7 @@ export default class WebpackServerConfig extends WebpackBaseConfig {
whitelist.push(new RegExp(escapeRegExp(posixModule)))
}
}
return whitelist
}
@ -52,6 +53,27 @@ export default class WebpackServerConfig extends WebpackBaseConfig {
}
}
resolve() {
const resolveConfig = super.resolve()
resolveConfig.resolve.mainFields = ['main', 'module']
return resolveConfig
}
alias() {
const aliases = super.alias()
for (const p of this.buildContext.plugins) {
if (!aliases[p.name]) {
// Do not load client-side plugins on server-side
aliases[p.name] = p.mode === 'client' ? './empty.js' : p.src
}
}
return aliases
}
plugins() {
const plugins = super.plugins()
plugins.push(
@ -81,7 +103,7 @@ export default class WebpackServerConfig extends WebpackBaseConfig {
maxEntrypointSize: Infinity,
maxAssetSize: Infinity
},
externals: []
externals: [].concat(config.externals || [])
})
// https://webpack.js.org/configuration/externals/#externals

Some files were not shown because too many files have changed in this diff Show More