D
D
dpablo_escobarr2021-11-07 03:02:26
Node.js
dpablo_escobarr, 2021-11-07 03:02:26

Will there be an increase in optimization if modules are imported from submodules?

Does it make sense to port modules by calling your package.json -
import template from 'template', if one of the modules of my project already uses this module, and let's say I turn to -
import template from 'template' from 'template/node_modules/template' ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2021-11-07
@dpablo_escobarr

When installing dependencies, this module will already be in the root. If you have two versions of the same module - one of yours in the root, the other in a subfolder of another dependency - this is bad and senselessly inflates the bundle. Try to update all dependencies so that this does not happen. In extreme cases, you can use yarn resolutions or install yourself the same version as the dependency.
And on the question, if all the same this happens - there is no difference, except that you do not control it in any way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question