jasonaden / angular-cli-lib-example Goto Github PK
View Code? Open in Web Editor NEWExample of making an Angular CLI project with a library distributed separate from the app.
Example of making an Angular CLI project with a library distributed separate from the app.
Hi there! I'm having a bad time here trying to get npm run build:lib to succeed and I'm not sure what I'm doing wrong. Here's my console output:
Building Angular Package
Building entry point 'ng-mylib'
Rendering Stylesheets
Rendering Templates
Compiling TypeScript sources through ngc
BUILD ERROR
: Angular compiler option "flatModuleIndex" requires one and only one .ts file in the "files" field.
Error: : Angular compiler option "flatModuleIndex" requires one and only one .ts file in the "files" field.
at Object.<anonymous> (/home/dev/ng-mylib/node_modules/ng-packagr/lib/ngc/compile-source-files.js:61:68)
at Generator.next (<anonymous>)
at /home/dev/ng-mylib/node_modules/ng-packagr/lib/ngc/compile-source-files.js:7:71
at new Promise (<anonymous>)
at __awaiter (/home/dev/ng-mylib/node_modules/ng-packagr/lib/ngc/compile-source-files.js:3:12)
at Object.compileSourceFiles (/home/dev/ng-mylib/node_modules/ng-packagr/lib/ngc/compile-source-files.js:19:12)
at Object.<anonymous> (/home/dev/ng-mylib/node_modules/ng-packagr/lib/ng-v5/entry-point/ts/compile-ngc.transform.js:42:34)
at Generator.next (<anonymous>)
at /home/dev/ng-mylib/node_modules/ng-packagr/lib/ng-v5/entry-point/ts/compile-ngc.transform.js:7:71
at new Promise (<anonymous>)
I've tried putting breakpoints down in the angular compile level, and what I'm seeing is the complaint happens because two rootFiles are being offered to createBundleIndexHost:
0:"/home/dev/ng-mylib/libs/ng-mylib/public_api.ts"
1:"/home/dev/ng-mylib/libs/ng-mylib/ng-mylib.ts"
I have not yet been able to figure out why that is the case though. Can you offer any pointers on where I might be going wrong? I think I followed the guidance on editing tsconfig.json and package.json files in the project, but clearly I missed something. Any help would be appreciated!
Hi,
It may be more a question that an issue, maybe I missed something. It seems to me that the library and the "demo" app (i.e. the app listing the lib in its own package.json
) shouldn't be sharing all the dependencies in node_modules.
Currently it seems to me that there is no validation of the library's peerDependencies
. A build can work for this repo, but then if the lib gets published, and another project add it to its dependencies, it will only get notified of some peerDependencies
like @angular/common
/@angular/core
in your case.
If the lib itself has external dependencies, nothing makes sure to add those to the delivered package.json
. You have to manually check what's needed and add it to the library's peerDependencies
.
Am I missing something or is this process currently manual/unsafe?
Thank you!
why do you use an .angular_cli.tgz
in the project root instead of just installing a version from npm using the package.json
?
The link in the following line:
the talk given at the Angular Mountain View Meetup (video here).
When following the link, Youtube reports This video is unavailable
.
Getting Error Above when I run this command: npm run build:lib
What's up with this line of the package.json file for this project?
https://github.com/jasonaden/angular-cli-lib-example/blob/master/package.json#L48
Why not just an appropriate semver dependency? Can this be explained in the README please?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.