From 4b6db638ae267671ba4219e59329a5a917de7c87 Mon Sep 17 00:00:00 2001 From: Idan Gozlan Date: Wed, 7 Jun 2017 23:56:54 +0300 Subject: [PATCH 1/2] Update themr.js when the source style is empty / contain only :global rules, `extract-text-webpack-plugin` put string instead of json, which break the merge. this if prevent this specific case https://github.com/javivelasco/react-css-themr/issues/66 --- src/components/themr.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/themr.js b/src/components/themr.js index e19711f..bb4d9bb 100644 --- a/src/components/themr.js +++ b/src/components/themr.js @@ -222,6 +222,13 @@ function merge(original = {}, mixin = {}) { switch (typeof originalValue) { case 'object': { //can't merge a non-object with an object + if (mixinValue === '// removed by extract-text-webpack-plugin') { + // when the source style is empty / contain only :global rules, + // extract-text-webpack-plugin put string instead of json, which break the merge. + // this if prevent this specific case + // https://github.com/javivelasco/react-css-themr/issues/66 + break; + } throw new Error(`You are merging non-object ${mixinValue} with an object ${key}`) } From 7756ddc08c17b6c09d37c787831d3d12d86e0682 Mon Sep 17 00:00:00 2001 From: Idan Gozlan Date: Thu, 8 Jun 2017 16:00:07 +0300 Subject: [PATCH 2/2] Modify error to be more informative --- src/components/themr.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/components/themr.js b/src/components/themr.js index bb4d9bb..3d7fa61 100644 --- a/src/components/themr.js +++ b/src/components/themr.js @@ -222,14 +222,7 @@ function merge(original = {}, mixin = {}) { switch (typeof originalValue) { case 'object': { //can't merge a non-object with an object - if (mixinValue === '// removed by extract-text-webpack-plugin') { - // when the source style is empty / contain only :global rules, - // extract-text-webpack-plugin put string instead of json, which break the merge. - // this if prevent this specific case - // https://github.com/javivelasco/react-css-themr/issues/66 - break; - } - throw new Error(`You are merging non-object ${mixinValue} with an object ${key}`) + throw new Error(`You are merging non-object ${mixinValue} with an object ${key}, (can occur when using empty or :global only base theme stylesheet)`) } case 'undefined': {