From 3d89558c6df2eadcf9a747e1e40306e09df730b0 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 | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/metro.config.js b/metro.config.js index 783f349..0a01322 100644 --- a/metro.config.js +++ b/metro.config.js @@ -1,17 +1,20 @@ -/** - * 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: { + sourceExts: [...sourceExts, 'cjs'], + }, + transformer: { + getTransformOptions: async () => ({ + transform: { + experimentalImportSupport: false, + inlineRequires: false, + }, + }), + }, + }; +})();