-
Notifications
You must be signed in to change notification settings - Fork 14
Add browser compatibility (add to window object) #30
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
base: master
Are you sure you want to change the base?
Conversation
This gives compatibility for browsers by adding on to the window object if `define` and `module.exports` isn't available.
@inolen please 🙏🏻🙏🏻 👉🏻👈🏻 🥺🥺 |
|
If anybody needs this, I've published a version with this fix |
|
Sorry, but why is this needed? Can't you just import it as an es6 module vs merging with the window object? |
It's impossible to import it because you don't export it as an ES module. I had to create a new file that exports your 2 classes and removes the IIFE for that. I added the Check |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Demo</title>
<script type="importmap">
{
"imports": {
"bit-buffer": "https://cdn.jsdelivr.net/npm/bit-buffer@0.3.0/+esm",
"@nikelborm/bit-buffer": "https://cdn.jsdelivr.net/npm/@nikelborm/bit-buffer@0.3.1/+esm"
}
}
</script>
<script type="module">
import { BitView } from '@nikelborm/bit-buffer';
console.log('BitView from nikelborm', BitView);
</script>
<script type="module">
import { BitView } from 'bit-buffer';
</script>
</head>
<body></body>
</html>Repro |
|
I initially wanted this PR to be merged because it was already there, and I wouldn't have to do any work. Then I decided that I can't wait for this to be landed and published However, since I was already in this rabbit hole, I realized that implementing it with ESM would be a better idea, so I republished it with proper ESM syntax in |
|
Yea, I can update the module later today to export that. Sorry, I thought
it already did, I had forgot it was still doing the conditional export.
…On Mon, Dec 22, 2025, 12:55 PM EVA (Entity Value Attribute) < ***@***.***> wrote:
*nikelborm* left a comment (inolen/bit-buffer#30)
<#30 (comment)>
I initially wanted this PR to be merged because it was already there I
would have to do any work.
Then I decided, that I can't wait for this to be landed and published
@***@***.***, which has the fix from PR applied.
But then since I was already in this rabbit-hole, I realized that
implementing it with ESM would be actually a better idea, so I republished
it with proper ESM syntax in @***@***.***
—
Reply to this email directly, view it on GitHub
<#30 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADQMCF5RXZW3KHWJRZ5OYL4C7L33AVCNFSM6AAAAACPWSGAXGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTMOBRG42TENRRGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|

This gives compatibility for browsers by adding on to the window object
if
defineandmodule.exportsisn't available.