planttheidea / fast-copy

A blazing fast deep object copier
MIT License
1.13k stars 31 forks source link

CDN version #75

Closed 1isten closed 2 years ago

1isten commented 2 years ago

How to use this package via CDN? I've tried https://cdn.jsdelivr.net/npm/fast-copy@3.0.0/dist/umd/index.js but seems no global function exported to the window object.

planttheidea commented 2 years ago

You are correct that a global function is not exported to the window object, however a namespace is. This was an aspect of the breaking changes where exports are always named. I mentioned it was for CJS, but the same applies to UMD where you have instantiated a global.

To use the package via CDN, just add the default property to the global retrieved:

const copy = globalThis['fast-copy'].default;

Example with a CodePen

I'll update the explanation in the CHANGELOG to include this.