Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build doesn't work when using Dynamic Import #25077

Closed
shiftrtech opened this issue May 12, 2021 · 4 comments
Closed

Build doesn't work when using Dynamic Import #25077

shiftrtech opened this issue May 12, 2021 · 4 comments
Labels
please add a complete reproduction The issue lacks information for further investigation

Comments

@shiftrtech
Copy link

shiftrtech commented May 12, 2021

What version of Next.js are you using?

10.2.0

What version of Node.js are you using?

16.1.0

What browser are you using?

Chrome

What operating system are you using?

Windows

How are you deploying your application?

next build

Describe the Bug

When i try to build my app (next build) im getting this error:

info  - Using webpack 5. Reason: future.webpack5 option enabled https://nextjs.org/docs/messages/webpack5
info  - Checking validity of types  
info  - Creating an optimized production build

.\node_modules\next\dist\compiled\webpack\bundle5.js:114742
                                fn: str => str.startsWith(condition)
                                               ^

TypeError: Cannot read property 'startsWith' of null
    at Object.fn (.\node_modules\next\dist\compiled\webpack\bundle5.js:114742:20)

Expected Behavior

A successful compilation

To Reproduce

import dynamic from 'next/dynamic'

export default function BlockDynamicRenderer({ blocks = [] }) {
  return <div>
    {blocks.map(({ __typename }, index) => {
            const BlockComponent = dynamic(() =>
              import(`@/components/Blocks/${__typename}`)
            );
    })}
  </div>
}
  1. next build
  2. See error

To Bypass

When i use this on next.config.js it works:

module.exports = {
  future: {
    webpack5: false
  },
}
@shiftrtech shiftrtech added the bug Issue was opened via the bug report template. label May 12, 2021
@shiftrtech
Copy link
Author

I can confirm this is related to this

@shiftrtech shiftrtech changed the title Build doesn't work Build doesn't work when using Dynamic Import May 12, 2021
@valse
Copy link
Contributor

valse commented May 26, 2021

Hi, I have issues with next/dynamic in production too after upgrading to next 10.2.1... the project built but when it is started javascript isn't executed at all: disabling webpack 5 the issue disappear

@github-actions
Copy link
Contributor

This issue has been automatically closed after 30 days of inactivity with no reproduction. If you are running into a similar issue, please open a new issue with a reproduction. Thank you.

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
please add a complete reproduction The issue lacks information for further investigation
Projects
None yet
Development

No branches or pull requests

3 participants