259 questions
Advice
1
vote
3
replies
61
views
Angular 20 @defer dynamic dependencies
I have an Angular component in a private npm package using ng-packagr and hosted on AWS (CodeArtifact).
The purpose of the component is to be a reactive form field that shows and hides errors based on ...
1
vote
1
answer
160
views
Build of angular library with ng-packagr fails for json translation files not found
I migrated one of our projects from Angular 18 to Angular 20.
The projects is strutured in this way:
project_name
-- projects
---- frontend
---- lib
------ src
------ lib
-------- i18n
-------- public-...
0
votes
2
answers
599
views
How to import font assets?
I am trying to create an Angular 19 library with a personalized fonts linked directly into a global SCSS file.
On build time, I have the exact same error being raised by builder:
src/lib/label/label....
1
vote
1
answer
66
views
Injection Token Renamed When Importing Angular Library
I have created a test library (NgxTest) using ng-packagr, which makes use of the APP_BOOTSTRAP_LISTENER injection token:
import { APP_BOOTSTRAP_LISTENER, ComponentRef, NgModule } from "@angular/...
1
vote
1
answer
196
views
How to copy the README.md file, inside an angular project before publishing it to npm
I've created a library with Angular libraries
This is my pretty default project structure
- README.md
- package.json
- angular.json
- projects
- my-project
- ng-package.json
- package.json
...
1
vote
1
answer
174
views
ngPackagr define allowedCommonJsDependencies
In Angular when using a CommonJS dependency like moment one gets a warning like
CommonJS or AMD dependencies can cause optimization bailouts.
For more information see: https://angular.dev/tools/cli/...
1
vote
1
answer
465
views
Angular library secondary entry points that reference each other , use via npm link
All the examples I find for developing libraries in Angular always have the library in the same workspace as the app, but I can't do so.
I have three different Angular 18 workspaces, one for libraryA, ...
0
votes
1
answer
69
views
Migrate Angular functions to common library
Our Angular project has evolved to have a bunch of functions that don't really belong in any class (in addition to all the normal classes of course). We now need a new Angular project that wants to ...
0
votes
1
answer
462
views
Add images assets in angular library
I'm in the process of creating an angular library so that I can reuse certain functionalities between 2 projects without having to copy and paste.
I'm faced with a problem: How to add images for use ...
1
vote
1
answer
684
views
How to bundle standalone component and directive when building an Angular library
I have built an Angular library that contains a component and a directive which are intrinsically linked. That is the component uses the directive. Everything works fine other than to successfully use ...
1
vote
1
answer
823
views
angular custom package missing specifier
I have created an angular custom package (angular 17.3) in which there is a service.
After publish, I install the package and am able to see the service. But I have en error
An unhandled exception ...
1
vote
2
answers
3k
views
How to build and consume an Angular 18 library
The project I'm working on needs to split some components into a shared library. I'm using Angular 18 with standalone components. I've found a lot of answers / articles for these issues online, but ...
0
votes
1
answer
1k
views
Angular 17+ new build system and ng-packagr
I am currently upgrading from Angular 16 to Angular 18. I read on the changes that there is a new build system being implemented for the newer version.
However, most of my packages are using "ng-...
-1
votes
1
answer
561
views
Cannot Find Stylesheet From Custom Library in Angular
I'm using Angular v17. I'm building a custom library with a stylesheet that I'd like to import using @import "@my-company/ngx-luai/styles/index"; in my application's style.scss file.
My ...
3
votes
0
answers
2k
views
How to export stylesheets from Angular libraries?
Recently I've started splitting up a large angular project into seperate libraries. This worked fine until I tried to create a library with the css variables that are used by all other libraries. This ...
0
votes
1
answer
247
views
Angular 13 package throws error "moment is not a function" when imported into a Angular 13 project
i'm upgrading a private library (privLib) to Angular 13, so i can migrate all other projects, but when imported into a project one of the services uses moment and throws an error: "ERROR ...
1
vote
0
answers
145
views
Angular: problem using code from one library in another library
Suppose an Angular workspace with two libraries inside (e.g. projects/libA and projects/libB). In libA I'm importing code from libB
import { ComponentX } from '@myscope/libB';
ComponentX is exported ...
0
votes
0
answers
159
views
Angular MonoRepo Secondary Enpoints with different paths
I have a monorep using @nx and @angular and I have setup a folder structure as follows:
libs
- ui-components
--_components
---atoms
----alert
---molecules
----datepicker
--alert
--datepicker
As you ...
2
votes
0
answers
1k
views
How to use allowedNonPeerDependencies with npm workspaces for Angular libraries?
I'm working on an Angular library in a monorepo comprised of multiple projects which we publish separately and use internally across multiple apps. Our tooling has been fairly archaic until now. I'm ...
1
vote
2
answers
734
views
Obtaining "Invalid string length" while running ng build of a library
In Angular (see spec below), trying to generate a large library, thus running ng build <project>, we obtain
❌ Generating "fesm2015"
Invalid string length
Indeed, fesm2020 build ...
0
votes
1
answer
277
views
Angular library: make local TypeScript dependency part of the compilation
I have a Angular lib inside a Nx workspace...
The lib consumes code from another local lib for some shared TS code.
The shared libs path is defined in the tsconfig paths setting:
"paths": {
...
1
vote
0
answers
1k
views
Angular 12 library not including css styling on build
It's my first time trying to build a library in Angular, so I'm a little bit lost here. When I style my components with the assigned stylesheets, nothing follows into the actual library, leaving my ...
0
votes
1
answer
569
views
Can't find stylesheet to import after angular upgrade
When I run
npx ng build @mls-ops/tests
I have an error:
Building Angular Package
× Compiling with Angular sources in Ivy partial compilation mode.
Can't find stylesheet to import.
╷
1 │ @import '...
1
vote
0
answers
27
views
angular lib skip resolve npm package
I have a angular lib and it is named 'ngx-qwe'.
The 'ngx-qwe' quote a npm package 'ngx-asd'.
The 'asd' package has build error when i build 'qwe'
I use 'ng build ngx-qwe --configuration production' to ...
2
votes
0
answers
220
views
ng-packagr: share code between sub-entries but exclude the shared code from distribution
I have an angular library with multiple secondary entry points: a and b.
I do also have some code which is shared accross a and b.
The shared code is located in another secondary entry point shared.
...
1
vote
0
answers
568
views
Exclude unused dependencies from package.json using ng-packagr
I have a shared web/nativescript library. All nativescript files have a **/*.tns.ts filename format. Nativescript handles replacing any file with the same name but without the tns part with its tns ...
1
vote
1
answer
841
views
Angular 12 build package error without any detail
I have an Angular 12 library project that built fine in the past (year or two ago), but now it is failing. The only output I'm seeing is as follows:
Building Angular Package
moduleName.startsWith is ...
2
votes
1
answer
124
views
Resolving a library projects SASS files from an application in the same workspace?
Is it possible to resolve SASS contained in a workspace library using an approach that is similar to resolving ts files from an application within the same workspace? For context I'll setup a real ...
1
vote
1
answer
2k
views
Entry point X has a circular dependency on Y
I have a component X which imports a component Y.
In componentx.model.ts I defined some types and interfaces.
In component Y I would like to use one of these interfaces so I import it with import { ...
3
votes
1
answer
2k
views
How to declare a dependency as optional in an Angular Library?
We have an Angular library where we have multiple modules. Each module can be imported and used independently in parent projects.
In one of those modules' component we have an import from a dependency ...
1
vote
2
answers
5k
views
How to create a Angular library NPM package, that will allow importing modules the way the Angular Material does
In Angular Material (AM) we can import single module from the @angular/material like this:
import { MatButtonModule } from '@angular/material'
I would like to re-use this approach also for my library, ...
1
vote
1
answer
371
views
Import scss from a secondary entry
I have an Angular library which has secondary entries.
From one of those, I'd like to export a .scss file.
In my .tsconfig, I create a path:
...
path:{
"@my-entry/*":["my-entry/*"]...
2
votes
1
answer
1k
views
Entry point @example/ng-bootstrap/core which is required by @example/ng-bootstrap/src/lib/badge doesn't exists. - NX
I've built an angular component library in an NX workspace. For several weeks I've been struggling to get my angular library to work properly. The library contains some 50 components with their ...
2
votes
0
answers
458
views
ng-packagr with secondary entry point
I got an error while building the source code using ng-packagr with Secondary Entry Points.
My project structure:
enter image description here
I followed the guide from official repo https://github....
1
vote
1
answer
1k
views
Angular 14 to 15 update results in constructor parameter compatibility error in library
I have authored a library for extracting environment variables that are set from server-side rendering.
This library provides a base class to extend. getEnvironmentValues() has been omitted for ...
0
votes
1
answer
770
views
No provider for InjectionToken ng.v5.defaultTsConfig
I have a problem when I was execute npm run build. In the terminal an error appears:
No provider for InjectionToken ng.v5.defaultTsConfig! (InjectionToken ng.v5.packageTransform -> InjectionToken ...
0
votes
0
answers
1k
views
NG8001: 'some-component' is not a known element - angular 13
I use angular 13.3. I have a project that name is "pazh-base-source" that some of my base component is in it such as pazh-component.ts . I want to use this components in my main project. I ...
2
votes
2
answers
1k
views
Use JS script file in angular library
I am trying to create an angular library in which one of the service has to make use of web-sdk.js file by importing it.
Everything is working perfectly fine when I create that service inside of the ...
0
votes
0
answers
116
views
Link angular library projects together
Our angular application is getting refactor to be split up into multiple small libraries. However we are having problems creating the links in between the libraries. Most articles explain in details ...
0
votes
2
answers
921
views
Material doesn't work in Angular 13 library project
I have an Angular 13 library on the go. It works with the other modules I have already got in there, but this new module I'm moving into place uses material, and it's not happy.
The new module itself ...
14
votes
1
answer
6k
views
peerDependencies configuration for publishable libraries with NX & Angular
I have a monorepo using NX & Angular and I am publishing some libs to NPM and i have the following scenario
apps
only_App
libs
lib_A // v1.0.0
lib_B // v1.0.0
lib_C // v1.0.0
lib_A ...
3
votes
0
answers
807
views
use require() in .mjs bundles - Angular 13
I recently upgraded my project to Angular 13, I noticed that the new ng-packgr 13 bundles in .mjs extension by default. I have lots of code that uses require() to import some static assets and files. ...
1
vote
1
answer
402
views
After update of either npm, or ng-packagr, publish tries to use incorrect package name and version
After migration to [email protected], [email protected] and Angular@13 I am not able to publish package generated by ng-packager to npm repository.
package.json:
{
"name": "@me/ng13",
"...
2
votes
1
answer
5k
views
How to import angular 13 library packaged SASS?
With Angular 13 and the ng-packagr when we publish SASS mixins with a library we need to add the library to exports in package.json and also declare an assets block in ng-package.json.
These are the ...
4
votes
0
answers
1k
views
In Angular 13 How to switch library build to .js output instead .mjs format
In Angular 13 the main app compiles in .js format but when we build library with ng build, output format are .mjs files
Can we build libs to .js with ng build in Angular 13?
I'm trying to use built ....
0
votes
1
answer
327
views
Does ng-packagr generate script who can run in the browser like normal js?
Can I use ng-packagr to build library with one script file that can run on the browser in the html by import as <script src="bundle.js"></script>?
For example I have main.ts that ...
2
votes
1
answer
2k
views
SCSS paths in angular library
I am creating angular library, and I have some scss files in my-lib/src/styles and I include those files in component scss files. For instance:
@import 'src/styles/_tokens.scss';
When I build the ...
1
vote
0
answers
1k
views
angular library, secondary entry points with shared resources?
I'm trying to make an angular library with secondary entry points.
I have 2 entry points: input and select:
📦library
┣ 📂assets
┃ ┗ 📜_all.scss
┣ 📂select
┃ ┣ 📂src
┃ ┃ ┣ 📂components
┃ ┃ ┃ ┗ 📂...
0
votes
1
answer
362
views
How to get ng-packagr to recognize a Typescript type definition
Since upgrading to Typescript 4.4.2 (needed to support Angular 13), the require syntax is no longer supported.
Now it seems I must use this syntax instead:
import * as d3ContextMenu from 'd3-context-...
9
votes
3
answers
9k
views
Angular 13 package/library throws error "moment is not a function" when imported into a Angular 13 project
Im upgrading a private angular library/package (my-lib) so i can migrate all other projects, but when imported into a project one of the services uses moment and throws an error:
"ERROR TypeError:...