Skip to content

Fix Chunks in extensions#7374

Merged
dreamofabear merged 4 commits intoampproject:masterfrom
dreamofabear:chunk-installed-twice
Feb 7, 2017
Merged

Fix Chunks in extensions#7374
dreamofabear merged 4 commits intoampproject:masterfrom
dreamofabear:chunk-installed-twice

Conversation

@dreamofabear
Copy link
Copy Markdown

@dreamofabear dreamofabear commented Feb 6, 2017

Fixes #7329. Use getExistingServiceForDoc() to prevent Chunks from being installed in each extension that uses it.

If you think it's a good idea, I can follow up this bug fix with a PR to split this file into chunk.js and service/chunk-impl.js like other services.

@dreamofabear
Copy link
Copy Markdown
Author

/to @dvoytenko /cc @cramforce PTAL

if (deactivated) {
resolved.then(fn);
return;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just calling getExistingServiceForDoc should have the desired result code size wise. I personally feel that is a nicer pattern that we should move towards.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed, that's actually what I'm doing in this PR.

  • Extensions use chunksForDoc -> getExistingServiceForDoc
  • Entry points continue to use startupChunk -> fromClassForDoc to install the service as a side effect

Did you mean I should change startupChunk to use getExistingServiceForDoc and explicitly install the service in each entry point?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No, I meant that you can keep the chunk function to limit the exported interface to just that function.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ohh, I assumed that we'd want to make Chunks more consistent with other services. Done!

@dreamofabear dreamofabear force-pushed the chunk-installed-twice branch from 0438dd6 to 4a5e6e3 Compare February 7, 2017 02:10
@dreamofabear dreamofabear merged commit 483e227 into ampproject:master Feb 7, 2017
@dreamofabear dreamofabear deleted the chunk-installed-twice branch February 7, 2017 17:41
torch2424 pushed a commit to torch2424/amphtml that referenced this pull request Feb 14, 2017
* avoid referencing Chunks in extension

* fix unit test

* fix presubmit

* malte's comment
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
* avoid referencing Chunks in extension

* fix unit test

* fix presubmit

* malte's comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

amp-bind console error

2 participants