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

service worker should be supported #258

Closed
loynoir opened this issue Aug 22, 2023 · 2 comments
Closed

service worker should be supported #258

loynoir opened this issue Aug 22, 2023 · 2 comments

Comments

@loynoir
Copy link

loynoir commented Aug 22, 2023

Env

service worker

Detail

> JSON.stringify([typeof window, typeof Buffer, typeof btoa, typeof self, typeof self.btoa, typeof globalThis.btoa])
 '["undefined","undefined","function","object","function","function"]' 

Actual

Got Error.

Unsupported environment: window.btoa or Buffer should be supported

Expected

service worker should be supported

@loynoir
Copy link
Author

loynoir commented Aug 22, 2023

@antfu

Given

I suggest check Buffer first

if (typeof Buffer === "function") {
  // ...
} else if (typeof btoa === "function") {
  // ...
}

@antfu antfu closed this as completed in 2dea20b Sep 29, 2023
@curran
Copy link
Contributor

curran commented Jan 20, 2024

It still fails as this logic was not updated:

https://github.com/Rich-Harris/magic-string/blob/master/src/SourceMap.js#L3

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

No branches or pull requests

2 participants