A rewrite of using Vue 2 and Vue 3 to manage packages in the Lerna monorepo titled: Using Vue 2 and Vue 3 to manage modules in the Lerna monorepo
P粉221046425
P粉221046425 2023-08-27 09:48:38
0
1
567
<p>I'm trying to create a PR to contribute to an open source library that uses Lerna to manage multiple packages and npm as the package manager. </p> <p>The library already supports Vue 2 using package <code>support-vue</code>. The purpose of my PR is to add Vue 3 support by creating a new package called <code>support-vue3</code>. </p> <p>Package <code>support-vue</code> depends on certain packages of Vue 2 and Vue 2 compatible versions (<code>vue-router</code>, <code>@vue/test -utils</code>), while package <code>support-vue3</code> depends on Vue 3-compatible versions of these packages. </p> <p>The problem I can't solve is how to use different versions of Vue and related packages in <code>support-vue</code> and <code>support-vue3</code>. As far as I know, Lerna will only promote one version to the root <code>node_modules</code> (Vue 2 in this case). I can only get one package working at a time, depending on which version of Vue is installed. </p> <p>I need to install different versions of Vue for each package. </p> <p>I tried to solve this problem by using a package alias in <code>package.json</code>, like this: </p> <pre class="brush:json;toolbar:false;">{ "devDependencies": { "vue2": "npm:vue@2", "vue3": "npm:vue@3", "@vue/test-utils1": "npm:@vue/test-utils@1", "@vue/test-utils2": "npm:@vue/test-utils@2", ... } } </pre> <p>and importing Vue from these aliases, but <code>vue</code> is not found in <code>@vue/test-utils</code> and other packages that require Vue as a peer dependency Dependencies. </p> <p> I also tried adding a filter in <code>lerna.json</code> to disable elevating vue to the root <code>package.json</code> and add vue only to the support package dependencies, but to no avail. </p> <p>Is using different versions of Vue in each package possible in Lerna, or is this a dead end? </p>
P粉221046425
P粉221046425

reply all(1)
P粉237689596

I think Lerna doesn't support such a thing, you can use SingleSpa or OpenComponent instead

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!