{"id":138,"date":"2021-12-29T15:00:00","date_gmt":"2021-12-29T15:00:00","guid":{"rendered":"http:\/\/frontendguruji.com\/?p=138"},"modified":"2021-12-30T11:05:02","modified_gmt":"2021-12-30T11:05:02","slug":"warn-export-default-imported-as-content-was-not-found","status":"publish","type":"post","link":"https:\/\/frontendguruji.com\/blog\/warn-export-default-imported-as-content-was-not-found\/","title":{"rendered":"WARN export &#8216;default&#8217; (imported as &#8216;content&#8217;) was not found"},"content":{"rendered":"\n<p>Hello Friends &#x1f64f;, today while I was <a href=\"http:\/\/frontendguruji.com\/how-to-setup-a-react-js-project-from-scratch-without-create-react-app\/\" target=\"_blank\" rel=\"noreferrer noopener\">setting up a new React project from scratch without using create-react-app<\/a> and after doing all the required steps when I compiled the React App, I got below warning&#x1f62e;:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img width=\"964\" height=\"74\" src=\"http:\/\/frontendguruji.com\/wp-content\/uploads\/2021\/12\/image-16.png\" alt=\"\" class=\"wp-image-139\" srcset=\"https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2021\/12\/image-16.png 964w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2021\/12\/image-16-300x23.png 300w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2021\/12\/image-16-768x59.png 768w\" sizes=\"(max-width: 964px) 100vw, 964px\" \/><figcaption><span style=\"color:#cccccc\" class=\"has-inline-color\">export &#8216;default&#8217; (imported as &#8216;content&#8217;) was not found in &#8216;!!..\/node_modules\/mini-css-extract-plugin\/dist\/loader.js!..\/node_modules\/css-loader\/dist\/cjs.js!..\/node_modules\/sass-loader\/dist\/cjs.js!.\/styles.scss&#8217; (module has no exports)<\/span><\/figcaption><\/figure>\n\n\n\n<p>So basically it is related to<strong> mini-css-extract-plugin<\/strong>, we have used it to extract the styles from the project to a style file.<\/p>\n\n\n\n<p>Below is the configuration I had done to setup the CSS loaders along with this plugin<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img width=\"453\" height=\"249\" src=\"http:\/\/frontendguruji.com\/wp-content\/uploads\/2021\/12\/image-17.png\" alt=\"\" class=\"wp-image-140\" srcset=\"https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2021\/12\/image-17.png 453w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2021\/12\/image-17-300x165.png 300w\" sizes=\"(max-width: 453px) 100vw, 453px\" \/><\/figure>\n\n\n\n<p>And as you can see in the warning there is a red color text <span style=\"color:#ff0000\" class=\"has-inline-color\">(module has no exports)<\/span>, it made me think is it related to the way we are importing the css (i.e. directly importing without naming it as SCSS files do not use export syntaxes).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img width=\"650\" height=\"156\" src=\"http:\/\/frontendguruji.com\/wp-content\/uploads\/2021\/12\/image-19.png\" alt=\"\" class=\"wp-image-143\" srcset=\"https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2021\/12\/image-19.png 650w, https:\/\/frontendguruji.com\/blog\/wp-content\/uploads\/2021\/12\/image-19-300x72.png 300w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/figure>\n\n\n\n<p>After some googling &#x1f50d; , I found out that there is an option in mini-css-extract-plugin &#8220;<strong>esModule<\/strong>&#8221; and by setting it false warnings were not coming up again&#x1f601; &#x1f973;&#x1f973;.<br>So basically <em>esModules <\/em>are ECMAScript standard for working with modules. And <em>modules <\/em>is a JS file having variables and methods which must be exported, so that other files can import those methods and reuse it.<br>And in our case, as we don&#8217;t export styles as its not a js file and can be imported directly in the component, we have to turn off the esModule flag for the mini-css-extract plugin.<\/p>\n\n\n\n<p>Do you know anyother way to resolve this issue, feel free to comment.<\/p>\n\n\n\n<p>Thanks&#x1f64f;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello Friends &#x1f64f;, today while I was setting up a new React project from scratch without using create-react-app and after doing all the required steps when I compiled the React App, I got below warning&#x1f62e;: So basically it is related to mini-css-extract-plugin, we have used it to extract the styles from the project to a &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/frontendguruji.com\/blog\/warn-export-default-imported-as-content-was-not-found\/\"> <span class=\"screen-reader-text\">WARN export &#8216;default&#8217; (imported as &#8216;content&#8217;) was not found<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[30],"tags":[31,35,27,33,32,23,36],"_links":{"self":[{"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/posts\/138"}],"collection":[{"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/comments?post=138"}],"version-history":[{"count":0,"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/posts\/138\/revisions"}],"wp:attachment":[{"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/media?parent=138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/categories?post=138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frontendguruji.com\/blog\/wp-json\/wp\/v2\/tags?post=138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}