Greenheart / pagecrypt

Password Protected Single Page Applications and HTML files
GNU Affero General Public License v3.0
233 stars 25 forks source link

fix: prefer `globalThis` over `window` in Node 19 #35

Closed metonym closed 1 year ago

metonym commented 1 year ago

Fixes #34

This is a hotfix that allows pagecrypt usage with Node 19.

For some reason, the window/globalThis check is evaluated differently in Node 19.

Setting globalThis before window avoids the reference error thrown by Node when the branch is evaluated.

I've tested this in Node 19 and Node 16.

Greenheart commented 1 year ago

Thank you so much for the rapid fix! 💚

I'll test this with Node 16, 18 and 19, and then we can likely have a new npm release out soon.


Findings so far:

Until this is done, I'd recommend you and others to use Node 18 if possible, which seems to work fine.

Greenheart commented 1 year ago

Nice work! Thanks again for the quick fix :smile: This works well for all environments. with node 16, 18 and 19.

I'm merging this, but will fix the other tasks in separate PRs before making a new release since something has changed with how the styling is loaded in the latest versions.

If you want to use the new version directly, feel free to swap the npm install with linking to the GitHub repository and a specific commit: https://stackoverflow.com/a/17509764/4183985

metonym commented 1 year ago

Thank you for addressing this so quickly.

Greenheart commented 1 year ago

For sure, whenever there's an opportunity!

Welcome to help make further improvements if you have more ideas! 😄