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.

[Feature] Highlight the module which is imported/used duplicately.

See original GitHub issue

Hey Guys, I wanna discuss a new feature about module imported/used duplicately.

Actually, I have been working on project optimization for days. I wanna decrease webpack bundle size, make it fast to load.

So I have looked into the diagram from webpack-bundle-analyzer for hundred times in those days. This is a great plugin, many thanks to team.

Scenario

In modern web framework like Angular, React, Vue, they all support dynamic routing. And if we use static import to import same module in some dynamical routers, we may make the bundles “dirty”.

As you see below, common.ts is imported twice.

static import & dynamic import.

image

What I want

For web developer beginners, they have no idea about what kind of bundles they will get in different way of coding. We have many web developers in company, so I wanna to know: Is there a same problem in my project?

We could imagine if webpack-bundle-analyzer can represent it (highlight them in red or sth.) to us, that would be great!

Not all duplicate modules need to be extracted as individual. Maybe we can bundle it into main module (app.js), it depends on business and module size etc.

Questions need to discuss

  1. main module (app.js) may take the most area of diagram. It is hard to find duplicate modules. After hiding main module, it better. Do we need to make a new diagram or component for this?
  2. How to represent if we have many different duplicate modules. Use different colors ? Maybe a list or table is better ?

webpack-bundle-analyzer

Any thoughts or suggestion are welcome. Thanks

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
th0rcommented, Sep 23, 2019

I’ll reopen this issue as a reminder.

0reactions
th0rcommented, Sep 23, 2019

Well, I had thoughts about it. Maybe we’ll come back to it a little later after implementing a few other important features e.g. import reasons.

P.S. This duplication logic can be tuned with optimization.splitChunks webpack config option: https://webpack.js.org/plugins/split-chunks-plugin/

An important quotes from there:

webpack will automatically split chunks based on these conditions:

- New chunk can be shared OR modules are from the node_modules folder
- New chunk would be bigger than 30kb (before min+gz)
- Maximum number of parallel requests when loading chunks on demand would be lower or equal to 5
- Maximum number of parallel requests at initial page load would be lower or equal to 3

When trying to fulfill the last two conditions, bigger chunks are preferred.
The default configuration was chosen to fit web performance best practices,
but the optimal strategy for your project might differ.
If you're changing the configuration, you should measure the impact of your changes
to ensure there's a real benefit.

So, as @valscion said, module duplication it not necessary a problem at all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - What happens when a module is imported twice?
Nothing, if a module has already been imported, it's not loaded again. You will simply get a reference to the module that has...
Read more >
How to find and highlight duplicates in Excel - Ablebits
It can find, highlight, select, copy or move duplicated cells or entire duplicate rows. Despite its name, the add-in can quickly highlight ......
Read more >
Solved: Help Canvas page overwrites all copies of the copi...
Solved: I have a Canvas "page" that was part of an imported course template. One particular page has been copied into several modules....
Read more >
Duplicate entries - Module to module import
Hi, While carrying out a module to module import, if we do not import zeroes first in the target module, the values tend...
Read more >
Identifying and removing duplicate records from systematic ...
Because they are used as the foundation for clinical and policy-related ... identifies duplicates among imported references, which can be deleted.
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