angular / closure-demo

MIT License
115 stars 27 forks source link

ngsummary files are missing #22

Closed steveblue closed 6 years ago

steveblue commented 6 years ago

@alexeagle TY for updating this repository. I mirrored the changes in our conf and updated to the fork of closure compiler, but the following conf results in several warnings.

WARNING - Failed to load module "@angular/common/common.ngsummary"

WARNING - Failed to load module "@angular/common/http/http.ngsummary"

WARNING - Failed to load module "@angular/core/core.ngsummary"

WARNING - Failed to load module "@angular/http/http.ngsummary"

WARNING - Failed to load module "@angular/platform-browser/animations/animations.ngsummary"

WARNING - Failed to load module "@angular/platform-browser/platform-browser.ngsummary"

WARNING - Failed to load module "@angular/router/router.ngsummary"

Is there something missing from the conf?

--compilation_level=ADVANCED_OPTIMIZATIONS
--language_out=ES5
--variable_renaming_report=closure/variable_renaming_report
--property_renaming_report=closure/property_renaming_report
--create_source_map=%outname%.map

--warning_level=QUIET
--dependency_mode=STRICT
--rewrite_polyfills=false
--module_resolution=NODE
--jscomp_off=checkVars

--externs closure.externs.js
--externs node_modules/zone.js/dist/zone_externs.js
--externs node_modules/@angular/core/src/testability/testability.externs.js

