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

Fix VERSION_NAME in Banner + do a full extension reload #618

Merged
merged 8 commits into from
Jun 27, 2021

Conversation

fregante
Copy link
Contributor

Fixes:

  • VERSION_NAME was only applied once and never updated
  • web-ext run did not fully reload the extension (mozilla/web-ext#2277) in Chrome

I added some hackish code that forces a reload if a previous update/install matches the current version. The only drawback is that clicking the reload button now causes a second reload within 500ms.

localStorage.setItem("dev:last-version", version_name);
}
});
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Want me to move it to a new file?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think it's helpful to keep generic functionality in separate modules.

As we collect more generic functionality, we can decide to upstream into dependencies (e.g., web-ext) or create a new module so others can benefit from it

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 added a /development/ folder so that we separate dev code from production code

src/background.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@twschiller twschiller left a comment

Choose a reason for hiding this comment

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

Approved - see comment on moving reload code to it's own module and then go ahead and merge

There's also a merge conflict with the GAPI PR I merged in


// In Chrome, `web-ext run` reloads the extension without reloading the manifest.
// This forces a full reload if the version hasn't changed since the last run.
if (process.env.ENVIRONMENT === "development" && isChrome) {
Copy link
Contributor

@twschiller twschiller Jun 27, 2021

Choose a reason for hiding this comment

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

@fregante As per our side-effect free module initialization discussion, I think this should be wrapped in a method, e.g., installDevAutoReloadHook or something similar

Copy link
Contributor Author

@fregante fregante Jun 27, 2021

Choose a reason for hiding this comment

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

I think that makes it harder to treeshake. Given it's a dev-only background script, I don’t think that discussion applies here (it was mostly to avoid running unnecessary code when the content script was injected multiple times).

Also we want this code to be executed as soon as possible instead of after everything where the other initialization functions are

Copy link
Contributor

Choose a reason for hiding this comment

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

The code is small enough that I don't think tree-shaking is a big concern.

I'm going to merge in now though since I'm having some issues with background page reloading during development. I want to see if this solves the issue

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.

2 participants