From d868225479070c42e8557f9d4648d11c5c3f2eaf Mon Sep 17 00:00:00 2001 From: Isaac Overacker Date: Tue, 1 Sep 2020 20:24:31 -0700 Subject: [PATCH] Update metro config to support loading .cjs files Workaround for metro deficiency: https://github.com/facebook/metro/issues/535 Caused by stylis shipping a .cjs file: https://github.com/thysultan/stylis.js/issues/233 Fix from https://github.com/emotion-js/emotion/issues/1986 --- metro.config.js | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/metro.config.js b/metro.config.js index 783f349..1f7cebf 100644 --- a/metro.config.js +++ b/metro.config.js @@ -1,17 +1,21 @@ -/** - * Metro configuration for React Native - * https://github.com/facebook/react-native - * - * @format - */ +const { getDefaultConfig } = require('metro-config'); -module.exports = { - transformer: { - getTransformOptions: async () => ({ - transform: { - experimentalImportSupport: false, - inlineRequires: false, - }, - }), - }, -}; +module.exports = (async () => { + const { + resolver: { sourceExts }, + } = await getDefaultConfig(); + return { + resolver: { + // Add cjs extension so stylis will load. + sourceExts: [...sourceExts, 'cjs'], + }, + transformer: { + getTransformOptions: async () => ({ + transform: { + experimentalImportSupport: false, + inlineRequires: false, + }, + }), + }, + }; +})();