A
A
amiznikov2018-03-22 16:04:19
JavaScript
amiznikov, 2018-03-22 16:04:19

How to make node_modules only import in main js?

There are two modules that are loaded on the page

<script type="text/javascript" charset="utf-8" src="corejs"></script>
<script type="text/javascript" charset="utf-8" src="module1.js"></script>

Then I initialize the core module, and insert the module1 module into it, both of these modules use, for example, jquery. assembly is done by webpack. The question is how to make the first module import jquery when building, and the second one does not import, but uses the one imported in the core module? PS: maybe something needs to be changed at the assembly stage, maybe not Thanks in advance!
var core = new Core(new Module);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kulaeff, 2018-03-22
@amiznikov

Use CommonChunksPlugin. But this plugin is needed if you use vepack version 3 or lower. Version 4 has native support for code splitting.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question