From 15854f515b060d34387156b1c3679ab11fc368a4 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Sun, 4 Nov 2018 01:11:40 +0100 Subject: [PATCH] Transpile styled-jsx into server bundle (#5588) Drops an additional 6MB from the next-server node_modules size as there's no lodash --- packages/next-server/package.json | 1 - packages/next/build/webpack.js | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/next-server/package.json b/packages/next-server/package.json index d9f63d5f..bc8a607b 100644 --- a/packages/next-server/package.json +++ b/packages/next-server/package.json @@ -36,7 +36,6 @@ "path-to-regexp": "2.1.0", "prop-types": "15.6.2", "send": "0.16.1", - "styled-jsx": "3.1.0", "url": "0.11.0" }, "peerDependencies": { diff --git a/packages/next/build/webpack.js b/packages/next/build/webpack.js index 0263cd25..90d5db99 100644 --- a/packages/next/build/webpack.js +++ b/packages/next/build/webpack.js @@ -31,7 +31,7 @@ function externalsConfig (dir, isServer) { return externals } - const notExternalModules = ['next/app', 'next/document', 'next/error', 'http-status', 'styled-jsx'] + const notExternalModules = ['next/app', 'next/document', 'next/error', 'http-status'] externals.push((context, request, callback) => { if (notExternalModules.indexOf(request) !== -1) { @@ -53,6 +53,11 @@ function externalsConfig (dir, isServer) { return callback() } + // styled-jsx has to be transpiled + if (res.match(/node_modules[/\\]styled-jsx/)) { + return callback() + } + if (res.match(/node_modules[/\\].*\.js$/)) { return callback(null, `commonjs ${request}`) }