generator-angular2-library
generator-angular2-library copied to clipboard
`dist/` should not be deleted on rebuilds, only contents instead
@jvandemo heya, I recently discovered a shortcoming in my starter, where the dist/
dir is always deleted.
This causes linked libraries to not update the project that are using it, since the link is broken when dist/
is deleted. Instead, only its contents should be deleted.
Details and repro can be found at https://github.com/angular/angular-cli/issues/6195.
Update: removing `clean:dist' from line 173 and 182 is actually necessary to fully get refreshes to work. This isn't ideal. Discussion ongoing in angular/angular-cli#6195.
@filipesilva — Thank you for your note, much appreciated! 👍
I will have a look at this tomorrow morning before work and will keep you posted. Thanks again!
Just fo confirm that I am seeing the same behavior here (on Mac).
Setup:
- generate library using generator-angular2-library in directory
my-lib
- in
my-lib
, rungulp
to buildmy-lib/dist
- in
my-lib/dist
, runnpm link
- generate app with Angular CLI in
my-app
- in
my-app
, runnpm link my-lib
- import
my-lib
inapp.module.ts
- in
my-app
, runng serve --aot
Scenario:
- change file in
my-lib/src
- gulp will pick up change and regenerate
my-lib/dist
-
ng-serve --aot
detects a change and recompiles successfully - the web page does not reflect the change
Learnings so far:
- files in
my-app/node_modules
update correctly - angular-cli does seem to detect the change and runs a compilation, but the output does not reflect the change
- running
ng serve
instead ofng serve --aot
shows the change correctly
I will perform some additional research before work later this week 👍
It looks like the refresh issue with Angular CLI still isn't figured out, but I've made a change to my local instance of the gulp file and got clean to work without unlinking dist/
using the steps outlined here. I'd be happy to do a quick PR if you'd like.
@bniedermeyer I'm running into this same issue-would you mind posting your gulp file, as I'm struggling to find where I should be making these changes? Thanks!
@clarkj Sure thing. I made a modification to deleteFolders()
. I posted a Gist here. Because using del, deletes the folder itself, you just have to set it to ignore.
Edit: I should mention that this doesn't fix the refresh issue with running ng serve
. I still need to restart my dev server for the changes to be picked up but I do see them after a restart.
I have just released v10.2.2, which no longer deletes the dist
directory.
@filipesilva and @bniedermeyer — Thank you for your help! Much appreciated! 👍
I will leave this issue open to further investigate the refresh issue.
now I get the error
RROR in ../ng-library/dist/index.js
Module build failed: Error: ENOENT: no such file or direc
tory, open '.../ng-library/dist/index.js'
@ ./src/app/app.module.ts 10:0-53
@ ./src/main.ts
@ multi webpack-dev-server/client?http://localhost:4200
./src/main.ts
webpack: Failed to compile.
The workaround around i am using is to comment out the code in clean:dist task
@sgentile — Are you still getting this error with the latest version of the generator? Thanks!
@jvandemo i tested it today with the latest generator and the missing index.js error still happens.
the problem persists when the components are in subdirectories in the library
yes, because the app linking to it fails because index.js doesn't exist any longer... (the host is using angular-cli and in watch mode, as soon as it rebuilds it fails, and then exits).
ie.
ERROR in ../library/dist/index.js Module build failed: Error: ENOENT: no such file or directory, open '.../Projects/library/dist/index.js' at Error (native) @ ./src/app/app.module.ts 29:0-53 @ ./src/main.ts @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
my workaround has been to link to src during development and then just validate aot, tests before pushing my code by then linking to dist.
On Wed, Sep 20, 2017 at 12:03 AM, Jurgen Van de Moere < [email protected]> wrote:
@sgentile https://github.com/sgentile — Are you still getting this error with the latest version of the generator? Thanks!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jvandemo/generator-angular2-library/issues/91#issuecomment-330739120, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIFNCy5iB1fAKONnY9deWJE1PEGQV9fks5skI6JgaJpZM4NdjOZ .
Due the the more strict cli 1.5, When linking from /src in my library, I get the following error in the app that consumes my library:
Module build failed: Error: .../src/index.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
Does it mean that I have to add files in tsconfig manually (and not to forget to remove it further), or is there a better practice ?
I left a comment https://github.com/angular/angular-cli/issues/6195#issuecomment-355992061 that might help some people resolve issues around this.