-
-
Notifications
You must be signed in to change notification settings - Fork 422
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
Switch to ESM #333
base: master
Are you sure you want to change the base?
Switch to ESM #333
Conversation
Lines 5 to 12 in 5b372f7
We can remove all of this: <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ponyfill.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/StreamSaver.min.js"></script>
<script>
import streamSaver from 'streamsaver'
const streamSaver = require('streamsaver')
const streamSaver = window.streamSaver
</script> and replace it with: <script type="importmap">
{
"imports": {
"streamsaver/StreamSaver.js": "https://cdn.jsdelivr.net/npm/streamsaver@3/StreamSaver.min.js"
}
}
</script>
<script type="module">
// either one works fine, the later one requires importmaps or a web bundler.
import streamSaver from 'https://cdn.jsdelivr.net/npm/streamsaver@3/StreamSaver.min.js'
import streamSaver from 'streamsaver/StreamSaver.min.js'
const uInt8 = new TextEncoder().encode('StreamSaver is awesome')
...
</script>
// StreamSaver can detect and use the Ponyfill that is loaded from the cdn.
streamSaver.WritableStream = streamSaver.WritableStream
streamSaver.TransformStream = streamSaver.TransformStream
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
☝️
This comment was marked as off-topic.
This comment was marked as off-topic.
@jimmywarting , i did some small changes, feel free to complete the rest :) |
If you're using next.js, etc., make sure you dynamically bring in streamSaver.js. the way to do this is to |
closes #185