I was reading the docs on React.lazy()
and it wasn't clear to me whether using that API requires me to use a module bundler that supports that syntax.
What if I am not using any bundler and just using <script type="module" src="example.mjs"></script>
to provide modules, will React.lazy()
still work and does it even make sense to do so?
Without bundler React.lazy
will not work because it depends on dynamic imports.
Dynamic imports it is not a feature that browsers support for now(it is ecmascript proposal), but bundlers do.
So answer is yes. Read more about dynamic imports in webpack.