bubkoo / html-to-image

✂️ Generates an image from a DOM node using HTML5 canvas and SVG.
MIT License
5.66k stars 524 forks source link

Running using es5 configuration gives error on command line with browserify #1

Closed jwir3 closed 3 years ago

jwir3 commented 6 years ago

Steps to Reproduce:

  1. Add the following to the source file being run:
    var htmlToImage = require('html-to-image');
    var svgNode = document.getElementById('someIdOfSvgElement');
    htmlToImage.toPng(svgNode)
    .then(function (dataUrl) {
      console.log(dataUrl);
    })
    .catch(function (error) {
      console.error('Unable to capture SVG node with id: "' + aSvgId + '"');
    });
  2. Run using browserify (command in package.json):
    "scripts": {
    "captureImage": "browserify captureImage.js -o bundle.js && open run.html"
    }

Note that run.html in this case includes the bundle.js script.

Expected Results:

Actual Results:

My thinking is that this has something to do with how browserify isn't using es2015 or es2016. I did try using babelify, as in the following example:

"scripts": {
    "captureImage": "browserify captureImage.js -o bundle.js -t [ babelify --presets [ env ] ] && open run.html"
}

(After installing babelify, babel-core, and babel-preset-env, of course)

This seems to result in the same error.

sylviestephanies commented 6 years ago

yes i got the same error, can someone help me?

edsmcosta commented 6 years ago

Me too, i've got this output from the line:

var htmlToImage = require('html-to-image');

/media/edsmc/Dados/VALE/passportRAC/node_modules/html-to-image/lib/index.js:1 (function (exports, require, module, filename, dirname) { import cloneNode from './cloneNode'; ^^^^^^^^^

SyntaxError: Unexpected identifier at new Script (vm.js:74:7) at createScript (vm.js:246:10) at Object.runInThisContext (vm.js:298:10) at Module._compile (internal/modules/cjs/loader.js:670:28) at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10) at Module.load (internal/modules/cjs/loader.js:612:32) at tryModuleLoad (internal/modules/cjs/loader.js:551:12) at Function.Module._load (internal/modules/cjs/loader.js:543:3) at Module.require (internal/modules/cjs/loader.js:650:17) at require (internal/modules/cjs/helpers.js:20:18)

vivcat[bot] commented 3 years ago

Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not-stale" to keep this issue open! As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request.

Thanks for being a part of the Antv community! 💪💯

vivcat[bot] commented 3 years ago

Hey again! It’s been 60 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to comment on this issue or create a new one if you need anything else. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Thanks again for being part of the Antv community! 💪💯

vivcat[bot] commented 2 years ago

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.