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

Only use error overlay if there's a document #6960

Merged
merged 1 commit into from
Sep 20, 2021
Merged

Only use error overlay if there's a document #6960

merged 1 commit into from
Sep 20, 2021

Conversation

mischnic
Copy link
Member

@mischnic mischnic commented Sep 20, 2021

↪️ Pull Request

This is a first step towards making HMR work within workers in some situations, namely that an update can be applied cleanly (because there is no location.reload() in workers).

If an update cannot be applied, you now get "window is not defined" (because of window.location.reload) instead of "document is not defined", so we still need to figure that out.

💻 Examples

This works correctly now when editing the worker to change the response:

// main.js
let worker = new Worker(new URL("worker.js", import.meta.url), {
	type: "module",
});

setInterval(() => {
	worker.postMessage(null);
}, 1000);

worker.onmessage = (d) => console.log("response from worker:", d);
// worker.js
console.log("worker started");

self.onmessage = () => self.postMessage("pong2"); // <----------

module.hot.accept();

@height
Copy link

height bot commented Sep 20, 2021

Link Height tasks by mentioning a task ID in the pull request title or description, commit messages, or comments.

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

@parcel-benchmark
Copy link

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 1.93s +65.00ms
Cached 296.00ms -18.00ms 🚀

Cold Bundles

No bundle changes detected.

Cached Bundles

Bundle Size Difference Time Difference
dist/legacy/parcel.7cdb0fad.webp 102.94kb +0.00b 570.00ms -60.00ms 🚀
dist/legacy/parcel.7cdb0fad.webp 102.94kb +0.00b 571.00ms -60.00ms 🚀
dist/modern/parcel.7cdb0fad.webp 102.94kb +0.00b 571.00ms -60.00ms 🚀

React HackerNews ✅

Timings

Description Time Difference
Cold 9.86s -241.00ms
Cached 487.00ms +4.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 1.08m -111.00ms
Cached 1.71s -15.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/index.9b105bfa.js 694.71kb +4.00b ⚠️ 50.08s +166.00ms

Cached Bundles

Bundle Size Difference Time Difference
dist/index.4949d75b.js 1.78mb -2.00b 🚀 18.87s -262.00ms
dist/index.7ddec6b9.js 694.71kb -15.00b 🚀 50.10s -674.00ms
dist/editorView.16833c2e.js 594.84kb +0.00b 49.69s +11.68s ⚠️
dist/popup.481fbd19.js 209.67kb +0.00b 49.69s +11.68s ⚠️
dist/Toolbar.1be6ca93.js 107.23kb +0.00b 49.69s +11.68s ⚠️
dist/Modal.0d5c71f8.js 45.31kb +15.00b ⚠️ 49.69s +11.68s ⚠️
dist/js.0f0bb621.js 17.25kb +0.00b 49.69s +11.68s ⚠️
dist/ui.6b61e054.js 14.94kb +0.00b 49.69s +11.68s ⚠️
dist/smartMediaEditor.c4af75e7.js 13.25kb +0.00b 49.69s +11.68s ⚠️
dist/dropzone.0d183115.js 12.15kb +0.00b 49.69s +11.68s ⚠️
dist/EmojiPickerComponent.55e0a64c.js 3.73kb +0.00b 49.69s +11.69s ⚠️
dist/png-chunks-extract.94b5b9fc.js 3.58kb +0.00b 49.69s +11.68s ⚠️
dist/dropzone.cf53fd41.js 3.29kb +0.00b 49.69s +11.68s ⚠️
dist/clipboard.f917539f.js 2.93kb +0.00b 49.69s +11.68s ⚠️
dist/ResourcedEmojiComponent.78f6ddfc.js 2.12kb +0.00b 49.69s +11.69s ⚠️
dist/browser.17513657.js 1.69kb +0.00b 49.69s +11.68s ⚠️
dist/media-card-analytics-error-boundary.75fac461.js 1.12kb +0.00b 49.69s +11.68s ⚠️
dist/media-picker-analytics-error-boundary.1602c912.js 966.00b +0.00b 49.69s +11.68s ⚠️
dist/simpleHasher.2a6e12b6.js 643.00b +0.00b 49.69s +11.69s ⚠️

Three.js ✅

Timings

Description Time Difference
Cold 7.10s -63.00ms
Cached 384.00ms +9.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

@mischnic mischnic merged commit aaec5ba into v2 Sep 20, 2021
@mischnic mischnic deleted the worker-hmr branch September 20, 2021 21:42
lettertwo added a commit that referenced this pull request Sep 22, 2021
* v2:
  Upgrade Flow to 0.160.1 (#6964)
  Only use error overlay if there's a document (#6960)
  Don't fail when HTML tags are implied (#6752)
  Reorder resolveOptions() env priority (#6904)
  Change edge types to numbers (#6126)
  Bump swc (#6848)
  Print diagnostics for scope hoisting bailouts at verbose log level (#6918)
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.

3 participants