diff --git a/.babelrc b/.babelrc deleted file mode 100644 index f42ee73a..00000000 --- a/.babelrc +++ /dev/null @@ -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 - }] - ] -} diff --git a/.babelrc.js b/.babelrc.js new file mode 100644 index 00000000..8865de5d --- /dev/null +++ b/.babelrc.js @@ -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 + }] + ] +} diff --git a/package.json b/package.json index 32617578..44c87623 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/server/index.js b/server/index.js index d5b02c9a..04de276a 100644 --- a/server/index.js +++ b/server/index.js @@ -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) }