--js node_modules/rxjs/**.js

--js node_modules/@angular/core/package.json
--js node_modules/@angular/core/esm2015/core.js

--js node_modules/@angular/common/package.json
--js node_modules/@angular/common/esm2015/common.js

--js node_modules/@angular/platform-browser/package.json
--js node_modules/@angular/platform-browser/esm2015/platform-browser.js

--js node_modules/@angular/forms/package.json
--js node_modules/@angular/forms/esm2015/forms.js

--js node_modules/@angular/http/package.json
--js node_modules/@angular/http/esm2015/http.js

--js node_modules/@angular/common/http/package.json
--js node_modules/@angular/common/esm2015/http.js

--js node_modules/@angular/router/package.json
--js node_modules/@angular/router/esm2015/router.js

--js node_modules/@angular/animations/package.json
--js node_modules/@angular/animations/esm2015/animations.js

--js node_modules/@angular/animations/browser/package.json
--js node_modules/@angular/animations/esm2015/browser.js

--js node_modules/@angular/platform-browser/animations/package.json
--js node_modules/@angular/platform-browser/esm2015/animations.js

--js ngfactory/**.js
--js main.prod.js

--package_json_entry_names es2015
--process_common_js_modules

--entry_point=./main.prod

or the tsconfig.json?

{
  "compilerOptions": {
    "target": "es2015",
    "module": "es2015",
    "declaration": true,
    "stripInternal": true,
    "sourceMap": true,
    "inlineSources": true,
    "skipLibCheck": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "noImplicitAny": false,
    "removeComments": true,
    "allowUnreachableCode": false,
    "moduleResolution": "node",
    "typeRoots": [
      "node_modules/@types"
    ],
    "types": [
      "node"
    ]
  },
  "angularCompilerOptions": {
    "annotationsAs": "static fields",
    "annotateForClosureCompiler": true,
    "skipMetadataEmit": false
  },
  "files": [
    "./ngfactory/src/app/app.module.ts",
    "./ngfactory/src/app/view/doc-file/file.module.ts"
  ]
}
gregmagolan commented 6 years ago

I ran into the same issue in this repo: https://github.com/gregmagolan/abc-demo-build-with-aot-universal

If you add the ngsummary files to the closure.conf like this you should be good:

--js node_modules/@angular/core/package.json
--js node_modules/@angular/core/esm2015/core.js
--js node_modules/@angular/core/core.ngsummary.js

--js node_modules/@angular/common/package.json
--js node_modules/@angular/common/esm2015/common.js
--js node_modules/@angular/common/common.ngsummary.js

--js node_modules/@angular/platform-browser/package.json
--js node_modules/@angular/platform-browser/esm2015/platform-browser.js
--js node_modules/@angular/platform-browser/platform-browser.ngsummary.js

--js node_modules/@angular/forms/package.json
--js node_modules/@angular/forms/esm2015/forms.js
--js node_modules/@angular/forms/forms.ngsummary.js
steveblue commented 6 years ago

It appears some of the packages are missing ngsummary.js files in 5.0.0-rc.0. I inspected all the node_modules and the files are indeed missing.

Here is my updated conf, and the result.

--compilation_level=ADVANCED_OPTIMIZATIONS
--language_out=ES5
--variable_renaming_report=closure/variable_renaming_report
--property_renaming_report=closure/property_renaming_report
--create_source_map=%outname%.map

--warning_level=QUIET
--dependency_mode=STRICT
--rewrite_polyfills=false
--module_resolution=NODE
--jscomp_off=checkVars

--externs closure.externs.js
--externs node_modules/zone.js/dist/zone_externs.js
--externs node_modules/@angular/core/src/testability/testability.externs.js

--js node_modules/rxjs/**.js

--js node_modules/@angular/core/package.json
--js node_modules/@angular/core/esm2015/core.js
--js node_modules/@angular/core/core.ngsummary.js

--js node_modules/@angular/common/package.json
--js node_modules/@angular/common/esm2015/common.js
--js node_modules/@angular/common/common.ngsummary.js

--js node_modules/@angular/platform-browser/package.json
--js node_modules/@angular/platform-browser/esm2015/platform-browser.js
--js node_modules/@angular/platform-browser/platform-browser.ngsummary.js

--js node_modules/@angular/forms/package.json
--js node_modules/@angular/forms/esm2015/forms.js
--js node_modules/@angular/forms/forms.ngsummary.js

--js node_modules/@angular/http/package.json
--js node_modules/@angular/http/esm2015/http.js
--js node_modules/@angular/http/http.ngsummary.js

--js node_modules/@angular/common/http/package.json
--js node_modules/@angular/common/esm2015/http.js
--js node_modules/@angular/common/http/http.ngsummary.js

--js node_modules/@angular/router/package.json
--js node_modules/@angular/router/esm2015/router.js
--js node_modules/@angular/router/router.ngsummary.js

--js node_modules/@angular/animations/package.json
--js node_modules/@angular/animations/esm2015/animations.js
--js node_modules/@angular/animations/animations.ngsummary.js

--js node_modules/@angular/animations/browser/package.json
--js node_modules/@angular/animations/esm2015/browser.js
--js node_modules/@angular/animations/browser/browser.ngsummary.js

--js node_modules/@angular/platform-browser/animations/package.json
--js node_modules/@angular/platform-browser/esm2015/animations.js
--js node_modules/@angular/platform-browser/animations/animations.ngsummary.js

--js ngfactory/**.js
--js main.prod.js

--package_json_entry_names es2015
--process_common_js_modules

--entry_point=./main.prod

ERROR

ERROR - Cannot read file node_modules/@angular/animations/animations.ngsummary.js: {1}

ERROR - Cannot read file node_modules/@angular/animations/browser/browser.ngsummary.js: {1}

ERROR - Cannot read file node_modules/@angular/forms/forms.ngsummary.js: {1}

3 error(s), 0 warning(s)

node_modules/@angular/forms/forms.ngsummary.js does not exist node_modules/@angular/animations/browser/browser.ngsummary.js is formatted as JSON node_modules/@angular/animations/animations.ngsummary.js is formatted as JSON

steveblue commented 6 years ago

Maybe unrelated but if I widdle my app down only to a few modules I can get past all the modules that do not have properly formatted ngsummary, but I still get an error with ClosureCompiler and this error is fairly obscure.

--compilation_level=ADVANCED_OPTIMIZATIONS
--language_in=ES6_STRICT
--language_out=ES5
--variable_renaming_report=closure/variable_renaming_report
--property_renaming_report=closure/property_renaming_report
--create_source_map=%outname%.map

--warning_level=QUIET
--dependency_mode=STRICT
--rewrite_polyfills=false
--module_resolution=NODE
--jscomp_off=checkVars

--externs closure.externs.js
--externs node_modules/zone.js/dist/zone_externs.js
--externs node_modules/@angular/core/src/testability/testability.externs.js

--js node_modules/rxjs/**.js

--js node_modules/@angular/core/package.json
--js node_modules/@angular/core/esm2015/core.js
--js node_modules/@angular/core/core.ngsummary.js

--js node_modules/@angular/common/package.json
--js node_modules/@angular/common/esm2015/common.js
--js node_modules/@angular/common/common.ngsummary.js

--js node_modules/@angular/platform-browser/package.json
--js node_modules/@angular/platform-browser/esm2015/platform-browser.js
--js node_modules/@angular/platform-browser/platform-browser.ngsummary.js

--js node_modules/@angular/http/package.json
--js node_modules/@angular/http/esm2015/http.js
--js node_modules/@angular/http/http.ngsummary.js

--js node_modules/@angular/router/package.json
--js node_modules/@angular/router/esm2015/router.js
--js node_modules/@angular/router/router.ngsummary.js

--js ngfactory/**.js
--js main.prod.js

--package_json_entry_names es2015
--process_common_js_modules

--entry_point=./main.prod
[14:17:02] WARN java.lang.IllegalArgumentException: a source must have a name
    at com.google.javascript.jscomp.SourceFile.<init>(SourceFile.java:106)
    at com.google.javascript.jscomp.SourceFile$OnDisk.<init>(SourceFile.java:606)
    at com.google.javascript.jscomp.SourceFile$Builder.buildFromPath(SourceFile.java:508)
    at com.google.javascript.jscomp.SourceFile.fromPath(SourceFile.java:413)
    at com.google.javascript.jscomp.SourceMapResolver.getRelativePath(SourceMapResolver.java:72)
    at com.google.javascript.jscomp.Compiler.getSourceMapping(Compiler.java:2874)
    at com.google.javascript.jscomp.SourceMap.addMapping(SourceMap.java:164)
    at com.google.javascript.jscomp.CodePrinter$MappedCodePrinter.generateSourceMap(CodePrinter.java:141)
    at com.google.javascript.jscomp.CodePrinter.toSource(CodePrinter.java:904)
    at com.google.javascript.jscomp.CodePrinter.access$300(CodePrinter.java:42)
    at com.google.javascript.jscomp.CodePrinter$Builder.build(CodePrinter.java:828)
    at com.google.javascript.jscomp.Compiler.toSource(Compiler.java:2337)
    at com.google.javascript.jscomp.Compiler.access$700(Compiler.java:102)
    at com.google.javascript.jscomp.Compiler$14.call(Compiler.java:2296)
    at com.google.javascript.jscomp.Compiler$14.call(Compiler.java:2257)
    at com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread(CompilerExecutor.java:128)
    at com.google.javascript.jscomp.Compiler.runInCompilerThread(Compiler.java:862)
    at com.google.javascript.jscomp.Compiler.toSource(Compiler.java:2256)
    at com.google.javascript.jscomp.Compiler$10.call(Compiler.java:2151)
    at com.google.javascript.jscomp.Compiler$10.call(Compiler.java:2133)
    at com.google.javascript.jscomp.CompilerExecutor$2.call(CompilerExecutor.java:101)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
gregmagolan commented 6 years ago

Re: the ngfactory.js & ngsummary.js files. These are not shipped with the @angular npm packages. They need to be generated with an ngc postinstall step. If you look at https://github.com/alexeagle/angular-bazel-example you can see how it is done there.

postinstall in package.json runs the ngc compiler on the @angular packages. postinstall will be run automatically after every npm or yarn install. https://github.com/alexeagle/angular-bazel-example/blob/master/package.json#L21

It uses angular.tsconfig.json in that repo: https://github.com/alexeagle/angular-bazel-example/blob/master/angular.tsconfig.json

steveblue commented 6 years ago

ngfactory.js and ngsummary.js are generated in the node_modules folder when I run ngc just for my app code @gregmagolan I don't think the postinstall script is necessary. I have no idea why the last error keeps happening though, as this same project compiles fine with 4.4.4

tbosch commented 6 years ago

This is a bug on current master of Angular, which was introduced by https://github.com/angular/angular/commit/b0868915aea3cef2e650bd4e5337c5d7fa673537 . Will fix this soon.

On Mon, Oct 2, 2017 at 4:32 PM, Steve Belovarich notifications@github.com wrote:

ngsummary.js are shipped with most of the packages though @gregmagolan https://github.com/gregmagolan by the looks of my node_modules folder. I will look into this though, TY.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/angular/closure-demo/issues/22#issuecomment-333694647, or mute the thread https://github.com/notifications/unsubscribe-auth/AAqKfxSVrO_2Ip_2JUp5tEuVlpOtDp0jks5soXKDgaJpZM4PrIZL .

gregmagolan commented 6 years ago

@steveblue The [14:17:02] WARN java.lang.IllegalArgumentException: a source must have a name looks to be caused by the source map. Also looks like this was introduced in 5.0.0-rc.0. I created another issue #25 for this. Work-around is to turn off sourceMap in your tsconfig.json. Not ideal but it will fix the compile for now.

steveblue commented 6 years ago

This is not an issue in 5.0.0