node-gfx / node-canvas-prebuilt

Repo used to build binaries for node-canvas on CI
169 stars 31 forks source link

Incorrect path to main, should be index.js? #21

Closed alexeckermann closed 7 years ago

alexeckermann commented 7 years ago

https://github.com/node-gfx/node-canvas-prebuilt/blob/25087a490e93462492f648bfcbca6521a9029315/package.json#L28

Using the latest 2.0.0-alpha.5, the main is pointing to ./canvas/lib/canvas.js which doesn't make any of what is described in ./canvas/index.js available — such as registerFont and Image.

I'm not a day-to-day node user so I am interested to know if this is intentional? In basic debugging locally, changing the reference of main to point to the index file I got access to everything I was expecting to.

alexeckermann commented 7 years ago

Upon further research into this, I looks as though the purpose of index.js was changed upstream in node-canvas during 2.0.0 commits.

https://github.com/Automattic/node-canvas/commit/c47aa3def92f26f6be699be024f474fee2a6cf21#diff-168726dbe96b3ce427e7fedce31bb0bc

In that case I'll put a pull request together as I now believe this will be necessary going forward.

chearon commented 7 years ago

Yeah, you're right. It looks like it's been wrong since 2.0.0-alpha.3 😞 Thanks for reporting though!

chearon commented 7 years ago

Fixed via #22

preco21 commented 6 years ago

Looks like the changed path does not affect to the module as there is no new release since this changes.

Maybe this patch would be helpful until get the new release of the module?

const {join} = require('path');
const readPkg = require('read-pkg');
const writePkg = require('write-pkg');

const packagePath = join('node_modules', 'canvas-prebuilt');

(async () => {
  const packageJSON = await readPkg(packagePath);
  await writePkg(packagePath, {
    ...packageJSON,
    main: './canvas/index.js',
  });
})();
"postinstall": "node scripts/_patch-canvas-prebuilt.js"