Uncompiled dependency issues #7246
Unanswered
PurpleTape
asked this question in
Help/Questions
Replies: 1 comment 3 replies
-
Maybe what you need is a About |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
I want to make a set of Vue components and use it in my projects for rapid development under Vite. Let it be called CORE. Its structure is approximately as follows:
Next, I want to use the CORE module in another project (let's call it APP). At the same time, when developing the APP module, I want to be able to make quick edits to the CORE module.
But in this case, after each edit in the CORE module, I will need to rebuild it again and install it in the APP module, which significantly slows down development.
To avoid this, I decided to use the following strategy: distribute the CORE module through the GitHub repository in an uncompiled form (that is, in the form of source code) and already build when publishing the APP module.
However, here I ran into the following problems:
@ ='./src'
when importing, but since there are completely different files in the APP module along the path./src
, an error occurs. I solved this by redefining the alias@ = './node_modules/CORE/src'
in the APP module. But in my opinion, this solution is not very beautiful. Maybe you know the best way to solve it?node_modules/.vite/deps/CORE.js
. But in the directorynode_modules/.vite
there are a lot of files of the form@_components_input.js
,@_components_button.js
etc. These files are not used in the APP module, but are used inside the CORE module. Thus, due to the fact that for some reason the components are divided into separate files, the optimization of "Dependency Pre-Bundling" becomes less effective and when loading the page of the APP module in the browser during development, I have to wait ~20 seconds for loading all files of the form@_components_*.js
, which slows down development. How I can change this behavior so that the CORE module components are in the same filenode_modules/.vite/deps/CORE.js
?provide()
andinject()
functions, which communicate with each other usingconst key = Symbol()
. In the CORE module itself, components usingprovide()
andinject()
work fine, but when I use these components in the APP module,inject()
does not bind toprovide()
. After some research, I found out thatconst key = Symbol()
is called twice: once in the CORE module, and the second in the APP module. And sincekey
is redefined,provide()
andinject()
cannot communicate with each other. To solve the problem, I tried using theresolve.dedupe
option in thevite.config.ts
configuration with the valueresolve.dedupe: ['vue']
,resolve.dedupe: ['CORE']
,resolve.dedupe: ['@vueuse/core']
, but all this did not help. How canprovide()
andinject()
be made to work in the APP module?Also may tell me if I chose the right development strategy (with the distribution of the CORE module through the GitHub repository in an uncompiled form) or maybe there are some more optimal strategies that accelerate development?
I am grateful in advance for studying my problem and answering questions!
Beta Was this translation helpful? Give feedback.
All reactions