Transpile styled-jsx into server bundle (#5588)

Drops an additional 6MB from the next-server node_modules size as there's no lodash
This commit is contained in:
Tim Neutkens 2018-11-04 01:11:40 +01:00 committed by GitHub
parent 745b2da006
commit 15854f515b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -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": {

View file

@ -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}`)
}