Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dist/ should not be deleted on rebuilds, only contents instead #91

Open
filipesilva opened this issue May 17, 2017 · 15 comments
Open

dist/ should not be deleted on rebuilds, only contents instead #91

filipesilva opened this issue May 17, 2017 · 15 comments

Comments

@filipesilva
Copy link

filipesilva commented May 17, 2017

@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 angular/angular-cli#6195.

@filipesilva
Copy link
Author

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.

@jvandemo
Copy link
Owner

@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!

@filipesilva filipesilva changed the title dist/ should not be deleted win rebuilds, only contents instead dist/ should not be deleted on rebuilds, only contents instead May 17, 2017
@jvandemo
Copy link
Owner

Just fo confirm that I am seeing the same behavior here (on Mac).

Setup:

  1. generate library using generator-angular2-library in directory my-lib
  2. in my-lib, run gulp to build my-lib/dist
  3. in my-lib/dist, run npm link
  4. generate app with Angular CLI in my-app
  5. in my-app, run npm link my-lib
  6. import my-lib in app.module.ts
  7. in my-app, run ng serve --aot

Scenario:

  1. change file in my-lib/src
  2. gulp will pick up change and regenerate my-lib/dist
  3. ng-serve --aot detects a change and recompiles successfully
  4. the web page does not reflect the change

Learnings so far:

  1. files in my-app/node_modules update correctly
  2. angular-cli does seem to detect the change and runs a compilation, but the output does not reflect the change
  3. running ng serve instead of ng serve --aot shows the change correctly

I will perform some additional research before work later this week 👍

Watch recording to see it happening live on screen

@bniedermeyer
Copy link

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.

@clarkj
Copy link

clarkj commented May 18, 2017

@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!

@bniedermeyer
Copy link

bniedermeyer commented May 18, 2017

@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.

@jvandemo
Copy link
Owner

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.

@sgentile
Copy link

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.

@sgunapude
Copy link

The workaround around i am using is to comment out the code in clean:dist task

@jvandemo
Copy link
Owner

@sgentile — Are you still getting this error with the latest version of the generator? Thanks!

@sgunapude
Copy link

@jvandemo i tested it today with the latest generator and the missing index.js error still happens.

@ljacques
Copy link

the problem persists when the components are in subdirectories in the library

@sgentile
Copy link

sgentile commented Sep 21, 2017 via email

@sambaptista
Copy link

sambaptista commented Nov 29, 2017

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 ?

@txinfo
Copy link

txinfo commented Jan 5, 2018

I left a comment angular/angular-cli#6195 (comment) that might help some people resolve issues around this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants