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

[ssr] Don't assign DOM shim window.global to window #2120

Merged
merged 2 commits into from
Sep 1, 2021
Merged

Conversation

aomarks
Copy link
Member

@aomarks aomarks commented Sep 1, 2021

This means that globalThis.global will retain its Node built-ins, and globalThis.global === globalThis will hold, whereas before it would lose anything we didn't explicitly set on window, so something like global.Promise would be undefined.

This window.global assignment seems to have been done for compatibility with node-fetch, but I tried a fetch from the demo/global/module.js module, and the fetch seemed to work fine. Not sure if there is another invocation path I missed, but it seems ok?

Fixes #2118

cc @fetherston

…window

This means that globalThis.global will retain its Node built-ins,
whereas before it would lose anything we didn't explicitly set on
window.

Fixes #2118
@changeset-bot
Copy link

changeset-bot bot commented Sep 1, 2021

🦋 Changeset detected

Latest commit: 32a0307

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@google-cla google-cla bot added the cla: yes label Sep 1, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2021

📊 Tachometer Benchmark Results

Summary

nop-update

  • lit-html-kitchen-sink: unsure 🔍 -2% - +5% (-0.56ms - +1.56ms)
    this-change vs tip-of-tree

render

  • lit-element-list: unsure 🔍 -3% - +3% (-3.11ms - +3.08ms)
    this-change vs tip-of-tree
  • lit-html-kitchen-sink: unsure 🔍 -2% - +3% (-0.78ms - +1.14ms)
    this-change vs tip-of-tree
  • lit-html-repeat: unsure 🔍 -4% - +5% (-0.57ms - +0.65ms)
    this-change vs tip-of-tree
  • lit-html-template-heavy: unsure 🔍 -2% - +3% (-1.62ms - +1.75ms)
    this-change vs tip-of-tree
  • reactive-element-list: unsure 🔍 -2% - +1% (-1.68ms - +0.59ms)
    this-change vs tip-of-tree

update

  • lit-element-list: unsure 🔍 -3% - +2% (-20.83ms - +18.37ms)
    this-change vs tip-of-tree
  • lit-html-kitchen-sink: unsure 🔍 -2% - +4% (-2.32ms - +3.44ms)
    this-change vs tip-of-tree
  • lit-html-repeat: unsure 🔍 -4% - +1% (-16.75ms - +6.14ms)
    this-change vs tip-of-tree
  • lit-html-template-heavy: unsure 🔍 -3% - +4% (-4.52ms - +4.75ms)
    this-change vs tip-of-tree
  • reactive-element-list: unsure 🔍 -3% - +2% (-22.82ms - +13.92ms)
    this-change vs tip-of-tree

update-reflect

  • lit-element-list: unsure 🔍 -3% - +2% (-26.95ms - +17.73ms)
    this-change vs tip-of-tree
  • reactive-element-list: unsure 🔍 -2% - +2% (-21.00ms - +21.90ms)
    this-change vs tip-of-tree

Results

lit-element-list

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
96.87ms - 101.77ms-unsure 🔍
-3% - +3%
-3.11ms - +3.08ms
faster ✔
17% - 24%
20.57ms - 30.34ms
tip-of-tree
tip-of-tree
97.44ms - 101.23msunsure 🔍
-3% - +3%
-3.08ms - +3.11ms
-faster ✔
17% - 23%
20.81ms - 30.07ms
previous-release
previous-release
120.55ms - 129.00msslower ❌
20% - 31%
20.57ms - 30.34ms
slower ❌
21% - 30%
20.81ms - 30.07ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
764.76ms - 793.02ms-unsure 🔍
-3% - +2%
-20.83ms - +18.37ms
faster ✔
7% - 13%
62.07ms - 109.59ms
tip-of-tree
tip-of-tree
766.54ms - 793.70msunsure 🔍
-2% - +3%
-18.37ms - +20.83ms
-faster ✔
7% - 12%
61.17ms - 108.03ms
previous-release
previous-release
845.62ms - 883.81msslower ❌
8% - 14%
62.07ms - 109.59ms
slower ❌
8% - 14%
61.17ms - 108.03ms
-

update-reflect

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
811.58ms - 844.83ms-unsure 🔍
-3% - +2%
-26.95ms - +17.73ms
faster ✔
1% - 7%
8.99ms - 57.35ms
tip-of-tree
tip-of-tree
817.90ms - 847.74msunsure 🔍
-2% - +3%
-17.73ms - +26.95ms
-faster ✔
1% - 6%
5.52ms - 51.60ms
previous-release
previous-release
843.82ms - 878.94msslower ❌
1% - 7%
8.99ms - 57.35ms
slower ❌
1% - 6%
5.52ms - 51.60ms
-
lit-html-kitchen-sink

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
36.51ms - 37.92ms-unsure 🔍
-2% - +3%
-0.78ms - +1.14ms
faster ✔
18% - 22%
8.19ms - 10.54ms
tip-of-tree
tip-of-tree
36.38ms - 37.69msunsure 🔍
-3% - +2%
-1.14ms - +0.78ms
-faster ✔
18% - 23%
8.40ms - 10.70ms
previous-release
previous-release
45.64ms - 47.53msslower ❌
22% - 29%
8.19ms - 10.54ms
slower ❌
22% - 29%
8.40ms - 10.70ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
91.77ms - 95.93ms-unsure 🔍
-2% - +4%
-2.32ms - +3.44ms
faster ✔
5% - 10%
5.24ms - 10.78ms
tip-of-tree
tip-of-tree
91.29ms - 95.29msunsure 🔍
-4% - +2%
-3.44ms - +2.32ms
-faster ✔
6% - 11%
5.86ms - 11.28ms
previous-release
previous-release
100.03ms - 103.69msslower ❌
5% - 12%
5.24ms - 10.78ms
slower ❌
6% - 12%
5.86ms - 11.28ms
-

nop-update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
31.93ms - 33.47ms-unsure 🔍
-2% - +5%
-0.56ms - +1.56ms
unsure 🔍
-3% - +4%
-1.07ms - +1.15ms
tip-of-tree
tip-of-tree
31.46ms - 32.92msunsure 🔍
-5% - +2%
-1.56ms - +0.56ms
-unsure 🔍
-5% - +2%
-1.55ms - +0.62ms
previous-release
previous-release
31.86ms - 33.46msunsure 🔍
-4% - +3%
-1.15ms - +1.07ms
unsure 🔍
-2% - +5%
-0.62ms - +1.55ms
-
lit-html-repeat

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
13.38ms - 14.30ms-unsure 🔍
-4% - +5%
-0.57ms - +0.65ms
faster ✔
6% - 12%
0.87ms - 1.89ms
tip-of-tree
tip-of-tree
13.39ms - 14.21msunsure 🔍
-5% - +4%
-0.65ms - +0.57ms
-faster ✔
6% - 12%
0.95ms - 1.89ms
previous-release
previous-release
14.99ms - 15.45msslower ❌
6% - 14%
0.87ms - 1.89ms
slower ❌
7% - 14%
0.95ms - 1.89ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
400.63ms - 418.50ms-unsure 🔍
-4% - +1%
-16.75ms - +6.14ms
faster ✔
27% - 31%
157.11ms - 184.05ms
tip-of-tree
tip-of-tree
407.71ms - 422.03msunsure 🔍
-2% - +4%
-6.14ms - +16.75ms
-faster ✔
27% - 30%
152.91ms - 177.64ms
previous-release
previous-release
570.06ms - 590.23msslower ❌
38% - 46%
157.11ms - 184.05ms
slower ❌
36% - 43%
152.91ms - 177.64ms
-
lit-html-template-heavy

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
64.36ms - 66.63ms-unsure 🔍
-2% - +3%
-1.62ms - +1.75ms
faster ✔
16% - 20%
12.39ms - 15.85ms
tip-of-tree
tip-of-tree
64.19ms - 66.67msunsure 🔍
-3% - +2%
-1.75ms - +1.62ms
-faster ✔
16% - 20%
12.38ms - 15.99ms
previous-release
previous-release
78.31ms - 80.92msslower ❌
19% - 24%
12.39ms - 15.85ms
slower ❌
19% - 25%
12.38ms - 15.99ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
128.48ms - 135.28ms-unsure 🔍
-3% - +4%
-4.52ms - +4.75ms
faster ✔
9% - 15%
13.69ms - 22.80ms
tip-of-tree
tip-of-tree
128.62ms - 134.91msunsure 🔍
-4% - +3%
-4.75ms - +4.52ms
-faster ✔
9% - 15%
13.99ms - 22.73ms
previous-release
previous-release
147.10ms - 153.16msslower ❌
10% - 18%
13.69ms - 22.80ms
slower ❌
10% - 17%
13.99ms - 22.73ms
-
reactive-element-list

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
66.94ms - 68.61ms-unsure 🔍
-2% - +1%
-1.68ms - +0.59ms
unsure 🔍
-3% - +1%
-2.12ms - +0.54ms
tip-of-tree
tip-of-tree
67.54ms - 69.09msunsure 🔍
-1% - +2%
-0.59ms - +1.68ms
-unsure 🔍
-2% - +2%
-1.53ms - +1.05ms
previous-release
previous-release
67.53ms - 69.60msunsure 🔍
-1% - +3%
-0.54ms - +2.12ms
unsure 🔍
-2% - +2%
-1.05ms - +1.53ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
812.33ms - 838.83ms-unsure 🔍
-3% - +2%
-22.82ms - +13.92ms
unsure 🔍
-3% - +2%
-21.90ms - +14.31ms
tip-of-tree
tip-of-tree
817.31ms - 842.76msunsure 🔍
-2% - +3%
-13.92ms - +22.82ms
-unsure 🔍
-2% - +2%
-17.07ms - +18.39ms
previous-release
previous-release
817.03ms - 841.72msunsure 🔍
-2% - +3%
-14.31ms - +21.90ms
unsure 🔍
-2% - +2%
-18.39ms - +17.07ms
-

update-reflect

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
908.91ms - 936.75ms-unsure 🔍
-2% - +2%
-21.00ms - +21.90ms
unsure 🔍
-2% - +2%
-21.73ms - +18.15ms
tip-of-tree
tip-of-tree
906.06ms - 938.70msunsure 🔍
-2% - +2%
-21.90ms - +21.00ms
-unsure 🔍
-3% - +2%
-23.93ms - +19.45ms
previous-release
previous-release
910.34ms - 938.90msunsure 🔍
-2% - +2%
-18.15ms - +21.73ms
unsure 🔍
-2% - +3%
-19.45ms - +23.93ms
-

tachometer-reporter-action v2 for Benchmarks


// User-provided globals, like `require`
...props,
};

window.window = window;
window.global = window; // Required for node-fetch
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about node-fetch here? Should we do something like this?

Object.assign(window.global, window):

Copy link
Member Author

Choose a reason for hiding this comment

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

See PR description -- unless you know a reason it actually fails?

If we do need it, I think we can do window.global = globalThis

@aomarks aomarks merged commit 2043eb0 into main Sep 1, 2021
@aomarks aomarks deleted the ssr-global branch September 1, 2021 19:06
@aomarks
Copy link
Member Author

aomarks commented Sep 1, 2021

This will go out with the next batch of Lit RC releases, probably a little later this week.

PonomareVlad pushed a commit to SvaLit/lit-async-ssr that referenced this pull request Mar 27, 2022
This means that globalThis.global will retain its Node built-ins, and globalThis.global === globalThis will hold, whereas before it would lose anything we didn't explicitly set on window, so something like global.Promise would be undefined.

This window.global assignment seems to have been done for compatibility with node-fetch, but I tried a fetch from the demo/global/module.js module, and the fetch seemed to work fine. Not sure if there is another invocation path I missed, but it seems ok?

Fixes lit#2118
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ssr] installWindowOnGlobal shim globalThis.global does not inherit any of the existing builtins like Promise
2 participants