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

Please add 'module" entrypoint in package.json manifest to be compatible with modern web ES modules #185

Open
kristianmandrup opened this issue Oct 7, 2020 · 4 comments · May be fixed by #333
Assignees

Comments

@kristianmandrup
Copy link

Package found! However, no web-optimized "module" entrypoint was found in its package.json manifest.

This will allow it to work with snowpack, a modern package manager for the web

@jimmywarting
Copy link
Owner

All in favor 👍
...now that browser, Node and Deno all also supports native (lazy loading) ES modules. (all doe, this package have nothing to do with server side code and is only meant to run on the main thread)

Do you have any suggestion how to keep it backwards compatible?
leave the streamsaver.js as is and just copy and make a new streamsaver.esm.js?

@kristianmandrup

This comment was marked as outdated.

@jimmywarting
Copy link
Owner

jimmywarting commented Nov 7, 2023

I'm going to make a major release making this a ESM-only module. and remove all cjs umd stuff and only use ESM

It will require to change streamsaver.js into using ESM export syntax, the other files mitm.html and sw.js don't need any change. so it's just one file.

Something like this needs to be added to package.json

  "type": "module",
  "exports": {
    "./*.js": "./*.js"
  },

also remove the "main" entry point from package.json. i want to be explicit about what path you can import.
so it should be:

- import streamsaver from 'streamsaver'
+ import streamsaver from 'streamsaver/StreamSaver.js'

...And the README examples needs to be updated.
could be nice to mention if someone are stuck with cjs then they could install the current release version.

@jimmywarting
Copy link
Owner

it's important to test out that this settings still works:

// StreamSaver can detect and use the Ponyfill that is loaded from the cdn.
streamSaver.WritableStream = streamSaver.WritableStream
streamSaver.TransformStream = streamSaver.TransformStream
// if you decide to host mitm + sw yourself
streamSaver.mitm = 'https://example.com/custom_mitm.html'

i think it will be alright if we do export default ... instead of named exports cuz those are live bindings and acts more like a constant variable, so it can't be changed in ESM easily unless it's a default object that is exported

@erjonify erjonify linked a pull request Nov 7, 2023 that will close this issue
@jimmywarting jimmywarting linked a pull request Nov 11, 2023 that will close this issue
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 a pull request may close this issue.

3 participants