From d6c7050816ca364aa42cf82a4b583c2fa7086f9a Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Tue, 4 Sep 2018 17:30:01 +0200 Subject: [PATCH] Remove module.exports from client bundles (#5093) Removes `module.exports` so that `module` is no longer required Ref: https://github.com/zeit/next.js/pull/4943#discussion_r213232263 This saves 15 bytes from every client bundle + 9 bytes from the initial HTML. --- build/webpack.js | 2 +- server/document.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/build/webpack.js b/build/webpack.js index 746ceb62..4efaafad 100644 --- a/build/webpack.js +++ b/build/webpack.js @@ -185,7 +185,7 @@ export default async function getBaseWebpackConfig (dir: string, {dev = false, i } return '[name]' }, - libraryTarget: 'commonjs2', + libraryTarget: isServer ? 'commonjs2' : 'jsonp', hotUpdateChunkFilename: 'static/webpack/[id].[hash].hot-update.js', hotUpdateMainFilename: 'static/webpack/[hash].hot-update.json', // This saves chunks with the name given via `import()` diff --git a/server/document.js b/server/document.js index 7a8ec75a..f7803c13 100644 --- a/server/document.js +++ b/server/document.js @@ -182,7 +182,6 @@ export class NextScript extends Component { return ` __NEXT_DATA__ = ${htmlescape(__NEXT_DATA__)} - module={} __NEXT_LOADED_PAGES__ = [] __NEXT_REGISTER_PAGE = function (route, fn) {