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

feat(compiler-cli): add watch mode to `ngc` #18818

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
5 participants
@chuckjaz
Member

chuckjaz commented Aug 21, 2017

PR Type

What kind of change does this PR introduce?

[x] Feature

What is the current behavior?

ngc does not have a watch mode that automatically recompiles files when they are changed on disk.

What is the new behavior?

ngc now accepts -w and --watch that will watch for changes made on disk and automatically recompile the files. This is similar to tscs -w parameter but will also emit the factory classes and metadata.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

@googlebot googlebot added the cla: yes label Aug 21, 2017

@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Aug 22, 2017

@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Aug 22, 2017

@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Aug 22, 2017

@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Aug 22, 2017

@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Aug 22, 2017

@tbosch

tbosch approved these changes Aug 24, 2017

Show outdated Hide outdated packages/compiler-cli/src/perform_compile.ts
Show outdated Hide outdated packages/compiler-cli/src/perform_compile.ts
Show outdated Hide outdated packages/compiler-cli/src/perform_compile.ts
import {createCompilerHost} from './transformers/entry_points';
const ChangeDiagnostics = {
Compilation_complete_Watching_for_file_changes: {

This comment has been minimized.

@tbosch

tbosch Aug 24, 2017

Member

I think these should all have a code property too, see above.

@tbosch

tbosch Aug 24, 2017

Member

I think these should all have a code property too, see above.

This comment has been minimized.

@tbosch

tbosch Aug 29, 2017

Member

Agreed to do this later.

@tbosch

tbosch Aug 29, 2017

Member

Agreed to do this later.

it('should recompile when a ts file changes', expectRecompile(() => {
write('greet.ts', `
import {Component, Input} from '@angular/core';

This comment has been minimized.

@tbosch

tbosch Aug 24, 2017

Member

Consider adding checks for the generated files too, eg some assertion on the time stamps of .ngfactory files.

@tbosch

tbosch Aug 24, 2017

Member

Consider adding checks for the generated files too, eg some assertion on the time stamps of .ngfactory files.

This comment has been minimized.

@tbosch

tbosch Aug 24, 2017

Member

Consider also adding unit tests for watch mode with a mock WatchHost, as these will execute faster. When we add more functionality, we would just add tests to the true unit tests...

@tbosch

tbosch Aug 24, 2017

Member

Consider also adding unit tests for watch mode with a mock WatchHost, as these will execute faster. When we add more functionality, we would just add tests to the true unit tests...

@tbosch

This comment has been minimized.

Show comment
Hide comment
@tbosch

tbosch Aug 24, 2017

Member

Regarding NgDiagnostic: should be so that TS.Diagnostic us assignable to it.

Member

tbosch commented Aug 24, 2017

Regarding NgDiagnostic: should be so that TS.Diagnostic us assignable to it.

@tbosch

This comment has been minimized.

Show comment
Hide comment
@tbosch

tbosch Aug 24, 2017

Member

Oh, and maybe we can use TS.formatDiagnostics for ngDiagnostic too then, assuming it only relies on SourceFileLike properties -> our formatDiagnostics would just delegate to ts.formatDiagnostics with a cast.

Also all of our API should just return NgDiagnostic[], and not a (TS.Diagnostic | NgDiagnostic)[]

Member

tbosch commented Aug 24, 2017

Oh, and maybe we can use TS.formatDiagnostics for ngDiagnostic too then, assuming it only relies on SourceFileLike properties -> our formatDiagnostics would just delegate to ts.formatDiagnostics with a cast.

Also all of our API should just return NgDiagnostic[], and not a (TS.Diagnostic | NgDiagnostic)[]

@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Aug 29, 2017

@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Aug 29, 2017

/**
* The logic in this function is adapted from `tsc.ts` from TypeScript.
*/
export function performWatchCompilation(host: PerformWatchHost): {

This comment has been minimized.

@tbosch

tbosch Aug 29, 2017

Member

It would be nice to have unit tests for this function as well.

@tbosch

tbosch Aug 29, 2017

Member

It would be nice to have unit tests for this function as well.

This comment has been minimized.

@chuckjaz

chuckjaz Aug 29, 2017

Member

As agreed offline, this will be a follow-up PR.

@chuckjaz

chuckjaz Aug 29, 2017

Member

As agreed offline, this will be a follow-up PR.

@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Aug 29, 2017

feat(compiler-cli): add watch mode to `ngc`
With this change ngc now accepts a `-w` or a `--watch`
command-line option that will automatically perform a
recompile whenever any source files change on disk.
@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Aug 30, 2017

@jasonaden jasonaden closed this in 06d01b2 Aug 31, 2017

jasonaden added a commit that referenced this pull request Aug 31, 2017

vicb added a commit to vicb/angular that referenced this pull request Aug 31, 2017

feat(compiler-cli): add watch mode to `ngc` (#18818)
With this change ngc now accepts a `-w` or a `--watch`
command-line option that will automatically perform a
recompile whenever any source files change on disk.

PR Close #18818

jasonaden added a commit that referenced this pull request Aug 31, 2017

feat(compiler-cli): add watch mode to `ngc` (#18818)
With this change ngc now accepts a `-w` or a `--watch`
command-line option that will automatically perform a
recompile whenever any source files change on disk.

PR Close #18818

@PanayotCankov PanayotCankov referenced this pull request Nov 2, 2017

Closed

Webpack for development #5024

4 of 5 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment