@nuxt/server
Advanced tools
Comparing version 2.14.1 to 2.14.2
/*! | ||
* @nuxt/server v2.14.1 (c) 2016-2020 | ||
* @nuxt/server v2.14.2 (c) 2016-2020 | ||
@@ -12,40 +12,59 @@ * - All the amazing contributors | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
const path = require('path'); | ||
const consola = require('consola'); | ||
const launchMiddleware = require('launch-editor-middleware'); | ||
const serveStatic = require('serve-static'); | ||
const servePlaceholder = require('serve-placeholder'); | ||
const connect = require('connect'); | ||
const utils = require('@nuxt/utils'); | ||
const generateETag = require('etag'); | ||
const fresh = require('fresh'); | ||
const fs = require('fs-extra'); | ||
const Youch = require('@nuxtjs/youch'); | ||
const http = require('http'); | ||
const https = require('https'); | ||
const enableDestroy = require('server-destroy'); | ||
const ip = require('ip'); | ||
const pify = require('pify'); | ||
const onHeaders = require('on-headers'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
function _interopNamespace(e) { | ||
if (e && e.__esModule) { return e; } else { | ||
var n = {}; | ||
var n = Object.create(null); | ||
if (e) { | ||
Object.keys(e).forEach(function (k) { | ||
var d = Object.getOwnPropertyDescriptor(e, k); | ||
Object.defineProperty(n, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { | ||
return e[k]; | ||
} | ||
}); | ||
if (k !== 'default') { | ||
var d = Object.getOwnPropertyDescriptor(e, k); | ||
Object.defineProperty(n, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { | ||
return e[k]; | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
n['default'] = e; | ||
return n; | ||
return Object.freeze(n); | ||
} | ||
} | ||
const path = _interopDefault(require('path')); | ||
const consola = _interopDefault(require('consola')); | ||
const launchMiddleware = _interopDefault(require('launch-editor-middleware')); | ||
const serveStatic = _interopDefault(require('serve-static')); | ||
const servePlaceholder = _interopDefault(require('serve-placeholder')); | ||
const connect = _interopDefault(require('connect')); | ||
const utils = require('@nuxt/utils'); | ||
const generateETag = _interopDefault(require('etag')); | ||
const fresh = _interopDefault(require('fresh')); | ||
const fs = _interopDefault(require('fs-extra')); | ||
const Youch = _interopDefault(require('@nuxtjs/youch')); | ||
const http = _interopDefault(require('http')); | ||
const https = _interopDefault(require('https')); | ||
const enableDestroy = _interopDefault(require('server-destroy')); | ||
const ip = _interopDefault(require('ip')); | ||
const pify = _interopDefault(require('pify')); | ||
const onHeaders = _interopDefault(require('on-headers')); | ||
const path__default = /*#__PURE__*/_interopDefaultLegacy(path); | ||
const consola__default = /*#__PURE__*/_interopDefaultLegacy(consola); | ||
const launchMiddleware__default = /*#__PURE__*/_interopDefaultLegacy(launchMiddleware); | ||
const serveStatic__default = /*#__PURE__*/_interopDefaultLegacy(serveStatic); | ||
const servePlaceholder__default = /*#__PURE__*/_interopDefaultLegacy(servePlaceholder); | ||
const connect__default = /*#__PURE__*/_interopDefaultLegacy(connect); | ||
const generateETag__default = /*#__PURE__*/_interopDefaultLegacy(generateETag); | ||
const fresh__default = /*#__PURE__*/_interopDefaultLegacy(fresh); | ||
const fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); | ||
const Youch__default = /*#__PURE__*/_interopDefaultLegacy(Youch); | ||
const http__default = /*#__PURE__*/_interopDefaultLegacy(http); | ||
const https__default = /*#__PURE__*/_interopDefaultLegacy(https); | ||
const enableDestroy__default = /*#__PURE__*/_interopDefaultLegacy(enableDestroy); | ||
const ip__default = /*#__PURE__*/_interopDefaultLegacy(ip); | ||
const pify__default = /*#__PURE__*/_interopDefaultLegacy(pify); | ||
const onHeaders__default = /*#__PURE__*/_interopDefaultLegacy(onHeaders); | ||
@@ -70,6 +89,6 @@ class ServerContext { | ||
) { | ||
const jsdom = await Promise.resolve().then(function () { return _interopNamespace(require('jsdom')); }) | ||
const jsdom = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('jsdom')); }) | ||
.then(m => m.default || m) | ||
.catch((e) => { | ||
consola.error(` | ||
consola__default['default'].error(` | ||
jsdom is not installed. Please install jsdom with: | ||
@@ -100,3 +119,3 @@ $ yarn add --dev jsdom | ||
if (options.virtualConsole === true) { | ||
options.virtualConsole = new jsdom.VirtualConsole().sendTo(consola); | ||
options.virtualConsole = new jsdom.VirtualConsole().sendTo(consola__default['default']); | ||
} | ||
@@ -168,4 +187,4 @@ // Throw error when window creation failed | ||
const { hash } = options.render.etag; | ||
const etag = hash ? hash(html, options.render.etag) : generateETag(html, options.render.etag); | ||
if (fresh(req.headers, { etag })) { | ||
const etag = hash ? hash(html, options.render.etag) : generateETag__default['default'](html, options.render.etag); | ||
if (fresh__default['default'](req.headers, { etag })) { | ||
res.statusCode = 304; | ||
@@ -217,3 +236,3 @@ await nuxt.callHook('render:beforeResponse', url, result, context); | ||
if (context && context.redirected) { | ||
consola.error(err); | ||
consola__default['default'].error(err); | ||
return err | ||
@@ -231,3 +250,3 @@ } | ||
if (shouldPush && options.dev) { | ||
consola.warn('http2.shouldPush is deprecated. Use http2.pushAssets function'); | ||
consola__default['default'].warn('http2.shouldPush is deprecated. Use http2.pushAssets function'); | ||
} | ||
@@ -320,3 +339,3 @@ | ||
if (error.statusCode !== 404) { | ||
consola.error(error); | ||
consola__default['default'].error(error); | ||
} | ||
@@ -340,3 +359,3 @@ | ||
// Show stack trace | ||
const youch = new Youch( | ||
const youch = new Youch__default['default']( | ||
error, | ||
@@ -376,3 +395,3 @@ req, | ||
rootDir, | ||
path.join(buildDir, 'dist', 'server'), | ||
path__default['default'].join(buildDir, 'dist', 'server'), | ||
buildDir, | ||
@@ -384,4 +403,4 @@ process.cwd() | ||
for (const dir of searchPath) { | ||
const fullPath = path.resolve(dir, fileName); | ||
if (fs.existsSync(fullPath)) { | ||
const fullPath = path__default['default'].resolve(dir, fileName); | ||
if (fs__default['default'].existsSync(fullPath)) { | ||
return fullPath | ||
@@ -409,5 +428,5 @@ } | ||
async function readSource (frame) { | ||
if (fs.existsSync(frame.fileName)) { | ||
if (fs__default['default'].existsSync(frame.fileName)) { | ||
frame.fullPath = frame.fileName; // Youch BW compat | ||
frame.contents = await fs.readFile(frame.fileName, 'utf-8'); | ||
frame.contents = await fs__default['default'].readFile(frame.fileName, 'utf-8'); | ||
} | ||
@@ -441,3 +460,3 @@ } | ||
await this.server.destroy(); | ||
consola.debug('server closed'); | ||
consola__default['default'].debug('server closed'); | ||
} | ||
@@ -458,3 +477,3 @@ | ||
case '127.0.0.1': this.host = 'localhost'; break | ||
case '0.0.0.0': this.host = ip.address(); break | ||
case '0.0.0.0': this.host = ip__default['default'].address(); break | ||
} | ||
@@ -475,3 +494,3 @@ this.port = address.port; | ||
// Initialize underlying http(s) server | ||
const protocol = this.https ? https : http; | ||
const protocol = this.https ? https__default['default'] : http__default['default']; | ||
const protocolOpts = this.https ? [this.https] : []; | ||
@@ -496,4 +515,4 @@ this._server = protocol.createServer.apply(protocol, protocolOpts.concat(this.app)); | ||
// Enable destroy support | ||
enableDestroy(this.server); | ||
pify(this.server.destroy); | ||
enableDestroy__default['default'](this.server); | ||
pify__default['default'](this.server.destroy); | ||
@@ -518,4 +537,4 @@ // Compute listen URL | ||
if (this.dev && !this.socket && this.port !== RANDOM_PORT) { | ||
consola.warn(error.message); | ||
consola.info('Trying a random port...'); | ||
consola__default['default'].warn(error.message); | ||
consola__default['default'].info('Trying a random port...'); | ||
this.port = RANDOM_PORT; | ||
@@ -536,3 +555,3 @@ await this.close(); | ||
if (res.timing) { | ||
consola.warn('server-timing is already registered.'); | ||
consola__default['default'].warn('server-timing is already registered.'); | ||
} | ||
@@ -545,3 +564,3 @@ res.timing = new ServerTiming(); | ||
onHeaders(res, () => { | ||
onHeaders__default['default'](res, () => { | ||
res.timing.end('total'); | ||
@@ -607,3 +626,3 @@ | ||
// Create new connect instance | ||
this.app = connect(); | ||
this.app = connect__default['default'](); | ||
@@ -630,3 +649,3 @@ // Close hook | ||
// Initialize vue-renderer | ||
const { VueRenderer } = await Promise.resolve().then(function () { return _interopNamespace(require('@nuxt/vue-renderer')); }); | ||
const { VueRenderer } = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@nuxt/vue-renderer')); }); | ||
@@ -668,4 +687,4 @@ this.serverContext = new ServerContext(this); | ||
// For serving static/ files to / | ||
const staticMiddleware = serveStatic( | ||
path.resolve(this.options.srcDir, this.options.dir.static), | ||
const staticMiddleware = serveStatic__default['default']( | ||
path__default['default'].resolve(this.options.srcDir, this.options.dir.static), | ||
this.options.render.static | ||
@@ -679,6 +698,6 @@ ); | ||
if (!this.options.dev) { | ||
const distDir = path.resolve(this.options.buildDir, 'dist', 'client'); | ||
const distDir = path__default['default'].resolve(this.options.buildDir, 'dist', 'client'); | ||
this.useMiddleware({ | ||
path: this.publicPath, | ||
handler: serveStatic( | ||
handler: serveStatic__default['default']( | ||
distDir, | ||
@@ -703,3 +722,3 @@ this.options.render.dist | ||
path: '__open-in-editor', | ||
handler: launchMiddleware(this.options.editor) | ||
handler: launchMiddleware__default['default'](this.options.editor) | ||
}); | ||
@@ -721,3 +740,3 @@ } | ||
path: this.publicPath, | ||
handler: servePlaceholder(fallback.dist) | ||
handler: servePlaceholder__default['default'](fallback.dist) | ||
}); | ||
@@ -730,3 +749,3 @@ } | ||
path: '/', | ||
handler: servePlaceholder(fallback.static) | ||
handler: servePlaceholder__default['default'](fallback.static) | ||
}); | ||
@@ -813,3 +832,3 @@ } | ||
// Show full error | ||
consola.error('ServerMiddleware Error:', error); | ||
consola__default['default'].error('ServerMiddleware Error:', error); | ||
@@ -816,0 +835,0 @@ // Placeholder for error |
{ | ||
"name": "@nuxt/server", | ||
"version": "2.14.1", | ||
"version": "2.14.2", | ||
"repository": "nuxt/nuxt.js", | ||
@@ -11,5 +11,5 @@ "license": "MIT", | ||
"dependencies": { | ||
"@nuxt/config": "2.14.1", | ||
"@nuxt/utils": "2.14.1", | ||
"@nuxt/vue-renderer": "2.14.1", | ||
"@nuxt/config": "2.14.2", | ||
"@nuxt/utils": "2.14.2", | ||
"@nuxt/vue-renderer": "2.14.2", | ||
"@nuxtjs/youch": "^4.2.3", | ||
@@ -19,3 +19,3 @@ "chalk": "^3.0.0", | ||
"connect": "^3.7.0", | ||
"consola": "^2.14.0", | ||
"consola": "^2.15.0", | ||
"etag": "^1.8.1", | ||
@@ -22,0 +22,0 @@ "fresh": "^0.5.2", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29435
804
+ Added@nuxt/config@2.14.2(transitive)
+ Added@nuxt/utils@2.14.2(transitive)
+ Added@nuxt/vue-renderer@2.14.2(transitive)
+ Addedpostcss@8.4.47(transitive)
- Removed@nuxt/config@2.14.1(transitive)
- Removed@nuxt/utils@2.14.1(transitive)
- Removed@nuxt/vue-renderer@2.14.1(transitive)
- Removedpostcss@8.4.48(transitive)
Updated@nuxt/config@2.14.2
Updated@nuxt/utils@2.14.2
Updated@nuxt/vue-renderer@2.14.2
Updatedconsola@^2.15.0