mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
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:
parent
745b2da006
commit
15854f515b
|
@ -36,7 +36,6 @@
|
||||||
"path-to-regexp": "2.1.0",
|
"path-to-regexp": "2.1.0",
|
||||||
"prop-types": "15.6.2",
|
"prop-types": "15.6.2",
|
||||||
"send": "0.16.1",
|
"send": "0.16.1",
|
||||||
"styled-jsx": "3.1.0",
|
|
||||||
"url": "0.11.0"
|
"url": "0.11.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|
|
@ -31,7 +31,7 @@ function externalsConfig (dir, isServer) {
|
||||||
return externals
|
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) => {
|
externals.push((context, request, callback) => {
|
||||||
if (notExternalModules.indexOf(request) !== -1) {
|
if (notExternalModules.indexOf(request) !== -1) {
|
||||||
|
@ -53,6 +53,11 @@ function externalsConfig (dir, isServer) {
|
||||||
return callback()
|
return callback()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// styled-jsx has to be transpiled
|
||||||
|
if (res.match(/node_modules[/\\]styled-jsx/)) {
|
||||||
|
return callback()
|
||||||
|
}
|
||||||
|
|
||||||
if (res.match(/node_modules[/\\].*\.js$/)) {
|
if (res.match(/node_modules[/\\].*\.js$/)) {
|
||||||
return callback(null, `commonjs ${request}`)
|
return callback(null, `commonjs ${request}`)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue