1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Don't require package.json at runtime (#5321)

* Remove obsolete check in dev-server

* Don’t require package.json at runtime

Inline the Next.js version at publish time, so that there’s no runtime dependency for this
This commit is contained in:
Tim Neutkens 2018-09-28 14:53:28 +02:00 committed by GitHub
parent 7f39aef912
commit 0461413348
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 19 deletions

View file

@ -1,15 +0,0 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-flow"
],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-proposal-class-properties",
["@babel/plugin-transform-runtime", {
"corejs": 2
}]
]
}

18
.babelrc.js Normal file
View file

@ -0,0 +1,18 @@
module.exports = {
'presets': [
'@babel/preset-env',
'@babel/preset-react',
'@babel/preset-flow'
],
'plugins': [
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties',
['@babel/plugin-transform-runtime', {
'corejs': 2
}],
['babel-plugin-transform-define', {
'process.env.NEXT_VERSION': require('./package.json').version
}]
]
}

View file

@ -125,6 +125,7 @@
"@zeit/next-typescript": "1.1.0",
"babel-eslint": "9.0.0",
"babel-jest": "23.4.2",
"babel-plugin-transform-define": "1.3.0",
"benchmark": "2.1.4",
"cheerio": "0.22.0",
"chromedriver": "2.42.0",

View file

@ -17,9 +17,6 @@ import * as asset from '../lib/asset'
import * as envConfig from '../lib/runtime-config'
import { isResSent } from '../lib/utils'
// We need to go up one more level since we are in the `dist` directory
import pkg from '../../package'
export default class Server {
constructor ({ dir = '.', staticMarkup = false, quiet = false, conf = null } = {}) {
this.dir = resolve(dir)
@ -192,7 +189,7 @@ export default class Server {
}
if (this.nextConfig.poweredByHeader) {
res.setHeader('X-Powered-By', `Next.js ${pkg.version}`)
res.setHeader('X-Powered-By', 'Next.js ' + process.env.NEXT_VERSION)
}
return sendHTML(req, res, html, req.method, this.renderOpts)
}