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

remove dynamic js and map files from appcache (app.manifest) #9434

Merged
merged 2 commits into from
Dec 5, 2017
Merged

remove dynamic js and map files from appcache (app.manifest) #9434

merged 2 commits into from
Dec 5, 2017

Conversation

CaptainN
Copy link
Collaborator

@CaptainN CaptainN commented Dec 4, 2017

As described in issue #9407, dynamic-imports does not load modules from the appcache, and since we don't want the browser to download these assets twice, this patch avoids adding those files to app.manifest.

This patch does pass the appcache unit test, but I'm not sure how to create a test for this, as I'm not sure how to set gt it to load dynamic imports to test with.

…ey aren't loaded from there by dynamic-imports
@apollo-cla
Copy link

@CaptainN: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

Copy link
Contributor

@hwillson hwillson left a comment

Choose a reason for hiding this comment

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

Thanks for submitting this PR @CaptainN! I'm sure @benjamn will have functionality comments, but I've mentioned a few small nit picky code formatting details. We try to make sure new code follows the same formatting as the existing source file (as much as possible). Thanks again!

@@ -39,6 +39,13 @@ var browserDisabled = function (request) {
return disabledBrowsers[request.browser.name];
};

function isDynamic (resource) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a named function, please remove the space between the function name and the parens: function isDynamic(resource) {.

@@ -97,7 +104,8 @@ WebApp.connectHandlers.use(function (req, res, next) {
manifest += "/" + "\n";
_.each(WebApp.clientPrograms[WebApp.defaultArch].manifest, function (resource) {
if (resource.where === 'client' &&
! RoutePolicy.classify(resource.url)) {
! RoutePolicy.classify(resource.url) &&
!isDynamic(resource)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please adjust your logical not's to have a space after the !.

Copy link
Contributor

@benjamn benjamn left a comment

Choose a reason for hiding this comment

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

I appreciate that this PR involves changes only to the appcache package, rather than changing the way we bundle and serve JS resources (which would require a new version of Meteor to be released). Thanks for spotting this problem and moving forward with the fix, @CaptainN!

function isDynamic(resource) {
return resource.type === 'dynamic js' ||
(resource.type === 'json' &&
resource.url.startsWith('/dynamic/') &&
Copy link
Contributor

Choose a reason for hiding this comment

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

This URL prefix may change after #9439, which makes these URLs look like /__browser/dynamic/... but that's OK—this is mostly a note to myself to update this code in that PR.

@benjamn benjamn added this to the Package Patches milestone Dec 5, 2017
@benjamn benjamn merged commit 491f678 into meteor:devel Dec 5, 2017
@benjamn
Copy link
Contributor

benjamn commented Dec 5, 2017

@CaptainN These changes have been published in appcache@1.1.1. Please let us know if you encounter any further problems after running meteor update appcache.

@CaptainN
Copy link
Collaborator Author

CaptainN commented Dec 5, 2017

Awesome! Thanks!

The url check is really only used for .map files. The check for dynamic js files was relatively easier, since the type attribute reflects it's dynamic status. If the .map files were similarly marked as dynamic in the type (like 'dynamic json') that might help avoid the problem.

Alternatively, we could remove all .map files from the app cache, and not inspect the url at all, but that's a bigger change.

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.

None yet

4 participants