question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow multiple entries when using build with the target flag.

See original GitHub issue

What problem does this feature solve?

It would allow users to build multiple libraries at once, ideally this would be usable with the --watch flag.

I have posted a detailed issue on the forum describing my use case for those interested, but after looking at the code I can see that this will most likely require updates to the internal structure of the Vue cli.

This is primarily aimed at people building modular component libraries on top of Vue (particularly ones that can be loaded from a CDN which is my use case).

For additional background I am trying to pre-compile my components (using --target lib) and then load them over http using the technique outlined here but that is outside of the context of what I am actually asking for.

What does the proposed API look like?

If no path is provided when using build with the --target command fallback to the entries config (particularly the one in vue.config.js) ie:

    config.entryPoints.delete("app");
    // Add entry points
    config
      .entry("component-one")
      .add("./src/components/ComponentOne.vue")
      .end()
      .entry("component-two")
      .add("./src/components/ComponentTwo.vue")
      .end();

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:15
  • Comments:21 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
xfyrecommented, Mar 30, 2020

Another use case for this is when you embed Vue into an existing non-SPA application. To modernize pages separately you’ll need to build a Vue library for each one of them, so multiple entries is a necessity to avoid (1) invoking vue-cli-service multiple times during production build (2) supporting dev workflow when vue-cli-service should run in the background and watch for changes.

8reactions
morficuscommented, Aug 30, 2019

This is primarily aimed at people building modular component libraries on top of Vue

🙋‍♂ hi, hello, yes. this is me. this is exactly what I’m trying to do.

Currently I’m just doing vue-cli-service build --target lib --name my-lib-name ./src/index.js (where index.js has a list of imports and named exports for each component). This results in a single output file… but consumers of the library would still be importing ALL components unless they have tree-shaking turned on.

The problem we are running in to now is that some consumers are doing SSR… and not all components are SSR-friendly (they relay on browser APIs like localStorage, etc). But because everything gets rolled in to a single file… even if they import an SSR-friend component, an error still happens because it’s trying to evaluate the entire file (this is specific to non-production / local dev mode, where tree-shaking is never enabled).

So now we are looking to create an individual export file per component. But just realized that the vue-cli-service does not allow for multiple inputs nor multiple outputs (I tried doing vue-cli-service build --target lib ./src/**/*.vue which did not give an error… but did produce a rather bizarre file with not my components haha).

I did come across this issue which is somewhat related: https://github.com/vuejs/vue-cli/issues/2744, which is not ideal but does get us a closer to what we need.

Anyways… that is just a very long-winded way of saying that I would love for vue-cli-service to support multiple and dynamic entry points 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple values for AfterTargets in .proj file - msbuild
First, rename your two files as Project1.targets and Project2.targets . The file with proj suffix cannot be used in other referenced files.
Read more >
Targets - Parcel
Parcel can compile your source code in multiple different ways simultaneously. These are called targets. For example, you could have a “modern” target...
Read more >
Flags: constraints in dependencies - FuseSoC Documentation
Flags in FuseSoC are global boolean variables that influence the dependency resolution and other aspects of the build. Flags can be used in...
Read more >
MSBuild Targets - Microsoft Learn
Learn how MSBuild uses targets to group tasks together and allow the ... For details and more information about the target build order, ......
Read more >
Targeting rules - LaunchDarkly docs
This topic explains how to use targeting rules to target segments of ... LaunchDarkly treats it as multiple values and allows any of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found