What is the best method for releasing an NX library along with all its bundled dependencies?

This problem is quite common in GitHub's NX repository, but I have not been able to find a solution there.

Within my workspace, I have two buildable libraries: ui/avatar and ui/icon, as well as a publishable library named bar

The goal is to utilize ui/avatar and ui/icon as internal monorepo libraries that can be directly imported into apps. In addition, I want to bundle these buildable libs into bar and publish it as an npm package for external users to benefit from.

Here is an overview of the file structure:

📦libs
 ┣ 📂external
 ┃ ┗ 📂bar
 ┃ ┃ ┣ 📂src
 ┃ ┃ ...

So far, this initial setup works fine. I can import ui/avatar into bar and generate the @blue/bar package. However, the issue arises with the generated package.json for @blue/bar:

{
  "name": "@blue/bar",
  "version": "0.0.1",
  ...

The generated package assumes that ui/avatar is an existing npm package, when in reality I need to include it within the @blue/bar package itself, rather than as an external dependency.

I've attempted to modify the tsconfig.json file of the bar library to locally resolve the dependencies using path mapping (using paths), but so far it has not been successful.

  "compilerOptions": {
    "declarationMap": false,
    "paths": {
      "@blue/ui-avatar": ["libs/ui/avatar/src/index.ts"],
      "@blue/ui-icon": ["libs/ui/icon/src/index.ts"]
    }
  }

Any advice or suggestions on how to address this issue would be greatly appreciated. Thank you :)

Answer â„–1

After exhausting all other options and still facing an unresolved issue, I took matters into my own hands and created a custom Nx executor to get the job done. Sharing it here in the hopes that it may benefit others.

To access the executor, you can install it via npm at this link: https://www.npmjs.com/package/@altack/nx-bundlefy

The source code is also available on Github for reference: https://github.com/altack/nx-bundlefy

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Developing J2EE servlets with Angular for HTTP POST requests

I've exhausted my search on Google and tried numerous PHP workarounds to no avail. My issue lies in attempting to send POST parameters to a j2ee servlet, as the parameters are not being received at the servlet. Strangely though, I can successfully rec ...

Discovering the intricacies of using *ngFor on an object in Angular with Firebase

Tools I'm Utilizing Angular Firebase My Current Setup A component that showcases information about an 'Issue' Within the issue, there is another section called 'images' Under the image node, there are additional properti ...

Implementing a SetTimeout Function in HTML

Is there a way to delay calling the mouseHoverTableRow() function until after hovering on tr for 3 seconds? I only want to call this function if the hover duration is at least 3 seconds, as it triggers an API request. How can I achieve this? <tr *ngF ...

Is there a way to access the value of a variable from a .ts file within a .scss file?

Utilizing a css-only pie chart, I am looking to incorporate the value of this.performance in my scss to determine the percentage. How can I manipulate my scss file from .ts file? Below is a snippet of my css code in scss: $configs: ( chart-one: ( sv ...

Ensure all fields in an interface are nullable when using TypeScript

Is it possible to create type constraints in TypeScript that ensure all fields in an interface have a type of null? For example, if I want to write a validation function that replaces all false values with null, how can I achieve this? interface y { ...

Encountered an issue while trying to run the production script. Received an error when attempting to

Encountering a problem when running the command below npm run production Upon executing the command, the following error is displayed: ERROR Failed to compile with 5 errors error in ./resources/assets/sass/app.scss Module build failed: ModuleBuildErro ...

Guide on resolving the error "Type 'Emits' does not have any call signatures" in Vue 3 with the combination of script setup and TypeScript

I've come across some code that seems to be functioning properly, but my IDE is flagging it with the following warnings: TS2349: This expression is not callable. Type 'Emits' has no call signatures Below is the code snippet in question: ...

displaying post data in the URL address bar

During the development of my portal using angular 5, everything was running smoothly in the testing environment. However, due to production requirements, I made some changes to access modifiers from private to public. This modification has caused issues in ...

Angular 2 Encounter Error When Trying to Access Undefined Property in a Function

Element: import { Component, OnInit } from '@angular/core'; import { HttpClient } from '@angular/common/http'; @Component({ selector: 'app-ore-table', templateUrl: './ore-table.component.html', styleUrls: [&a ...

Ensuring Data Consistency: Using TypeScript to Strongly Type Arrays with Mixed Variable Types

I have a JSON array that may contain objects of two types, defined by IPerson and ICompany. [ { "Name" : "Bob", "Age" : 50, "Address": "New Jersey"}, { "Name" : "AB ...

typescript create object with immutable property already set

Can you create an object literal in JavaScript and define its interface with read-only properties simultaneously? For instance let obj = { readonly prop1: 'hello', readonly prop2: 'world' } ...

Typescript: Select just one option from the union

There is a specific Query type that contains the getBankAccounts property: export type Query = { getBankAccounts: GetBankAccountsResponseOrUserInputRequest, }; This property can return either a GetAccountsResponse or a UserInputRequest: export type Ge ...

Utilizing TypeScript with Context API

This is my first time working with Typescript to create a context, and I'm struggling to get it functioning properly. Whenever I try to define interfaces and include them in my value prop, I encounter errors that I can't figure out on my own. Spe ...

parsing a TypeScript query

Is there a simpler way to convert a query string into an object while preserving the respective data types? Let me provide some context: I utilize a table from an external service that generates filters as I add them. The challenge arises when I need to en ...

Tips on utilizing the context variable of an EmbeddedViewRef

I'm a bit confused on how to properly utilize the EmbeddedViewRef's context variable in Angular 2. According to the Angular 2 changelog, the context variable replaces the setLocal and getLocal methods for setting local variables in an embedded vi ...

Transition your Sequelize migrations to TypeORM

I'm currently in the process of transitioning a Node.js application from vanilla JS to Nest.js. In our previous setup, we used Sequelize as our ORM, but now we've decided to switch to TypeORM for its improved type safety. While exploring the Type ...

Angular: Granting an external module access to a provider

One of the modules I imported provides a service with an optional dependency. Although it being optional didn't affect my application, as it just prevented any errors from occurring when not present. Here's an example: import { FooModule } from ...

Having trouble receiving a response from the websocket using RxJS in Node.js with Angular

Currently experimenting with setting up a WebSocket using rxjs webSocket I have managed to create a node server without any errors, but it is not sending messages to the server or connected users When I switch to 'ws://echo.websocket.org/', I c ...

What is the syntax for using typeof with anonymous types in TypeScript?

After reading an article, I'm still trying to grasp the concept of using typeof in TypeScript for real-world applications. I understand it's related to anonymous types, but could someone provide a practical example of how it can be used? Appreci ...

Empty nested Map in POST request

I am currently working on a springboot application with a React/Typescript frontend. I have defined two interfaces and created an object based on these interfaces. export interface Order { customer_id: number; date: Date; total: number; sp ...