mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-29 23:02:42 +00:00
Merge branch 'dev' of github.com:Atinux/nuxt.js into dev
This commit is contained in:
commit
9a2b4af728
4
bin/nuxt
4
bin/nuxt
@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
// Node Source Map Support
|
|
||||||
// https://github.com/evanw/node-source-map-support
|
|
||||||
require('source-map-support').install()
|
|
||||||
|
|
||||||
const join = require('path').join
|
const join = require('path').join
|
||||||
|
|
||||||
const defaultCommand = 'dev'
|
const defaultCommand = 'dev'
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const parseArgs = require('minimist')
|
const parseArgs = require('minimist')
|
||||||
const { Nuxt, Server } = require('../')
|
const { Nuxt } = require('../')
|
||||||
const { join, resolve } = require('path')
|
const { join, resolve } = require('path')
|
||||||
|
|
||||||
const argv = parseArgs(process.argv.slice(2), {
|
const argv = parseArgs(process.argv.slice(2), {
|
||||||
@ -60,7 +60,7 @@ if (typeof options.rootDir !== 'string') {
|
|||||||
options.dev = false
|
options.dev = false
|
||||||
|
|
||||||
// Check if project is built for production
|
// Check if project is built for production
|
||||||
const distDir = join(options.rootDir, options.buildDir || '.nuxt', 'dist' )
|
const distDir = join(options.rootDir, options.buildDir || '.nuxt', 'dist')
|
||||||
if (!fs.existsSync(join(distDir, 'server-bundle.json'))) {
|
if (!fs.existsSync(join(distDir, 'server-bundle.json'))) {
|
||||||
console.error('> No build files found, please run `nuxt build` before launching `nuxt start`') // eslint-disable-line no-console
|
console.error('> No build files found, please run `nuxt build` before launching `nuxt start`') // eslint-disable-line no-console
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
|
@ -5,7 +5,7 @@ const rollupAlias = require('rollup-plugin-alias')
|
|||||||
const rollupCommonJS = require('rollup-plugin-commonjs')
|
const rollupCommonJS = require('rollup-plugin-commonjs')
|
||||||
const rollupReplace = require('rollup-plugin-replace')
|
const rollupReplace = require('rollup-plugin-replace')
|
||||||
const rollupNodeResolve = require('rollup-plugin-node-resolve')
|
const rollupNodeResolve = require('rollup-plugin-node-resolve')
|
||||||
const packageJson = require('./package.json')
|
const packageJson = require('../package.json')
|
||||||
|
|
||||||
const dependencies = Object.keys(packageJson.dependencies)
|
const dependencies = Object.keys(packageJson.dependencies)
|
||||||
const version = packageJson.version || process.env.VERSION
|
const version = packageJson.version || process.env.VERSION
|
||||||
@ -22,7 +22,7 @@ const banner =
|
|||||||
// -----------------------------
|
// -----------------------------
|
||||||
// Aliases
|
// Aliases
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
const rootDir = resolve(__dirname)
|
const rootDir = resolve(__dirname, '..')
|
||||||
const libDir = resolve(rootDir, 'lib')
|
const libDir = resolve(rootDir, 'lib')
|
||||||
const distDir = resolve(rootDir, 'dist')
|
const distDir = resolve(rootDir, 'dist')
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ const aliases = {
|
|||||||
builder: resolve(libDir, 'builder/index.js'),
|
builder: resolve(libDir, 'builder/index.js'),
|
||||||
common: resolve(libDir, 'common/index.js'),
|
common: resolve(libDir, 'common/index.js'),
|
||||||
utils: resolve(libDir, 'common/utils.js'),
|
utils: resolve(libDir, 'common/utils.js'),
|
||||||
app: resolve(libDir, 'app'),
|
app: resolve(libDir, 'app')
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
@ -45,10 +45,6 @@ const builds = {
|
|||||||
core: {
|
core: {
|
||||||
entry: resolve(libDir, 'core/index.js'),
|
entry: resolve(libDir, 'core/index.js'),
|
||||||
dest: resolve(distDir, 'core.js')
|
dest: resolve(distDir, 'core.js')
|
||||||
},
|
|
||||||
builder: {
|
|
||||||
entry: resolve(libDir, 'builder/index.js'),
|
|
||||||
dest: resolve(distDir, 'builder.js')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,9 +79,9 @@ function genConfig (opts) {
|
|||||||
presets: [
|
presets: [
|
||||||
'babel-preset-es2015-rollup'
|
'babel-preset-es2015-rollup'
|
||||||
],
|
],
|
||||||
"env": {
|
'env': {
|
||||||
"test": {
|
'test': {
|
||||||
"plugins": [ "istanbul" ]
|
'plugins': [ 'istanbul' ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, opts.babel)),
|
}, opts.babel)),
|
92
build/start.js
Executable file
92
build/start.js
Executable file
@ -0,0 +1,92 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const { readFileSync, readJSONSync, writeFileSync, copySync, removeSync } = require('fs-extra')
|
||||||
|
const { resolve, relative } = require('path')
|
||||||
|
|
||||||
|
// Dirs
|
||||||
|
const rootDir = resolve(__dirname, '..')
|
||||||
|
const startDir = resolve(rootDir, 'start')
|
||||||
|
|
||||||
|
// Read main package.json
|
||||||
|
const packageJSON = readJSONSync(resolve(rootDir, 'package.json'))
|
||||||
|
|
||||||
|
// Required and Excluded packages for start
|
||||||
|
let requires = [
|
||||||
|
'source-map-support'
|
||||||
|
]
|
||||||
|
const excludes = [
|
||||||
|
'path',
|
||||||
|
'fs'
|
||||||
|
].concat(Object.keys(packageJSON.devDependencies))
|
||||||
|
|
||||||
|
// Parse dist/core.js for all external dependencies
|
||||||
|
const requireRegex = /require\('([-\w]+)'\)/g
|
||||||
|
const rawCore = readFileSync(resolve(rootDir, 'dist/core.js'))
|
||||||
|
let match = requireRegex.exec(rawCore)
|
||||||
|
while (match) {
|
||||||
|
requires.push(match[1])
|
||||||
|
match = requireRegex.exec(rawCore)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply Excludes
|
||||||
|
requires = requires.filter(r => excludes.indexOf(r) === -1)
|
||||||
|
|
||||||
|
// Resolve version constrains
|
||||||
|
let dependencies = {}
|
||||||
|
requires.forEach(r => {
|
||||||
|
if (!packageJSON.dependencies[r]) {
|
||||||
|
console.warn('cannot resolve dependency version for ' + r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dependencies[r] = packageJSON.dependencies[r]
|
||||||
|
})
|
||||||
|
|
||||||
|
// Drop fields
|
||||||
|
let drops = ['devDependencies', 'scripts', 'nyc', 'types']
|
||||||
|
drops.forEach(k => {
|
||||||
|
delete packageJSON[k]
|
||||||
|
})
|
||||||
|
|
||||||
|
// Update dependencies
|
||||||
|
packageJSON.dependencies = dependencies
|
||||||
|
|
||||||
|
// Update package meta
|
||||||
|
packageJSON.name = 'nuxt-start'
|
||||||
|
packageJSON.description = 'runtime-only build for nuxt'
|
||||||
|
|
||||||
|
// Update package.json
|
||||||
|
writeFileSync(resolve(startDir, 'package.json'), JSON.stringify(packageJSON, null, 2))
|
||||||
|
|
||||||
|
// Copy required files
|
||||||
|
const excludeFiles = [
|
||||||
|
'README.md',
|
||||||
|
'.gitignore'
|
||||||
|
]
|
||||||
|
packageJSON.files.forEach(file => {
|
||||||
|
if (excludeFiles.indexOf(file) !== -1) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let src = resolve(rootDir, file)
|
||||||
|
let dst = resolve(startDir, file)
|
||||||
|
// console.log(relative(rootDir, src), '~>', relative(rootDir, dst))
|
||||||
|
removeSync(dst)
|
||||||
|
copySync(src, dst)
|
||||||
|
})
|
||||||
|
|
||||||
|
// Remove extras
|
||||||
|
const extraFiles = [
|
||||||
|
'bin/nuxt-build',
|
||||||
|
'bin/nuxt-generate',
|
||||||
|
'bin/nuxt-dev',
|
||||||
|
'dist/nuxt.js',
|
||||||
|
'dist/nuxt.js.map'
|
||||||
|
]
|
||||||
|
extraFiles.forEach(file => {
|
||||||
|
removeSync(resolve(startDir, file))
|
||||||
|
})
|
||||||
|
|
||||||
|
// Patch index.js
|
||||||
|
const startIndexjs = resolve(startDir, 'index.js')
|
||||||
|
writeFileSync(startIndexjs, String(readFileSync(startIndexjs)).replace('./dist/nuxt', './dist/core'))
|
||||||
|
|
||||||
|
console.log('generated ' + packageJSON.name + '@' + packageJSON.version)
|
@ -92,8 +92,10 @@ async function createApp (ssrContext) {
|
|||||||
const _nuxt = this._nuxt || this.$options._nuxt
|
const _nuxt = this._nuxt || this.$options._nuxt
|
||||||
_nuxt.dateErr = Date.now()
|
_nuxt.dateErr = Date.now()
|
||||||
_nuxt.err = err
|
_nuxt.err = err
|
||||||
console.error(err)
|
if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
|
||||||
console.error('[nuxt] ' + err)
|
console.error(err)
|
||||||
|
console.error('[nuxt] ' + err)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -43,9 +43,6 @@ export default class Builder extends Tapable {
|
|||||||
// Helper to resolve build paths
|
// Helper to resolve build paths
|
||||||
this.relativeToBuild = (...args) => relativeTo(this.options.buildDir, ...args)
|
this.relativeToBuild = (...args) => relativeTo(this.options.buildDir, ...args)
|
||||||
|
|
||||||
// Call builder plugin on parent nuxt to notify all modules of builder existence
|
|
||||||
this.nuxt.applyPluginsAsync('builder', this).catch(this.nuxt.errorHandler)
|
|
||||||
|
|
||||||
this._buildStatus = STATUS.INITIAL
|
this._buildStatus = STATUS.INITIAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +74,7 @@ export default class Builder extends Tapable {
|
|||||||
// Wait for nuxt ready
|
// Wait for nuxt ready
|
||||||
await this.nuxt.ready()
|
await this.nuxt.ready()
|
||||||
|
|
||||||
await this.applyPluginsAsync('build', this)
|
await this.nuxt.applyPluginsAsync('build', this)
|
||||||
|
|
||||||
// Check if pages dir exists and warn if not
|
// Check if pages dir exists and warn if not
|
||||||
this._nuxtPages = typeof this.options.build.createRoutes !== 'function'
|
this._nuxtPages = typeof this.options.build.createRoutes !== 'function'
|
||||||
|
@ -21,9 +21,6 @@ export default class Generator extends Tapable {
|
|||||||
this.srcBuiltPath = resolve(this.options.buildDir, 'dist')
|
this.srcBuiltPath = resolve(this.options.buildDir, 'dist')
|
||||||
this.distPath = resolve(this.options.rootDir, this.options.generate.dir)
|
this.distPath = resolve(this.options.rootDir, this.options.generate.dir)
|
||||||
this.distNuxtPath = join(this.distPath, (isUrl(this.options.build.publicPath) ? '' : this.options.build.publicPath))
|
this.distNuxtPath = join(this.distPath, (isUrl(this.options.build.publicPath) ? '' : this.options.build.publicPath))
|
||||||
|
|
||||||
// Call generator plugin on parent nuxt to notify all modules of generator existence
|
|
||||||
this.nuxt.applyPluginsAsync('generator', this).catch(this.nuxt.errorHandler)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async generate ({ build = true, init = true } = {}) {
|
async generate ({ build = true, init = true } = {}) {
|
||||||
@ -38,7 +35,7 @@ export default class Generator extends Tapable {
|
|||||||
await this.builder.build()
|
await this.builder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.applyPluginsAsync('beforeGenerate', this)
|
await this.nuxt.applyPluginsAsync('generate', this)
|
||||||
|
|
||||||
// Initialize dist directory
|
// Initialize dist directory
|
||||||
if (init) {
|
if (init) {
|
||||||
|
@ -14,11 +14,11 @@ export default class ModuleContainer extends Tapable {
|
|||||||
this.nuxt = nuxt
|
this.nuxt = nuxt
|
||||||
this.options = nuxt.options
|
this.options = nuxt.options
|
||||||
this.requiredModules = []
|
this.requiredModules = []
|
||||||
|
}
|
||||||
|
|
||||||
this.nuxt.plugin('beforeInit', async () => {
|
async _ready () {
|
||||||
await sequence(this.options.modules, this.addModule.bind(this))
|
await sequence(this.options.modules, this.addModule.bind(this))
|
||||||
await this.applyPluginsAsync('ready', this)
|
await this.nuxt.applyPluginsAsync('module', this)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addVendor (vendor) {
|
addVendor (vendor) {
|
||||||
|
@ -28,7 +28,7 @@ export default class Nuxt extends Tapable {
|
|||||||
this.renderRoute = this.renderer.renderRoute.bind(this.renderer)
|
this.renderRoute = this.renderer.renderRoute.bind(this.renderer)
|
||||||
this.renderAndGetWindow = this.renderer.renderAndGetWindow.bind(this.renderer)
|
this.renderAndGetWindow = this.renderer.renderAndGetWindow.bind(this.renderer)
|
||||||
|
|
||||||
this._ready = this.ready()
|
this._ready = this.ready().catch(this.errorHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
@ -36,10 +36,9 @@ export default class Nuxt extends Tapable {
|
|||||||
return this._ready
|
return this._ready
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for all components to be ready
|
await this.moduleContainer._ready()
|
||||||
await this.applyPluginsAsync('beforeInit') // 1- Modules
|
await this.applyPluginsAsync('ready')
|
||||||
await this.applyPluginsAsync('init') // 2- Builder
|
await this.renderer._ready()
|
||||||
await this.applyPluginsAsync('afterInit') // 3- Renderer
|
|
||||||
|
|
||||||
this.initialized = true
|
this.initialized = true
|
||||||
return this
|
return this
|
||||||
@ -73,6 +72,7 @@ export default class Nuxt extends Tapable {
|
|||||||
|
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Add server.destroy(cb) method
|
// Add server.destroy(cb) method
|
||||||
enableDestroy(server)
|
enableDestroy(server)
|
||||||
})
|
})
|
||||||
|
@ -50,27 +50,9 @@ export default class Renderer extends Tapable {
|
|||||||
// Bind middleware to this context
|
// Bind middleware to this context
|
||||||
this.nuxtMiddleware = this.nuxtMiddleware.bind(this)
|
this.nuxtMiddleware = this.nuxtMiddleware.bind(this)
|
||||||
this.errorMiddleware = this.errorMiddleware.bind(this)
|
this.errorMiddleware = this.errorMiddleware.bind(this)
|
||||||
|
|
||||||
// Initialize
|
|
||||||
/* istanbul ignore if */
|
|
||||||
if (nuxt.initialized) {
|
|
||||||
// If nuxt already initialized
|
|
||||||
this._ready = this.ready().catch(this.nuxt.errorHandler)
|
|
||||||
} else {
|
|
||||||
// Wait for hook
|
|
||||||
this.nuxt.plugin('afterInit', () => {
|
|
||||||
this._ready = this.ready()
|
|
||||||
return this._ready
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async ready () {
|
async _ready () {
|
||||||
/* istanbul ignore if */
|
|
||||||
if (this._ready) {
|
|
||||||
return this._ready
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup all middleWare
|
// Setup all middleWare
|
||||||
await this.setupMiddleware()
|
await this.setupMiddleware()
|
||||||
|
|
||||||
@ -85,7 +67,7 @@ export default class Renderer extends Tapable {
|
|||||||
await this.loadResources()
|
await this.loadResources()
|
||||||
}
|
}
|
||||||
|
|
||||||
return this
|
await this.nuxt.applyPluginsAsync('renderer', this)
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadResources (_fs = fs) {
|
async loadResources (_fs = fs) {
|
||||||
|
43
package.json
43
package.json
@ -52,13 +52,14 @@
|
|||||||
"test": "npm run lint && cross-env NODE_ENV=test npm run build:nuxt && nyc ava --verbose --serial test/ -- && nyc report --reporter=html",
|
"test": "npm run lint && cross-env NODE_ENV=test npm run build:nuxt && nyc ava --verbose --serial test/ -- && nyc report --reporter=html",
|
||||||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
|
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
|
||||||
"lint": "eslint --ext .js,.vue bin lib pages test/*.js --ignore-pattern app",
|
"lint": "eslint --ext .js,.vue bin lib pages test/*.js --ignore-pattern app",
|
||||||
"build": "rimraf dist/ && npm run build:nuxt && npm run build:core && npm run build:builder",
|
"build": "rimraf dist/ && npm run build:nuxt && npm run build:core",
|
||||||
"build:nuxt": "rollup -c rollup.config.js --environment TARGET:nuxt",
|
"build:nuxt": "rollup -c build/rollup.config.js --environment TARGET:nuxt",
|
||||||
"build:core": "rollup -c rollup.config.js --environment TARGET:core",
|
"build:core": "rollup -c build/rollup.config.js --environment TARGET:core",
|
||||||
"build:builder": "rollup -c rollup.config.js --environment TARGET:builder",
|
|
||||||
"watch": "npm run build:nuxt -- -w",
|
"watch": "npm run build:nuxt -- -w",
|
||||||
|
"make-start": "node ./build/start.js",
|
||||||
"precommit": "npm run lint",
|
"precommit": "npm run lint",
|
||||||
"prepublish": "npm run build",
|
"prepublish": "npm run build && npm run make-start",
|
||||||
|
"postpublish": "cd start && npm publish",
|
||||||
"postinstall": "opencollective postinstall"
|
"postinstall": "opencollective postinstall"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@ -75,17 +76,17 @@
|
|||||||
"chalk": "^2.0.1",
|
"chalk": "^2.0.1",
|
||||||
"chokidar": "^1.7.0",
|
"chokidar": "^1.7.0",
|
||||||
"clone": "^2.1.1",
|
"clone": "^2.1.1",
|
||||||
"compression": "^1.6.2",
|
"compression": "^1.7.0",
|
||||||
"connect": "^3.6.2",
|
"connect": "^3.6.2",
|
||||||
"css-loader": "^0.28.4",
|
"css-loader": "^0.28.4",
|
||||||
"debug": "^2.6.8",
|
"debug": "^2.6.8",
|
||||||
"es6-promise": "^4.1.1",
|
"es6-promise": "^4.1.1",
|
||||||
"etag": "^1.8.0",
|
"etag": "^1.8.0",
|
||||||
"extract-text-webpack-plugin": "^2.1.2",
|
"extract-text-webpack-plugin": "^3.0.0",
|
||||||
"file-loader": "^0.11.2",
|
"file-loader": "^0.11.2",
|
||||||
"fresh": "^0.5.0",
|
"fresh": "^0.5.0",
|
||||||
"friendly-errors-webpack-plugin": "^1.6.1",
|
"friendly-errors-webpack-plugin": "^1.6.1",
|
||||||
"fs-extra": "^3.0.1",
|
"fs-extra": "^4.0.0",
|
||||||
"glob": "^7.1.2",
|
"glob": "^7.1.2",
|
||||||
"hash-sum": "^1.0.2",
|
"hash-sum": "^1.0.2",
|
||||||
"html-minifier": "^3.5.2",
|
"html-minifier": "^3.5.2",
|
||||||
@ -93,34 +94,34 @@
|
|||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"memory-fs": "^0.4.1",
|
"memory-fs": "^0.4.1",
|
||||||
"minimist": "^1.2.0",
|
"minimist": "^1.2.0",
|
||||||
"offline-plugin": "^4.8.1",
|
"offline-plugin": "^4.8.3",
|
||||||
"opencollective": "^1.0.3",
|
"opencollective": "^1.0.3",
|
||||||
"pify": "^3.0.0",
|
"pify": "^3.0.0",
|
||||||
"preload-webpack-plugin": "^1.2.2",
|
"preload-webpack-plugin": "^1.2.2",
|
||||||
"progress-bar-webpack-plugin": "^1.9.3",
|
"progress-bar-webpack-plugin": "^1.10.0",
|
||||||
"script-ext-html-webpack-plugin": "^1.8.3",
|
"script-ext-html-webpack-plugin": "^1.8.3",
|
||||||
"serialize-javascript": "^1.3.0",
|
"serialize-javascript": "^1.3.0",
|
||||||
"serve-static": "^1.12.3",
|
"serve-static": "^1.12.3",
|
||||||
"source-map-support": "^0.4.15",
|
"source-map-support": "^0.4.15",
|
||||||
"tapable": "^0.2.6",
|
"tapable": "^0.2.6",
|
||||||
"tappable": "^1.0.1",
|
"tappable": "^1.1.0",
|
||||||
"url-loader": "^0.5.9",
|
"url-loader": "^0.5.9",
|
||||||
"vue": "~2.3.4",
|
"vue": "~2.4.1",
|
||||||
"vue-loader": "^13.0.0",
|
"vue-loader": "^13.0.1",
|
||||||
"vue-meta": "^1.0.4",
|
"vue-meta": "^1.0.4",
|
||||||
"vue-router": "^2.7.0",
|
"vue-router": "^2.7.0",
|
||||||
"vue-server-renderer": "~2.3.4",
|
"vue-server-renderer": "~2.4.1",
|
||||||
"vue-ssr-html-stream": "^2.2.0",
|
"vue-ssr-html-stream": "^2.2.0",
|
||||||
"vue-template-compiler": "~2.3.4",
|
"vue-template-compiler": "~2.4.1",
|
||||||
"vuex": "^2.3.1",
|
"vuex": "^2.3.1",
|
||||||
"webpack": "^3.0.0",
|
"webpack": "^3.3.0",
|
||||||
"webpack-bundle-analyzer": "^2.8.2",
|
"webpack-bundle-analyzer": "^2.8.2",
|
||||||
"webpack-dev-middleware": "^1.11.0",
|
"webpack-dev-middleware": "^1.11.0",
|
||||||
"webpack-hot-middleware": "^2.18.1",
|
"webpack-hot-middleware": "^2.18.1",
|
||||||
"webpack-node-externals": "^1.6.0"
|
"webpack-node-externals": "^1.6.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"ava": "^0.20.0",
|
"ava": "^0.21.0",
|
||||||
"babel-eslint": "^7.2.3",
|
"babel-eslint": "^7.2.3",
|
||||||
"babel-plugin-array-includes": "^2.0.3",
|
"babel-plugin-array-includes": "^2.0.3",
|
||||||
"babel-plugin-istanbul": "^4.1.4",
|
"babel-plugin-istanbul": "^4.1.4",
|
||||||
@ -131,9 +132,9 @@
|
|||||||
"codecov": "^2.2.0",
|
"codecov": "^2.2.0",
|
||||||
"copy-webpack-plugin": "^4.0.1",
|
"copy-webpack-plugin": "^4.0.1",
|
||||||
"cross-env": "^5.0.1",
|
"cross-env": "^5.0.1",
|
||||||
"eslint": "^4.1.1",
|
"eslint": "^4.2.0",
|
||||||
"eslint-config-standard": "^10.2.1",
|
"eslint-config-standard": "^10.2.1",
|
||||||
"eslint-plugin-html": "^3.0.0",
|
"eslint-plugin-html": "^3.1.0",
|
||||||
"eslint-plugin-import": "^2.6.1",
|
"eslint-plugin-import": "^2.6.1",
|
||||||
"eslint-plugin-node": "^5.1.0",
|
"eslint-plugin-node": "^5.1.0",
|
||||||
"eslint-plugin-promise": "^3.5.0",
|
"eslint-plugin-promise": "^3.5.0",
|
||||||
@ -145,13 +146,13 @@
|
|||||||
"request": "^2.81.0",
|
"request": "^2.81.0",
|
||||||
"request-promise-native": "^1.0.4",
|
"request-promise-native": "^1.0.4",
|
||||||
"rimraf": "^2.6.1",
|
"rimraf": "^2.6.1",
|
||||||
"rollup": "^0.43.0",
|
"rollup": "^0.45.2",
|
||||||
"rollup-plugin-alias": "^1.3.1",
|
"rollup-plugin-alias": "^1.3.1",
|
||||||
"rollup-plugin-babel": "^2.7.1",
|
"rollup-plugin-babel": "^2.7.1",
|
||||||
"rollup-plugin-commonjs": "^8.0.2",
|
"rollup-plugin-commonjs": "^8.0.2",
|
||||||
"rollup-plugin-node-resolve": "^3.0.0",
|
"rollup-plugin-node-resolve": "^3.0.0",
|
||||||
"rollup-plugin-replace": "^1.1.1",
|
"rollup-plugin-replace": "^1.1.1",
|
||||||
"rollup-watch": "^4.0.0",
|
"rollup-watch": "^4.3.1",
|
||||||
"server-destroy": "^1.0.1",
|
"server-destroy": "^1.0.1",
|
||||||
"std-mocks": "^1.0.1",
|
"std-mocks": "^1.0.1",
|
||||||
"uglify-js": "^3.0.23"
|
"uglify-js": "^3.0.23"
|
||||||
|
6
start/.gitignore
vendored
6
start/.gitignore
vendored
@ -1,3 +1,3 @@
|
|||||||
bin
|
*
|
||||||
dist
|
!README.md
|
||||||
lib
|
!package.json
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "nuxt-start",
|
"name": "nuxt-start",
|
||||||
"version": "0.0.0",
|
"version": "1.0.0-alpha.4",
|
||||||
"description": "A minimalistic framework for server-rendered Vue.js applications (inspired by Next.js)",
|
"description": "runtime-only build for nuxt",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
{
|
{
|
||||||
"name": "Sebastien Chopin (@Atinux)"
|
"name": "Sebastien Chopin (@Atinux)"
|
||||||
@ -23,6 +23,7 @@
|
|||||||
"bin",
|
"bin",
|
||||||
"dist",
|
"dist",
|
||||||
"lib",
|
"lib",
|
||||||
|
"index.d.ts",
|
||||||
"index.js"
|
"index.js"
|
||||||
],
|
],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@ -37,35 +38,35 @@
|
|||||||
"vue isomorphic",
|
"vue isomorphic",
|
||||||
"vue versatile"
|
"vue versatile"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/nuxt/nuxt.js/start#readme",
|
"homepage": "https://github.com/nuxt/nuxt.js#readme",
|
||||||
"bin": {
|
"bin": {
|
||||||
"nuxt": "./bin/nuxt"
|
"nuxt": "./bin/nuxt"
|
||||||
},
|
},
|
||||||
"scripts": {
|
|
||||||
"build": "rm -rf bin/* dist/* lib/* && cd .. && npm run build && cp -r bin dist lib start",
|
|
||||||
"prepublish": "npm run build"
|
|
||||||
},
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4.3.0 <5.0.0 || >=5.10",
|
"node": ">=4.3.0 <5.0.0 || >=5.10",
|
||||||
"npm": ">=3.0.0"
|
"npm": ">=3.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ansi-html": "^0.0.7",
|
"source-map-support": "^0.4.15",
|
||||||
"chalk": "^1.1.3",
|
"lodash": "^4.17.4",
|
||||||
"compression": "^1.6.2",
|
"hash-sum": "^1.0.2",
|
||||||
"connect": "^3.6.2",
|
"tappable": "^1.0.1",
|
||||||
"debug": "^2.6.8",
|
"debug": "^2.6.8",
|
||||||
|
"chalk": "^2.0.1",
|
||||||
|
"ansi-html": "^0.0.7",
|
||||||
|
"serialize-javascript": "^1.3.0",
|
||||||
"etag": "^1.8.0",
|
"etag": "^1.8.0",
|
||||||
"fresh": "^0.5.0",
|
"fresh": "^0.5.0",
|
||||||
"fs-extra": "^3.0.1",
|
|
||||||
"hash-sum": "^1.0.2",
|
|
||||||
"lodash": "^4.17.4",
|
|
||||||
"minimist": "^1.2.0",
|
|
||||||
"pify": "^3.0.0",
|
"pify": "^3.0.0",
|
||||||
"serialize-javascript": "^1.3.0",
|
|
||||||
"serve-static": "^1.12.3",
|
"serve-static": "^1.12.3",
|
||||||
"source-map-support": "^0.4.15",
|
"compression": "^1.7.0",
|
||||||
"tappable": "^1.0.1",
|
"fs-extra": "^3.0.1",
|
||||||
"vue-server-renderer": "~2.3.4"
|
"vue-server-renderer": "~2.4.1",
|
||||||
|
"connect": "^3.6.2"
|
||||||
|
},
|
||||||
|
"collective": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/nuxtjs",
|
||||||
|
"logo": "https://opencollective.com/nuxtjs/logo.txt?reverse=true&variant=variant2"
|
||||||
}
|
}
|
||||||
}
|
}
|
18
test/fixtures/module/modules/tapable/index.js
vendored
Normal file
18
test/fixtures/module/modules/tapable/index.js
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
module.exports = function () {
|
||||||
|
let ctr = 1
|
||||||
|
|
||||||
|
// Add hook for module
|
||||||
|
this.nuxt.plugin('module', moduleContainer => {
|
||||||
|
this.nuxt.__module_hook = moduleContainer && ctr++
|
||||||
|
})
|
||||||
|
|
||||||
|
// Add hook for renderer
|
||||||
|
this.nuxt.plugin('renderer', renderer => {
|
||||||
|
this.nuxt.__renderer_hook = renderer && ctr++
|
||||||
|
})
|
||||||
|
|
||||||
|
// Add hook for build
|
||||||
|
this.nuxt.plugin('build', builder => {
|
||||||
|
this.nuxt.__builder_hook = builder && ctr++
|
||||||
|
})
|
||||||
|
}
|
@ -3,6 +3,7 @@ const path = require('path')
|
|||||||
module.exports = function () {
|
module.exports = function () {
|
||||||
// Disable parsing pages/
|
// Disable parsing pages/
|
||||||
this.nuxt.options.build.createRoutes = () => {}
|
this.nuxt.options.build.createRoutes = () => {}
|
||||||
|
|
||||||
// Add /api endpoint
|
// Add /api endpoint
|
||||||
this.addTemplate({
|
this.addTemplate({
|
||||||
fileName: 'router.js',
|
fileName: 'router.js',
|
||||||
|
3
test/fixtures/module/nuxt.config.js
vendored
3
test/fixtures/module/nuxt.config.js
vendored
@ -1,7 +1,8 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
loading: true,
|
loading: true,
|
||||||
modules: [
|
modules: [
|
||||||
'~/modules/basic', // Use ~ for deprication warning coverage
|
'~/modules/basic',
|
||||||
|
'~/modules/tapable',
|
||||||
{
|
{
|
||||||
src: '~/modules/middleware',
|
src: '~/modules/middleware',
|
||||||
options: {
|
options: {
|
||||||
|
@ -37,6 +37,12 @@ test('Middleware', async t => {
|
|||||||
t.is(response, 'It works!', '/api response is correct')
|
t.is(response, 'It works!', '/api response is correct')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('Tapable', async t => {
|
||||||
|
t.is(nuxt.__module_hook, 1)
|
||||||
|
t.is(nuxt.__renderer_hook, 2)
|
||||||
|
t.is(nuxt.__builder_hook, 3)
|
||||||
|
})
|
||||||
|
|
||||||
// Close server and ask nuxt to stop listening to file changes
|
// Close server and ask nuxt to stop listening to file changes
|
||||||
test.after('Closing server and nuxt.js', t => {
|
test.after('Closing server and nuxt.js', t => {
|
||||||
nuxt.close()
|
nuxt.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user