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.

Unclear Dynamic Import Error Messages

See original GitHub issue

Forgive me for dropping the GitHub issue template, but this is a little more philosophical than technical!

I think the dynamic import error messages could be a little clearer in meaning.

https://github.com/zeit/next.js/blob/master/lib/dynamic.js#L21 This error is thrown when you have a { modules: ..., render: ... } object as the first argument, and a { loading: ...} object as the second argument. To me, the phrasing of the error indicates that this is what I should be doing. I think rewording it to say something like “Cannot include options when the first argument is an object that contains modules and render fields” is much clearer in describing what the programmer has done wrong.

https://github.com/zeit/next.js/blob/master/lib/dynamic.js#L16 This could also be rewritten to read “The first argument should contain both module and render fields” or something similar.

I’m happy to submit a patch on this, but wanted to discuss new wording a little bit before doing it 😄

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
johhansantanacommented, Dec 4, 2017

I’m getting this error message, how do I fix this?

Here’s my code:

import dynamic from 'next/dynamic'
const RoutesMap = dynamic(import("./components/routesMap"), {
  ssr: false
})
// routesMap
import * as React from 'react'
class RoutesMap extends React.Component {

  render() {
    return (
      <div>
        <p>hello</p>
      </div>
    )
  }
}

export default RoutesMap

I’m using typescript.

1reaction
alxcommented, Feb 9, 2018

I had the same issue as @johhansantana and @rohmanhm

I’ve solved it with the “4. With Multiple Modules At Once” example by adding the ssr: false inside the root object:

const HelloBundle = dynamic({
  ssr: false,
  modules: props => {
  ...

https://github.com/zeit/next.js#4-with-multiple-modules-at-once

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unclear Dynamic Import Error Messages · Issue #2794 - GitHub
I think the dynamic import error messages could be a little clearer in meaning. ... This error is thrown when you have a...
Read more >
Confusing error message when using dynamic import with ...
Confusing error message when using dynamic import with relative paths when the referrer does not have a valid URL.
Read more >
What is the best practice for dealing with a failed dynamic ...
I use Webpack dynamic imports to split my bundle. ... However, sometimes, the code fails to download on user side and the user...
Read more >
expected the result of a dynamic import() call. instead received
Instead received: [object Object] Your code should look like: const MyComponent = lazy ( () => import ('./MyComponent')) And then the error: Uncaught...
Read more >
Python import: Advanced Techniques and Tips
In Python, you use the import keyword to make code in one module available in ... Import modules dynamically at runtime; Customize Python's...
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