-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Add support for ES6 module import #568
Comments
BTW I can import clipboard 2.0.1 from TypeScript ( import whatever from 'clipboard';
new whatever('#clipboard'); |
@chulkilee Thanks but the issue is about importing the library using raw JavaScript, not TypeScript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import |
@lpellegr I know - that's why I said "BTW" :) I'm also curious what's the current "modern" web-asset packaging which supports both direct import on web browser and webpack - could you add example of such libraries here so that the maintainer can take a look? |
My usage is for an app built with Polymer 3 and bundled for differential serving (esm, es6, es5). Examples are the PWA sample apps: https://polymer.github.io/pwa-starter-kit/building-and-deploying/ There are several different ways to add support for ESM. Several libraries such as momentjs, firebase-js-sdk, etc. have such a support. |
It's not working here too. :( |
I have just summit a PR to make clipboard.js available as an ES6 module, as I needed it to migrate my I needed to migrate some other @zenorocha libraries before, as |
Is this planned for Clipboard.js 3.0 #516? |
Thanks for your patience on this. Can you confirm that #596 address this problem? |
I can't recall what was the problem here. This was a long time ago and we ended up importing the minified version of the library:
because this was working we didn't spend much time figuring out what's the problem. Now we tried importing:
with version
and it worked so I have no idea why we used the minified version. 🤷♂ |
Great news! 🎉 🎉 🎉 |
I think this is just a partial work. We have enabled ES6 module for clipboard.js, but it's dependencies 'select' and 'good-listener' aren't still upgraded for ES6 modules. So, Those dependencies also need to be updated, and it's upgraded version should be used in the clipboard.js for the seamless integration. Changes similar to https://github.com/zenorocha/clipboard.js/pull/596/files ( |
It seems the library cannot be loaded with module imports on modern browsers.
The purpose would be to allow such imports since JavaScript imports are now available with all major browsers. Including an esm file or adapting existing files in the NPM package to have a default export would allow the following:
The text was updated successfully, but these errors were encountered: