generator-angular2-library | Yeoman generator to create an Angular library | Generator Utils library
kandi X-RAY | generator-angular2-library Summary
kandi X-RAY | generator-angular2-library Summary
Yeoman generator to create a standalone Angular library in seconds. If you want to create an Angular library with directives, services and/or pipes, then this generator is just what you need. This generator aligns with the official Angular Package Format and automatically generates a Flat ES Module, a UMD bundle, a single metadata.json and type definitions to make your library ready for AOT compilation by the consuming Angular application. Watch Jason Aden's talk to learn more about the Angular Package Format.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Traverse all templates and inline scripts .
- Traverse inline stylesheet to inline content files
- Build s css .
- Turn a promise into a function .
- Traverse inline content in a template directory .
- Inspects text from a string .
- Remove module id .
- Delete a folder
generator-angular2-library Key Features
generator-angular2-library Examples and Code Snippets
Community Discussions
Trending Discussions on generator-angular2-library
QUESTION
Hi I am trying to build a custom Angular Library. Using yeoman-generator (link) I get a template to build upon, that works just fine. The problem is that it uses a (not anymore best practice) barrel index.ts
, and what I want is to be able to have one module per component and import accordingly.
ANSWER
Answered 2017-Sep-07 at 05:28In case someone faces the same problem, here is how my files are now structured and connected:
I have a component with the desired functionality HelloWorld
Then a module for this component:
QUESTION
I'm building an Angular (2+) component library using jvandemo/generator-angular2-library as a starter, which uses Rollup as a module builder. The component I am creating in the library uses MomentJS.
I've had various build issues with the inclusion of MomentJS.
I first used import moment from 'moment';
to import moment into the component, but that produces the following error at build;
ANSWER
Answered 2017-Oct-25 at 21:59In the sample directive I had no problem compiling when I used the following:
QUESTION
I recently upgraded an existing Angular 6 App to Angular 7. Most of my App was built on Angular 6 and then I upgraded it.
Here's my package.json:
...ANSWER
Answered 2018-Oct-30 at 06:40I had the same WARNINGS and ERROR after upgrade from Angular 6 to Angular 7. I have deleted my node_modules folder then npm install again. Now the compilation succeeds without warnings and I have no more the error "Uncaught TypeError: e is not a constructor".
QUESTION
I'm following the Angular CLI 6 instructions for creating a library here. I was able to make my library, and build it successfully. The library consists of a Component
I am using for the UI and has an HTML selector
.
ANSWER
Answered 2018-Jun-08 at 03:26Only issue i see is that your instance of the service also has the same name, change it as
QUESTION
Hi guys I need a bit of help, as I can't seem to get it to work. I think I might be using the incorrect syntax or something.
I am currently building Angular 4 libraries using YO https://github.com/jvandemo/generator-angular2-library
So everything is working except for the @Input
decorators.
Some simple code here
...ANSWER
Answered 2018-Mar-07 at 09:10Here is your mistake:
QUESTION
I generate my angular 2 lib with yeoman generator and added to main angular project. If i compile app in dev mode i haven't error, but if i run prod mode, i get many errors:
...ANSWER
Answered 2017-Nov-16 at 20:51Your intent was probably to export just what is needed, but you need to export everything from your src/index.ts
file, including all the services, directives, and pipes.
QUESTION
I am currently building an Angular library, and I wanted to be able to run some tests. After following these instructions I managed to set up everything properly and actually be able to run my tests.
Main question
Although everything runs properly something awkward happens. When I run npm test
next to every .ts
file a .js
file is generated. Normally all the d.ts
and the one big .js
files go inside a dist
folder that projects using the library use. So does anyone know from where could these javascript files are generated, and if they are indeed needed, since all this code already exists so to speak in the dist folder.
Bonus question
Not as important as the above, all the test results are displayed in the terminal, whereas the browser displays only:
Karma v1.4.1 - connected Chrome 61.0.3163 (Mac OS X 10.12.6) is idle
So is there a nice fix to display my test as nicely as the angular-cli
does out of the box?
Note that after doing my homework I did not find something relative online, and I don't want to upload a bunch of unpleasant jsons. If anyone has an idea on the direction of the problem I will be happy to include code.
The basic structure of my library was generated by this
Edit:
karma.config.js
ANSWER
Answered 2017-Oct-18 at 16:06You are getting .js
file for every .ts file because of your typescript configuration. You can change your configuration in tsconfig.json
to tell compiler that write a single file or in a folder and add all script there.
"outDir": "../out-tsc/spec"
--> will add all output javascript files in a single folder.
For your second question, When karma runs internally it runs webdriver
and connect to the browser. That is the reason you see localhost:9876
or similar url open with a debug button at the right.
While the webdriver is running you can also debug any bug situation in the browser and lot more.
QUESTION
I red this article about creating Angular 2 component library, and it uses inline styles. Is there a way to create a lib without inline styles in Angular 2?
Also I saw this, but there is no word about styles, css.
My problem is, I want to create a complex component with multiple components in it and I use SASS also.
...ANSWER
Answered 2017-Sep-22 at 03:57The problem here is that when you compile your npm package the styles templates must be inline because when you load it as a npm package you won't be able to achieve the template/css path inside node_modules.
The Angular Material 2 team used the follow gulp task to inline the css and template in its components:
They have created this task file that
- Get external CSS and put inline;
- Get external Html and put inline;
- Removes the module.id from components;
Finally, in the build process they call this task here.
My approach of doing this:Install
gulp
,gulp-angular-embed-templates
,gulp-inline-ng2-styles
.Create a file called
gulpfile.js
at the root of your appadd the following code to your
gulpfile
:
QUESTION
I am trying to create an Angular 2 library for services, components, and models I want to share between 3-4 different interfaces/apps that are frontends to the same database.
I am using the very helpful Angular 2 generator library here.
My services in the library are based around Apollo client and GraphQL.
However, when I symlink the library build to import into my main project, the Apollo dependencies don't seem to resolve.
I get the following two errors from my app build: Can't resolve 'apollo-angular/index'
and Can't resolve 'graphql-tag/index'
. This is in spite of the fact that both these libraries are installed to my node_modules
in my app, however, they don't seem to transferred by the Gulp build into my dist
directory of my library but I am not even sure they are meant to be.
I have also tried to setup peer dependencies in my library's package.json
as follows:
ANSWER
Answered 2017-Jul-27 at 16:03It might occur because of this issue.
Try to define paths in your ts
QUESTION
I'm currently working on exporting an Angular 4 component library in the format described by the Angular Package Format. To simplify this, I generated a default setup using this Yeoman generator. Everything worked perfectly at first and I could generate a working library that I could import in another Angular application. I then updated our library files after fetching all the latest changes and tried to generate a new package. The build failed this time however, with an error that I couldn't link to one of the changes that I fetched.
The message:
...ANSWER
Answered 2017-Jun-12 at 14:40Turned out that a path in a //
comment was being replaced during the build which caused it to point to a non-existing file. That led to the TsickleCompilerHost
not finding a file, which in turn led to an undefined source file. Hence the TypeError: Cannot read property 'path' of undefined
message.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install generator-angular2-library
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page