From 24edfbdea728d9a3886e1da16ede9eb0f13dd003 Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Thu, 2 Feb 2017 11:26:21 +0530 Subject: [PATCH] Resolve styled-jsx/style when transpiling ES2015 modules. (#953) --- server/build/babel/preset.js | 3 +-- server/build/webpack.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/server/build/babel/preset.js b/server/build/babel/preset.js index 03370e8b..b0354dac 100644 --- a/server/build/babel/preset.js +++ b/server/build/babel/preset.js @@ -26,8 +26,7 @@ module.exports = { 'next/css': require.resolve('../../../lib/css'), 'next/head': require.resolve('../../../lib/head'), 'next/document': require.resolve('../../../server/document'), - 'next/router': require.resolve('../../../lib/router'), - 'styled-jsx/style': require.resolve('styled-jsx/style') + 'next/router': require.resolve('../../../lib/router') } } ] diff --git a/server/build/webpack.js b/server/build/webpack.js index 54ddaad7..c0a0ffe0 100644 --- a/server/build/webpack.js +++ b/server/build/webpack.js @@ -158,6 +158,21 @@ export default async function createCompiler (dir, { dev = false, quiet = false const transpiled = babelCore.transform(content, { presets: [require.resolve('babel-preset-es2015')], sourceMaps: dev ? 'both' : false, + // Here we need to resolve styled-jsx/style to the absolute paths. + // Earlier we did it with the babel-preset. + // But since we don't transpile ES2015 in the preset this is not resolving. + // That's why we need to do it here. + // See more: https://github.com/zeit/next.js/issues/951 + plugins: [ + [ + require.resolve('babel-plugin-module-resolver'), + { + alias: { + 'styled-jsx/style': require.resolve('styled-jsx/style') + } + } + ] + ], inputSourceMap: sourceMap })