question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Gatsby SSR error. Failed Building static HTML for pages

See original GitHub issue

šŸ› Bug Report

During gatsby build get an error:

  failed Building static HTML for pages

  4 | export default function About() {
  5 |   const path = 'CustomLoaded';
> 6 |   const ModuleComponent = loadable(() => import(`../component/${path}`));
    |                                   ^
  7 | 
  8 |   return (
  9 |     <div>


  WebpackError: TypeError: Cannot read property 'call' of undefined
  
  - about.js:6 
    src/pages/about.js:6:35
  
  - loadable.esm.js:205 
    node_modules/@loadable/component/dist/loadable.esm.js:205:1
  
  - loadable.esm.js:141 
    node_modules/@loadable/component/dist/loadable.esm.js:141:1

To Reproduce

gatsby build

Expected behavior

Build without errors.

Link to repl or repo (highly encouraged)

Please, find minimal working example here: https://github.com/MaxBoltik/loadable-components-bug

Run npx envinfo --system --binaries --npmPackages @loadable/component,@loadable/server,@loadable/webpack-plugin,@loadable/babel-plugin --markdown --clipboard

## System:
 - OS: Linux 5.4 Ubuntu 18.04.4 LTS (Bionic Beaver)
 - CPU: (4) x64 Intel(R) Core(TM) i7-4510U CPU @ 2.00GHz
 - Memory: 317.04 MB / 7.66 GB
 - Container: Yes
 - Shell: 4.4.20 - /bin/bash
## Binaries:
 - Node: 14.0.0 - ~/.nvm/versions/node/v14.0.0/bin/node
 - npm: 6.14.4 - ~/.nvm/versions/node/v14.0.0/bin/npm
 - Watchman: 20200802.200524.0 - /usr/local/bin/watchman
## npmPackages:
 - @loadable/babel-plugin: ^5.13.0 => 5.13.0 
 - @loadable/component: ^5.13.1 => 5.13.1 
 - @loadable/server: ^5.13.1 => 5.13.1 
 - @loadable/webpack-plugin: ^5.13.0 => 5.13.0 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:13
  • Comments:9

github_iconTop GitHub Comments

1reaction
theKasheycommented, Sep 5, 2020

So there are good news and bad news:

Good news

  • you are using loadable in a little bit ā€œwrongā€ way, and itā€™s more or less expected to fail
// create it once
const LoadableComponent = loadable(({name}) => import(`../component/${name}`));

const componentName = 'SomeLoadableComponent';
export default function About() {

  return (
    <div>
      <h1>About</h1>
      // use specify the component name here
      <LoadableComponent name={componentName} />
    </div>
  );
}

Bad news

Look like ā€œfull dynamic importā€ is just working as expected with Gatsby, and chunks referred using it just not included. Iā€™ve checked module cache, and components are not there.

1reaction
theKasheycommented, Aug 31, 2020

What do you mean?

That the ā€œrun timeā€ problem in #618 is your problem.

do you have some workarounds to fix the problem

I donā€™t have a solution unless I have a problem. The minimal use case youā€™ve provided should be enough to find the root cause and fix it. But it would be not today.

Read more comments on GitHub >

github_iconTop Results From Across the Web

failed Building static HTML for pages, Building static HTML ...
I am getting this error when i am trying to build my gatsby site. "gatsby build". Note that it works fine on "gatsby...
Read more >
failed Building static HTML for pages - Gatsby and p5js
Getting this error when deploying to github pages: failed Building static HTML for pages. I am using "react-p5": "^1.3.6".
Read more >
Debugging HTML Builds | Gatsby
Errors while building static HTML files (the build-time React SSR process) or ... Gatsby treats any JS file listed under the pages dir...
Read more >
Debugging HTML Builds | GatsbyJS äø­ę–‡ē½‘
Errors while building static HTML files generally happen for one of the following reasons: Some of your code references "browser globalsā€¦
Read more >
[Gatsby] Building static HTML failed for path - Support
There is an error when trying to build the website, the weird thing is that this is only happening in netlify, when I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found