-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include Vue instance when Build Target is Lib mode #4055
Comments
I've seen that config is defined based on user webpack chain:
and then used to remove Vue instances: Is it possible to create the config another way, apply externals and then apply the chain? If it's not, maybe a flag on vue.config can do that, so we add an "if" before applying externals |
Personally, not having reviewed the source code in depth, @trickstival approach seems like a simple, backwards compatible solution to the problem. We would be happy with a change like that! |
I'm still trying to understand the project structure as a whole, but I imagine something like that might work: if (!api.service.projectOptions.keepVueInstance) {
// externalize Vue in case user imports it
config
.externals({
...config.get('externals'),
vue: {
commonjs: 'vue',
commonjs2: 'vue',
root: 'Vue'
}
})
} Here in the original file: But I'm not sure how to create a test to it right now, still searching some examples in the project |
Looking at the code snippet you provided, I might suggest a slightly different incarnation of it. That approach has a limitation in that if your "keepVueInstance" is false, then externals that the developer wanted to configure will not be applied either. Maybe something like the following:
|
That's actually much better! |
Apologies for the formatting, just fixed it. I am still learning my way around GitHub's formatting features. |
[OFFTOPIC]If you add js after your backticks you get some code highlighting. Like that: `` ` let a = 'hey' |
i am trying to do something very similar (a core app with modules the user can install, but i don't want to update the app when new modules become available). I justed wanted to start looking into the lib or wc option when i tumbled upon this. If you want to load them at runtime, won't the webcomponent build be an option? or does the webcomponent solution not offer the following capabilities: <component :is="moduleA">slot content</component> |
I'm trying to do this exact thing. Is there any workaround? Also, I wonder if this issue is up for grabs, I would like to work on it. |
…tion of Vue when build target is Lib. Resolves vuejs#4055.
…tion of Vue when build target is Lib. Resolves vuejs#4055.
I'm skeptical about the actual use case. What about adding a flag to the
|
I got my plan to work by globally registering the components i wanted to share to the subcomponents. This way i don't have to call anything special. For data transfer between both i use either props or vuex. I build with target lib and include them using dynamic imports with the native require instead of webpack require. So far no issues for me |
@sodatea When will it be released? i strongly need this feature |
@mithom how do you resolve this question? is there some code to see ? |
@romansp Yeah go ahead please. |
…tion of Vue when build target is Lib. Resolves vuejs#4055.
…rnalization of Vue when build target is Lib. Resolves vuejs#4055.
…ernalization of Vue when build target is Lib. Resolves vuejs#4055.
…ernalization of Vue when build target is Lib.Resolves vuejs#4055.
@sodatea |
This feature is now shipped in both v3.11.0 & v4.0.0-rc.0 |
@sodatea thanks. perfect! |
When inline flag is true, is Vue attached to global variable? What if two components bundle different versions of Vue? |
@Dika-pro no. Vue is module |
What problem does this feature solve?
We are building multiple micro frontend applications that are then stitched together into singular spa experience at run-time. As such, building these applications in using a build target "--target app" is not a viable approach. We need a single file that contains the application source code to load up as we are stitching applications together. For this reason, using a build target "--target lib" seemed like a ideal solution for us. However, we've noticed the build tool contains logic when it is building the application that it excludes Vue instances automatically, which you folks have clearly indicated in your documentation. We weren't able to override this behavior using either the configureWebpack object nor the chainWebpack() callback function.
What does the proposed API look like?
As simple fix would be to move the process of externalizing Vue up prior to applying configureWebpack config object or executing chainWebpack() callback. That way, you are giving programmers the flexibility to include it if it suits their architectural scenario without it being a breaking change.
The text was updated successfully, but these errors were encountered: