[Vuejs]-Import_once or require_once in vue, react like llibraries?

0👍

There is no need for import_once because as Remicaster’s links explain, imported modules are cached during first evaluation so that multiple imports of the same module return the exact same object. Your bundle analysis shows multiple bn.js modules because bn.js is a dependency to other modules and those other modules are very likely all using different versions of bn.js.

What you can try to do is add an override in your package.json to force only one install of bn.js for all your dependencies to use, though there is no guarantee that this won’t break dependencies that rely on bn.js being a specific version.

Leave a comment