Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

feat(closure): fix #727, add zone_externs.js for closure compiler #731

Merged
merged 1 commit into from
Apr 17, 2017

Conversation

JiaLiPassion
Copy link
Collaborator

@JiaLiPassion JiaLiPassion commented Apr 11, 2017

  1. add closure compiler externs file in dist/zone_externs.js
  2. add test script in travis.
    now we have 2 cases.
  • normal case, can compile and keep the names defined in extern
  • fail case, will throw error if the extern file is broken (definition error).

package.json Outdated
@@ -43,7 +43,9 @@
"bugs": {
"url": "https://github.com/angular/zone.js/issues"
},
"dependencies": {},
"dependencies": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be a devDependency right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you are right, I will change it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and you can remove the dependencies{} block too

lib/zone.ts Outdated
@@ -136,11 +136,11 @@
interface Zone {
/**
*
* @returns {Zone} The parent Zone.
* @returns {?Zone} The parent Zone.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reasoning for updating all the inline types?

If the externs file is independent of the .ts file,

  1. we'll have to maintain two different copies of the same info, and
  2. nothing enforces the JSDoc annotations in the .ts file are correct, so we will probably fail to maintain them

angular/tsickle can generate externs from the TS types, so we could just remove the JSDoc annotations if we were using the extern generator.

I know you already did a lot of work here, sorry to have to ask this!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for the review, I am new to closure compiler, so I just check the document and add the type I can find.

So I just revert all those inline type changes from zone.ts, is that correct?

# Flags to simplify debugging.
"--formatting=PRETTY_PRINT"

"--externs=test/closure/zone_externs_failed.js"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd have one options block with the options that are in common (including the zone.closure.js input file)
then when you call compiler.jar below, give the options that differ between the two cases

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexeagle , yes, you are right, I will make it change that way.

# compile closure test source file
tsc -p .
# Run the Google Closure compiler java runnable.
java -jar node_modules/google-closure-compiler/compiler.jar --flagfile $closureFlags 'build/test/closure/zone.closure.js'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I prefer to have the flagfile be an actual file in this directory, then you don't have to use the fancy bash array construct that few people understand

Copy link
Collaborator Author

@JiaLiPassion JiaLiPassion Apr 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I just copied from material, I also prefer use flagfile directly, I will modify it.

*/

/**
* @fileoverview Externs for zone.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file also looks like a lot of maintenance work. What is different between this and the other one? Could we get the same test coverage by just calling closure with no externs at all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you are right , I will change it that way.

@JiaLiPassion
Copy link
Collaborator Author

JiaLiPassion commented Apr 12, 2017

@alexeagle , thank you the review, I will make the changes of the comments you write above, and about the dist/zone_externs.js, is that ok? It can keep the name unchanged, I am not sure the @type @interface @record definitions are correct or not, please help me to check it , thank you.

Updated:
@alexeagle , I just commit a new version and have changed files based on your comment, please review. thank you.

@JiaLiPassion JiaLiPassion force-pushed the closure branch 2 times, most recently from 138f5c4 to ed36db1 Compare April 12, 2017 02:36
Copy link
Contributor

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good, thanks! I'll let Misko look as well...

*/

/**
* @fileoverview Externs for zone.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can verify that these work in a real project, like overwrite https://github.com/alexeagle/closure-compiler-angular-bundling/blob/master/vendor/zone_externs.js with yours and re-build

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, I will check it too

package.json Outdated
@@ -43,7 +43,9 @@
"bugs": {
"url": "https://github.com/angular/zone.js/issues"
},
"dependencies": {},
"dependencies": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and you can remove the dependencies{} block too

package.json Outdated
@@ -52,6 +53,7 @@
"concurrently": "^2.2.0",
"conventional-changelog": "^1.1.0",
"es6-promise": "^3.0.2",
"google-closure-compiler": "^20170218.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a new April release just came out, may as well upgrade this now

Copy link
Collaborator Author

@JiaLiPassion JiaLiPassion Apr 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, got it. and the earlier version has a empty

dependencies: {}

I just reverted it to that way.

exit 1
fi

# Run the Google Closure compiler java runnable with error zone externs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update comment - "without externs"

Copy link
Collaborator Author

@JiaLiPassion JiaLiPassion Apr 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just updated the comment.

@JiaLiPassion
Copy link
Collaborator Author

@alexeagle, I have modified the comment and update package.json, please review.


if [ $? -eq 1 ]
then
echo "Successfully detect closure compiler error with wrong zone externs"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too, wrong -> missing

then
echo "Successfully detect closure compiler error with wrong zone externs"
else
echo "failed to detect closure compiler error with wrong zone externs"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexeagle , thanks, I will modify it now.

@JiaLiPassion JiaLiPassion force-pushed the closure branch 2 times, most recently from fc3f529 to 1423dfe Compare April 12, 2017 18:45
@mhevery mhevery merged commit b60e9e6 into angular:master Apr 17, 2017
@JiaLiPassion JiaLiPassion deleted the closure branch May 6, 2017 04:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants