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

Can we get the UMD builds back in the /dist folder? #3814

Closed
andrewheadricke opened this issue Feb 22, 2023 · 10 comments
Closed

Can we get the UMD builds back in the /dist folder? #3814

andrewheadricke opened this issue Feb 22, 2023 · 10 comments
Assignees
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published. v6 Issues regarding v6

Comments

@andrewheadricke
Copy link

Ethers Version

6.0.5

Search Terms

umd build

Describe the Problem

The previous version included UMD builds that could be loaded directly into a browser. 6.x doesn't appear to include them anymore.

Code Snippet

No response

Contract ABI

No response

Errors

No response

Environment

No response

Environment (Other)

No response

@andrewheadricke andrewheadricke added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Feb 22, 2023
@ricmoo
Copy link
Member

ricmoo commented Feb 22, 2023

I think that should be pretty easy to add. I can try adding it to the rollup config tomorrow.

I’d figured UMD was not widely used anymore, so I didn’t bother. :)

@andrewheadricke
Copy link
Author

I package apps for deployment to IPFS, and I prefer to publish a common library file because it then shares the same hash as anyone else using it. If I use build scripts to integrate it into one custom bundle than the hash is unique everytime.

Anyway, appreciate you looking into it.

@ricmoo ricmoo added the on-deck This Enhancement or Bug is currently being worked on. label Feb 23, 2023
ricmoo added a commit that referenced this issue Feb 23, 2023
@ricmoo
Copy link
Member

ricmoo commented Feb 23, 2023

I've added this in v6.0.6. Try it out and let me know if it works for you.

Thanks! :)

@ricmoo ricmoo closed this as completed Feb 23, 2023
@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. and removed on-deck This Enhancement or Bug is currently being worked on. labels Feb 23, 2023
@andrewheadricke
Copy link
Author

Works great. Thanks!

@andrewheadricke
Copy link
Author

I just learnt a new trick, how to load ESM modules in the browser. Which means I no longer need the UMD builds :)

@paulmillr
Copy link

paulmillr commented Mar 12, 2023

@ricmoo I would vote for rolling back the addition. It increases bundle size and ESM can be freely imported by folks in browsers. Bundlers allow folks to compile ESM to commonjs when necessary (Electron). This simply increases bundle size and delays switching people to ESM.

UMD builds can be brought back if enough folks ask for it again.

@ricmoo
Copy link
Member

ricmoo commented Mar 13, 2023

Once a feature is added, I tend to it want to break backwards compatibility without a good reason.

What is wrong with offering it? It has zero impact on people using bundlers, since they will use the normal entry points, into the relevant /lib.{esm,commonjs} anyways.

The dist builds are only meaningfully available in the repo and on cdnjs.

@paulmillr
Copy link

What is wrong with offering it?

  1. NPM package size increased: Additional files in package increase it
  2. Worse security: users need to audit BOTH dist AND lib source. It's possible a bad bundler would insert something bad into dist when you're doing it and not in lib source.

@marsrobertson
Copy link

I still use UMD version.


<!doctype html>

<html>
  <head>

    <script type="text/javascript"
        integrity="sha384-Jk2KQmxNIrlZNY8bE1bEnOjnx9PkvpwWgH/MEBCK+gpks+KdtHLnr2RzmMseDrGh"
        crossorigin="anonymous"
        src="https://cdn-cors.ethers.io/lib/ethers-5.5.4.umd.min.js">
    </script>

    <!-- IPFS upload example using Infura: https://genesis.re/kleros-metaevidence-metahash/ -->
    <script src="https://unpkg.com/ipfs-http-client@30.1.3/dist/index.js"></script>
    <script src="https://bundle.run/buffer@5.2.1"></script>

   ...

Practical for quick demos.

I see no harm.

@ricmoo
Copy link
Member

ricmoo commented Jun 19, 2023

The UMD will remain in v6. I don’t like breaking backwards compatibility without significant justification. :)

@ricmoo ricmoo added enhancement New feature or improvement. and removed investigate Under investigation and may be a bug. labels Jun 19, 2023
Woodpile37 pushed a commit to Woodpile37/ethers.js that referenced this issue Jan 14, 2024
Woodpile37 pushed a commit to Woodpile37/ethers.js that referenced this issue Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

4 participants