Skip to content
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

Refactor amp-geo to use externs, #20015

Merged
merged 9 commits into from Jan 10, 2019
Merged

Conversation

jpettitt
Copy link
Contributor

Refactor amp-geo to use externs, update dependant extension to use isInCountryGroup()

Fixes #19968

update dependant extension to use isInCountryGroup()
Copy link
Contributor

@zhouyx zhouyx left a comment

Choose a reason for hiding this comment

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

to @erwinmombay on adding extern change.

extensions/amp-consent/0.1/amp-consent.js Outdated Show resolved Hide resolved
* isInCountryGroup: (function(string):GEO_IN_GROUP),
* }}
*/
let GeoDef;
Copy link
Member

Choose a reason for hiding this comment

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

do you want these fields preserved or are they OK to be mangled during minification?

Copy link
Contributor

Choose a reason for hiding this comment

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

I created the issue because I saw

const ISOCountryGroups = /** @type {!Object<string, !Array<string>>} */(
config.ISOCountryGroups);

But since ISOCountryGroups is removed from GeoDef. Is it better to change the above line to config['ISOCountryGroups'] and allow other fields to be mangled instead?

Copy link
Member

Choose a reason for hiding this comment

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

why and where is it removed?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@jpettitt jpettitt Dec 21, 2018

Choose a reason for hiding this comment

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

@erwinmombay Not sure where to go here, suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. I couldn't find where GeoDef is directly exposed to 3p. So we should be good to remove it from the extern.

Another thing is we need to change how ampGeo read the configuration. @jpettitt Let me know if you want me to fix that instead. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've reverted the externs - what do we need to change on the configuration?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think

const ISOCountryGroups = /** @type {!Object<string, !Array<string>>} */(
config.ISOCountryGroups);

and
if (config.AmpBind) {

need to use config['ISOCountryGroups'] and config['AmpBind'], because we need to preserve the fileNames to read inline config. @erwinmombay to confirm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you talking about the global AMP config?

This config is the am-geo configuration, it comes from parsing the application/json script. If that is the issue it probably makes sense to rename config here to differentiate.

Copy link
Contributor

Choose a reason for hiding this comment

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

Talked offline. We decided to avoid using dot fieldName to avoid singlepass mangling the value there.

@jpettitt jpettitt merged commit e8e52a9 into ampproject:master Jan 10, 2019
@jpettitt jpettitt deleted the amp-geo-refactor branch January 10, 2019 22:58
noranazmy pushed a commit to noranazmy/amphtml that referenced this pull request Mar 22, 2019
* Refactor amp-geo to use externs,
update dependant extension to use isInCountryGroup()

* isInGeoGroup() returns enum.

* bad path

* revert externs

* remove stray newline

* change config to prevent single pass closure mangle

* add new owners
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants