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

Why is webpack/replace necessary? #24

Open
sseppola opened this issue Dec 23, 2015 · 3 comments
Open

Why is webpack/replace necessary? #24

sseppola opened this issue Dec 23, 2015 · 3 comments

Comments

@sseppola
Copy link

I don't understand what these do, and why they are necessary. Is there a discussion around why they were built somewhere?

@jhen0409
Copy link
Collaborator

The webpack/replace it do two things:

  1. if modules couldn't be hot updated, we need full reload, but it's inconvenient for Chrome Extension, so we call chrome.runtime.reload. (log-apply-result.js#L16-L21, origin: hot/log-apply-result.js)
  2. The script tag have problem in Content Scripts page, because it‘s no way to get webpackHotUpdate function (in a different context), so we eval code to fix it. (JsonpMainTemplate.runtime.js#L12-L26, origin: lib/JsonpMainTemplate.runtime.js#L12-L19)

@sseppola
Copy link
Author

I think you switched up the references to JsonpMainTemplate and log-apply-result between point 1 and 2 as eval is used in 1 and reload in 2. Thank you for explaining, while reading the code there's one thing that sticks out:

Why is hotDownloadUpdateChunk defined on the context object instead of declaring a function like in the original? The original does not really make sense as the function is never used, however I've noticed other files in the webpack repo seem to use hotDownloadUpdateChunk as a global function. If you don't mind, how does that work?

zalmoxisus referenced this issue in jhen0409/react-chrome-extension-boilerplate Jan 13, 2016
@develra
Copy link

develra commented Jan 13, 2016

Thanks for the explanation.

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

No branches or pull requests

3 participants