gatsby: "Uncaught Error: Missing resources for /" with Component Shadowing

Description

Since today after I serve my static files, I got this notorious Error: Uncaught Error: Missing resources for /. After researching and trying to find out what happened, I was able to pinpoint it to Component Shadowing with Themes.

My setup is, that I have a Theme that exports Utility Components and Section Components, basically behaving like a UI-Kit. It’s exported by an export.js file.

Now when I shadow a Component, that I use, to let the user inject custom Components in a certain spot and at the same time import something from the theme, this occurs in the browser. This happens whenever that component is rendered on the page.

Steps to reproduce

  1. Build a theme with an export of any components.
  2. Shadow a component in that Theme and import X from 'your-theme' and use X.
  3. yarn build
  4. yarn serve
  5. Visit the page

Expected result

Page should work normally

Actual result

Missing resources for / occurs.

Environment

  System:
    OS: macOS 10.14.3
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.15.1 - /usr/local/bin/node
    Yarn: 1.13.0 - /usr/local/bin/yarn
    npm: 6.4.1 - /usr/local/bin/npm
  Languages:
    Python: 2.7.10 - /usr/bin/python
  Browsers:
    Chrome: 74.0.3729.169
    Firefox: 66.0.5
    Safari: 12.0.3
  npmPackages:
    gatsby: ^2.8.6 => 2.8.6 
    gatsby-image: ^2.1.2 => 2.1.2 
    gatsby-plugin-compile-es6-packages: ^1.1.0 => 1.1.0 
    gatsby-plugin-manifest: ^2.1.1 => 2.1.1 
    gatsby-plugin-offline: ^2.1.1 => 2.1.1 
    gatsby-plugin-typescript: ^2.0.15 => 2.0.15 
    gatsby-theme-shopify-poulo: ^0.8.12 => 0.8.12 

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 27 (25 by maintainers)

Most upvoted comments

Oh, I misunderstood the question. In my repro I was using styled to add additional styles, which is necessary sometimes and of course is an edge case.

—-

I understand what you mean and I will think more about my setup and how to improve without adding any overhead and complicating things.

Thanks for your input and insights^^

The thing is, that I don’t want to make the User of the Theme to import it from the file, because if the location changes, it will always be a Breaking Change, which I would like to avoid.

Also, due to the ability to shadow any component, refactoring file locations for components is always considered a breaking change and you would want to provide a codemod or other automated tool for users to upgrade if you plan on doing this often.

The warning is fine, need to fix that in the Theme, didnt get around to it.

You are running gatsby develop. You need to do a build and then serve that. It doesn’t occur in dev mode.