Yes - ts does generate invalid code in watch mode. Gulp generates a compilation failed message - which is of course exactly what I want - I want to be warned that my code wonāt compile.
Most times, au run or au build --watch recovers itself, but sometimes I get the A build is already in progress, deferring change detection...
message.
This used to happen with webpack as well - mostly when I was importing a new file import {xxx} from "myFiles"
and I think alameda struggles with this sometimes.
Iām just guessing here but I think the sequence of events for au build --watch is
- Build the app
- Watch for changes
- Warn on ts compilation error
- Build app - I think that while its building the app, and there are still compilation errors it goes into ādefer modeā.
- When the compilation errors are fixed, it should come out of ādefer modeā and try to build again - but it doesnāt.
Maybe it needs some kind of timer to try to rebuild after it entered ādefer modeā.
I would gladly suffer an extra couple of rebuilds if I could avoid this problemā¦
As to specific moments when this happens - Iām not 100% sure itās exactly this but it could be something like.
I write the method:
public async activate(){
this.loadBankList()
}
but I havenāt written āloadBankList()
yet - so I get a compilation error.
I now write
private async loadBankList(){
... do something
}
and TS compiles fine . Alameda is now in ādefer modeā.
This is the stack trace just now
Finished 'writeBundles'
Application Available At: https://localhost:9000
BrowserSync Available At: http://localhost:3001
[12:45:12] modules\production\production-edit.ts was changed
Watcher: Adding path src\modules\production\production-edit.ts to pending build changes...
Watcher: Running transpile tasks on next build...
Starting 'readProjectConfiguration'...
Finished 'readProjectConfiguration'
Starting 'configureEnvironment'...
Finished 'configureEnvironment'
Starting 'buildTypeScript'...
src\modules\production\production-edit.ts(128,49): error TS1003: Identifier expected.
TypeScript: 1 syntax error
TypeScript: emit succeeded (with errors)
[12:45:16] gulp-notify: [Error running Gulp] Error: TypeScript: Compilation failed
Finished 'buildTypeScript'
Starting 'writeBundles'...
INFO [Bundler] Tracing files ...
ERROR [BundledSource] Could not convert to AMD module, skipping C:\Visual Studio\FactoryCashFlow\FactoryCashFlow\src\modules\production\production-edit.js
ERROR [BundledSource] Error was: SyntaxError: unknown: Unexpected token (209:74)
207 | bank = this.banksList.find(function (c) { return c.id === _this.auth.payload.bankId; });
208 | if (bank) {
> 209 | this.bankImageUrl = bank.imageDataUrls[0].;
| ^
210 | }
211 | return [2 /*return*/];
212 | }
ERROR [Bundler] Failed to do transforms
INFO [Bundler] Error: Line 209: Unexpected token ;
{ uid: 20,
name: 'writeBundles',
branch: false,
error:
{ Error: Line 209: Unexpected token ;
at ErrorHandler.constructError (C:\Visual Studio\FactoryCashFlow\FactoryCashFlow\node_modules\aurelia-cli\node_modules\esprima\dist\esprima.js:5012:22)
at ErrorHandler.createError (C:\Visual Studio\FactoryCashFlow\FactoryCashFlow\node_modules\aurelia-cli\node_modules\esprima\dist\esprima.js:5028:27)
at Parser.unexpectedTokenError (C:\Visual Studio\FactoryCashFlow\FactoryCashFlow\node_modules\aurelia-cli\node_modules\esprima\dist\esprima.js:1985:39)
at Parser.throwUnexpectedToken (C:\Visual Studio\FactoryCashFlow\FactoryCashFlow\node_modules\aurelia-cli\node_modules\esprima\dist\esprima.js:1995:21)
at Parser.parseIdentifierName (C:\Visual Studio\FactoryCashFlow\FactoryCashFlow\node_modules\aurelia-cli\node_modules\esprima\dist\esprima.js:2831:19)
at Parser.parseLeftHandSideExpressionAllowCall (C:\Visual Studio\FactoryCashFlow\FactoryCashFlow\node_modules\aurelia-cli\node_modules\esprima\dist\esprima.js:2906:38)
at Parser.inheritCoverGrammar (C:\Visual Studio\FactoryCashFlow\FactoryCashFlow\node_modules\aurelia-cli\node_modules\esprima\dist\esprima.js:2285:37)
at Parser.parseUpdateExpression (C:\Visual Studio\FactoryCashFlow\FactoryCashFlow\node_modules\aurelia-cli\node_modules\esprima\dist\esprima.js:3004:26)
at Parser.parseUnaryExpression (C:\Visual Studio\FactoryCashFlow\FactoryCashFlow\node_modules\aurelia-cli\node_modules\esprima\dist\esprima.js:3048:26)
at Parser.inheritCoverGrammar (C:\Visual Studio\FactoryCashFlow\FactoryCashFlow\node_modules\aurelia-cli\node_modules\esprima\dist\esprima.js:2285:37)
index: 11460,
lineNumber: 209,
description: 'Unexpected token ;' },
duration: [ 0, 580632599 ],
time: 1550234717154 }
[12:45:17] modules\production\production-edit.ts was changed
Watcher: Adding path src\modules\production\production-edit.ts to pending build changes...
Watcher: A build is already in progress, deferring change detection...
[12:45:20] modules\users\users-edit.ts was changed
Watcher: Adding path src\modules\users\users-edit.ts to pending build changes...
Watcher: A build is already in progress, deferring change detection...
Of course the compilation errors are quite correct.
You can see as [12:45:17; that its reading in the newly edited production-edit.ts
file, but its apparently trying to finish its previous build.
Maybe it should cancel any previous builds the moment it observes that a file has been edited and then start again?
Hey - Iām way way out of of comfort zone making comments to you about this