Caveat: I don't use Next.js (yet?). But trying to help anyway:
I think the nature of dynamic is that it creates and returns a single component facade when you call it, so you'll have to make multiple calls to dynamic. But that doesn't mean you have to repeat everything. Unless dynamic is a pseudo-function that's replaced at build time, you can give yourself a helper to do the heavy lifting:
const dynamicStyle = (name) => dynamic( () => import("./style").then((module) => module[name]), { ssr: false } );
Then at least each component is simpler and not (that) repetitive:
const Heading = dynamicStyle("Heading"); const CustomError = dynamicStyle("CustomError");
About this:
how can I import all the modules at once instead of importing them separately for every module from the same file
I suspect you meant "...for every component from the same file..." In case you're worried about the module being imported multiple times, don't be. Regardless of how many times you call import("./style"), the module is only imported once. If the module is already imported or being imported the second/third/fourth time you call import(), the promises from those calls just get fulfilled with the same module namespace object that the first one did/will. That's effectively guaranteed by the specification where it says:
Any subsequent call to HostResolveImportedModule after FinishDynamicImport has completed, given the arguments referencingScriptOrModule and specifier, must return a normal completion containing a module which has already been evaluated, i.e. whose Evaluate concrete method has already been called and returned a normal completion.
dynamicis only meant for single components. Nextjs will do some behind-the-scene magic to make it a loadable component (wrap it inside a custom component of theirs) so you can't load several components that way. If you're worried about bundling / loading, you should look into webpack rather than nextjs itself, but I probably wouldn't recommend it unless you actually notice some performance issues.dynamicdoesn't necessarily need a default export. The first code snippet in this question will work, and it uses a named export.React.lazy's requirement. In fact, the docs I linked even show how to do a named export. :-)