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.

Loadable Components raises error `SSR requires @loadable/babel-plugin, please install it` when using TypeScript `commonjs` modules.

See original GitHub issue

šŸ› Bug Report

Dynamic import of some components randomly raise (node:12876) UnhandledPromiseRejectionWarning: Invariant Violation: loadable: SSR requires @loadable/babel-plugin, please install it when access any page of the app in Chrome (server is starting ok) ; while others donā€™t. The plugin is obviously installed. Some components randomly raise the same error not when calling them but when trying to ā€˜display source codeā€™ in Chrome. Some components just run fine.

To Reproduce

This component systematically raise this error when any page is called:

import React, { Component } from 'react'
import { IAppDictonary, IAppSetMeta, IAppUser } from '../Shared/App'
import { siteHomepage } from 'bnc-libs/lib/page'
import { Page } from '../../libs/page'

let pageMeta = new Page()
Object.assign(pageMeta, siteHomepage)

export interface IHomeProps extends IAppDictonary, IAppUser, IAppSetMeta { }

export interface IHomeStates { }

export class Home extends Component<IHomeProps, IHomeStates> {

  componentDidMount() {
    this.props.setMeta(pageMeta)
  }

  render() {
    const d = this.props.dictionary
    return (
      <div id="mainDiv" className="homepage">
        <div className="devBanner">
          <h2>{d.devInProgressTitle}</h2>
          <div className="mainDiv center bigMargin">
            <img
              id="tortoise"
              src='/i/ui/tortoise.webp' alt={d.devInProgressTitle} /><br />
            <p>{d.devInProgressText}</p>
          </div>
        </div>
      </div>
    )
  }
}

export default Home

Other similar components donā€™t raise the error when displayed, but do when trying to display source code of the page in Chrome.

Expected behavior

No error.

System:

  • OS: Windows 10 10.0.19041
  • CPU: (4) x64 IntelĀ® Coreā„¢ i5-2500K CPU @ 3.30GHz
  • Memory: 4.61 GB / 9.98 GB

Binaries:

  • Node: 14.16.0 - D:\DEV\nodejs\node.EXE
  • npm: 6.14.11 - D:\DEV\nodejs\npm.CMD

Config

"dependencies": {
    "@loadable/component": "^5.14.1",
    "@loadable/server": "^5.14.2",
    "bnc-libs": "^0.2.33",
    "cookie-parser": "^1.4.5",
    "express": "^4.17.1",
    "isomorphic-fetch": "^3.0.0",
    "lazysizes": "^5.3.1",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-router-dom": "^5.2.0"
  },
  "devDependencies": {
    "@babel/cli": "^7.13.10",
    "@babel/core": "^7.13.13",
    "@babel/plugin-proposal-class-properties": "^7.13.0",
    "@babel/preset-react": "^7.13.13",
    "@babel/preset-typescript": "^7.13.0",
    "@loadable/babel-plugin": "^5.13.2",
    "@loadable/webpack-plugin": "^5.14.2",
    "@types/express": "^4.17.11",
    "@types/isomorphic-fetch": "0.0.35",
    "@types/loadable__component": "^5.13.3",
    "@types/loadable__server": "^5.12.3",
    "@types/node": "^14.14.37",
    "@types/react": "^17.0.3",
    "@types/react-dom": "^17.0.3",
    "@types/react-router-dom": "^5.1.7",
    "babel-loader": "^8.2.2",
    "jshint": "^2.12.0",
    "ts-node": "^9.1.1",
    "ts-node-dev": "^1.1.6",
    "typescript": "^4.2.3",
    "webpack": "^5.28.0",
    "webpack-cli": "^4.5.0",
    "webpack-node-externals": "^2.5.2"
  }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:24

github_iconTop GitHub Comments

4reactions
jjblumenfeldcommented, Apr 22, 2021

We are experiencing the same issue. We are using commonJS modules and are doing SSR using our own expressJS server on node v12.

4reactions
denchiklutcommented, Apr 18, 2021

@theKashey is there any chance to fix ā€˜@loadable/babel-pluginā€™ to work with commonjs?

Read more comments on GitHub >

github_iconTop Results From Across the Web

SSR requires `@loadable/babel-plugin`, please install it ...
I'm using the loadable component in a ReactJS project. For SSR but I get the following error when I run start command, I...
Read more >
Server Side Rendering - Loadable Components
1. Install @loadable/babel-plugin .babelrc. { Ā· 2. Install @loadable/webpack-plugin. webpack.config.js Ā· 3. Setup ChunkExtractor server-side. import {Ā ...
Read more >
loadable-components | Yarn - Package Manager
Please use @loadable/component. React code splitting made easy. react, ssr, webpack, code-splitting. readme. loadable-components.
Read more >
error: rendered more hooks than during the previous render.
Examine which components are taking more time to load. Install To use this devtool, you'll need to install a npm module which will...
Read more >
UiRoundup.com
The same command for running JavaScript & TypeScript files with bun's JavaScript runtime ... Since we know how to fix this error We...
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