modelfoxdotdev / modelfox

ModelFox makes it easy to train, deploy, and monitor machine learning models.
Other
1.47k stars 64 forks source link

Support for Deno and native ES modules #18

Closed nitsky closed 3 years ago

nitsky commented 3 years ago

The JavaScript library currently has support for Node.js and bundlers. We should be able to add support for Deno and native ES modules like so:

import * as tangram from "https://js.tangram.xyz";
yesmar commented 3 years ago

I'd really like to be able to import tangram from "@tangramdotdev/tangram"; in an ES6 module. Hopefully this feature will happen.

isabella commented 3 years ago

As of v0.7.0 you can import * as tangram from "@tangramdotdev/tangram"; in an ES Module with Node.js v14 or later, so long as you set "type": "module" in your package.json. In the browser, you can import * as tangram from "https://js.tangram.xyz";, and in deno you import * as tangram from "https://js.tangram.xyz/deno";.

@yesmar does this satisfy what you are looking for?

yesmar commented 3 years ago

Yes, that totally works. I must have missed it in the docs. Thanks!

nitsky commented 3 years ago

@yesmar the docs use require for maximum compatibility, but the examples in the repo use es modules because they have their own package.jsons so they can specify the type key.