We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi! 馃憢
Firstly, thanks for your work on this project! 馃檪
Today I used patch-package to patch tslog@4.7.5 for the project I'm working on.
tslog@4.7.5
'window' does not work on WebWorkers, 'globalThis' has been available pretty much everywhere (browsers AND Node) for about four years.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#browser_compatibility https://caniuse.com/?search=globalThis
Here is the diff that solved my problem:
diff --git a/node_modules/tslog/dist/esm/runtime/browser/index.js b/node_modules/tslog/dist/esm/runtime/browser/index.js index adae196..b33903d 100644 --- a/node_modules/tslog/dist/esm/runtime/browser/index.js +++ b/node_modules/tslog/dist/esm/runtime/browser/index.js @@ -3,7 +3,7 @@ import { formatWithOptions } from "./util.inspect.polyfil.js"; import { jsonStringifyRecursive } from "./helper.jsonStringifyRecursive.js"; const meta = { runtime: "Browser", - browser: window?.["navigator"].userAgent, + browser: globalThis?.["navigator"].userAgent, }; const pathRegex = /(?:(?:file|https?|global code|[^@]+)@)?(?:file:)?((?:\/[^:/]+){2,})(?::(\d+))?(?::(\d+))?/; export function getMeta(logLevelId, logLevelName, stackDepthLevel, hideLogPositionForPerformance, name, parentNames) { @@ -29,7 +29,7 @@ export function getErrorTrace(error) { }, []); } function stackLineToStackFrame(line) { - const href = window.location.origin; + const href = globalThis.location.origin; const pathResult = { fullFilePath: undefined, fileName: undefined,
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered:
Nice one! I must have missed this and caniuse looks promising: https://caniuse.com/?search=globalThis
Thank you.
Sorry, something went wrong.
7018919
Check out V4.8.0.
V4.8.0
No branches or pull requests
Hi! 馃憢
Firstly, thanks for your work on this project! 馃檪
Today I used patch-package to patch
tslog@4.7.5
for the project I'm working on.'window' does not work on WebWorkers, 'globalThis' has been available pretty much everywhere (browsers AND Node) for about four years.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#browser_compatibility
https://caniuse.com/?search=globalThis
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: