clipboard-polyfill icon indicating copy to clipboard operation
clipboard-polyfill copied to clipboard

Missing text only version with polyfill?

Open jamieburchell opened this issue 5 years ago • 5 comments

The version including the promise appears to be the full-fat version which supports more than just text. I only need to support text in my project, but also old browsers. Is there a text only version which includes the promise?

I can't work it out from the README, but does the library actually need the promise polyfill to work in IE <=11 when using the basic syntax:

  clipboard.writeText("This text is plain.").then(
    function () {
      console.log("success!");
    },
    function () {
      console.log("error!");
    }
  );

jamieburchell avatar Aug 27 '20 19:08 jamieburchell

Is there a text only version which includes the promise?

No, unfortunately not. What's your use case?

I can't work it out from the README, but does the library actually need the promise polyfill to work in IE <=11 when using the basic syntax:

Yes, the library assumes that there's a global Promise object in order to actually construct the Promise.

lgarron avatar Aug 27 '20 19:08 lgarron

No, unfortunately not. What's your use case?

Just that your comments state:

// Using the `clipboard/text` build saves code size.
// This is recommended if you only need to copy text.

I only need to copy text to the clipboard, and support old browsers. I guess in that case I should find/use my own promise and include the text only version of the clipboard polyfill if I'm bothered about shaving a few KB off the build size.

jamieburchell avatar Aug 27 '20 19:08 jamieburchell

Coming back to this, I'm wary of adding more builds to the project. However, you can make a build yourself by using:

{
  input: "./src/targets/text.ts",
  output: [
    {
      banner: promisePolyfill,
      file: "dist/text.promise/clipboard-polyfill.text.promise.js",
      format: "umd",
      name: "clipboard",
      sourcemap: true,
    },
  ],
  plugins: promisePlugins,
},

in https://github.com/lgarron/clipboard-polyfill/blob/main/rollup.config.js

lgarron avatar Oct 03 '20 19:10 lgarron

Thanks for your help. Would I need to fork this repo to have that included in my project? Sorry, I'm not too familiar with the ecosystem.

jamieburchell avatar Oct 05 '20 14:10 jamieburchell

Thanks for your help. Would I need to fork this repo to have that included in my project? Sorry, I'm not too familiar with the ecosystem.

You'd have to check out the project and run npm install; make build yourself to get a file.

lgarron avatar Oct 05 '20 17:10 lgarron

I do not plan to publish a build for this. The Promise code is pretty large and we no longer publish minified builds, and so the savings for a text-only build is a bit questionable. The full version with the Promise polyfill includes the relevant functionality.

lgarron avatar Jan 05 '23 09:01 lgarron