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

Update node.js workaround from global → globalThis #3806

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

acusti
Copy link

@acusti acusti commented Jul 2, 2024

first of all, i saw in the readme that Prism v2 is in the works and any ESM compatibility fixes it brings will undoubtedly fix the issue i am currently running into. however, the Roadmap for Prism v2 hasn’t been updated since august 2022, so in the meantime, i propose this as a very simple update to make prism’s node.js compatibility hack (introduced in #754) work with non-node.js runtimes that don’t have a global object (e.g. workerd).

also, the node.js global object has been deprecated in favor of the cross-platform standard globalThis object, so making this update brings the workaround up-to-date with the latest standards.

an alternative approach to this improvement would be to do something like:

if (typeof global !== 'undefined') {
	global.Prism = Prism;
} else if (typeof globalThis !== 'undefined') {
	globalThis.Prism = Prism;
}

…which i’m happy to implement if that would be preferable.

Copy link

github-actions bot commented Jul 2, 2024

No JS Changes

Generated by 🚫 dangerJS against 8963503

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.

1 participant