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.

SSR App but client only loadable-components v5

See original GitHub issue

I have a working Razzle (Razzle next with babel 7) app and just added loadable-components v5 to it. But only on the client side, I haven’t set up the server part of it.

When I import a component like this:

import loadable from '@loadable/component';

...

const AsyncComp = loadable(comp => import(`./../../components/${comp.id}`));

I get the following babel error:

ERROR in ./src/app/containers/PageContainer/index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: Property params expected type of array but got null
    at validate (/Users/demo/app_test/node_modules/@babel/types/lib/definitions/utils.js:161:13)
    at Object.validate (/Users/demo/app_test/node_modules/@babel/types/lib/definitions/utils.js:172:7)
    at validate (/Users/demo/app_test/node_modules/@babel/types/lib/validators/validate.js:17:9)
    at builder (/Users/demo/app_test/node_modules/@babel/types/lib/builders/builder.js:46:27)
    at ObjectMethod (/Users/demo/app_test/node_modules/@babel/types/lib/builders/generated/index.js:368:31)
    at /Users/demo/app_test/node_modules/@loadable/babel-plugin/lib/properties/chunkName.js:133:14
    at /Users/demo/app_test/node_modules/@loadable/babel-plugin/lib/index.js:71:18
    at Array.map (<anonymous>)
    at PluginPass.CallExpression (/Users/demo/app_test/node_modules/@loadable/babel-plugin/lib/index.js:70:67)
    at newFn (/Users/demo/app_test/node_modules/@babel/traverse/lib/visitors.js:193:21)
    at NodePath._call (/Users/demo/app_test/node_modules/@babel/traverse/lib/path/context.js:53:20)
    at NodePath.call (/Users/demo/app_test/node_modules/@babel/traverse/lib/path/context.js:40:17)
    at NodePath.visit (/Users/demo/app_test/node_modules/@babel/traverse/lib/path/context.js:88:12)
    at TraversalContext.visitQueue (/Users/demo/app_test/node_modules/@babel/traverse/lib/context.js:118:16)
    at TraversalContext.visitSingle (/Users/demo/app_test/node_modules/@babel/traverse/lib/context.js:90:19)
    at TraversalContext.visit (/Users/demo/app_test/node_modules/@babel/traverse/lib/context.js:146:19)
 @ ./src/app/routes/index.js 1:0-56 10:13-26 15:13-26 20:13-26
 @ ./src/client.js
 @ multi ./node_modules/razzle/config/polyfills.js ./node_modules/razzle-dev-utils/webpackHotDevClient.js ./src/client

My .babelrc file looks like this:

{
  "presets": [
    [
      "@babel/preset-env", {
        "modules": false,
        "useBuiltIns": "usage",
        "debug": false
      }
    ],
    "razzle/babel"
  ],
  "plugins": [
    "@babel/plugin-syntax-dynamic-import",
    "@babel/plugin-transform-runtime",
    "@loadable/babel-plugin"
  ]
}

Before I do more testing and wire up the SSR for loadable-components, my question is this supposed to work without the SSR part set up?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
helly0dcommented, Jan 14, 2019

@radum Yes, I still seem to have the same error as you do, even though I am actually having the code more or else copy-pasted from the docs, not trying to do anything fishy.

@neoziro I might be having babel-plugins in conflict or something in the webpack config, because otherwise everything should be working perfectly according to your docs and most of the guys using it.

I will try to debug it further, but unfortunately I am a bit behind schedule with some tasks and it will take a few days to come back with an answer.

1reaction
gregbergecommented, Nov 24, 2018

I think it is not a bug, your function was not correctly written. I close it. Thanks for your time!

Read more comments on GitHub >

github_iconTop Results From Across the Web

SSR App but client only loadable-components v5 #165 - GitHub
I have a working Razzle (Razzle next with babel 7) app and just added loadable-components v5 to it. But only on the client...
Read more >
Server Side Rendering - Loadable Components
Loadable components loads all your scripts asynchronously to ensure optimal performances. All scripts are loaded in parallel, so you have to wait for...
Read more >
React Loadable SSR isn't always giving client complete list of ...
I am using the babel and webpack plugins as described in the React-Loadable Readme. It seems like React-Loadable is only smart enough to...
Read more >
gatsby-plugin-loadable-components-ssr
This plugin implements the steps described in the link above using gatsby's APIs, so you can use it only by adding gatsby-plugin-loadable-components-ssr in...
Read more >
Server rendering - Material UI - MUI
When the server receives the request, it renders the required component(s) into an HTML string, and then sends it as a response to...
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