Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@e111077
Copy link
Contributor

@e111077 e111077 commented Mar 19, 2022

Background

I was trying to import this using a CDN and native ES Modules, but then I ran into the issue that this package's ESM build uses copy-to-clipboard which is written in CJS. This means when you try to load this package, it throws an error in copy-to-clipboard that require is not defined.

Changes

I've replaced copy-to-clipboard with the native clipboard api. Browser compatibility can be found here.

This should allow using this package with just:

import "https://unpkg.com/@figspec/components?module"

Testing

I was able to test this manually in Chrome and Firefox with the storybook command.

Safari did not allow me to click on anything and bring up the inspector view. Not sure why. But, i ran the copy function separately in another window and it copied correctly.

@pocka
Copy link
Owner

pocka commented Mar 21, 2022

Thanks for your contribution.

I confirmed the Safari bug then opened a new issue (#37 ).

@pocka pocka merged commit 4d901a9 into pocka:master Mar 21, 2022
@pocka pocka added this to the v1.0.1 milestone Mar 21, 2022
pocka added a commit to pocka/figspec-react that referenced this pull request Oct 16, 2022
storybookjs/addon-designs#161 (comment)

In order to avoid importing `copy-to-clipboard` package, which was
[removed](pocka/figspec#36) at v1.0.1.
That package is written CJS so v1.0.0 ESM build does not work
at all.
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 this pull request may close these issues.

2 participants