angular-cli: [v1.5] ng build doesn't work with `noEmit`

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.


    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
    
Angular CLI: 1.5.0
Node: 8.5.0
OS: darwin x64
Angular: 5.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.0
@angular-devkit/build-optimizer: 0.0.32
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.0
typescript: 2.4.2
webpack: 3.8.1

Repro steps.

  • ng new
  • open tsconfig.json and add "noEmit": true
  • ng build

The log given by the failure.

No error logs are shown but bundled js files are clearly broken. too small!

Date: 2017-11-02T08:04:03.438Z
Hash: ee253d778b0f6e79b7e3
Time: 5256ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 303 bytes [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 323 bytes [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.3 kB [initial] [rendered]

generated main.bundle.js

webpackJsonp(["main"],{

/***/ "../../../../../src/main.ts":
/***/ (function(module, exports) {



/***/ }),

/***/ 0:
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__("../../../../../src/main.ts");


/***/ })

},[0]);
//# sourceMappingURL=main.bundle.js.map

Desired functionality.

I think there are 2 solutions for this.

  1. enforce noEmit = false in AngularCompilerPlugin (ignore tsconfig’s setting)
  2. Emit error log if noEmit is turned on

the current behavior is very difficult to find the reason for app crashing silently.

Mention any other details that might be useful.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 7
  • Comments: 17 (10 by maintainers)

Most upvoted comments

@Tragetaschen what is creating those JS files? Angular CLI doesn’t create any JS files but maybe you have something else creating them.

You can also set different options in the base tsconfig.json and on ./src/tsconfig.app.json (the latter being the one that’s used by Angular CLI for your app). For instance, you can have "noEmit": true on tsconfig.json and "noEmit": false on ./src/tsconfig.app.json. The base tsconfig.json is there for the editor which sounds like your usecase.

This change is really, really annoying: Until now, I was able to convince VS not to generate a bunch of useless *.js file throughout my entire directory structure when building the project by setting noEmit in the tsconfig and loaders like awesome-typescript-loader ignore that flag for the compilation.

Now, I can either have great tooling or a working webpack build process.

@filipesilva That quote (and the remaining paragraph around it) as an example for where you documented this breaking change sounds to me more like a taunt than good reasoning and I’m quite angry about that.

I’m also not convinced that this is the way noEmit was meant to work. For me, that flag always meant: don’t write transpiled js files to the disk. No matter how hard I try, I’m not able to figure out an actual use case for the current no-emit-behavior of ngtools. The net result (an empty entry module) is never correct.

I’ve felt that is not enough information, but it is mentioned actually. I understood. Thank you so much.