Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Advantages/disadvantages over import() #64

Open
iamakulov opened this issue Nov 30, 2017 · 1 comment
Open

Advantages/disadvantages over import() #64

iamakulov opened this issue Nov 30, 2017 · 1 comment

Comments

@iamakulov
Copy link

I’d like to document how this solution is different from import()/require.ensure(). This would simplify the choice between these tools: from the first sight, bundle-loader?lazy and import() are very similar, and you could get stuck thinking what to choose.

This is what I’ve found so far:

  • Advantage: Per react-router docs, on additional renders, the loader calls the callback synchronously. This prevent the flashing of the loading screen.
  • Disadvantage: import() and require.ensure() allow handling the loading error (e.g. with .catch()), and bundle-loader doesn’t.
  • Disadvantage: Because this is a loader, the developer should either
    • name a file after a specific pattern (e.g. .lazy.js) to apply the loader to it (this requires renaming files, which is a pretty large event) or
    • specify the loader inline (which is a rare and webpack-specific notation).

Are there any other known differences I’m missing?

@stevemao
Copy link

stevemao commented Nov 5, 2018

Thanks @iamakulov for writing this up. I thought this exists because import() wasn't a thing. would like to see the opinions from the maintainers.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants