imgcook/datacook

image: load image using Node.js/webpack custom ESModule

Closed this issue · 4 comments

See https://nodejs.org/dist/latest-v15.x/docs/api/esm.html#esm_https_loader, Node.js is able to add a custom loader for ESM sugar, and boa is also using it to load Python module:

import tensorflow as tf from 'py:tensorflow';

Just figure it out that we are able to read an image in the same way:

import yorkie from 'datacook:/path/to/a/dog.png';
console.log(yorkie); // should be an instance of `datacook.Image`

/cc @WenheLI @risenW

The same for tabular and text-related resources, too.

IMO, this syntax may not be compatible with browser env.
We should keep the experience of browser and node as same as possible.

Hmm, IMOH it's compatible with ESM, which is supported by both Node.js and browser :)

Closing because of inactive.